From 6acd4d7ee897caac1a07c0677b6165d5ab28d7d4 Mon Sep 17 00:00:00 2001 From: Anil Admal Date: Tue, 11 Jun 2019 14:37:31 -0700 Subject: [PATCH] Emergency location notification text must be in the correct language When the sytem language is changed, the emergency location user notification text is not posted in the new language unless the system server is restarted. Bug: 116328114 Test: Visually verified that the notification reflects system language changes. Change-Id: I63c265da985395879683484af94e10159557789a --- .../server/location/GnssVisibilityControl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/location/GnssVisibilityControl.java b/services/core/java/com/android/server/location/GnssVisibilityControl.java index 65bd5c6a14da1..3ee941920f480 100644 --- a/services/core/java/com/android/server/location/GnssVisibilityControl.java +++ b/services/core/java/com/android/server/location/GnssVisibilityControl.java @@ -78,7 +78,6 @@ class GnssVisibilityControl { private final Handler mHandler; private final Context mContext; private final GpsNetInitiatedHandler mNiHandler; - private final Notification mEmergencyLocationUserNotification; private boolean mIsGpsEnabled; @@ -107,7 +106,6 @@ class GnssVisibilityControl { mNiHandler = niHandler; mAppOps = mContext.getSystemService(AppOpsManager.class); mPackageManager = mContext.getPackageManager(); - mEmergencyLocationUserNotification = createEmergencyLocationUserNotification(mContext); // Complete initialization as the first event to run in mHandler thread. After that, // all object state read/update events run in the mHandler thread. @@ -632,13 +630,15 @@ class GnssVisibilityControl { } notificationManager.notifyAsUser(/* tag= */ null, /* notificationId= */ 0, - mEmergencyLocationUserNotification, UserHandle.ALL); + createEmergencyLocationUserNotification(mContext), UserHandle.ALL); } private static Notification createEmergencyLocationUserNotification(Context context) { - String firstLineText = context.getString(R.string.gpsNotifTitle); - String secondLineText = context.getString(R.string.global_action_emergency); - String accessibilityServicesText = firstLineText + " (" + secondLineText + ")"; + // NOTE: Do not reuse the returned notification object as it will not reflect + // changes to notification text when the system language is changed. + final String firstLineText = context.getString(R.string.gpsNotifTitle); + final String secondLineText = context.getString(R.string.global_action_emergency); + final String accessibilityServicesText = firstLineText + " (" + secondLineText + ")"; return new Notification.Builder(context, SystemNotificationChannels.NETWORK_ALERTS) .setSmallIcon(com.android.internal.R.drawable.stat_sys_gps_on) .setWhen(0)