diff options
Diffstat (limited to 'services/java')
4 files changed, 73 insertions, 4 deletions
diff --git a/services/java/com/android/server/DeviceStorageMonitorService.java b/services/java/com/android/server/DeviceStorageMonitorService.java index d056cf6..1568b1b 100644 --- a/services/java/com/android/server/DeviceStorageMonitorService.java +++ b/services/java/com/android/server/DeviceStorageMonitorService.java @@ -16,10 +16,13 @@ package com.android.server; +import com.android.internal.app.ThemeUtils; import com.android.server.am.ActivityManagerService; + import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; +import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; @@ -76,6 +79,7 @@ class DeviceStorageMonitorService extends Binder { private boolean mLowMemFlag=false; private boolean mMemFullFlag=false; private Context mContext; + private Context mUiContext; private ContentResolver mContentResolver; private long mTotalMemory; // on /data/data private StatFs mDataFileStats; @@ -302,6 +306,14 @@ class DeviceStorageMonitorService extends Binder { mLastReportedFreeMemTime = 0; mContext = context; mContentResolver = mContext.getContentResolver(); + + ThemeUtils.registerThemeChangeReceiver(mContext, new BroadcastReceiver() { + @Override + public void onReceive(Context content, Intent intent) { + mUiContext = null; + } + }); + //create StatFs object mDataFileStats = new StatFs(DATA_PATH); mSystemFileStats = new StatFs(SYSTEM_PATH); @@ -349,7 +361,7 @@ class DeviceStorageMonitorService extends Binder { notification.icon = com.android.internal.R.drawable.stat_notify_disk_full; notification.tickerText = title; notification.flags |= Notification.FLAG_NO_CLEAR; - notification.setLatestEventInfo(mContext, title, details, intent); + notification.setLatestEventInfo(getUiContext(), title, details, intent); mNotificationMgr.notify(LOW_MEMORY_NOTIFICATION_ID, notification); mContext.sendStickyBroadcast(mStorageLowIntent); } @@ -394,4 +406,11 @@ class DeviceStorageMonitorService extends Binder { // force an early check postCheckMemoryMsg(true, 0); } + + private Context getUiContext() { + if (mUiContext == null) { + mUiContext = ThemeUtils.createUiContext(mContext); + } + return mUiContext != null ? mUiContext : mContext; + } } diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java index ecad3cc..8e50828 100644 --- a/services/java/com/android/server/InputMethodManagerService.java +++ b/services/java/com/android/server/InputMethodManagerService.java @@ -16,6 +16,7 @@ package com.android.server; +import com.android.internal.app.ThemeUtils; import com.android.internal.content.PackageMonitor; import com.android.internal.os.HandlerCaller; import com.android.internal.view.IInputContext; @@ -33,6 +34,7 @@ import org.xmlpull.v1.XmlPullParserException; import android.app.ActivityManagerNative; import android.app.AlertDialog; import android.app.PendingIntent; +import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; @@ -110,6 +112,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub static final long TIME_TO_RECONNECT = 10*1000; final Context mContext; + private Context mUiContext; final Handler mHandler; final SettingsObserver mSettingsObserver; final StatusBarManagerService mStatusBar; @@ -466,6 +469,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub screenOnOffFilt.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); mContext.registerReceiver(new ScreenOnOffReceiver(), screenOnOffFilt); + ThemeUtils.registerThemeChangeReceiver(mContext, new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + mUiContext = null; + } + }); + mStatusBar = statusBar; statusBar.setIconVisibility("ime", false); @@ -1501,7 +1511,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub void showInputMethodMenu() { if (DEBUG) Slog.v(TAG, "Show switching menu"); - final Context context = mContext; + final Context context = getUiContext(); final PackageManager pm = context.getPackageManager(); @@ -1706,6 +1716,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub return false; } + private Context getUiContext() { + if (mUiContext == null) { + mUiContext = ThemeUtils.createUiContext(mContext); + } + return mUiContext != null ? mUiContext : mContext; + } + // ---------------------------------------------------------------------- @Override diff --git a/services/java/com/android/server/ThrottleService.java b/services/java/com/android/server/ThrottleService.java index a93a6ee..fb7b56c 100644 --- a/services/java/com/android/server/ThrottleService.java +++ b/services/java/com/android/server/ThrottleService.java @@ -50,6 +50,7 @@ import android.text.TextUtils; import android.util.Slog; import com.android.internal.R; +import com.android.internal.app.ThemeUtils; import com.android.internal.telephony.TelephonyProperties; import java.io.BufferedWriter; @@ -76,6 +77,7 @@ public class ThrottleService extends IThrottleManager.Stub { private HandlerThread mThread; private Context mContext; + private Context mUiContext; private static final int INITIAL_POLL_DELAY_SEC = 90; private static final int TESTING_POLLING_PERIOD_SEC = 60 * 1; @@ -305,6 +307,13 @@ public class ThrottleService extends IThrottleManager.Stub { } }, new IntentFilter(ACTION_RESET)); + ThemeUtils.registerThemeChangeReceiver(mContext, new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + mUiContext = null; + } + }); + // use a new thread as we don't want to stall the system for file writes mThread = new HandlerThread(TAG); mThread.start(); @@ -339,6 +348,12 @@ public class ThrottleService extends IThrottleManager.Stub { } } + private Context getUiContext() { + if (mUiContext == null) { + mUiContext = ThemeUtils.createUiContext(mContext); + } + return mUiContext != null ? mUiContext : mContext; + } private static final int EVENT_REBOOT_RECOVERY = 0; private static final int EVENT_POLICY_CHANGED = 1; @@ -619,7 +634,7 @@ public class ThrottleService extends IThrottleManager.Stub { } mThrottlingNotification.flags = flags; mThrottlingNotification.tickerText = title; - mThrottlingNotification.setLatestEventInfo(mContext, title, message, pi); + mThrottlingNotification.setLatestEventInfo(getUiContext(), title, message, pi); mNotificationManager.notify(mThrottlingNotification.icon, mThrottlingNotification); } 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) |