diff options
Diffstat (limited to 'services/java/com/android/server/UiModeManagerService.java')
-rw-r--r-- | services/java/com/android/server/UiModeManagerService.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/services/java/com/android/server/UiModeManagerService.java b/services/java/com/android/server/UiModeManagerService.java index 759b686..d9a6117 100644 --- a/services/java/com/android/server/UiModeManagerService.java +++ b/services/java/com/android/server/UiModeManagerService.java @@ -56,6 +56,7 @@ import java.util.Iterator; import com.android.internal.R; import com.android.internal.app.DisableCarModeActivity; +import com.android.internal.app.ThemeUtils; class UiModeManagerService extends IUiModeManager.Stub { private static final String TAG = UiModeManager.class.getSimpleName(); @@ -77,6 +78,7 @@ class UiModeManagerService extends IUiModeManager.Stub { private static final String ACTION_UPDATE_NIGHT_MODE = "com.android.server.action.UPDATE_NIGHT_MODE"; private final Context mContext; + private Context mUiContext; final Object mLock = new Object(); @@ -233,6 +235,13 @@ class UiModeManagerService extends IUiModeManager.Stub { } }; + private final BroadcastReceiver mThemeChangeReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + mUiContext = null; + } + }; + // A LocationListener to initialize the network location provider. The location updates // are handled through the passive location provider. private final LocationListener mEmptyLocationListener = new LocationListener() { @@ -326,6 +335,8 @@ class UiModeManagerService extends IUiModeManager.Stub { filter.addAction(Intent.ACTION_TIMEZONE_CHANGED); mContext.registerReceiver(mUpdateLocationReceiver, filter); + ThemeUtils.registerThemeChangeReceiver(mContext, mThemeChangeReceiver); + PowerManager powerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); mWakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, TAG); @@ -593,7 +604,7 @@ class UiModeManagerService extends IUiModeManager.Stub { n.flags = Notification.FLAG_ONGOING_EVENT; n.when = 0; n.setLatestEventInfo( - mContext, + getUiContext(), mContext.getString(R.string.car_mode_disable_notification_title), mContext.getString(R.string.car_mode_disable_notification_message), PendingIntent.getActivity(mContext, 0, carModeOffIntent, 0)); @@ -789,6 +800,13 @@ class UiModeManagerService extends IUiModeManager.Stub { mComputedNightMode = nightMode; } + private Context getUiContext() { + if (mUiContext == null) { + mUiContext = ThemeUtils.createUiContext(mContext); + } + return mUiContext != null ? mUiContext : mContext; + } + @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) |