diff options
author | Jim Miller <jaggies@google.com> | 2013-02-28 17:36:24 -0800 |
---|---|---|
committer | Jim Miller <jaggies@google.com> | 2013-02-28 17:41:34 -0800 |
commit | 25190577cc69eaa5930c6fbdc2fcca03afc84982 (patch) | |
tree | 6e0679b910c2949f5cd66e1ac0e7d70acef9ed41 /packages/Keyguard/src/com | |
parent | 32e18d9f325d8ba59d90505008578f9448031496 (diff) | |
download | frameworks_base-25190577cc69eaa5930c6fbdc2fcca03afc84982.zip frameworks_base-25190577cc69eaa5930c6fbdc2fcca03afc84982.tar.gz frameworks_base-25190577cc69eaa5930c6fbdc2fcca03afc84982.tar.bz2 |
Post-review Keyguard cleanup.
- remove userActivity() from KeyguardService interface and call it
on PowerManager directly
- Split IKeyguardResult into two parts: IKeyguardShowCallback and
IKeyguardExitCallback.
- Misc other changes from the review.
Change-Id: I3f679cfa5d3f8bc742f2b2259ac354045e89a87b
Diffstat (limited to 'packages/Keyguard/src/com')
4 files changed, 58 insertions, 56 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardService.java b/packages/Keyguard/src/com/android/keyguard/KeyguardService.java index e697948..9fa4790 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardService.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardService.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 The Android Open Source Project + * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,10 +24,10 @@ import android.content.Intent; import android.os.Bundle; import android.os.IBinder; import android.util.Log; -import android.view.accessibility.AccessibilityManager; import com.android.internal.policy.IKeyguardService; -import com.android.internal.policy.IKeyguardResult; +import com.android.internal.policy.IKeyguardExitCallback; +import com.android.internal.policy.IKeyguardShowCallback; import com.android.internal.widget.LockPatternUtils; public class KeyguardService extends Service { @@ -66,11 +66,8 @@ public class KeyguardService extends Service { public boolean isInputRestricted() { return mKeyguardViewMediator.isInputRestricted(); } - public void userActivity() { - mKeyguardViewMediator.userActivity(); - } - public void verifyUnlock(IKeyguardResult result) { - mKeyguardViewMediator.verifyUnlock(result); + public void verifyUnlock(IKeyguardExitCallback callback) { + mKeyguardViewMediator.verifyUnlock(callback); } public void keyguardDone(boolean authenticated, boolean wakeup) { mKeyguardViewMediator.keyguardDone(authenticated, wakeup); @@ -81,11 +78,11 @@ public class KeyguardService extends Service { public void dismiss() { mKeyguardViewMediator.dismiss(); } - public void onWakeKeyWhenKeyguardShowingTq(int keyCode) { - mKeyguardViewMediator.onWakeKeyWhenKeyguardShowingTq(keyCode); + public void onWakeKeyWhenKeyguardShowing(int keyCode) { + mKeyguardViewMediator.onWakeKeyWhenKeyguardShowing(keyCode); } - public void onWakeMotionWhenKeyguardShowingTq() { - mKeyguardViewMediator.onWakeMotionWhenKeyguardShowingTq(); + public void onWakeMotionWhenKeyguardShowing() { + mKeyguardViewMediator.onWakeMotionWhenKeyguardShowing(); } public void onDreamingStarted() { mKeyguardViewMediator.onDreamingStarted(); @@ -96,8 +93,8 @@ public class KeyguardService extends Service { public void onScreenTurnedOff(int reason) { mKeyguardViewMediator.onScreenTurnedOff(reason); } - public void onScreenTurnedOn(IKeyguardResult result) { - mKeyguardViewMediator.onScreenTurnedOn(result); + public void onScreenTurnedOn(IKeyguardShowCallback callback) { + mKeyguardViewMediator.onScreenTurnedOn(callback); } public void setKeyguardEnabled(boolean enabled) { mKeyguardViewMediator.setKeyguardEnabled(enabled); diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardTestActivity.java b/packages/Keyguard/src/com/android/keyguard/KeyguardTestActivity.java index 3deaeed..0ff00e3 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardTestActivity.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardTestActivity.java @@ -16,7 +16,8 @@ package com.android.keyguard; -import com.android.internal.policy.IKeyguardResult; +import com.android.internal.policy.IKeyguardShowCallback; +import com.android.internal.policy.IKeyguardExitCallback; import com.android.internal.policy.IKeyguardService; import android.app.Activity; @@ -58,16 +59,21 @@ public class KeyguardTestActivity extends Activity implements OnClickListener { IKeyguardService mService = null; - KeyguardResult mKeyguardResult = new KeyguardResult(); + KeyguardShowCallback mKeyguardShowCallback = new KeyguardShowCallback(); + KeyguardExitCallback mKeyguardExitCallback = new KeyguardExitCallback(); + RemoteServiceConnection mConnection; private boolean mSentSystemReady; - class KeyguardResult extends IKeyguardResult.Stub { + class KeyguardShowCallback extends IKeyguardShowCallback.Stub { @Override public void onShown(IBinder windowToken) throws RemoteException { Log.v(TAG, "Keyguard is shown, windowToken = " + windowToken); } + } + + class KeyguardExitCallback extends IKeyguardExitCallback.Stub { @Override public void onKeyguardExitResult(boolean success) throws RemoteException { @@ -236,7 +242,7 @@ public class KeyguardTestActivity extends Activity implements OnClickListener { try { switch (v.getId()) { case R.id.on_screen_turned_on: - mService.onScreenTurnedOn(mKeyguardResult); + mService.onScreenTurnedOn(mKeyguardShowCallback); break; case R.id.on_screen_turned_off: mService.onScreenTurnedOff(WindowManagerPolicy.OFF_BECAUSE_OF_USER); @@ -249,7 +255,7 @@ public class KeyguardTestActivity extends Activity implements OnClickListener { mService.doKeyguardTimeout(null); break; case R.id.verify_unlock: - mService.verifyUnlock(mKeyguardResult); + mService.verifyUnlock(mKeyguardExitCallback); break; } } catch (RemoteException e) { diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java index dac52ad..ef3fa6e 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java @@ -16,7 +16,7 @@ package com.android.keyguard; -import com.android.internal.policy.IKeyguardResult; +import com.android.internal.policy.IKeyguardShowCallback; import com.android.internal.widget.LockPatternUtils; import android.app.Activity; @@ -331,7 +331,7 @@ public class KeyguardViewManager { } } - public synchronized void onScreenTurnedOn(final IKeyguardResult result) { + public synchronized void onScreenTurnedOn(final IKeyguardShowCallback callback) { if (DEBUG) Log.d(TAG, "onScreenTurnedOn()"); mScreenOn = true; if (mKeyguardView != null) { @@ -339,7 +339,7 @@ public class KeyguardViewManager { // Caller should wait for this window to be shown before turning // on the screen. - if (result != null) { + if (callback != null) { if (mKeyguardHost.getVisibility() == View.VISIBLE) { // Keyguard may be in the process of being shown, but not yet // updated with the window manager... give it a chance to do so. @@ -351,28 +351,25 @@ public class KeyguardViewManager { token = mKeyguardHost.getWindowToken(); } try { - result.onShown(token); + callback.onShown(token); } catch (RemoteException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + Slog.w(TAG, "Exception calling onShown():", e); } } }); } else { try { - result.onShown(null); + callback.onShown(null); } catch (RemoteException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + Slog.w(TAG, "Exception calling onShown():", e); } } } - } else if (result != null) { + } else if (callback != null) { try { - result.onShown(null); + callback.onShown(null); } catch (RemoteException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + Slog.w(TAG, "Exception calling onShown():", e); } } } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java index f8fbddf..cc35b5f 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java @@ -16,7 +16,8 @@ package com.android.keyguard; -import com.android.internal.policy.IKeyguardResult; +import com.android.internal.policy.IKeyguardExitCallback; +import com.android.internal.policy.IKeyguardShowCallback; import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT; import android.app.Activity; @@ -46,6 +47,7 @@ import android.provider.Settings; import android.telephony.TelephonyManager; import android.util.EventLog; import android.util.Log; +import android.util.Slog; import android.view.KeyEvent; import android.view.WindowManager; import android.view.WindowManagerPolicy; @@ -220,7 +222,7 @@ public class KeyguardViewMediator { * how we'll ultimately let them know whether it was successful. We use this * var being non-null as an indicator that there is an in progress request. */ - private IKeyguardResult mExitSecureCallback; + private IKeyguardExitCallback mExitSecureCallback; // the properties of the keyguard @@ -463,7 +465,7 @@ public class KeyguardViewMediator { mPM.wakeUp(SystemClock.uptimeMillis()); } - public void userActivity() { + private void userActivity() { userActivity(AWAKE_INTERVAL_DEFAULT_MS); } @@ -590,7 +592,7 @@ public class KeyguardViewMediator { try { mExitSecureCallback.onKeyguardExitResult(false); } catch (RemoteException e) { - e.printStackTrace(); + Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); } mExitSecureCallback = null; if (!mExternallyEnabled) { @@ -664,13 +666,13 @@ public class KeyguardViewMediator { /** * Let's us know the screen was turned on. */ - public void onScreenTurnedOn(IKeyguardResult result) { + public void onScreenTurnedOn(IKeyguardShowCallback callback) { synchronized (this) { mScreenOn = true; cancelDoKeyguardLaterLocked(); if (DEBUG) Log.d(TAG, "onScreenTurnedOn, seq = " + mDelayedShowingSequence); - if (result != null) { - notifyScreenOnLocked(result); + if (callback != null) { + notifyScreenOnLocked(callback); } } maybeSendUserPresentBroadcast(); @@ -744,7 +746,7 @@ public class KeyguardViewMediator { try { mExitSecureCallback.onKeyguardExitResult(false); } catch (RemoteException e) { - e.printStackTrace(); + Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); } mExitSecureCallback = null; resetStateLocked(null); @@ -773,16 +775,16 @@ public class KeyguardViewMediator { /** * @see android.app.KeyguardManager#exitKeyguardSecurely */ - public void verifyUnlock(IKeyguardResult result) { + public void verifyUnlock(IKeyguardExitCallback callback) { synchronized (this) { if (DEBUG) Log.d(TAG, "verifyUnlock"); if (!mUpdateMonitor.isDeviceProvisioned()) { // don't allow this api when the device isn't provisioned if (DEBUG) Log.d(TAG, "ignoring because device isn't provisioned"); try { - result.onKeyguardExitResult(false); + callback.onKeyguardExitResult(false); } catch (RemoteException e) { - e.printStackTrace(); + Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); } } else if (mExternallyEnabled) { // this only applies when the user has externally disabled the @@ -790,19 +792,19 @@ public class KeyguardViewMediator { // using the api properly. Log.w(TAG, "verifyUnlock called when not externally disabled"); try { - result.onKeyguardExitResult(false); + callback.onKeyguardExitResult(false); } catch (RemoteException e) { - e.printStackTrace(); + Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); } } else if (mExitSecureCallback != null) { // already in progress with someone else try { - result.onKeyguardExitResult(false); + callback.onKeyguardExitResult(false); } catch (RemoteException e) { - e.printStackTrace(); + Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); } } else { - mExitSecureCallback = result; + mExitSecureCallback = callback; verifyUnlockLocked(); } } @@ -962,7 +964,7 @@ public class KeyguardViewMediator { * @see #onScreenTurnedOn() * @see #handleNotifyScreenOn */ - private void notifyScreenOnLocked(IKeyguardResult result) { + private void notifyScreenOnLocked(IKeyguardShowCallback result) { if (DEBUG) Log.d(TAG, "notifyScreenOnLocked"); Message msg = mHandler.obtainMessage(NOTIFY_SCREEN_ON, result); mHandler.sendMessage(msg); @@ -973,7 +975,7 @@ public class KeyguardViewMediator { * its state accordingly and then poke the wake lock when it is ready. * @param keyCode The wake key. * @see #handleWakeWhenReady - * @see #onWakeKeyWhenKeyguardShowingTq(int) + * @see #onWakeKeyWhenKeyguardShowing(int) */ private void wakeWhenReady(int keyCode) { if (DBG_WAKE) Log.d(TAG, "wakeWhenReady(" + keyCode + ")"); @@ -1055,7 +1057,7 @@ public class KeyguardViewMediator { * * @param keyCode The keycode of the key that woke the device */ - public void onWakeKeyWhenKeyguardShowingTq(int keyCode) { + public void onWakeKeyWhenKeyguardShowing(int keyCode) { if (DEBUG) Log.d(TAG, "onWakeKeyWhenKeyguardShowing(" + keyCode + ")"); // give the keyguard view manager a chance to adjust the state of the @@ -1074,7 +1076,7 @@ public class KeyguardViewMediator { * Be sure not to take any action that takes a long time; any significant * action should be posted to a handler. */ - public void onWakeMotionWhenKeyguardShowingTq() { + public void onWakeMotionWhenKeyguardShowing() { if (DEBUG) Log.d(TAG, "onWakeMotionWhenKeyguardShowing()"); // give the keyguard view manager a chance to adjust the state of the @@ -1100,7 +1102,7 @@ public class KeyguardViewMediator { try { mExitSecureCallback.onKeyguardExitResult(authenticated); } catch (RemoteException e) { - e.printStackTrace(); + Slog.w(TAG, "Failed to call onKeyguardExitResult(" + authenticated + ")", e); } mExitSecureCallback = null; @@ -1142,7 +1144,7 @@ public class KeyguardViewMediator { handleNotifyScreenOff(); return; case NOTIFY_SCREEN_ON: - handleNotifyScreenOn((IKeyguardResult) msg.obj); + handleNotifyScreenOn((IKeyguardShowCallback) msg.obj); return; case WAKE_WHEN_READY: handleWakeWhenReady(msg.arg1); @@ -1433,10 +1435,10 @@ public class KeyguardViewMediator { * Handle message sent by {@link #notifyScreenOnLocked()} * @see #NOTIFY_SCREEN_ON */ - private void handleNotifyScreenOn(IKeyguardResult result) { + private void handleNotifyScreenOn(IKeyguardShowCallback callback) { synchronized (KeyguardViewMediator.this) { if (DEBUG) Log.d(TAG, "handleNotifyScreenOn"); - mKeyguardViewManager.onScreenTurnedOn(result); + mKeyguardViewManager.onScreenTurnedOn(callback); } } |