diff options
Diffstat (limited to 'policy/src')
4 files changed, 89 insertions, 8 deletions
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); |