Loading policy/com/android/internal/policy/impl/AccountUnlockScreen.java +4 −67 Original line number Original line Diff line number Diff line Loading @@ -32,7 +32,6 @@ import android.text.Editable; import android.text.InputFilter; import android.text.InputFilter; import android.text.LoginFilter; import android.text.LoginFilter; import android.text.TextWatcher; import android.text.TextWatcher; import android.text.TextUtils; import android.util.Log; import android.util.Log; import android.view.KeyEvent; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.LayoutInflater; Loading @@ -51,6 +50,8 @@ import android.widget.TextView; */ */ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScreen, public class AccountUnlockScreen extends RelativeLayout implements KeyguardScreen, View.OnClickListener, ServiceConnection, TextWatcher { View.OnClickListener, ServiceConnection, TextWatcher { private static final String LOCK_PATTERN_PACKAGE = "com.android.settings"; private static final String LOCK_PATTERN_PACKAGE = "com.android.settings"; private static final String LOCK_PATTERN_CLASS = private static final String LOCK_PATTERN_CLASS = "com.android.settings.ChooseLockPattern"; "com.android.settings.ChooseLockPattern"; Loading Loading @@ -191,75 +192,11 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree return super.dispatchKeyEvent(event); return super.dispatchKeyEvent(event); } } /** * Given the string the user entered in the 'username' field, find * the stored account that they probably intended. Prefer, in order: * * - an exact match for what was typed, or * - a case-insensitive match for what was typed, or * - if they didn't include a domain, an exact match of the username, or * - if they didn't include a domain, a case-insensitive * match of the username. * * If there is a tie for the best match, choose neither -- * the user needs to be more specific. * * @return an account name from the database, or null if we can't * find a single best match. */ private String findIntendedAccount(String username) { String[] accounts = null; try { accounts = mAccountsService.getAccounts(); } catch (RemoteException e) { return null; } if (accounts == null) { return null; } // Try to figure out which account they meant if they // typed only the username (and not the domain), or got // the case wrong. String bestAccount = null; int bestScore = 0; for (String a: accounts) { int score = 0; if (username.equals(a)) { score = 4; } else if (username.equalsIgnoreCase(a)) { score = 3; } else if (username.indexOf('@') < 0) { int i = a.indexOf('@'); if (i >= 0) { String aUsername = a.substring(0, i); if (username.equals(aUsername)) { score = 2; } else if (username.equalsIgnoreCase(aUsername)) { score = 1; } } } if (score > bestScore) { bestAccount = a; bestScore = score; } else if (score == bestScore) { bestAccount = null; } } return bestAccount; } private boolean checkPassword() { private boolean checkPassword() { final String login = mLogin.getText().toString(); final String login = mLogin.getText().toString(); final String password = mPassword.getText().toString(); final String password = mPassword.getText().toString(); try { try { String account = findIntendedAccount(login); return mAccountsService.shouldUnlock(login, password); if (account == null) { return false; } return mAccountsService.shouldUnlock(account, password); } catch (RemoteException e) { } catch (RemoteException e) { return false; return false; } } Loading policy/com/android/internal/policy/impl/GlobalActions.java +50 −150 Original line number Original line Diff line number Diff line Loading @@ -16,30 +16,29 @@ package com.android.internal.policy.impl; package com.android.internal.policy.impl; import com.android.internal.R; import com.google.android.collect.Lists; import android.app.AlertDialog; import android.app.AlertDialog; import android.app.StatusBarManager; import android.app.StatusBarManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Context; import android.content.DialogInterface; import android.content.BroadcastReceiver; import android.content.Intent; import android.content.Intent; import android.content.IntentFilter; import android.content.IntentFilter; import android.content.DialogInterface; import android.media.AudioManager; import android.media.AudioManager; import android.os.LocalPowerManager; import android.os.Handler; import android.os.Handler; import android.os.Message; import android.os.Message; import android.provider.Settings; import android.os.SystemClock; import android.telephony.PhoneStateListener; import android.telephony.ServiceState; import android.telephony.TelephonyManager; import android.util.Log; import android.view.LayoutInflater; import android.view.LayoutInflater; import android.view.View; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup; import android.view.WindowManager; import android.view.WindowManager; import android.widget.BaseAdapter; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.TextView; import com.android.internal.R; import com.google.android.collect.Lists; import java.util.ArrayList; import java.util.ArrayList; Loading @@ -50,41 +49,34 @@ import java.util.ArrayList; */ */ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterface.OnClickListener { class GlobalActions implements DialogInterface.OnDismissListener, DialogInterface.OnClickListener { private static final String TAG = "GlobalActions"; private StatusBarManager mStatusBar; private StatusBarManager mStatusBar; private final Context mContext; private final Context mContext; private final LocalPowerManager mPowerManager; private final AudioManager mAudioManager; private final AudioManager mAudioManager; private ArrayList<Action> mItems; private ArrayList<Action> mItems; private AlertDialog mDialog; private AlertDialog mDialog; private ToggleAction mSilentModeToggle; private ToggleAction mSilentModeToggle; private ToggleAction mAirplaneModeOn; private MyAdapter mAdapter; private MyAdapter mAdapter; private boolean mKeyguardShowing = false; private boolean mKeyguardShowing = false; private boolean mDeviceProvisioned = false; private boolean mDeviceProvisioned = false; private ToggleAction.State mAirplaneState = ToggleAction.State.Off; /** /** * @param context everything needs a context :( * @param context everything needs a context :) * @param powerManager used to turn the screen off (the lock action). */ */ public GlobalActions(Context context) { public GlobalActions(Context context, LocalPowerManager powerManager) { mContext = context; mContext = context; mPowerManager = powerManager; mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); // receive broadcasts // receive broadcasts IntentFilter filter = new IntentFilter(); IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); context.registerReceiver(mBroadcastReceiver, filter); context.registerReceiver(mBroadcastReceiver, filter); // get notified of phone state changes TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); telephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE); } } /** /** Loading Loading @@ -131,48 +123,29 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac } } }; }; mAirplaneModeOn = new ToggleAction( mItems = Lists.newArrayList( R.drawable.ic_lock_airplane_mode, /* Disabled pending bug 1304831 -- key or touch events wake up device before it R.drawable.ic_lock_airplane_mode_off, * can go to sleep. R.string.global_actions_toggle_airplane_mode, // first: lock screen R.string.global_actions_airplane_mode_on_status, new SinglePressAction(com.android.internal.R.drawable.ic_lock_lock, R.string.global_action_lock) { R.string.global_actions_airplane_mode_off_status) { void onToggle(boolean on) { // Change the system setting Settings.System.putInt( mContext.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, on ? 1 : 0); Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); intent.putExtra("state", on); mContext.sendBroadcast(intent); } @Override public void onPress() { protected void changeStateFromPress(boolean buttonOn) { mPowerManager.goToSleep(SystemClock.uptimeMillis() + 1); mState = buttonOn ? State.TurningOn : State.TurningOff; mAirplaneState = mState; } } public boolean showDuringKeyguard() { public boolean showDuringKeyguard() { return true; return false; } } public boolean showBeforeProvisioning() { public boolean showBeforeProvisioning() { return false; return false; } } }; }, */ mItems = Lists.newArrayList( // next: silent mode // silent mode mSilentModeToggle, mSilentModeToggle, // next: airplane mode mAirplaneModeOn, // last: power off // last: power off new SinglePressAction( new SinglePressAction(com.android.internal.R.drawable.ic_lock_power_off, R.string.global_action_power_off) { com.android.internal.R.drawable.ic_lock_power_off, R.string.global_action_power_off) { public void onPress() { public void onPress() { // shutdown by making sure radio and power are handled accordingly. // shutdown by making sure radio and power are handled accordingly. Loading Loading @@ -207,11 +180,10 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac } } private void prepareDialog() { private void prepareDialog() { // TODO: May need another 'Vibrate' toggle button, but for now treat them the same final boolean silentModeOn = final boolean silentModeOn = mAudioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL; mAudioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL; mSilentModeToggle.updateState( mSilentModeToggle.updateState(silentModeOn); silentModeOn ? ToggleAction.State.On : ToggleAction.State.Off); mAirplaneModeOn.updateState(mAirplaneState); mAdapter.notifyDataSetChanged(); mAdapter.notifyDataSetChanged(); if (mKeyguardShowing) { if (mKeyguardShowing) { mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); Loading @@ -220,7 +192,6 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac } } } } /** {@inheritDoc} */ /** {@inheritDoc} */ public void onDismiss(DialogInterface dialog) { public void onDismiss(DialogInterface dialog) { mStatusBar.disable(StatusBarManager.DISABLE_NONE); mStatusBar.disable(StatusBarManager.DISABLE_NONE); Loading Loading @@ -258,16 +229,6 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac return count; return count; } } @Override public boolean isEnabled(int position) { return getItem(position).isEnabled(); } @Override public boolean areAllItemsEnabled() { return false; } public Action getItem(int position) { public Action getItem(int position) { int filteredPos = 0; int filteredPos = 0; Loading Loading @@ -298,7 +259,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) { Action action = getItem(position); Action action = getItem(position); return action.create(mContext, convertView, parent, LayoutInflater.from(mContext)); return action.create(mContext, (LinearLayout) convertView, LayoutInflater.from(mContext)); } } } } Loading @@ -312,7 +273,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac * What each item in the global actions dialog must be able to support. * What each item in the global actions dialog must be able to support. */ */ private interface Action { private interface Action { View create(Context context, View convertView, ViewGroup parent, LayoutInflater inflater); LinearLayout create(Context context, LinearLayout convertView, LayoutInflater inflater); void onPress(); void onPress(); Loading @@ -327,8 +288,6 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac * device is provisioned. * device is provisioned. */ */ boolean showBeforeProvisioning(); boolean showBeforeProvisioning(); boolean isEnabled(); } } /** /** Loading @@ -344,17 +303,12 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac mMessageResId = messageResId; mMessageResId = messageResId; } } public boolean isEnabled() { return true; } abstract public void onPress(); abstract public void onPress(); public View create( public LinearLayout create(Context context, LinearLayout convertView, LayoutInflater inflater) { Context context, View convertView, ViewGroup parent, LayoutInflater inflater) { LinearLayout v = (LinearLayout) ((convertView != null) ? View v = (convertView != null) ? convertView : convertView : inflater.inflate(R.layout.global_actions_item, parent, false); inflater.inflate(R.layout.global_actions_item, null)); ImageView icon = (ImageView) v.findViewById(R.id.icon); ImageView icon = (ImageView) v.findViewById(R.id.icon); TextView messageView = (TextView) v.findViewById(R.id.message); TextView messageView = (TextView) v.findViewById(R.id.message); Loading @@ -372,26 +326,9 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac * A toggle action knows whether it is on or off, and displays an icon * A toggle action knows whether it is on or off, and displays an icon * and status message accordingly. * and status message accordingly. */ */ private static abstract class ToggleAction implements Action { static abstract class ToggleAction implements Action { enum State { Off(false), TurningOn(true), TurningOff(true), On(false); private final boolean inTransition; private boolean mOn = false; State(boolean intermediate) { inTransition = intermediate; } public boolean inTransition() { return inTransition; } } protected State mState = State.Off; // prefs // prefs private final int mEnabledIconResId; private final int mEnabledIconResId; Loading Loading @@ -419,12 +356,12 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac mDisabledStatusMessageResId = disabledStatusMessageResId; mDisabledStatusMessageResId = disabledStatusMessageResId; } } public View create(Context context, View convertView, ViewGroup parent, public LinearLayout create(Context context, LinearLayout convertView, LayoutInflater inflater) { LayoutInflater inflater) { View v = (convertView != null) ? LinearLayout v = (LinearLayout) ((convertView != null) ? convertView : convertView : inflater.inflate(R inflater.inflate(R .layout.global_actions_item, parent, false); .layout.global_actions_item, null)); ImageView icon = (ImageView) v.findViewById(R.id.icon); ImageView icon = (ImageView) v.findViewById(R.id.icon); TextView messageView = (TextView) v.findViewById(R.id.message); TextView messageView = (TextView) v.findViewById(R.id.message); Loading @@ -432,50 +369,23 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac messageView.setText(mMessageResId); messageView.setText(mMessageResId); boolean on = ((mState == State.On) || (mState == State.TurningOn)); icon.setImageDrawable(context.getResources().getDrawable( icon.setImageDrawable(context.getResources().getDrawable( (on ? mEnabledIconResId : mDisabledIconResid))); (mOn ? mEnabledIconResId : mDisabledIconResid))); statusView.setText(on ? mEnabledStatusMessageResId : mDisabledStatusMessageResId); statusView.setText(mOn ? mEnabledStatusMessageResId : mDisabledStatusMessageResId); statusView.setVisibility(View.VISIBLE); statusView.setVisibility(View.VISIBLE); final boolean enabled = isEnabled(); messageView.setEnabled(enabled); statusView.setEnabled(enabled); icon.setEnabled(enabled); v.setEnabled(enabled); return v; return v; } } public final void onPress() { public void onPress() { if (mState.inTransition()) { updateState(!mOn); Log.w(TAG, "shouldn't be able to toggle when in transition"); onToggle(mOn); return; } final boolean nowOn = !(mState == State.On); onToggle(nowOn); changeStateFromPress(nowOn); } public boolean isEnabled() { return !mState.inTransition(); } /** * Implementations may override this if their state can be in on of the intermediate * states until some notification is received (e.g airplane mode is 'turning off' until * we know the wireless connections are back online * @param buttonOn Whether the button was turned on or off */ protected void changeStateFromPress(boolean buttonOn) { mState = buttonOn ? State.On : State.Off; } } abstract void onToggle(boolean on); abstract void onToggle(boolean on); public void updateState(State state) { public void updateState(boolean on) { mState = state; mOn = on; } } } } Loading @@ -491,16 +401,6 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac } } }; }; PhoneStateListener mPhoneStateListener = new PhoneStateListener() { @Override public void onServiceStateChanged(ServiceState serviceState) { final boolean inAirplaneMode = serviceState.getState() == ServiceState.STATE_POWER_OFF; mAirplaneState = inAirplaneMode ? ToggleAction.State.On : ToggleAction.State.Off; mAirplaneModeOn.updateState(mAirplaneState); mAdapter.notifyDataSetChanged(); } }; private static final int MESSAGE_DISMISS = 0; private static final int MESSAGE_DISMISS = 0; private Handler mHandler = new Handler() { private Handler mHandler = new Handler() { public void handleMessage(Message msg) { public void handleMessage(Message msg) { Loading policy/com/android/internal/policy/impl/LockPatternKeyguardView.java +3 −72 Original line number Original line Diff line number Diff line Loading @@ -32,12 +32,6 @@ import android.util.Log; import android.view.KeyEvent; import android.view.KeyEvent; import android.view.View; import android.view.View; import android.view.WindowManager; import android.view.WindowManager; import android.graphics.drawable.Drawable; import android.graphics.drawable.BitmapDrawable; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.PixelFormat; import android.graphics.ColorFilter; import com.android.internal.R; import com.android.internal.R; import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils; Loading Loading @@ -239,8 +233,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase { (LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET (LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET - LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) { - LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) { showAlmostAtAccountLoginDialog(); showAlmostAtAccountLoginDialog(); } else if (mHasAccount } else if (mHasAccount && failedAttempts >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET) { && failedAttempts >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET) { mLockPatternUtils.setPermanentlyLocked(true); mLockPatternUtils.setPermanentlyLocked(true); updateScreen(mMode); updateScreen(mMode); } else if ((failedAttempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) } else if ((failedAttempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) Loading @@ -261,11 +254,6 @@ public class LockPatternKeyguardView extends KeyguardViewBase { setFocusableInTouchMode(true); setFocusableInTouchMode(true); setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); // wall paper background final BitmapDrawable drawable = (BitmapDrawable) context.getWallpaper(); setBackgroundDrawable( new FastBitmapDrawable(drawable.getBitmap())); // create both the lock and unlock screen so they are quickly available // create both the lock and unlock screen so they are quickly available // when the screen turns on // when the screen turns on mLockScreen = createLockScreen(); mLockScreen = createLockScreen(); Loading Loading @@ -420,10 +408,6 @@ public class LockPatternKeyguardView extends KeyguardViewBase { final View visibleScreen = (mode == Mode.LockScreen) final View visibleScreen = (mode == Mode.LockScreen) ? mLockScreen : getUnlockScreenForCurrentUnlockMode(); ? mLockScreen : getUnlockScreenForCurrentUnlockMode(); // do this before changing visibility so focus isn't requested before the input // flag is set mWindowController.setNeedsInput(((KeyguardScreen)visibleScreen).needsInput()); if (mScreenOn) { if (mScreenOn) { if (goneScreen.getVisibility() == View.VISIBLE) { if (goneScreen.getVisibility() == View.VISIBLE) { Loading @@ -437,6 +421,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase { goneScreen.setVisibility(View.GONE); goneScreen.setVisibility(View.GONE); visibleScreen.setVisibility(View.VISIBLE); visibleScreen.setVisibility(View.VISIBLE); mWindowController.setNeedsInput(((KeyguardScreen)visibleScreen).needsInput()); if (!visibleScreen.requestFocus()) { if (!visibleScreen.requestFocus()) { throw new IllegalStateException("keyguard screen must be able to take " throw new IllegalStateException("keyguard screen must be able to take " Loading Loading @@ -582,58 +567,4 @@ public class LockPatternKeyguardView extends KeyguardViewBase { WindowManager.LayoutParams.FLAG_BLUR_BEHIND); WindowManager.LayoutParams.FLAG_BLUR_BEHIND); dialog.show(); dialog.show(); } } /** * Used to put wallpaper on the background of the lock screen. Centers it Horizontally and * vertically. */ static private class FastBitmapDrawable extends Drawable { private Bitmap mBitmap; private FastBitmapDrawable(Bitmap bitmap) { mBitmap = bitmap; } @Override public void draw(Canvas canvas) { canvas.drawBitmap( mBitmap, (getBounds().width() - mBitmap.getWidth()) / 2, (getBounds().height() - mBitmap.getHeight()) / 2, null); } @Override public int getOpacity() { return PixelFormat.TRANSLUCENT; } @Override public void setAlpha(int alpha) { } @Override public void setColorFilter(ColorFilter cf) { } @Override public int getIntrinsicWidth() { return mBitmap.getWidth(); } @Override public int getIntrinsicHeight() { return mBitmap.getHeight(); } @Override public int getMinimumWidth() { return mBitmap.getWidth(); } @Override public int getMinimumHeight() { return mBitmap.getHeight(); } } } } policy/com/android/internal/policy/impl/PhoneWindow.java +4 −36 Original line number Original line Diff line number Diff line Loading @@ -155,45 +155,14 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { private boolean mKeycodeCameraTimeoutActive = false; private boolean mKeycodeCameraTimeoutActive = false; static final int MSG_MENU_LONG_PRESS = 1; static final int MSG_MENU_LONG_PRESS = 1; static final int MSG_MENU_LONG_PRESS_COMPLETE = 2; static final int MSG_CALL_LONG_PRESS = 2; static final int MSG_CALL_LONG_PRESS = 3; static final int MSG_CAMERA_LONG_PRESS = 3; static final int MSG_CALL_LONG_PRESS_COMPLETE = 4; static final int MSG_CAMERA_LONG_PRESS = 5; static final int MSG_CAMERA_LONG_PRESS_COMPLETE = 6; private final Handler mKeycodeMenuTimeoutHandler = new Handler() { private final Handler mKeycodeMenuTimeoutHandler = new Handler() { @Override @Override public void handleMessage(Message msg) { public void handleMessage(Message msg) { switch (msg.what) { switch (msg.what) { case MSG_MENU_LONG_PRESS: { case MSG_MENU_LONG_PRESS: { if (mPanelChordingKey == 0) return; // Before actually doing the long press, enqueue another // message and do the processing there. This helps if // the app isn't being responsive, and finally woke up -- // if the window manager wasn't told about it processing // the down key for too long, it would enqueue the key up // at a time after the timeout of this message. So we go // through another message, to make sure we process an up // before continuing. mKeycodeMenuTimeoutHandler.sendEmptyMessage( MSG_MENU_LONG_PRESS_COMPLETE); break; } case MSG_CALL_LONG_PRESS: { if (!mKeycodeCallTimeoutActive) return; // See above. mKeycodeMenuTimeoutHandler.sendEmptyMessage( MSG_CALL_LONG_PRESS_COMPLETE); break; } case MSG_CAMERA_LONG_PRESS: { if (!mKeycodeCameraTimeoutActive) return; // See above. mKeycodeMenuTimeoutHandler.sendEmptyMessage( MSG_CAMERA_LONG_PRESS_COMPLETE); break; } case MSG_MENU_LONG_PRESS_COMPLETE: { if (mPanelChordingKey == 0) return; if (mPanelChordingKey == 0) return; mPanelChordingKey = 0; mPanelChordingKey = 0; mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); Loading @@ -203,7 +172,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { imm.showSoftInputUnchecked(InputMethodManager.SHOW_FORCED); imm.showSoftInputUnchecked(InputMethodManager.SHOW_FORCED); } } } break; } break; case MSG_CALL_LONG_PRESS_COMPLETE: { case MSG_CALL_LONG_PRESS: { if (!mKeycodeCallTimeoutActive) return; if (!mKeycodeCallTimeoutActive) return; mKeycodeCallTimeoutActive = false; mKeycodeCallTimeoutActive = false; mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); Loading @@ -217,7 +186,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { startCallActivity(); startCallActivity(); } } } break; } break; case MSG_CAMERA_LONG_PRESS_COMPLETE: { case MSG_CAMERA_LONG_PRESS: { if (!mKeycodeCameraTimeoutActive) return; if (!mKeycodeCameraTimeoutActive) return; mKeycodeCameraTimeoutActive = false; mKeycodeCameraTimeoutActive = false; mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); Loading @@ -225,7 +194,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { Intent intent = new Intent(Intent.ACTION_CAMERA_BUTTON, null); Intent intent = new Intent(Intent.ACTION_CAMERA_BUTTON, null); intent.putExtra(Intent.EXTRA_KEY_EVENT, (KeyEvent) msg.obj); intent.putExtra(Intent.EXTRA_KEY_EVENT, (KeyEvent) msg.obj); getContext().sendOrderedBroadcast(intent, null); getContext().sendOrderedBroadcast(intent, null); sendCloseSystemWindows(); } break; } break; } } } } Loading policy/com/android/internal/policy/impl/PhoneWindowManager.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -139,7 +139,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { static public final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps"; static public final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps"; // Vibrator pattern for haptic feedback of a long press. // Vibrator pattern for haptic feedback of a long press. private static final long[] LONG_PRESS_VIBE_PATTERN = {0, 1, 20, 21}; private static final long[] LONG_PRESS_VIBE_PATTERN = {0, 1, 40, 41}; // Vibrator pattern for haptic feedback of a zoom ring tick // Vibrator pattern for haptic feedback of a zoom ring tick private static final long[] ZOOM_RING_TICK_VIBE_PATTERN = {0, 10}; private static final long[] ZOOM_RING_TICK_VIBE_PATTERN = {0, 10}; Loading Loading @@ -388,7 +388,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { void showGlobalActionsDialog() { void showGlobalActionsDialog() { if (mGlobalActions == null) { if (mGlobalActions == null) { mGlobalActions = new GlobalActions(mContext); mGlobalActions = new GlobalActions(mContext, mPowerManager); } } final boolean keyguardShowing = mKeyguardMediator.isShowing(); final boolean keyguardShowing = mKeyguardMediator.isShowing(); mGlobalActions.showDialog(keyguardShowing, isDeviceProvisioned()); mGlobalActions.showDialog(keyguardShowing, isDeviceProvisioned()); Loading Loading
policy/com/android/internal/policy/impl/AccountUnlockScreen.java +4 −67 Original line number Original line Diff line number Diff line Loading @@ -32,7 +32,6 @@ import android.text.Editable; import android.text.InputFilter; import android.text.InputFilter; import android.text.LoginFilter; import android.text.LoginFilter; import android.text.TextWatcher; import android.text.TextWatcher; import android.text.TextUtils; import android.util.Log; import android.util.Log; import android.view.KeyEvent; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.LayoutInflater; Loading @@ -51,6 +50,8 @@ import android.widget.TextView; */ */ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScreen, public class AccountUnlockScreen extends RelativeLayout implements KeyguardScreen, View.OnClickListener, ServiceConnection, TextWatcher { View.OnClickListener, ServiceConnection, TextWatcher { private static final String LOCK_PATTERN_PACKAGE = "com.android.settings"; private static final String LOCK_PATTERN_PACKAGE = "com.android.settings"; private static final String LOCK_PATTERN_CLASS = private static final String LOCK_PATTERN_CLASS = "com.android.settings.ChooseLockPattern"; "com.android.settings.ChooseLockPattern"; Loading Loading @@ -191,75 +192,11 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree return super.dispatchKeyEvent(event); return super.dispatchKeyEvent(event); } } /** * Given the string the user entered in the 'username' field, find * the stored account that they probably intended. Prefer, in order: * * - an exact match for what was typed, or * - a case-insensitive match for what was typed, or * - if they didn't include a domain, an exact match of the username, or * - if they didn't include a domain, a case-insensitive * match of the username. * * If there is a tie for the best match, choose neither -- * the user needs to be more specific. * * @return an account name from the database, or null if we can't * find a single best match. */ private String findIntendedAccount(String username) { String[] accounts = null; try { accounts = mAccountsService.getAccounts(); } catch (RemoteException e) { return null; } if (accounts == null) { return null; } // Try to figure out which account they meant if they // typed only the username (and not the domain), or got // the case wrong. String bestAccount = null; int bestScore = 0; for (String a: accounts) { int score = 0; if (username.equals(a)) { score = 4; } else if (username.equalsIgnoreCase(a)) { score = 3; } else if (username.indexOf('@') < 0) { int i = a.indexOf('@'); if (i >= 0) { String aUsername = a.substring(0, i); if (username.equals(aUsername)) { score = 2; } else if (username.equalsIgnoreCase(aUsername)) { score = 1; } } } if (score > bestScore) { bestAccount = a; bestScore = score; } else if (score == bestScore) { bestAccount = null; } } return bestAccount; } private boolean checkPassword() { private boolean checkPassword() { final String login = mLogin.getText().toString(); final String login = mLogin.getText().toString(); final String password = mPassword.getText().toString(); final String password = mPassword.getText().toString(); try { try { String account = findIntendedAccount(login); return mAccountsService.shouldUnlock(login, password); if (account == null) { return false; } return mAccountsService.shouldUnlock(account, password); } catch (RemoteException e) { } catch (RemoteException e) { return false; return false; } } Loading
policy/com/android/internal/policy/impl/GlobalActions.java +50 −150 Original line number Original line Diff line number Diff line Loading @@ -16,30 +16,29 @@ package com.android.internal.policy.impl; package com.android.internal.policy.impl; import com.android.internal.R; import com.google.android.collect.Lists; import android.app.AlertDialog; import android.app.AlertDialog; import android.app.StatusBarManager; import android.app.StatusBarManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Context; import android.content.DialogInterface; import android.content.BroadcastReceiver; import android.content.Intent; import android.content.Intent; import android.content.IntentFilter; import android.content.IntentFilter; import android.content.DialogInterface; import android.media.AudioManager; import android.media.AudioManager; import android.os.LocalPowerManager; import android.os.Handler; import android.os.Handler; import android.os.Message; import android.os.Message; import android.provider.Settings; import android.os.SystemClock; import android.telephony.PhoneStateListener; import android.telephony.ServiceState; import android.telephony.TelephonyManager; import android.util.Log; import android.view.LayoutInflater; import android.view.LayoutInflater; import android.view.View; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup; import android.view.WindowManager; import android.view.WindowManager; import android.widget.BaseAdapter; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.TextView; import com.android.internal.R; import com.google.android.collect.Lists; import java.util.ArrayList; import java.util.ArrayList; Loading @@ -50,41 +49,34 @@ import java.util.ArrayList; */ */ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterface.OnClickListener { class GlobalActions implements DialogInterface.OnDismissListener, DialogInterface.OnClickListener { private static final String TAG = "GlobalActions"; private StatusBarManager mStatusBar; private StatusBarManager mStatusBar; private final Context mContext; private final Context mContext; private final LocalPowerManager mPowerManager; private final AudioManager mAudioManager; private final AudioManager mAudioManager; private ArrayList<Action> mItems; private ArrayList<Action> mItems; private AlertDialog mDialog; private AlertDialog mDialog; private ToggleAction mSilentModeToggle; private ToggleAction mSilentModeToggle; private ToggleAction mAirplaneModeOn; private MyAdapter mAdapter; private MyAdapter mAdapter; private boolean mKeyguardShowing = false; private boolean mKeyguardShowing = false; private boolean mDeviceProvisioned = false; private boolean mDeviceProvisioned = false; private ToggleAction.State mAirplaneState = ToggleAction.State.Off; /** /** * @param context everything needs a context :( * @param context everything needs a context :) * @param powerManager used to turn the screen off (the lock action). */ */ public GlobalActions(Context context) { public GlobalActions(Context context, LocalPowerManager powerManager) { mContext = context; mContext = context; mPowerManager = powerManager; mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); // receive broadcasts // receive broadcasts IntentFilter filter = new IntentFilter(); IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); context.registerReceiver(mBroadcastReceiver, filter); context.registerReceiver(mBroadcastReceiver, filter); // get notified of phone state changes TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); telephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE); } } /** /** Loading Loading @@ -131,48 +123,29 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac } } }; }; mAirplaneModeOn = new ToggleAction( mItems = Lists.newArrayList( R.drawable.ic_lock_airplane_mode, /* Disabled pending bug 1304831 -- key or touch events wake up device before it R.drawable.ic_lock_airplane_mode_off, * can go to sleep. R.string.global_actions_toggle_airplane_mode, // first: lock screen R.string.global_actions_airplane_mode_on_status, new SinglePressAction(com.android.internal.R.drawable.ic_lock_lock, R.string.global_action_lock) { R.string.global_actions_airplane_mode_off_status) { void onToggle(boolean on) { // Change the system setting Settings.System.putInt( mContext.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, on ? 1 : 0); Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); intent.putExtra("state", on); mContext.sendBroadcast(intent); } @Override public void onPress() { protected void changeStateFromPress(boolean buttonOn) { mPowerManager.goToSleep(SystemClock.uptimeMillis() + 1); mState = buttonOn ? State.TurningOn : State.TurningOff; mAirplaneState = mState; } } public boolean showDuringKeyguard() { public boolean showDuringKeyguard() { return true; return false; } } public boolean showBeforeProvisioning() { public boolean showBeforeProvisioning() { return false; return false; } } }; }, */ mItems = Lists.newArrayList( // next: silent mode // silent mode mSilentModeToggle, mSilentModeToggle, // next: airplane mode mAirplaneModeOn, // last: power off // last: power off new SinglePressAction( new SinglePressAction(com.android.internal.R.drawable.ic_lock_power_off, R.string.global_action_power_off) { com.android.internal.R.drawable.ic_lock_power_off, R.string.global_action_power_off) { public void onPress() { public void onPress() { // shutdown by making sure radio and power are handled accordingly. // shutdown by making sure radio and power are handled accordingly. Loading Loading @@ -207,11 +180,10 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac } } private void prepareDialog() { private void prepareDialog() { // TODO: May need another 'Vibrate' toggle button, but for now treat them the same final boolean silentModeOn = final boolean silentModeOn = mAudioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL; mAudioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL; mSilentModeToggle.updateState( mSilentModeToggle.updateState(silentModeOn); silentModeOn ? ToggleAction.State.On : ToggleAction.State.Off); mAirplaneModeOn.updateState(mAirplaneState); mAdapter.notifyDataSetChanged(); mAdapter.notifyDataSetChanged(); if (mKeyguardShowing) { if (mKeyguardShowing) { mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); Loading @@ -220,7 +192,6 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac } } } } /** {@inheritDoc} */ /** {@inheritDoc} */ public void onDismiss(DialogInterface dialog) { public void onDismiss(DialogInterface dialog) { mStatusBar.disable(StatusBarManager.DISABLE_NONE); mStatusBar.disable(StatusBarManager.DISABLE_NONE); Loading Loading @@ -258,16 +229,6 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac return count; return count; } } @Override public boolean isEnabled(int position) { return getItem(position).isEnabled(); } @Override public boolean areAllItemsEnabled() { return false; } public Action getItem(int position) { public Action getItem(int position) { int filteredPos = 0; int filteredPos = 0; Loading Loading @@ -298,7 +259,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) { Action action = getItem(position); Action action = getItem(position); return action.create(mContext, convertView, parent, LayoutInflater.from(mContext)); return action.create(mContext, (LinearLayout) convertView, LayoutInflater.from(mContext)); } } } } Loading @@ -312,7 +273,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac * What each item in the global actions dialog must be able to support. * What each item in the global actions dialog must be able to support. */ */ private interface Action { private interface Action { View create(Context context, View convertView, ViewGroup parent, LayoutInflater inflater); LinearLayout create(Context context, LinearLayout convertView, LayoutInflater inflater); void onPress(); void onPress(); Loading @@ -327,8 +288,6 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac * device is provisioned. * device is provisioned. */ */ boolean showBeforeProvisioning(); boolean showBeforeProvisioning(); boolean isEnabled(); } } /** /** Loading @@ -344,17 +303,12 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac mMessageResId = messageResId; mMessageResId = messageResId; } } public boolean isEnabled() { return true; } abstract public void onPress(); abstract public void onPress(); public View create( public LinearLayout create(Context context, LinearLayout convertView, LayoutInflater inflater) { Context context, View convertView, ViewGroup parent, LayoutInflater inflater) { LinearLayout v = (LinearLayout) ((convertView != null) ? View v = (convertView != null) ? convertView : convertView : inflater.inflate(R.layout.global_actions_item, parent, false); inflater.inflate(R.layout.global_actions_item, null)); ImageView icon = (ImageView) v.findViewById(R.id.icon); ImageView icon = (ImageView) v.findViewById(R.id.icon); TextView messageView = (TextView) v.findViewById(R.id.message); TextView messageView = (TextView) v.findViewById(R.id.message); Loading @@ -372,26 +326,9 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac * A toggle action knows whether it is on or off, and displays an icon * A toggle action knows whether it is on or off, and displays an icon * and status message accordingly. * and status message accordingly. */ */ private static abstract class ToggleAction implements Action { static abstract class ToggleAction implements Action { enum State { Off(false), TurningOn(true), TurningOff(true), On(false); private final boolean inTransition; private boolean mOn = false; State(boolean intermediate) { inTransition = intermediate; } public boolean inTransition() { return inTransition; } } protected State mState = State.Off; // prefs // prefs private final int mEnabledIconResId; private final int mEnabledIconResId; Loading Loading @@ -419,12 +356,12 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac mDisabledStatusMessageResId = disabledStatusMessageResId; mDisabledStatusMessageResId = disabledStatusMessageResId; } } public View create(Context context, View convertView, ViewGroup parent, public LinearLayout create(Context context, LinearLayout convertView, LayoutInflater inflater) { LayoutInflater inflater) { View v = (convertView != null) ? LinearLayout v = (LinearLayout) ((convertView != null) ? convertView : convertView : inflater.inflate(R inflater.inflate(R .layout.global_actions_item, parent, false); .layout.global_actions_item, null)); ImageView icon = (ImageView) v.findViewById(R.id.icon); ImageView icon = (ImageView) v.findViewById(R.id.icon); TextView messageView = (TextView) v.findViewById(R.id.message); TextView messageView = (TextView) v.findViewById(R.id.message); Loading @@ -432,50 +369,23 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac messageView.setText(mMessageResId); messageView.setText(mMessageResId); boolean on = ((mState == State.On) || (mState == State.TurningOn)); icon.setImageDrawable(context.getResources().getDrawable( icon.setImageDrawable(context.getResources().getDrawable( (on ? mEnabledIconResId : mDisabledIconResid))); (mOn ? mEnabledIconResId : mDisabledIconResid))); statusView.setText(on ? mEnabledStatusMessageResId : mDisabledStatusMessageResId); statusView.setText(mOn ? mEnabledStatusMessageResId : mDisabledStatusMessageResId); statusView.setVisibility(View.VISIBLE); statusView.setVisibility(View.VISIBLE); final boolean enabled = isEnabled(); messageView.setEnabled(enabled); statusView.setEnabled(enabled); icon.setEnabled(enabled); v.setEnabled(enabled); return v; return v; } } public final void onPress() { public void onPress() { if (mState.inTransition()) { updateState(!mOn); Log.w(TAG, "shouldn't be able to toggle when in transition"); onToggle(mOn); return; } final boolean nowOn = !(mState == State.On); onToggle(nowOn); changeStateFromPress(nowOn); } public boolean isEnabled() { return !mState.inTransition(); } /** * Implementations may override this if their state can be in on of the intermediate * states until some notification is received (e.g airplane mode is 'turning off' until * we know the wireless connections are back online * @param buttonOn Whether the button was turned on or off */ protected void changeStateFromPress(boolean buttonOn) { mState = buttonOn ? State.On : State.Off; } } abstract void onToggle(boolean on); abstract void onToggle(boolean on); public void updateState(State state) { public void updateState(boolean on) { mState = state; mOn = on; } } } } Loading @@ -491,16 +401,6 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac } } }; }; PhoneStateListener mPhoneStateListener = new PhoneStateListener() { @Override public void onServiceStateChanged(ServiceState serviceState) { final boolean inAirplaneMode = serviceState.getState() == ServiceState.STATE_POWER_OFF; mAirplaneState = inAirplaneMode ? ToggleAction.State.On : ToggleAction.State.Off; mAirplaneModeOn.updateState(mAirplaneState); mAdapter.notifyDataSetChanged(); } }; private static final int MESSAGE_DISMISS = 0; private static final int MESSAGE_DISMISS = 0; private Handler mHandler = new Handler() { private Handler mHandler = new Handler() { public void handleMessage(Message msg) { public void handleMessage(Message msg) { Loading
policy/com/android/internal/policy/impl/LockPatternKeyguardView.java +3 −72 Original line number Original line Diff line number Diff line Loading @@ -32,12 +32,6 @@ import android.util.Log; import android.view.KeyEvent; import android.view.KeyEvent; import android.view.View; import android.view.View; import android.view.WindowManager; import android.view.WindowManager; import android.graphics.drawable.Drawable; import android.graphics.drawable.BitmapDrawable; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.PixelFormat; import android.graphics.ColorFilter; import com.android.internal.R; import com.android.internal.R; import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils; Loading Loading @@ -239,8 +233,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase { (LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET (LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET - LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) { - LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) { showAlmostAtAccountLoginDialog(); showAlmostAtAccountLoginDialog(); } else if (mHasAccount } else if (mHasAccount && failedAttempts >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET) { && failedAttempts >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET) { mLockPatternUtils.setPermanentlyLocked(true); mLockPatternUtils.setPermanentlyLocked(true); updateScreen(mMode); updateScreen(mMode); } else if ((failedAttempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) } else if ((failedAttempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) Loading @@ -261,11 +254,6 @@ public class LockPatternKeyguardView extends KeyguardViewBase { setFocusableInTouchMode(true); setFocusableInTouchMode(true); setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); // wall paper background final BitmapDrawable drawable = (BitmapDrawable) context.getWallpaper(); setBackgroundDrawable( new FastBitmapDrawable(drawable.getBitmap())); // create both the lock and unlock screen so they are quickly available // create both the lock and unlock screen so they are quickly available // when the screen turns on // when the screen turns on mLockScreen = createLockScreen(); mLockScreen = createLockScreen(); Loading Loading @@ -420,10 +408,6 @@ public class LockPatternKeyguardView extends KeyguardViewBase { final View visibleScreen = (mode == Mode.LockScreen) final View visibleScreen = (mode == Mode.LockScreen) ? mLockScreen : getUnlockScreenForCurrentUnlockMode(); ? mLockScreen : getUnlockScreenForCurrentUnlockMode(); // do this before changing visibility so focus isn't requested before the input // flag is set mWindowController.setNeedsInput(((KeyguardScreen)visibleScreen).needsInput()); if (mScreenOn) { if (mScreenOn) { if (goneScreen.getVisibility() == View.VISIBLE) { if (goneScreen.getVisibility() == View.VISIBLE) { Loading @@ -437,6 +421,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase { goneScreen.setVisibility(View.GONE); goneScreen.setVisibility(View.GONE); visibleScreen.setVisibility(View.VISIBLE); visibleScreen.setVisibility(View.VISIBLE); mWindowController.setNeedsInput(((KeyguardScreen)visibleScreen).needsInput()); if (!visibleScreen.requestFocus()) { if (!visibleScreen.requestFocus()) { throw new IllegalStateException("keyguard screen must be able to take " throw new IllegalStateException("keyguard screen must be able to take " Loading Loading @@ -582,58 +567,4 @@ public class LockPatternKeyguardView extends KeyguardViewBase { WindowManager.LayoutParams.FLAG_BLUR_BEHIND); WindowManager.LayoutParams.FLAG_BLUR_BEHIND); dialog.show(); dialog.show(); } } /** * Used to put wallpaper on the background of the lock screen. Centers it Horizontally and * vertically. */ static private class FastBitmapDrawable extends Drawable { private Bitmap mBitmap; private FastBitmapDrawable(Bitmap bitmap) { mBitmap = bitmap; } @Override public void draw(Canvas canvas) { canvas.drawBitmap( mBitmap, (getBounds().width() - mBitmap.getWidth()) / 2, (getBounds().height() - mBitmap.getHeight()) / 2, null); } @Override public int getOpacity() { return PixelFormat.TRANSLUCENT; } @Override public void setAlpha(int alpha) { } @Override public void setColorFilter(ColorFilter cf) { } @Override public int getIntrinsicWidth() { return mBitmap.getWidth(); } @Override public int getIntrinsicHeight() { return mBitmap.getHeight(); } @Override public int getMinimumWidth() { return mBitmap.getWidth(); } @Override public int getMinimumHeight() { return mBitmap.getHeight(); } } } }
policy/com/android/internal/policy/impl/PhoneWindow.java +4 −36 Original line number Original line Diff line number Diff line Loading @@ -155,45 +155,14 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { private boolean mKeycodeCameraTimeoutActive = false; private boolean mKeycodeCameraTimeoutActive = false; static final int MSG_MENU_LONG_PRESS = 1; static final int MSG_MENU_LONG_PRESS = 1; static final int MSG_MENU_LONG_PRESS_COMPLETE = 2; static final int MSG_CALL_LONG_PRESS = 2; static final int MSG_CALL_LONG_PRESS = 3; static final int MSG_CAMERA_LONG_PRESS = 3; static final int MSG_CALL_LONG_PRESS_COMPLETE = 4; static final int MSG_CAMERA_LONG_PRESS = 5; static final int MSG_CAMERA_LONG_PRESS_COMPLETE = 6; private final Handler mKeycodeMenuTimeoutHandler = new Handler() { private final Handler mKeycodeMenuTimeoutHandler = new Handler() { @Override @Override public void handleMessage(Message msg) { public void handleMessage(Message msg) { switch (msg.what) { switch (msg.what) { case MSG_MENU_LONG_PRESS: { case MSG_MENU_LONG_PRESS: { if (mPanelChordingKey == 0) return; // Before actually doing the long press, enqueue another // message and do the processing there. This helps if // the app isn't being responsive, and finally woke up -- // if the window manager wasn't told about it processing // the down key for too long, it would enqueue the key up // at a time after the timeout of this message. So we go // through another message, to make sure we process an up // before continuing. mKeycodeMenuTimeoutHandler.sendEmptyMessage( MSG_MENU_LONG_PRESS_COMPLETE); break; } case MSG_CALL_LONG_PRESS: { if (!mKeycodeCallTimeoutActive) return; // See above. mKeycodeMenuTimeoutHandler.sendEmptyMessage( MSG_CALL_LONG_PRESS_COMPLETE); break; } case MSG_CAMERA_LONG_PRESS: { if (!mKeycodeCameraTimeoutActive) return; // See above. mKeycodeMenuTimeoutHandler.sendEmptyMessage( MSG_CAMERA_LONG_PRESS_COMPLETE); break; } case MSG_MENU_LONG_PRESS_COMPLETE: { if (mPanelChordingKey == 0) return; if (mPanelChordingKey == 0) return; mPanelChordingKey = 0; mPanelChordingKey = 0; mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); Loading @@ -203,7 +172,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { imm.showSoftInputUnchecked(InputMethodManager.SHOW_FORCED); imm.showSoftInputUnchecked(InputMethodManager.SHOW_FORCED); } } } break; } break; case MSG_CALL_LONG_PRESS_COMPLETE: { case MSG_CALL_LONG_PRESS: { if (!mKeycodeCallTimeoutActive) return; if (!mKeycodeCallTimeoutActive) return; mKeycodeCallTimeoutActive = false; mKeycodeCallTimeoutActive = false; mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); Loading @@ -217,7 +186,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { startCallActivity(); startCallActivity(); } } } break; } break; case MSG_CAMERA_LONG_PRESS_COMPLETE: { case MSG_CAMERA_LONG_PRESS: { if (!mKeycodeCameraTimeoutActive) return; if (!mKeycodeCameraTimeoutActive) return; mKeycodeCameraTimeoutActive = false; mKeycodeCameraTimeoutActive = false; mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); Loading @@ -225,7 +194,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { Intent intent = new Intent(Intent.ACTION_CAMERA_BUTTON, null); Intent intent = new Intent(Intent.ACTION_CAMERA_BUTTON, null); intent.putExtra(Intent.EXTRA_KEY_EVENT, (KeyEvent) msg.obj); intent.putExtra(Intent.EXTRA_KEY_EVENT, (KeyEvent) msg.obj); getContext().sendOrderedBroadcast(intent, null); getContext().sendOrderedBroadcast(intent, null); sendCloseSystemWindows(); } break; } break; } } } } Loading
policy/com/android/internal/policy/impl/PhoneWindowManager.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -139,7 +139,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { static public final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps"; static public final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps"; // Vibrator pattern for haptic feedback of a long press. // Vibrator pattern for haptic feedback of a long press. private static final long[] LONG_PRESS_VIBE_PATTERN = {0, 1, 20, 21}; private static final long[] LONG_PRESS_VIBE_PATTERN = {0, 1, 40, 41}; // Vibrator pattern for haptic feedback of a zoom ring tick // Vibrator pattern for haptic feedback of a zoom ring tick private static final long[] ZOOM_RING_TICK_VIBE_PATTERN = {0, 10}; private static final long[] ZOOM_RING_TICK_VIBE_PATTERN = {0, 10}; Loading Loading @@ -388,7 +388,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { void showGlobalActionsDialog() { void showGlobalActionsDialog() { if (mGlobalActions == null) { if (mGlobalActions == null) { mGlobalActions = new GlobalActions(mContext); mGlobalActions = new GlobalActions(mContext, mPowerManager); } } final boolean keyguardShowing = mKeyguardMediator.isShowing(); final boolean keyguardShowing = mKeyguardMediator.isShowing(); mGlobalActions.showDialog(keyguardShowing, isDeviceProvisioned()); mGlobalActions.showDialog(keyguardShowing, isDeviceProvisioned()); Loading