summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2012-03-12 09:36:39 +0100
committerrmcc@arcee-kang1 <cyanogenmod@cerqueira.org>2012-03-31 15:29:36 +0100
commitd390193632083a7ca1d5898c2203c0ae1327f33b (patch)
tree776ec6c1c6f603bc35be51184ad7652cf3d44f85
parentac0eaa9e829dd8bb316c42b9d3493ee8343f1ca4 (diff)
downloadframeworks_base-d390193632083a7ca1d5898c2203c0ae1327f33b.zip
frameworks_base-d390193632083a7ca1d5898c2203c0ae1327f33b.tar.gz
frameworks_base-d390193632083a7ca1d5898c2203c0ae1327f33b.tar.bz2
Allow theming of framework UI elements.
As the theme engine works by replacing resources while loading the APK, framework UI couldn't be themed so far. Workaround that by manually creating a com.android.systemui package context and using that for showing the UI. This attempt is a bit hacky, but should be safe as a) systemui should always be present b) if it isn't, we fall back to no theming Change-Id: I644e2e8d7d4abf07bae639b606197d691f16adac
-rw-r--r--core/java/android/app/ActivityThread.java2
-rw-r--r--core/java/com/android/internal/app/ThemeUtils.java56
-rw-r--r--core/jni/Android.mk16
-rw-r--r--media/java/android/media/AudioService.java37
-rw-r--r--policy/src/com/android/internal/policy/impl/AccountUnlockScreen.java22
-rw-r--r--policy/src/com/android/internal/policy/impl/GlobalActions.java33
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneWindowManager.java19
-rw-r--r--policy/src/com/android/internal/policy/impl/SimUnlockScreen.java23
-rwxr-xr-xservices/java/com/android/server/NotificationManagerService.java21
-rw-r--r--services/java/com/android/server/PowerManagerService.java12
-rw-r--r--services/java/com/android/server/RingerSwitchObserver.java27
-rwxr-xr-xservices/java/com/android/server/am/ActivityManagerService.java33
-rw-r--r--services/java/com/android/server/connectivity/Tethering.java18
13 files changed, 292 insertions, 27 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index d4f2db6..82cf23e 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -3175,7 +3175,7 @@ public final class ActivityThread {
// We removed the old resources object from the mActiveResources
// cache, now we need to trigger an update for each application.
if ((diff & ActivityInfo.CONFIG_THEME_RESOURCE) != 0) {
- if (cb instanceof Activity || cb instanceof Application) {
+ if (cb instanceof ContextWrapper) {
Context context = ((ContextWrapper)cb).getBaseContext();
if (context instanceof ContextImpl) {
((ContextImpl)context).refreshResourcesIfNecessary();
diff --git a/core/java/com/android/internal/app/ThemeUtils.java b/core/java/com/android/internal/app/ThemeUtils.java
new file mode 100644
index 0000000..6bfcd73
--- /dev/null
+++ b/core/java/com/android/internal/app/ThemeUtils.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.internal.app;
+
+import android.content.Context;
+import android.content.BroadcastReceiver;
+import android.content.IntentFilter;
+import android.content.pm.PackageManager;
+import android.util.Log;
+
+/**
+ * @hide
+ */
+
+public class ThemeUtils {
+ private static final String TAG = "ThemeUtils";
+ private static final String DATA_TYPE_TMOBILE_STYLE = "vnd.tmobile.cursor.item/style";
+ private static final String DATA_TYPE_TMOBILE_THEME = "vnd.tmobile.cursor.item/theme";
+ private static final String ACTION_TMOBILE_THEME_CHANGED = "com.tmobile.intent.action.THEME_CHANGED";
+
+ public static Context createUiContext(final Context context) {
+ try {
+ return context.createPackageContext("com.android.systemui", Context.CONTEXT_RESTRICTED);
+ } catch (PackageManager.NameNotFoundException e) {
+ }
+
+ return null;
+ }
+
+ public static void registerThemeChangeReceiver(final Context context, final BroadcastReceiver receiver) {
+ IntentFilter filter = new IntentFilter(ACTION_TMOBILE_THEME_CHANGED);
+ try {
+ filter.addDataType(DATA_TYPE_TMOBILE_THEME);
+ filter.addDataType(DATA_TYPE_TMOBILE_STYLE);
+ } catch (IntentFilter.MalformedMimeTypeException e) {
+ Log.e(TAG, "Could not add MIME types to filter", e);
+ }
+
+ context.registerReceiver(receiver, filter);
+ }
+}
+
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index 6fcee88..bb01d9d 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -174,6 +174,20 @@ ifeq ($(BOARD_HAVE_FM_RADIO),true)
ifeq ($(BOARD_FM_DEVICE),wl1271)
LOCAL_SRC_FILES += android_hardware_fm_wl1271.cpp
endif
+ ifeq ($(BOARD_FM_DEVICE),ti-st)
+ LOCAL_SRC_FILES += android_hardware_fm_ti-st.cpp
+ LOCAL_SHARED_LIBRARIES += libfmstack libmcphal
+ FMSTACK := hardware/ti/wpan/fmradio/fm_stack
+ LOCAL_C_INCLUDES += $(FMSTACK)/HSW_FMStack/stack/inc/ \
+ $(FMSTACK)/MCP_Common/Platform/fmhal/LINUX/common/inc/ \
+ $(FMSTACK)/MCP_Common/Platform/os/LINUX/common/inc \
+ $(FMSTACK)/MCP_Common/inc/ \
+ $(FMSTACK)/MCP_Common/Platform/inc/ \
+ $(FMSTACK)/MCP_Common/Platform/os/LINUX/android_zoom2/inc/ \
+ $(FMSTACK)/MCP_Common/Platform/fmhal/inc/int/ \
+ $(FMSTACK)/MCP_Common/Platform/fmhal/inc \
+ $(FMSTACK)/HSW_FMStack/stack/inc/int/
+ endif
endif
LOCAL_C_INCLUDES += \
@@ -199,7 +213,7 @@ LOCAL_C_INCLUDES += \
external/jpeg \
frameworks/opt/emoji
-LOCAL_SHARED_LIBRARIES := \
+LOCAL_SHARED_LIBRARIES += \
libexpat \
libnativehelper \
libcutils \
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index 9d543d5..1479ac8 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -50,6 +50,7 @@ import android.view.KeyEvent;
import android.view.VolumePanel;
import android.os.SystemProperties;
+import com.android.internal.app.ThemeUtils;
import com.android.internal.telephony.ITelephony;
import java.io.FileDescriptor;
@@ -87,6 +88,8 @@ public class AudioService extends IAudioService.Stub {
/** The UI */
private VolumePanel mVolumePanel;
+ private Context mUiContext;
+ private Handler mHandler;
// sendMsg() flags
/** Used when a message should be shared across all stream types. */
@@ -290,13 +293,13 @@ public class AudioService extends IAudioService.Stub {
public AudioService(Context context) {
mContext = context;
mContentResolver = context.getContentResolver();
+ mHandler = new Handler();
// Intialized volume
MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL] = SystemProperties.getInt(
"ro.config.vc_call_vol_steps",
MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]);
- mVolumePanel = new VolumePanel(context, this);
mSettingsObserver = new SettingsObserver();
mForcedUseForComm = AudioSystem.FORCE_NONE;
createAudioSystemThread();
@@ -337,6 +340,13 @@ public class AudioService extends IAudioService.Stub {
intentFilter.addAction(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED);
context.registerReceiver(mReceiver, intentFilter);
+ ThemeUtils.registerThemeChangeReceiver(context, new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mUiContext = null;
+ }
+ });
+
// Register for media button intent broadcasts.
intentFilter = new IntentFilter(Intent.ACTION_MEDIA_BUTTON);
intentFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
@@ -452,8 +462,8 @@ public class AudioService extends IAudioService.Stub {
&& !AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC))
&& streamType != AudioSystem.STREAM_RING) {
flags &= ~AudioManager.FLAG_PLAY_SOUND;
+ }
}
-}
adjustStreamVolume(streamType, direction, flags);
}
@@ -497,7 +507,7 @@ public class AudioService extends IAudioService.Stub {
index = streamState.mIndex;
}
// UI
- mVolumePanel.postVolumeChanged(streamType, flags);
+ showVolumeChangeUi(streamType, flags);
// Broadcast Intent
sendVolumeUpdate(streamType, oldIndex, index);
}
@@ -515,7 +525,7 @@ public class AudioService extends IAudioService.Stub {
index = (streamState.muteCount() != 0) ? streamState.mLastAudibleIndex : streamState.mIndex;
// UI, etc.
- mVolumePanel.postVolumeChanged(streamType, flags);
+ showVolumeChangeUi(streamType, flags);
// Broadcast Intent
sendVolumeUpdate(streamType, oldIndex, index);
}
@@ -2464,6 +2474,25 @@ public class AudioService extends IAudioService.Stub {
}
}
+ private void showVolumeChangeUi(final int streamType, final int flags) {
+ if (mUiContext != null && mVolumePanel != null) {
+ mVolumePanel.postVolumeChanged(streamType, flags);
+ } else {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ if (mUiContext == null) {
+ mUiContext = ThemeUtils.createUiContext(mContext);
+ }
+
+ final Context context = mUiContext != null ? mUiContext : mContext;
+ mVolumePanel = new VolumePanel(context, AudioService.this);
+ mVolumePanel.postVolumeChanged(streamType, flags);
+ }
+ });
+ }
+ }
+
//==========================================================================================
// RemoteControl
//==========================================================================================
diff --git a/policy/src/com/android/internal/policy/impl/AccountUnlockScreen.java b/policy/src/com/android/internal/policy/impl/AccountUnlockScreen.java
index 2098685..2e7a78c 100644
--- a/policy/src/com/android/internal/policy/impl/AccountUnlockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/AccountUnlockScreen.java
@@ -17,6 +17,7 @@
package com.android.internal.policy.impl;
import com.android.internal.R;
+import com.android.internal.app.ThemeUtils;
import com.android.internal.widget.LockPatternUtils;
import android.accounts.Account;
@@ -25,6 +26,7 @@ import android.accounts.OperationCanceledException;
import android.accounts.AccountManagerFuture;
import android.accounts.AuthenticatorException;
import android.accounts.AccountManagerCallback;
+import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
@@ -76,6 +78,7 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree
/**
* Shown while making asynchronous check of password.
*/
+ private Context mUiContext;
private ProgressDialog mCheckingDialog;
/**
@@ -90,6 +93,14 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree
mCallback = callback;
mLockPatternUtils = lockPatternUtils;
+ ThemeUtils.registerThemeChangeReceiver(context, new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mUiContext = null;
+ mCheckingDialog = null;
+ }
+ });
+
LayoutInflater.from(context).inflate(
R.layout.keyguard_screen_glogin_unlock, this, true);
@@ -310,8 +321,17 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree
}
private Dialog getProgressDialog() {
+ if (mUiContext == null && mCheckingDialog != null) {
+ mCheckingDialog.dismiss();
+ mCheckingDialog = null;
+ }
+
if (mCheckingDialog == null) {
- mCheckingDialog = new ProgressDialog(mContext);
+ mUiContext = ThemeUtils.createUiContext(mContext);
+
+ final Context context = mUiContext != null ? mUiContext : mContext;
+
+ mCheckingDialog = new ProgressDialog(context);
mCheckingDialog.setMessage(
mContext.getString(R.string.lockscreen_glogin_checking_password));
mCheckingDialog.setIndeterminate(true);
diff --git a/policy/src/com/android/internal/policy/impl/GlobalActions.java b/policy/src/com/android/internal/policy/impl/GlobalActions.java
index 5b0ccd4..c64541a 100644
--- a/policy/src/com/android/internal/policy/impl/GlobalActions.java
+++ b/policy/src/com/android/internal/policy/impl/GlobalActions.java
@@ -57,6 +57,8 @@ import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
+import com.android.internal.app.ThemeUtils;
+
import java.util.ArrayList;
import java.util.UUID;
@@ -72,6 +74,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
private StatusBarManager mStatusBar;
private final Context mContext;
+ private Context mUiContext;
private final AudioManager mAudioManager;
private ArrayList<Action> mItems;
@@ -156,6 +159,8 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
filter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
context.registerReceiver(mBroadcastReceiver, filter);
+ ThemeUtils.registerThemeChangeReceiver(context, mThemeChangeReceiver);
+
// get notified of phone state changes
TelephonyManager telephonyManager =
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
@@ -175,6 +180,10 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
public void showDialog(boolean keyguardShowing, boolean isDeviceProvisioned) {
mKeyguardShowing = keyguardShowing;
mDeviceProvisioned = isDeviceProvisioned;
+ if (mDialog != null && mUiContext == null) {
+ mDialog.dismiss();
+ mDialog = null;
+ }
if (mDialog == null) {
mStatusBar = (StatusBarManager)mContext.getSystemService(Context.STATUS_BAR_SERVICE);
mDialog = createDialog();
@@ -185,6 +194,13 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
mDialog.show();
}
+ private Context getUiContext() {
+ if (mUiContext == null) {
+ mUiContext = ThemeUtils.createUiContext(mContext);
+ }
+ return mUiContext != null ? mUiContext : mContext;
+ }
+
/**
* Create the global actions dialog.
* @return A new dialog.
@@ -351,7 +367,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
// next: reboot
new SinglePressAction(com.android.internal.R.drawable.ic_lock_reboot, R.string.global_action_reboot) {
public void onPress() {
- ShutdownThread.reboot(mContext, null, (Settings.System.getInt(mContext.getContentResolver(),
+ ShutdownThread.reboot(getUiContext(), null, (Settings.System.getInt(mContext.getContentResolver(),
Settings.System.POWER_DIALOG_PROMPT, 1) == 1));
}
@@ -370,7 +386,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
public void onPress() {
// shutdown by making sure radio and power are handled accordingly.
- ShutdownThread.shutdown(mContext,(Settings.System.getInt(mContext.getContentResolver(),
+ ShutdownThread.shutdown(getUiContext(),(Settings.System.getInt(mContext.getContentResolver(),
Settings.System.POWER_DIALOG_PROMPT, 1) == 1));
}
@@ -385,7 +401,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
mAdapter = new MyAdapter();
- final AlertDialog.Builder ab = new AlertDialog.Builder(mContext);
+ final AlertDialog.Builder ab = new AlertDialog.Builder(getUiContext());
ab.setAdapter(mAdapter, this)
.setInverseBackgroundForced(true);
@@ -437,7 +453,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
names[i++] = profile.getName();
}
- final AlertDialog.Builder ab = new AlertDialog.Builder(mContext);
+ final AlertDialog.Builder ab = new AlertDialog.Builder(getUiContext());
AlertDialog dialog = ab
.setSingleChoiceItems(names, checkedItem, new DialogInterface.OnClickListener() {
@@ -575,7 +591,8 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
public View getView(int position, View convertView, ViewGroup parent) {
Action action = getItem(position);
- return action.create(mContext, convertView, parent, LayoutInflater.from(mContext));
+ final Context context = getUiContext();
+ return action.create(context, convertView, parent, LayoutInflater.from(context));
}
}
@@ -823,6 +840,12 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
}
};
+ private BroadcastReceiver mThemeChangeReceiver = new BroadcastReceiver() {
+ public void onReceive(Context context, Intent intent) {
+ mUiContext = null;
+ }
+ };
+
PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
@Override
public void onServiceStateChanged(ServiceState serviceState) {
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 85d3b5d..6ee08a7 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -53,6 +53,7 @@ import android.os.Vibrator;
import android.provider.CmSystem;
import android.provider.Settings;
+import com.android.internal.app.ThemeUtils;
import com.android.internal.policy.PolicyManager;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.telephony.ITelephony;
@@ -187,6 +188,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
final Object mLock = new Object();
Context mContext;
+ Context mUiContext;
IWindowManager mWindowManager;
LocalPowerManager mPowerManager;
Vibrator mVibrator; // Vibrator for giving feedback of orientation changes
@@ -588,7 +590,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (uid >= Process.FIRST_APPLICATION_UID && uid <= Process.LAST_APPLICATION_UID
&& appInfo.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
// Kill the entire pid
- Toast.makeText(mContext, R.string.app_killed_message, Toast.LENGTH_SHORT).show();
+ Toast.makeText(getUiContext(), R.string.app_killed_message, Toast.LENGTH_SHORT).show();
if (appInfo.pkgList!=null && (apps.size() > 0)){
mgr.forceStopPackage(appInfo.pkgList[0]);
}else{
@@ -658,6 +660,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
};
};
+ private Context getUiContext() {
+ if (mUiContext == null) {
+ mUiContext = ThemeUtils.createUiContext(mContext);
+ }
+ return mUiContext != null ? mUiContext : mContext;
+ }
+
protected void sendMediaButtonEvent(int code) {
long eventtime = SystemClock.uptimeMillis();
@@ -768,6 +777,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE,
Intent.EXTRA_DOCK_STATE_UNDOCKED);
}
+ // register for theme change events
+ ThemeUtils.registerThemeChangeReceiver(context, mThemeChangeReceiver);
mVibrator = new Vibrator();
mLongPressVibePattern = loadHaptic(HapticFeedbackConstants.LONG_PRESS);
mVirtualKeyVibePattern = loadHaptic(HapticFeedbackConstants.VIRTUAL_KEY);
@@ -2361,6 +2372,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
};
+ BroadcastReceiver mThemeChangeReceiver = new BroadcastReceiver() {
+ public void onReceive(Context context, Intent intent) {
+ mUiContext = null;
+ }
+ };
+
/** {@inheritDoc} */
public void screenTurnedOff(int why) {
EventLog.writeEvent(70000, 0);
diff --git a/policy/src/com/android/internal/policy/impl/SimUnlockScreen.java b/policy/src/com/android/internal/policy/impl/SimUnlockScreen.java
index e5ae964..cfd985a 100644
--- a/policy/src/com/android/internal/policy/impl/SimUnlockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/SimUnlockScreen.java
@@ -18,11 +18,14 @@ package com.android.internal.policy.impl;
import android.app.Dialog;
import android.app.ProgressDialog;
+import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.Intent;
import android.content.res.Configuration;
import android.os.RemoteException;
import android.os.ServiceManager;
+import com.android.internal.app.ThemeUtils;
import com.android.internal.telephony.ITelephony;
import com.android.internal.widget.LockPatternUtils;
@@ -58,6 +61,7 @@ public class SimUnlockScreen extends LinearLayout implements KeyguardScreen, Vie
private final int[] mEnteredPin = {0, 0, 0, 0, 0, 0, 0, 0};
private int mEnteredDigits = 0;
+ private Context mUiContext;
private ProgressDialog mSimUnlockProgressDialog = null;
private LockPatternUtils mLockPatternUtils;
@@ -75,6 +79,14 @@ public class SimUnlockScreen extends LinearLayout implements KeyguardScreen, Vie
mUpdateMonitor = updateMonitor;
mCallback = callback;
+ ThemeUtils.registerThemeChangeReceiver(context, new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mUiContext = null;
+ mSimUnlockProgressDialog = null;
+ }
+ });
+
mCreationOrientation = configuration.orientation;
mKeyboardHidden = configuration.hardKeyboardHidden;
mLockPatternUtils = lockpatternutils;
@@ -192,8 +204,17 @@ public class SimUnlockScreen extends LinearLayout implements KeyguardScreen, Vie
}
private Dialog getSimUnlockProgressDialog() {
+ if (mUiContext == null && mSimUnlockProgressDialog != null) {
+ mSimUnlockProgressDialog.dismiss();
+ mSimUnlockProgressDialog = null;
+ }
+
if (mSimUnlockProgressDialog == null) {
- mSimUnlockProgressDialog = new ProgressDialog(mContext);
+ mUiContext = ThemeUtils.createUiContext(mContext);
+
+ final Context uiContext = mUiContext != null ? mUiContext : mContext;
+
+ mSimUnlockProgressDialog = new ProgressDialog(uiContext);
mSimUnlockProgressDialog.setMessage(
mContext.getString(R.string.lockscreen_sim_unlock_progress_dialog_message));
mSimUnlockProgressDialog.setIndeterminate(true);
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index a2bfe78..2ac2a96 100755
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -70,6 +70,8 @@ import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.widget.Toast;
+import com.android.internal.app.ThemeUtils;
+
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -102,6 +104,7 @@ public class NotificationManagerService extends INotificationManager.Stub
private static final int DEFAULT_STREAM_TYPE = AudioManager.STREAM_NOTIFICATION;
final Context mContext;
+ Context mUiContext;
final IActivityManager mAm;
final IBinder mForegroundToken = new Binder();
@@ -422,6 +425,13 @@ public class NotificationManagerService extends INotificationManager.Stub
}
};
+ private BroadcastReceiver mThemeChangeReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mUiContext = null;
+ }
+ };
+
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -809,6 +819,8 @@ public class NotificationManagerService extends INotificationManager.Stub
IntentFilter ledFilter = new IntentFilter(ACTION_UPDATE_LED);
mContext.registerReceiver(mIntentReceiver, ledFilter);
+ ThemeUtils.registerThemeChangeReceiver(mContext, mThemeChangeReceiver);
+
SettingsObserver observer = new SettingsObserver(mHandler);
observer.observe();
@@ -1819,7 +1831,7 @@ public class NotificationManagerService extends INotificationManager.Stub
PendingIntent pi = PendingIntent.getActivity(mContext, 0,
intent, 0);
- mAdbNotification.setLatestEventInfo(mContext, title, message, pi);
+ mAdbNotification.setLatestEventInfo(getUiContext(), title, message, pi);
mAdbNotificationShown = true;
mAdbNotificationIsUsb = !networkEnabled;
@@ -1837,6 +1849,13 @@ public class NotificationManagerService extends INotificationManager.Stub
}
}
+ private Context getUiContext() {
+ if (mUiContext == null) {
+ mUiContext = ThemeUtils.createUiContext(mContext);
+ }
+ return mUiContext != null ? mUiContext : mContext;
+ }
+
private void updateNotificationPulse() {
synchronized (mNotificationList) {
updateLightsLocked();
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index d1f8216..44eb228 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -73,6 +73,8 @@ import static android.provider.Settings.System.WINDOW_ANIMATION_SCALE;
import static android.provider.Settings.System.TRANSITION_ANIMATION_SCALE;
import static android.provider.Settings.System.TORCH_STATE;
+import com.android.internal.app.ThemeUtils;
+
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.PrintWriter;
@@ -201,6 +203,7 @@ class PowerManagerService extends IPowerManager.Stub
private Intent mScreenOnIntent;
private LightsService mLightsService;
private Context mContext;
+ private Context mUiContext;
private LightsService.Light mLcdLight;
private LightsService.Light mButtonLight;
private LightsService.Light mKeyboardLight;
@@ -2698,7 +2701,7 @@ class PowerManagerService extends IPowerManager.Stub
Runnable runnable = new Runnable() {
public void run() {
synchronized (this) {
- ShutdownThread.reboot(mContext, finalReason, false);
+ ShutdownThread.reboot(getUiContext(), finalReason, false);
}
}
@@ -2735,6 +2738,13 @@ class PowerManagerService extends IPowerManager.Stub
}
}
+ private Context getUiContext() {
+ if (mUiContext == null) {
+ mUiContext = ThemeUtils.createUiContext(mContext);
+ }
+ return mUiContext != null ? mUiContext : mContext;
+ }
+
private void goToSleepLocked(long time, int reason) {
if (mLastEventTime <= time) {
diff --git a/services/java/com/android/server/RingerSwitchObserver.java b/services/java/com/android/server/RingerSwitchObserver.java
index 54a6526..c1ea64c 100644
--- a/services/java/com/android/server/RingerSwitchObserver.java
+++ b/services/java/com/android/server/RingerSwitchObserver.java
@@ -17,7 +17,9 @@
package com.android.server;
import android.app.ActivityManagerNative;
+import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.Intent;
import android.os.UEventObserver;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
@@ -32,6 +34,8 @@ import android.media.AudioService;
import android.media.IAudioService;
import android.media.AudioManager;
+import com.android.internal.app.ThemeUtils;
+
import java.io.FileReader;
import java.io.FileNotFoundException;
@@ -50,6 +54,7 @@ class RingerSwitchObserver extends UEventObserver {
private String mRingerswitchName;
private IAudioService mAudioService;
private Context mContext;
+ private Context mUiContext;
private VolumePanel mVolumePanel;
private final WakeLock mWakeLock; // held while there is a pending route change
@@ -58,6 +63,13 @@ class RingerSwitchObserver extends UEventObserver {
mContext = context;
+ ThemeUtils.registerThemeChangeReceiver(context, new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mUiContext = null;
+ }
+ });
+
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "RingerSwitchObserver");
mWakeLock.setReferenceCounted(false);
@@ -100,7 +112,18 @@ class RingerSwitchObserver extends UEventObserver {
}
mAudioService = IAudioService.Stub.asInterface(ServiceManager.checkService(Context.AUDIO_SERVICE));
- mVolumePanel = new VolumePanel(mContext, (AudioService) mAudioService);
+ }
+
+ private synchronized final VolumePanel getVolumePanel() {
+ if (mUiContext == null || mVolumePanel == null) {
+ if (mUiContext == null) {
+ mUiContext = ThemeUtils.createUiContext(mContext);
+ }
+ final Context context = mUiContext != null ? mUiContext : mContext;
+ mVolumePanel = new VolumePanel(mContext, (AudioService) mAudioService);
+ }
+
+ return mVolumePanel;
}
private synchronized final void update(String newName, int newState) {
@@ -130,7 +153,7 @@ class RingerSwitchObserver extends UEventObserver {
}
// Raise UI
- mVolumePanel.postVolumeChanged(AudioManager.STREAM_RING,AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_VIBRATE);
+ getVolumePanel().postVolumeChanged(AudioManager.STREAM_RING,AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_VIBRATE);
} catch (RemoteException e) {
}
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 17f9214..96ffea2 100755
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -18,6 +18,7 @@
package com.android.server.am;
import com.android.internal.R;
+import com.android.internal.app.ThemeUtils;
import com.android.internal.os.BatteryStatsImpl;
import com.android.server.AttributeCache;
import com.android.server.IntentResolver;
@@ -790,6 +791,7 @@ public final class ActivityManagerService extends ActivityManagerNative
boolean mLaunchWarningShown = false;
Context mContext;
+ Context mUiContext;
int mFactoryTest;
@@ -1006,7 +1008,7 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
}
- Dialog d = new AppErrorDialog(mContext, res, proc, hasRevoked);
+ Dialog d = new AppErrorDialog(getUiContext(), res, proc, hasRevoked);
d.show();
proc.crashDialog = d;
} else {
@@ -1036,7 +1038,7 @@ public final class ActivityManagerService extends ActivityManagerNative
false, false, MY_PID, Process.SYSTEM_UID);
Dialog d = new AppNotRespondingDialog(ActivityManagerService.this,
- mContext, proc, (ActivityRecord)data.get("activity"));
+ getUiContext(), proc, (ActivityRecord)data.get("activity"));
d.show();
proc.anrDialog = d;
}
@@ -1057,7 +1059,7 @@ public final class ActivityManagerService extends ActivityManagerNative
}
AppErrorResult res = (AppErrorResult) data.get("result");
if (!mSleeping && !mShuttingDown) {
- Dialog d = new StrictModeViolationDialog(mContext, res, proc);
+ Dialog d = new StrictModeViolationDialog(getUiContext(), res, proc);
d.show();
proc.crashDialog = d;
} else {
@@ -1070,7 +1072,7 @@ public final class ActivityManagerService extends ActivityManagerNative
} break;
case SHOW_FACTORY_ERROR_MSG: {
Dialog d = new FactoryErrorDialog(
- mContext, msg.getData().getCharSequence("msg"));
+ getUiContext(), msg.getData().getCharSequence("msg"));
d.show();
ensureBootCompleted();
} break;
@@ -1090,7 +1092,7 @@ public final class ActivityManagerService extends ActivityManagerNative
if (!app.waitedForDebugger) {
Dialog d = new AppWaitingForDebuggerDialog(
ActivityManagerService.this,
- mContext, app);
+ getUiContext(), app);
app.waitDialog = d;
app.waitedForDebugger = true;
d.show();
@@ -1139,7 +1141,7 @@ public final class ActivityManagerService extends ActivityManagerNative
} break;
case SHOW_UID_ERROR_MSG: {
// XXX This is a temporary dialog, no need to localize.
- AlertDialog d = new BaseErrorDialog(mContext);
+ AlertDialog d = new BaseErrorDialog(getUiContext());
d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
d.setCancelable(false);
d.setTitle("System UIDs Inconsistent");
@@ -1208,7 +1210,7 @@ public final class ActivityManagerService extends ActivityManagerNative
notification.defaults = 0; // please be quiet
notification.sound = null;
notification.vibrate = null;
- notification.setLatestEventInfo(context, text,
+ notification.setLatestEventInfo(getUiContext(), text,
mContext.getText(R.string.heavy_weight_notification_detail),
PendingIntent.getActivity(mContext, 0, root.intent,
PendingIntent.FLAG_CANCEL_CURRENT));
@@ -1619,6 +1621,15 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
+ private Context getUiContext() {
+ synchronized (this) {
+ if (mUiContext == null && mBooted) {
+ mUiContext = ThemeUtils.createUiContext(mContext);
+ }
+ return mUiContext != null ? mUiContext : mContext;
+ }
+ }
+
/**
* Initialize the application bind args. These are passed to each
* process when the bindApplication() IPC is sent to the process. They're
@@ -3009,7 +3020,7 @@ public final class ActivityManagerService extends ActivityManagerNative
@Override
public void run() {
synchronized (ActivityManagerService.this) {
- final Dialog d = new LaunchWarningWindow(mContext, cur, next);
+ final Dialog d = new LaunchWarningWindow(getUiContext(), cur, next);
d.show();
mHandler.postDelayed(new Runnable() {
@Override
@@ -3721,6 +3732,12 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
}, pkgFilter);
+ ThemeUtils.registerThemeChangeReceiver(mContext, new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mUiContext = null;
+ }
+ });
synchronized (this) {
// Ensure that any processes we had put on hold are now started
diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java
index 4239e55..db19cfd 100644
--- a/services/java/com/android/server/connectivity/Tethering.java
+++ b/services/java/com/android/server/connectivity/Tethering.java
@@ -47,6 +47,7 @@ import android.os.SystemProperties;
import android.provider.Settings;
import android.util.Log;
+import com.android.internal.app.ThemeUtils;
import com.android.internal.telephony.Phone;
import com.android.internal.util.HierarchicalState;
import com.android.internal.util.HierarchicalStateMachine;
@@ -69,6 +70,7 @@ import java.util.Set;
public class Tethering extends INetworkManagementEventObserver.Stub {
private Context mContext;
+ private Context mUiContext;
private final String TAG = "Tethering";
private boolean mBooted = false;
@@ -148,6 +150,13 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
filter.addAction(Intent.ACTION_BOOT_COMPLETED);
mContext.registerReceiver(mStateReceiver, filter);
+ ThemeUtils.registerThemeChangeReceiver(mContext, new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context content, Intent intent) {
+ mUiContext = null;
+ }
+ });
+
filter = new IntentFilter();
filter.addAction(Intent.ACTION_MEDIA_SHARED);
filter.addAction(Intent.ACTION_MEDIA_UNSHARED);
@@ -422,11 +431,18 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
mTetheredNotification.defaults &= ~Notification.DEFAULT_SOUND;
mTetheredNotification.flags = Notification.FLAG_ONGOING_EVENT;
mTetheredNotification.tickerText = title;
- mTetheredNotification.setLatestEventInfo(mContext, title, message, pi);
+ mTetheredNotification.setLatestEventInfo(getUiContext(), title, message, pi);
notificationManager.notify(mTetheredNotification.icon, mTetheredNotification);
}
+ private Context getUiContext() {
+ if (mUiContext == null) {
+ mUiContext = ThemeUtils.createUiContext(mContext);
+ }
+ return mUiContext != null ? mUiContext : mContext;
+ }
+
private void clearTetheredNotification() {
NotificationManager notificationManager =
(NotificationManager)mContext.getSystemService(Context.NOTIFICATION_SERVICE);