Loading policy/com/android/internal/policy/impl/KeyguardUpdateMonitor.java +38 −15 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.database.ContentObserver; import static android.os.BatteryManager.BATTERY_STATUS_CHARGING; import static android.os.BatteryManager.BATTERY_STATUS_FULL; import static android.os.BatteryManager.BATTERY_STATUS_UNKNOWN; import android.media.AudioManager; import android.os.Handler; import android.os.Message; import android.provider.Settings; Loading Loading @@ -94,6 +95,7 @@ public class KeyguardUpdateMonitor { private static final int MSG_BATTERY_UPDATE = 302; private static final int MSG_CARRIER_INFO_UPDATE = 303; private static final int MSG_SIM_STATE_CHANGE = 304; private static final int MSG_RINGER_MODE_CHANGED = 305; /** Loading Loading @@ -160,6 +162,9 @@ public class KeyguardUpdateMonitor { case MSG_SIM_STATE_CHANGE: handleSimStateChange((SimArgs) msg.obj); break; case MSG_RINGER_MODE_CHANGED: handleRingerModeChange(msg.arg1); break; } } }; Loading Loading @@ -217,6 +222,7 @@ public class KeyguardUpdateMonitor { filter.addAction(Intent.ACTION_TIMEZONE_CHANGED); filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED); filter.addAction(SPN_STRINGS_UPDATED_ACTION); filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION); context.registerReceiver(new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { Loading Loading @@ -246,11 +252,21 @@ public class KeyguardUpdateMonitor { mHandler.sendMessage(mHandler.obtainMessage( MSG_SIM_STATE_CHANGE, new SimArgs(intent))); } else if (AudioManager.RINGER_MODE_CHANGED_ACTION.equals(action)) { mHandler.sendMessage(mHandler.obtainMessage(MSG_RINGER_MODE_CHANGED, intent.getIntExtra(AudioManager.EXTRA_RINGER_MODE, -1), 0)); } } }, filter); } protected void handleRingerModeChange(int mode) { if (DEBUG) Log.d(TAG, "handleRingerModeChange(" + mode + ")"); for (int i = 0; i < mInfoCallbacks.size(); i++) { mInfoCallbacks.get(i).onRingerModeChanged(mode); } } /** * Handle {@link #MSG_CONFIGURATION_CHANGED} */ Loading Loading @@ -443,7 +459,7 @@ public class KeyguardUpdateMonitor { } /** * Callback for general information releveant to lock screen. * Callback for general information relevant to lock screen. */ interface InfoCallback { void onRefreshBatteryInfo(boolean showBatteryInfo, boolean pluggedIn, int batteryLevel); Loading @@ -455,6 +471,13 @@ public class KeyguardUpdateMonitor { * @param spn The service provider name. May be null if it shouldn't be displayed. */ void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn); /** * Called when the ringer mode changes. * @param state the current ringer state, as defined in * {@link AudioManager#RINGER_MODE_CHANGED_ACTION} */ void onRingerModeChanged(int state); } /** Loading policy/com/android/internal/policy/impl/KeyguardViewManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ public class KeyguardViewManager implements KeyguardWindowController { * lazily. */ public synchronized void show() { if (DEBUG) Log.d(TAG, "show()"); if (DEBUG) Log.d(TAG, "show(); mKeyguardView==" + mKeyguardView); if (mKeyguardHost == null) { if (DEBUG) Log.d(TAG, "keyguard host is null, creating it..."); Loading policy/com/android/internal/policy/impl/KeyguardViewMediator.java +29 −4 Original line number Diff line number Diff line Loading @@ -105,6 +105,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback, private static final int KEYGUARD_DONE = 9; private static final int KEYGUARD_DONE_DRAWING = 10; private static final int KEYGUARD_DONE_AUTHENTICATING = 11; private static final int SET_HIDDEN = 12; /** * The default amount of time we stay awake (used for all key input) Loading Loading @@ -279,8 +280,9 @@ public class KeyguardViewMediator implements KeyguardViewCallback, /** * Called to let us know the screen was turned off. * @param why either {@link WindowManagerPolicy#OFF_BECAUSE_OF_USER} or * {@link WindowManagerPolicy#OFF_BECAUSE_OF_TIMEOUT}. * @param why either {@link WindowManagerPolicy#OFF_BECAUSE_OF_USER}, * {@link WindowManagerPolicy#OFF_BECAUSE_OF_TIMEOUT} or * {@link WindowManagerPolicy#OFF_BECAUSE_OF_PROX_SENSOR}. */ public void onScreenTurnedOff(int why) { synchronized (this) { Loading Loading @@ -311,6 +313,8 @@ public class KeyguardViewMediator implements KeyguardViewCallback, sender); if (DEBUG) Log.d(TAG, "setting alarm to turn off keyguard, seq = " + mDelayedShowingSequence); } else if (why == WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR) { // Do not enable the keyguard if the prox sensor forced the screen off. } else { doKeyguard(); } Loading Loading @@ -420,16 +424,34 @@ public class KeyguardViewMediator implements KeyguardViewCallback, return mShowing; } /** * Is the keyguard currently showing and not being force hidden? */ public boolean isShowingAndNotHidden() { return mShowing && !mHidden; } /** * Notify us when the keyguard is hidden by another window */ public void setHidden(boolean isHidden) { if (DEBUG) Log.d(TAG, "setHidden " + isHidden); mHandler.removeMessages(SET_HIDDEN); Message msg = mHandler.obtainMessage(SET_HIDDEN, (isHidden ? 1 : 0), 0); mHandler.sendMessage(msg); } /** * Handles SET_HIDDEN message sent by setHidden() */ private void handleSetHidden(boolean isHidden) { synchronized (KeyguardViewMediator.this) { if (mHidden != isHidden) { mHidden = isHidden; adjustUserActivityLocked(); } } } /** * Given the state of the keyguard, is the input restricted? Loading Loading @@ -812,6 +834,9 @@ public class KeyguardViewMediator implements KeyguardViewCallback, case KEYGUARD_DONE_AUTHENTICATING: keyguardDone(true); return; case SET_HIDDEN: handleSetHidden(msg.arg1 != 0); break; } } }; Loading policy/com/android/internal/policy/impl/LockPatternKeyguardView.java +29 −13 Original line number Diff line number Diff line Loading @@ -160,7 +160,10 @@ public class LockPatternKeyguardView extends KeyguardViewBase } catch (AuthenticatorException e) { } mEnableFallback = !hasSAMLAccount; if (mUnlockScreen instanceof UnlockScreen) { if (mUnlockScreen == null) { Log.w(TAG, "no unlock screen when receiving AccountManager information"); } else if (mUnlockScreen instanceof UnlockScreen) { ((UnlockScreen)mUnlockScreen).setEnableFallback(true); } } Loading @@ -179,18 +182,6 @@ public class LockPatternKeyguardView extends KeyguardViewBase KeyguardWindowController controller) { super(context); final boolean hasAccount = AccountManager.get(context).getAccounts().length > 0; if (hasAccount) { /* If we have a SAML account which requires web login we can not use the fallback screen UI to ask the user for credentials. For now we will disable fallback screen in this case. Ultimately we could consider bringing up a web login from GLS but need to make sure that it will work in the "locked screen" mode. */ String[] features = new String[] {"saml"}; AccountManager.get(context).getAccountsByTypeAndFeatures( "com.google", features, this, null); } mEnableFallback = false; mRequiresSim = Loading Loading @@ -275,6 +266,9 @@ public class LockPatternKeyguardView extends KeyguardViewBase public void reportFailedPatternAttempt() { mUpdateMonitor.reportFailedAttempt(); final int failedAttempts = mUpdateMonitor.getFailedAttempts(); if (DEBUG) Log.d(TAG, "reportFailedPatternAttempt: #" + failedAttempts + " (enableFallback=" + mEnableFallback + ")"); if (mEnableFallback && failedAttempts == (LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET - LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) { Loading Loading @@ -313,8 +307,28 @@ public class LockPatternKeyguardView extends KeyguardViewBase mLockScreen = createLockScreen(); addView(mLockScreen); final UnlockMode unlockMode = getUnlockMode(); if (DEBUG) Log.d(TAG, "LockPatternKeyguardView ctor: about to createUnlockScreenFor; mEnableFallback=" + mEnableFallback); mUnlockScreen = createUnlockScreenFor(unlockMode); mUnlockScreenMode = unlockMode; // Ask the account manager if we have an account that can be used as a // fallback in case the user forgets his pattern. The response comes // back in run() below; don't bother asking until you've called // createUnlockScreenFor(), else the information will go unused. final boolean hasAccount = AccountManager.get(context).getAccounts().length > 0; if (hasAccount) { /* If we have a SAML account which requires web login we can not use the fallback screen UI to ask the user for credentials. For now we will disable fallback screen in this case. Ultimately we could consider bringing up a web login from GLS but need to make sure that it will work in the "locked screen" mode. */ String[] features = new String[] {"saml"}; AccountManager.get(context).getAccountsByTypeAndFeatures( "com.google", features, this, null); } addView(mUnlockScreen); updateScreen(mMode); } Loading Loading @@ -475,6 +489,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase mUpdateMonitor, mKeyguardScreenCallback, mUpdateMonitor.getFailedAttempts()); if (DEBUG) Log.d(TAG, "createUnlockScreenFor(" + unlockMode + "): mEnableFallback=" + mEnableFallback); view.setEnableFallback(mEnableFallback); return view; } else if (unlockMode == UnlockMode.SimPin) { Loading policy/com/android/internal/policy/impl/LockScreen.java +68 −61 Original line number Diff line number Diff line Loading @@ -17,8 +17,9 @@ package com.android.internal.policy.impl; import com.android.internal.R; import com.android.internal.telephony.IccCard; import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.RotarySelector; import com.android.internal.widget.SlidingTab; import android.content.Context; import android.content.res.Resources; Loading @@ -33,11 +34,8 @@ import android.util.Log; import android.media.AudioManager; import android.os.SystemProperties; import com.android.internal.telephony.IccCard; import java.util.Date; import java.io.File; import java.text.SimpleDateFormat; /** * The screen within {@link LockPatternKeyguardView} that shows general Loading @@ -46,7 +44,7 @@ import java.text.SimpleDateFormat; */ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateMonitor.InfoCallback, KeyguardUpdateMonitor.SimStateCallback, KeyguardUpdateMonitor.ConfigurationChangeCallback, RotarySelector.OnDialTriggerListener { SlidingTab.OnTriggerListener { private static final boolean DBG = false; private static final String TAG = "LockScreen"; Loading @@ -59,7 +57,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM private final KeyguardScreenCallback mCallback; private TextView mCarrier; private RotarySelector mRotary; private SlidingTab mSelector; private TextView mTime; private TextView mDate; private TextView mStatus1; Loading @@ -83,7 +81,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM private boolean mSilentMode; private AudioManager mAudioManager; private java.text.DateFormat mDateFormat; private String mDateFormatString; private java.text.DateFormat mTimeFormat; private boolean mCreatedInPortrait; private boolean mEnableMenuKeyInLockScreen; Loading Loading @@ -175,13 +173,12 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM final LayoutInflater inflater = LayoutInflater.from(context); if (mCreatedInPortrait) { inflater.inflate(R.layout.keyguard_screen_rotary_unlock, this, true); inflater.inflate(R.layout.keyguard_screen_tab_unlock, this, true); } else { inflater.inflate(R.layout.keyguard_screen_rotary_unlock_land, this, true); inflater.inflate(R.layout.keyguard_screen_tab_unlock_land, this, true); } mCarrier = (TextView) findViewById(R.id.carrier); mTime = (TextView) findViewById(R.id.time); mDate = (TextView) findViewById(R.id.date); mStatus1 = (TextView) findViewById(R.id.status1); mStatus2 = (TextView) findViewById(R.id.status2); Loading @@ -189,7 +186,9 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM mEmergencyCallButton = (Button) findViewById(R.id.emergencyCallButton); mEmergencyCallButton.setText(R.string.lockscreen_emergency_call); mScreenLocked = (TextView) findViewById(R.id.screenLocked); mRotary = (RotarySelector) findViewById(R.id.rotary); mSelector = (SlidingTab) findViewById(R.id.tab_selector); mSelector.setHoldAfterTrigger(true, false); mSelector.setLeftHintText(R.string.lockscreen_unlock_label); mEmergencyCallButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mCallback.takeEmergencyCallAction(); Loading @@ -205,17 +204,35 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM updateMonitor.registerConfigurationChangeCallback(this); mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE); mSilentMode = mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT; mSilentMode = isSilentMode(); mRotary.setOnDialTriggerListener(this); mRotary.setLeftHandleResource(R.drawable.ic_jog_dial_unlock); mRotary.setRightHandleResource(mSilentMode ? R.drawable.ic_jog_dial_sound_off : R.drawable.ic_jog_dial_sound_on); mSelector.setLeftTabResources( R.drawable.ic_jog_dial_unlock, R.drawable.jog_tab_target_green, R.drawable.jog_tab_bar_left_unlock, R.drawable.jog_tab_left_unlock); updateRightTabResources(); mSelector.setOnTriggerListener(this); resetStatusInfo(updateMonitor); } private boolean isSilentMode() { return mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT; } private void updateRightTabResources() { mSelector.setRightTabResources( mSilentMode ? R.drawable.ic_jog_dial_sound_off : R.drawable.ic_jog_dial_sound_on, mSilentMode ? R.drawable.jog_tab_target_yellow : R.drawable.jog_tab_target_gray, mSilentMode ? R.drawable.jog_tab_bar_right_sound_on : R.drawable.jog_tab_bar_right_sound_off, mSilentMode ? R.drawable.jog_tab_right_sound_on : R.drawable.jog_tab_right_sound_off); } private void resetStatusInfo(KeyguardUpdateMonitor updateMonitor) { mShowingBatteryInfo = updateMonitor.shouldShowBatteryInfo(); mPluggedIn = updateMonitor.isDevicePluggedIn(); Loading @@ -228,7 +245,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM refreshAlarmDisplay(); mTimeFormat = DateFormat.getTimeFormat(getContext()); mDateFormat = getLockScreenDateFormat(); mDateFormatString = getContext().getString(R.string.full_wday_month_day_no_year); refreshTimeAndDateDisplay(); updateStatusLines(); } Loading @@ -242,24 +259,23 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM } /** {@inheritDoc} */ public void onDialTrigger(View v, int whichHandle) { if (whichHandle == RotarySelector.OnDialTriggerListener.LEFT_HANDLE) { public void onTrigger(View v, int whichHandle) { if (whichHandle == SlidingTab.OnTriggerListener.LEFT_HANDLE) { mCallback.goToUnlockScreen(); } else if (whichHandle == RotarySelector.OnDialTriggerListener.RIGHT_HANDLE) { } else if (whichHandle == SlidingTab.OnTriggerListener.RIGHT_HANDLE) { // toggle silent mode mSilentMode = !mSilentMode; mAudioManager.setRingerMode(mSilentMode ? AudioManager.RINGER_MODE_SILENT : AudioManager.RINGER_MODE_NORMAL); final int handleIcon = mSilentMode ? R.drawable.ic_jog_dial_sound_off : R.drawable.ic_jog_dial_sound_on; final int toastIcon = mSilentMode ? R.drawable.ic_lock_ringer_off : R.drawable.ic_lock_ringer_on; mRotary.setRightHandleResource(handleIcon); updateRightTabResources(); String message = mSilentMode ? getContext().getString(R.string.global_action_silent_mode_on_status) : getContext().getString(R.string.global_action_silent_mode_off_status); final int toastIcon = mSilentMode ? R.drawable.ic_lock_ringer_off : R.drawable.ic_lock_ringer_on; toastMessage(mScreenLocked, message, toastIcon); mCallback.pokeWakelock(); } Loading @@ -267,7 +283,12 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM /** {@inheritDoc} */ public void onGrabbedStateChange(View v, int grabbedState) { // TODO: Update onscreen hint text based on the new state. if (grabbedState == SlidingTab.OnTriggerListener.RIGHT_HANDLE) { mSilentMode = isSilentMode(); mSelector.setRightHintText(mSilentMode ? R.string.lockscreen_sound_on_label : R.string.lockscreen_sound_off_label); } mCallback.pokeWakelock(); } /** Loading Loading @@ -354,30 +375,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM } private void refreshTimeAndDateDisplay() { Date now = new Date(); mTime.setText(mTimeFormat.format(now)); mDate.setText(mDateFormat.format(now)); } /** * @return A localized format like "Fri, Sep 18, 2009" */ private java.text.DateFormat getLockScreenDateFormat() { SimpleDateFormat adjusted = null; try { // this call gives us the localized order final SimpleDateFormat dateFormat = (SimpleDateFormat) java.text.DateFormat.getDateInstance(java.text.DateFormat.FULL); adjusted = new SimpleDateFormat(dateFormat.toPattern() .replace("MMMM", "MMM") // we want "Sep", not "September" .replace("EEEE", "EEE")); // we want "Fri", no "Friday" } catch (ClassCastException e) { // in case the library implementation changes and this throws a class cast exception // or anything else that is funky Log.e("LockScreen", "couldn't finnagle our custom date format :(", e); return java.text.DateFormat.getDateInstance(java.text.DateFormat.MEDIUM); } return adjusted; mDate.setText(DateFormat.format(mDateFormatString, new Date())); } private void updateStatusLines() { Loading Loading @@ -468,7 +466,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM // layout mScreenLocked.setVisibility(View.VISIBLE); mRotary.setVisibility(View.VISIBLE); mSelector.setVisibility(View.VISIBLE); mEmergencyCallButton.setVisibility(View.GONE); break; case NetworkLocked: Loading @@ -478,7 +476,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM // layout mScreenLocked.setVisibility(View.VISIBLE); mRotary.setVisibility(View.VISIBLE); mSelector.setVisibility(View.VISIBLE); mEmergencyCallButton.setVisibility(View.GONE); break; case SimMissing: Loading @@ -488,9 +486,9 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM // layout mScreenLocked.setVisibility(View.INVISIBLE); mRotary.setVisibility(View.VISIBLE); mSelector.setVisibility(View.VISIBLE); mEmergencyCallButton.setVisibility(View.VISIBLE); putEmergencyBelow(R.id.divider); putEmergencyBelow(R.id.screenLocked); break; case SimMissingLocked: // text Loading @@ -499,7 +497,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM // layout mScreenLocked.setVisibility(View.VISIBLE); mRotary.setVisibility(View.GONE); mSelector.setVisibility(View.GONE); mEmergencyCallButton.setVisibility(View.VISIBLE); putEmergencyBelow(R.id.screenLocked); break; Loading @@ -509,7 +507,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM // layout mScreenLocked.setVisibility(View.INVISIBLE); mRotary.setVisibility(View.VISIBLE); mSelector.setVisibility(View.VISIBLE); mEmergencyCallButton.setVisibility(View.GONE); break; case SimPukLocked: Loading @@ -519,7 +517,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM // layout mScreenLocked.setVisibility(View.VISIBLE); mRotary.setVisibility(View.GONE); mSelector.setVisibility(View.GONE); mEmergencyCallButton.setVisibility(View.VISIBLE); putEmergencyBelow(R.id.screenLocked); break; Loading Loading @@ -578,4 +576,13 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM public void cleanUp() { mUpdateMonitor.removeCallback(this); } /** {@inheritDoc} */ public void onRingerModeChanged(int state) { boolean silent = AudioManager.RINGER_MODE_SILENT == state; if (silent != mSilentMode) { mSilentMode = silent; updateRightTabResources(); } } } Loading
policy/com/android/internal/policy/impl/KeyguardUpdateMonitor.java +38 −15 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.database.ContentObserver; import static android.os.BatteryManager.BATTERY_STATUS_CHARGING; import static android.os.BatteryManager.BATTERY_STATUS_FULL; import static android.os.BatteryManager.BATTERY_STATUS_UNKNOWN; import android.media.AudioManager; import android.os.Handler; import android.os.Message; import android.provider.Settings; Loading Loading @@ -94,6 +95,7 @@ public class KeyguardUpdateMonitor { private static final int MSG_BATTERY_UPDATE = 302; private static final int MSG_CARRIER_INFO_UPDATE = 303; private static final int MSG_SIM_STATE_CHANGE = 304; private static final int MSG_RINGER_MODE_CHANGED = 305; /** Loading Loading @@ -160,6 +162,9 @@ public class KeyguardUpdateMonitor { case MSG_SIM_STATE_CHANGE: handleSimStateChange((SimArgs) msg.obj); break; case MSG_RINGER_MODE_CHANGED: handleRingerModeChange(msg.arg1); break; } } }; Loading Loading @@ -217,6 +222,7 @@ public class KeyguardUpdateMonitor { filter.addAction(Intent.ACTION_TIMEZONE_CHANGED); filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED); filter.addAction(SPN_STRINGS_UPDATED_ACTION); filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION); context.registerReceiver(new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { Loading Loading @@ -246,11 +252,21 @@ public class KeyguardUpdateMonitor { mHandler.sendMessage(mHandler.obtainMessage( MSG_SIM_STATE_CHANGE, new SimArgs(intent))); } else if (AudioManager.RINGER_MODE_CHANGED_ACTION.equals(action)) { mHandler.sendMessage(mHandler.obtainMessage(MSG_RINGER_MODE_CHANGED, intent.getIntExtra(AudioManager.EXTRA_RINGER_MODE, -1), 0)); } } }, filter); } protected void handleRingerModeChange(int mode) { if (DEBUG) Log.d(TAG, "handleRingerModeChange(" + mode + ")"); for (int i = 0; i < mInfoCallbacks.size(); i++) { mInfoCallbacks.get(i).onRingerModeChanged(mode); } } /** * Handle {@link #MSG_CONFIGURATION_CHANGED} */ Loading Loading @@ -443,7 +459,7 @@ public class KeyguardUpdateMonitor { } /** * Callback for general information releveant to lock screen. * Callback for general information relevant to lock screen. */ interface InfoCallback { void onRefreshBatteryInfo(boolean showBatteryInfo, boolean pluggedIn, int batteryLevel); Loading @@ -455,6 +471,13 @@ public class KeyguardUpdateMonitor { * @param spn The service provider name. May be null if it shouldn't be displayed. */ void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn); /** * Called when the ringer mode changes. * @param state the current ringer state, as defined in * {@link AudioManager#RINGER_MODE_CHANGED_ACTION} */ void onRingerModeChanged(int state); } /** Loading
policy/com/android/internal/policy/impl/KeyguardViewManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ public class KeyguardViewManager implements KeyguardWindowController { * lazily. */ public synchronized void show() { if (DEBUG) Log.d(TAG, "show()"); if (DEBUG) Log.d(TAG, "show(); mKeyguardView==" + mKeyguardView); if (mKeyguardHost == null) { if (DEBUG) Log.d(TAG, "keyguard host is null, creating it..."); Loading
policy/com/android/internal/policy/impl/KeyguardViewMediator.java +29 −4 Original line number Diff line number Diff line Loading @@ -105,6 +105,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback, private static final int KEYGUARD_DONE = 9; private static final int KEYGUARD_DONE_DRAWING = 10; private static final int KEYGUARD_DONE_AUTHENTICATING = 11; private static final int SET_HIDDEN = 12; /** * The default amount of time we stay awake (used for all key input) Loading Loading @@ -279,8 +280,9 @@ public class KeyguardViewMediator implements KeyguardViewCallback, /** * Called to let us know the screen was turned off. * @param why either {@link WindowManagerPolicy#OFF_BECAUSE_OF_USER} or * {@link WindowManagerPolicy#OFF_BECAUSE_OF_TIMEOUT}. * @param why either {@link WindowManagerPolicy#OFF_BECAUSE_OF_USER}, * {@link WindowManagerPolicy#OFF_BECAUSE_OF_TIMEOUT} or * {@link WindowManagerPolicy#OFF_BECAUSE_OF_PROX_SENSOR}. */ public void onScreenTurnedOff(int why) { synchronized (this) { Loading Loading @@ -311,6 +313,8 @@ public class KeyguardViewMediator implements KeyguardViewCallback, sender); if (DEBUG) Log.d(TAG, "setting alarm to turn off keyguard, seq = " + mDelayedShowingSequence); } else if (why == WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR) { // Do not enable the keyguard if the prox sensor forced the screen off. } else { doKeyguard(); } Loading Loading @@ -420,16 +424,34 @@ public class KeyguardViewMediator implements KeyguardViewCallback, return mShowing; } /** * Is the keyguard currently showing and not being force hidden? */ public boolean isShowingAndNotHidden() { return mShowing && !mHidden; } /** * Notify us when the keyguard is hidden by another window */ public void setHidden(boolean isHidden) { if (DEBUG) Log.d(TAG, "setHidden " + isHidden); mHandler.removeMessages(SET_HIDDEN); Message msg = mHandler.obtainMessage(SET_HIDDEN, (isHidden ? 1 : 0), 0); mHandler.sendMessage(msg); } /** * Handles SET_HIDDEN message sent by setHidden() */ private void handleSetHidden(boolean isHidden) { synchronized (KeyguardViewMediator.this) { if (mHidden != isHidden) { mHidden = isHidden; adjustUserActivityLocked(); } } } /** * Given the state of the keyguard, is the input restricted? Loading Loading @@ -812,6 +834,9 @@ public class KeyguardViewMediator implements KeyguardViewCallback, case KEYGUARD_DONE_AUTHENTICATING: keyguardDone(true); return; case SET_HIDDEN: handleSetHidden(msg.arg1 != 0); break; } } }; Loading
policy/com/android/internal/policy/impl/LockPatternKeyguardView.java +29 −13 Original line number Diff line number Diff line Loading @@ -160,7 +160,10 @@ public class LockPatternKeyguardView extends KeyguardViewBase } catch (AuthenticatorException e) { } mEnableFallback = !hasSAMLAccount; if (mUnlockScreen instanceof UnlockScreen) { if (mUnlockScreen == null) { Log.w(TAG, "no unlock screen when receiving AccountManager information"); } else if (mUnlockScreen instanceof UnlockScreen) { ((UnlockScreen)mUnlockScreen).setEnableFallback(true); } } Loading @@ -179,18 +182,6 @@ public class LockPatternKeyguardView extends KeyguardViewBase KeyguardWindowController controller) { super(context); final boolean hasAccount = AccountManager.get(context).getAccounts().length > 0; if (hasAccount) { /* If we have a SAML account which requires web login we can not use the fallback screen UI to ask the user for credentials. For now we will disable fallback screen in this case. Ultimately we could consider bringing up a web login from GLS but need to make sure that it will work in the "locked screen" mode. */ String[] features = new String[] {"saml"}; AccountManager.get(context).getAccountsByTypeAndFeatures( "com.google", features, this, null); } mEnableFallback = false; mRequiresSim = Loading Loading @@ -275,6 +266,9 @@ public class LockPatternKeyguardView extends KeyguardViewBase public void reportFailedPatternAttempt() { mUpdateMonitor.reportFailedAttempt(); final int failedAttempts = mUpdateMonitor.getFailedAttempts(); if (DEBUG) Log.d(TAG, "reportFailedPatternAttempt: #" + failedAttempts + " (enableFallback=" + mEnableFallback + ")"); if (mEnableFallback && failedAttempts == (LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET - LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) { Loading Loading @@ -313,8 +307,28 @@ public class LockPatternKeyguardView extends KeyguardViewBase mLockScreen = createLockScreen(); addView(mLockScreen); final UnlockMode unlockMode = getUnlockMode(); if (DEBUG) Log.d(TAG, "LockPatternKeyguardView ctor: about to createUnlockScreenFor; mEnableFallback=" + mEnableFallback); mUnlockScreen = createUnlockScreenFor(unlockMode); mUnlockScreenMode = unlockMode; // Ask the account manager if we have an account that can be used as a // fallback in case the user forgets his pattern. The response comes // back in run() below; don't bother asking until you've called // createUnlockScreenFor(), else the information will go unused. final boolean hasAccount = AccountManager.get(context).getAccounts().length > 0; if (hasAccount) { /* If we have a SAML account which requires web login we can not use the fallback screen UI to ask the user for credentials. For now we will disable fallback screen in this case. Ultimately we could consider bringing up a web login from GLS but need to make sure that it will work in the "locked screen" mode. */ String[] features = new String[] {"saml"}; AccountManager.get(context).getAccountsByTypeAndFeatures( "com.google", features, this, null); } addView(mUnlockScreen); updateScreen(mMode); } Loading Loading @@ -475,6 +489,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase mUpdateMonitor, mKeyguardScreenCallback, mUpdateMonitor.getFailedAttempts()); if (DEBUG) Log.d(TAG, "createUnlockScreenFor(" + unlockMode + "): mEnableFallback=" + mEnableFallback); view.setEnableFallback(mEnableFallback); return view; } else if (unlockMode == UnlockMode.SimPin) { Loading
policy/com/android/internal/policy/impl/LockScreen.java +68 −61 Original line number Diff line number Diff line Loading @@ -17,8 +17,9 @@ package com.android.internal.policy.impl; import com.android.internal.R; import com.android.internal.telephony.IccCard; import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.RotarySelector; import com.android.internal.widget.SlidingTab; import android.content.Context; import android.content.res.Resources; Loading @@ -33,11 +34,8 @@ import android.util.Log; import android.media.AudioManager; import android.os.SystemProperties; import com.android.internal.telephony.IccCard; import java.util.Date; import java.io.File; import java.text.SimpleDateFormat; /** * The screen within {@link LockPatternKeyguardView} that shows general Loading @@ -46,7 +44,7 @@ import java.text.SimpleDateFormat; */ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateMonitor.InfoCallback, KeyguardUpdateMonitor.SimStateCallback, KeyguardUpdateMonitor.ConfigurationChangeCallback, RotarySelector.OnDialTriggerListener { SlidingTab.OnTriggerListener { private static final boolean DBG = false; private static final String TAG = "LockScreen"; Loading @@ -59,7 +57,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM private final KeyguardScreenCallback mCallback; private TextView mCarrier; private RotarySelector mRotary; private SlidingTab mSelector; private TextView mTime; private TextView mDate; private TextView mStatus1; Loading @@ -83,7 +81,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM private boolean mSilentMode; private AudioManager mAudioManager; private java.text.DateFormat mDateFormat; private String mDateFormatString; private java.text.DateFormat mTimeFormat; private boolean mCreatedInPortrait; private boolean mEnableMenuKeyInLockScreen; Loading Loading @@ -175,13 +173,12 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM final LayoutInflater inflater = LayoutInflater.from(context); if (mCreatedInPortrait) { inflater.inflate(R.layout.keyguard_screen_rotary_unlock, this, true); inflater.inflate(R.layout.keyguard_screen_tab_unlock, this, true); } else { inflater.inflate(R.layout.keyguard_screen_rotary_unlock_land, this, true); inflater.inflate(R.layout.keyguard_screen_tab_unlock_land, this, true); } mCarrier = (TextView) findViewById(R.id.carrier); mTime = (TextView) findViewById(R.id.time); mDate = (TextView) findViewById(R.id.date); mStatus1 = (TextView) findViewById(R.id.status1); mStatus2 = (TextView) findViewById(R.id.status2); Loading @@ -189,7 +186,9 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM mEmergencyCallButton = (Button) findViewById(R.id.emergencyCallButton); mEmergencyCallButton.setText(R.string.lockscreen_emergency_call); mScreenLocked = (TextView) findViewById(R.id.screenLocked); mRotary = (RotarySelector) findViewById(R.id.rotary); mSelector = (SlidingTab) findViewById(R.id.tab_selector); mSelector.setHoldAfterTrigger(true, false); mSelector.setLeftHintText(R.string.lockscreen_unlock_label); mEmergencyCallButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mCallback.takeEmergencyCallAction(); Loading @@ -205,17 +204,35 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM updateMonitor.registerConfigurationChangeCallback(this); mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE); mSilentMode = mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT; mSilentMode = isSilentMode(); mRotary.setOnDialTriggerListener(this); mRotary.setLeftHandleResource(R.drawable.ic_jog_dial_unlock); mRotary.setRightHandleResource(mSilentMode ? R.drawable.ic_jog_dial_sound_off : R.drawable.ic_jog_dial_sound_on); mSelector.setLeftTabResources( R.drawable.ic_jog_dial_unlock, R.drawable.jog_tab_target_green, R.drawable.jog_tab_bar_left_unlock, R.drawable.jog_tab_left_unlock); updateRightTabResources(); mSelector.setOnTriggerListener(this); resetStatusInfo(updateMonitor); } private boolean isSilentMode() { return mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT; } private void updateRightTabResources() { mSelector.setRightTabResources( mSilentMode ? R.drawable.ic_jog_dial_sound_off : R.drawable.ic_jog_dial_sound_on, mSilentMode ? R.drawable.jog_tab_target_yellow : R.drawable.jog_tab_target_gray, mSilentMode ? R.drawable.jog_tab_bar_right_sound_on : R.drawable.jog_tab_bar_right_sound_off, mSilentMode ? R.drawable.jog_tab_right_sound_on : R.drawable.jog_tab_right_sound_off); } private void resetStatusInfo(KeyguardUpdateMonitor updateMonitor) { mShowingBatteryInfo = updateMonitor.shouldShowBatteryInfo(); mPluggedIn = updateMonitor.isDevicePluggedIn(); Loading @@ -228,7 +245,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM refreshAlarmDisplay(); mTimeFormat = DateFormat.getTimeFormat(getContext()); mDateFormat = getLockScreenDateFormat(); mDateFormatString = getContext().getString(R.string.full_wday_month_day_no_year); refreshTimeAndDateDisplay(); updateStatusLines(); } Loading @@ -242,24 +259,23 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM } /** {@inheritDoc} */ public void onDialTrigger(View v, int whichHandle) { if (whichHandle == RotarySelector.OnDialTriggerListener.LEFT_HANDLE) { public void onTrigger(View v, int whichHandle) { if (whichHandle == SlidingTab.OnTriggerListener.LEFT_HANDLE) { mCallback.goToUnlockScreen(); } else if (whichHandle == RotarySelector.OnDialTriggerListener.RIGHT_HANDLE) { } else if (whichHandle == SlidingTab.OnTriggerListener.RIGHT_HANDLE) { // toggle silent mode mSilentMode = !mSilentMode; mAudioManager.setRingerMode(mSilentMode ? AudioManager.RINGER_MODE_SILENT : AudioManager.RINGER_MODE_NORMAL); final int handleIcon = mSilentMode ? R.drawable.ic_jog_dial_sound_off : R.drawable.ic_jog_dial_sound_on; final int toastIcon = mSilentMode ? R.drawable.ic_lock_ringer_off : R.drawable.ic_lock_ringer_on; mRotary.setRightHandleResource(handleIcon); updateRightTabResources(); String message = mSilentMode ? getContext().getString(R.string.global_action_silent_mode_on_status) : getContext().getString(R.string.global_action_silent_mode_off_status); final int toastIcon = mSilentMode ? R.drawable.ic_lock_ringer_off : R.drawable.ic_lock_ringer_on; toastMessage(mScreenLocked, message, toastIcon); mCallback.pokeWakelock(); } Loading @@ -267,7 +283,12 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM /** {@inheritDoc} */ public void onGrabbedStateChange(View v, int grabbedState) { // TODO: Update onscreen hint text based on the new state. if (grabbedState == SlidingTab.OnTriggerListener.RIGHT_HANDLE) { mSilentMode = isSilentMode(); mSelector.setRightHintText(mSilentMode ? R.string.lockscreen_sound_on_label : R.string.lockscreen_sound_off_label); } mCallback.pokeWakelock(); } /** Loading Loading @@ -354,30 +375,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM } private void refreshTimeAndDateDisplay() { Date now = new Date(); mTime.setText(mTimeFormat.format(now)); mDate.setText(mDateFormat.format(now)); } /** * @return A localized format like "Fri, Sep 18, 2009" */ private java.text.DateFormat getLockScreenDateFormat() { SimpleDateFormat adjusted = null; try { // this call gives us the localized order final SimpleDateFormat dateFormat = (SimpleDateFormat) java.text.DateFormat.getDateInstance(java.text.DateFormat.FULL); adjusted = new SimpleDateFormat(dateFormat.toPattern() .replace("MMMM", "MMM") // we want "Sep", not "September" .replace("EEEE", "EEE")); // we want "Fri", no "Friday" } catch (ClassCastException e) { // in case the library implementation changes and this throws a class cast exception // or anything else that is funky Log.e("LockScreen", "couldn't finnagle our custom date format :(", e); return java.text.DateFormat.getDateInstance(java.text.DateFormat.MEDIUM); } return adjusted; mDate.setText(DateFormat.format(mDateFormatString, new Date())); } private void updateStatusLines() { Loading Loading @@ -468,7 +466,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM // layout mScreenLocked.setVisibility(View.VISIBLE); mRotary.setVisibility(View.VISIBLE); mSelector.setVisibility(View.VISIBLE); mEmergencyCallButton.setVisibility(View.GONE); break; case NetworkLocked: Loading @@ -478,7 +476,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM // layout mScreenLocked.setVisibility(View.VISIBLE); mRotary.setVisibility(View.VISIBLE); mSelector.setVisibility(View.VISIBLE); mEmergencyCallButton.setVisibility(View.GONE); break; case SimMissing: Loading @@ -488,9 +486,9 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM // layout mScreenLocked.setVisibility(View.INVISIBLE); mRotary.setVisibility(View.VISIBLE); mSelector.setVisibility(View.VISIBLE); mEmergencyCallButton.setVisibility(View.VISIBLE); putEmergencyBelow(R.id.divider); putEmergencyBelow(R.id.screenLocked); break; case SimMissingLocked: // text Loading @@ -499,7 +497,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM // layout mScreenLocked.setVisibility(View.VISIBLE); mRotary.setVisibility(View.GONE); mSelector.setVisibility(View.GONE); mEmergencyCallButton.setVisibility(View.VISIBLE); putEmergencyBelow(R.id.screenLocked); break; Loading @@ -509,7 +507,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM // layout mScreenLocked.setVisibility(View.INVISIBLE); mRotary.setVisibility(View.VISIBLE); mSelector.setVisibility(View.VISIBLE); mEmergencyCallButton.setVisibility(View.GONE); break; case SimPukLocked: Loading @@ -519,7 +517,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM // layout mScreenLocked.setVisibility(View.VISIBLE); mRotary.setVisibility(View.GONE); mSelector.setVisibility(View.GONE); mEmergencyCallButton.setVisibility(View.VISIBLE); putEmergencyBelow(R.id.screenLocked); break; Loading Loading @@ -578,4 +576,13 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM public void cleanUp() { mUpdateMonitor.removeCallback(this); } /** {@inheritDoc} */ public void onRingerModeChanged(int state) { boolean silent = AudioManager.RINGER_MODE_SILENT == state; if (silent != mSilentMode) { mSilentMode = silent; updateRightTabResources(); } } }