summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/keyguard
diff options
context:
space:
mode:
authorJim Miller <jaggies@google.com>2014-10-10 18:21:49 -0700
committerJorim Jaggi <jjaggi@google.com>2014-11-25 23:22:52 +0100
commitab954546dc49e1070ed8513efbddc8954b529c23 (patch)
tree3b21b5955fe49df391b6ca2500cdc0447716d160 /packages/SystemUI/src/com/android/systemui/keyguard
parentfb6121e069f25dd43e15b1377fe4d5f60c3d0dbe (diff)
downloadframeworks_base-ab954546dc49e1070ed8513efbddc8954b529c23.zip
frameworks_base-ab954546dc49e1070ed8513efbddc8954b529c23.tar.gz
frameworks_base-ab954546dc49e1070ed8513efbddc8954b529c23.tar.bz2
Make IKeyguardService interface asynchronous
Add a state callback so lockscreen reports back whenever its state relevant for PhoneWindowManager changed, instead of synchronously calling into SysUI which can lead to deadlocks. Directly use LockPatternUtils for isSecure, and optimize the number of calls to this method to optimize layout performance. Bug: 17677097 Change-Id: I5d491fc8884d4f84d9562626b9ea0d5eaa5166fc
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/keyguard')
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java99
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java119
2 files changed, 104 insertions, 114 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
index 98d4112..73fa2ed 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
@@ -24,12 +24,11 @@ import android.os.Debug;
import android.os.IBinder;
import android.os.Process;
import android.util.Log;
-import android.view.MotionEvent;
import com.android.internal.policy.IKeyguardExitCallback;
import com.android.internal.policy.IKeyguardService;
-import com.android.internal.policy.IKeyguardServiceConstants;
import com.android.internal.policy.IKeyguardShowCallback;
+import com.android.internal.policy.IKeyguardStateCallback;
import com.android.systemui.SystemUIApplication;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
@@ -66,143 +65,85 @@ public class KeyguardService extends Service {
private final IKeyguardService.Stub mBinder = new IKeyguardService.Stub() {
- private boolean mIsOccluded;
-
- @Override
- public boolean isShowing() {
- return mKeyguardViewMediator.isShowing();
- }
-
- @Override
- public boolean isSecure() {
- return mKeyguardViewMediator.isSecure();
- }
-
- @Override
- public boolean isShowingAndNotOccluded() {
- return mKeyguardViewMediator.isShowingAndNotOccluded();
- }
-
- @Override
- public boolean isInputRestricted() {
- return mKeyguardViewMediator.isInputRestricted();
+ @Override // Binder interface
+ public void addStateMonitorCallback(IKeyguardStateCallback callback) {
+ checkPermission();
+ mKeyguardViewMediator.addStateMonitorCallback(callback);
}
- @Override
+ @Override // Binder interface
public void verifyUnlock(IKeyguardExitCallback callback) {
checkPermission();
mKeyguardViewMediator.verifyUnlock(callback);
}
- @Override
+ @Override // Binder interface
public void keyguardDone(boolean authenticated, boolean wakeup) {
checkPermission();
mKeyguardViewMediator.keyguardDone(authenticated, wakeup);
}
- @Override
- public int setOccluded(boolean isOccluded) {
- checkPermission();
- synchronized (this) {
- int result;
- if (isOccluded && mKeyguardViewMediator.isShowing()
- && !mIsOccluded) {
- result = IKeyguardServiceConstants
- .KEYGUARD_SERVICE_SET_OCCLUDED_RESULT_UNSET_FLAGS;
- } else if (!isOccluded && mKeyguardViewMediator.isShowing()
- && mIsOccluded) {
- result = IKeyguardServiceConstants
- .KEYGUARD_SERVICE_SET_OCCLUDED_RESULT_SET_FLAGS;
- } else {
- result = IKeyguardServiceConstants.KEYGUARD_SERVICE_SET_OCCLUDED_RESULT_NONE;
- }
- if (mIsOccluded != isOccluded) {
- mKeyguardViewMediator.setOccluded(isOccluded);
-
- // Cache the value so we always have a fresh view in whether Keyguard is occluded.
- // If we would just call mKeyguardViewMediator.isOccluded(), this might be stale
- // because that value gets updated in another thread.
- mIsOccluded = isOccluded;
- }
- return result;
- }
+ @Override // Binder interface
+ public void setOccluded(boolean isOccluded) {
+ checkPermission();
+ mKeyguardViewMediator.setOccluded(isOccluded);
}
- @Override
+ @Override // Binder interface
public void dismiss() {
checkPermission();
mKeyguardViewMediator.dismiss();
}
- @Override
+ @Override // Binder interface
public void onDreamingStarted() {
checkPermission();
mKeyguardViewMediator.onDreamingStarted();
}
- @Override
+ @Override // Binder interface
public void onDreamingStopped() {
checkPermission();
mKeyguardViewMediator.onDreamingStopped();
}
- @Override
+ @Override // Binder interface
public void onScreenTurnedOff(int reason) {
checkPermission();
mKeyguardViewMediator.onScreenTurnedOff(reason);
}
- @Override
+ @Override // Binder interface
public void onScreenTurnedOn(IKeyguardShowCallback callback) {
checkPermission();
mKeyguardViewMediator.onScreenTurnedOn(callback);
}
- @Override
+ @Override // Binder interface
public void setKeyguardEnabled(boolean enabled) {
checkPermission();
mKeyguardViewMediator.setKeyguardEnabled(enabled);
}
- @Override
- public boolean isDismissable() {
- return mKeyguardViewMediator.isDismissable();
- }
-
- @Override
+ @Override // Binder interface
public void onSystemReady() {
checkPermission();
mKeyguardViewMediator.onSystemReady();
}
- @Override
+ @Override // Binder interface
public void doKeyguardTimeout(Bundle options) {
checkPermission();
mKeyguardViewMediator.doKeyguardTimeout(options);
}
- @Override
+ @Override // Binder interface
public void setCurrentUser(int userId) {
checkPermission();
mKeyguardViewMediator.setCurrentUser(userId);
}
@Override
- public void showAssistant() {
- checkPermission();
- }
-
- @Override
- public void dispatch(MotionEvent event) {
- checkPermission();
- }
-
- @Override
- public void launchCamera() {
- checkPermission();
- }
-
- @Override
public void onBootCompleted() {
checkPermission();
mKeyguardViewMediator.onBootCompleted();
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index d8f8727..4e034ae 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -56,6 +56,7 @@ import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import com.android.internal.policy.IKeyguardExitCallback;
import com.android.internal.policy.IKeyguardShowCallback;
+import com.android.internal.policy.IKeyguardStateCallback;
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardConstants;
@@ -70,6 +71,8 @@ import com.android.systemui.statusbar.phone.ScrimController;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.phone.StatusBarWindowManager;
+import java.util.ArrayList;
+
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
@@ -224,6 +227,9 @@ public class KeyguardViewMediator extends SystemUI {
// answer whether the input should be restricted)
private boolean mShowing;
+ /** Cached value of #isInputRestricted */
+ private boolean mInputRestricted;
+
// true if the keyguard is hidden by another window
private boolean mOccluded = false;
@@ -293,6 +299,8 @@ public class KeyguardViewMediator extends SystemUI {
*/
private KeyguardDisplayManager mKeyguardDisplayManager;
+ private final ArrayList<IKeyguardStateCallback> mKeyguardStateCallbacks = new ArrayList<>();
+
KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() {
@Override
@@ -360,6 +368,7 @@ public class KeyguardViewMediator extends SystemUI {
@Override
public void onDeviceProvisioned() {
sendUserPresentBroadcast();
+ updateInputRestricted();
}
@Override
@@ -370,6 +379,16 @@ public class KeyguardViewMediator extends SystemUI {
+ ",state=" + simState + ")");
}
+ try {
+ int size = mKeyguardStateCallbacks.size();
+ boolean simPinSecure = mUpdateMonitor.isSimPinSecure();
+ for (int i = 0; i < size; i++) {
+ mKeyguardStateCallbacks.get(i).onSimSecureStateChanged(simPinSecure);
+ }
+ } catch (RemoteException e) {
+ Slog.w(TAG, "Failed to call onSimSecureStateChanged", e);
+ }
+
switch (simState) {
case NOT_READY:
case ABSENT:
@@ -377,7 +396,7 @@ public class KeyguardViewMediator extends SystemUI {
// gone through setup wizard
synchronized (this) {
if (shouldWaitForProvisioning()) {
- if (!isShowing()) {
+ if (!mShowing) {
if (DEBUG_SIM_STATES) Log.d(TAG, "ICC_ABSENT isn't showing,"
+ " we need to show the keyguard since the "
+ "device isn't provisioned yet.");
@@ -391,7 +410,7 @@ public class KeyguardViewMediator extends SystemUI {
case PIN_REQUIRED:
case PUK_REQUIRED:
synchronized (this) {
- if (!isShowing()) {
+ if (!mShowing) {
if (DEBUG_SIM_STATES) Log.d(TAG,
"INTENT_VALUE_ICC_LOCKED and keygaurd isn't "
+ "showing; need to show keyguard so user can enter sim pin");
@@ -403,7 +422,7 @@ public class KeyguardViewMediator extends SystemUI {
break;
case PERM_DISABLED:
synchronized (this) {
- if (!isShowing()) {
+ if (!mShowing) {
if (DEBUG_SIM_STATES) Log.d(TAG, "PERM_DISABLED and "
+ "keygaurd isn't showing.");
doKeyguardLocked(null);
@@ -416,7 +435,7 @@ public class KeyguardViewMediator extends SystemUI {
break;
case READY:
synchronized (this) {
- if (isShowing()) {
+ if (mShowing) {
resetStateLocked();
}
}
@@ -488,13 +507,18 @@ public class KeyguardViewMediator extends SystemUI {
public void playTrustedSound() {
KeyguardViewMediator.this.playTrustedSound();
}
+
+ @Override
+ public boolean isInputRestricted() {
+ return KeyguardViewMediator.this.isInputRestricted();
+ }
};
public void userActivity() {
mPM.userActivity(SystemClock.uptimeMillis(), false);
}
- private void setup() {
+ private void setupLocked() {
mPM = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
mWM = WindowManagerGlobal.getWindowManagerService();
mTrustManager = (TrustManager) mContext.getSystemService(Context.TRUST_SERVICE);
@@ -514,7 +538,7 @@ public class KeyguardViewMediator extends SystemUI {
mLockPatternUtils.setCurrentUser(ActivityManager.getCurrentUser());
// Assume keyguard is showing (unless it's disabled) until we know for sure...
- mShowing = !shouldWaitForProvisioning() && !mLockPatternUtils.isLockScreenDisabled();
+ setShowingLocked(!shouldWaitForProvisioning() && !mLockPatternUtils.isLockScreenDisabled());
mTrustManager.reportKeyguardShowingChanged();
mStatusBarKeyguardViewManager = new StatusBarKeyguardViewManager(mContext,
@@ -556,7 +580,9 @@ public class KeyguardViewMediator extends SystemUI {
@Override
public void start() {
- setup();
+ synchronized (this) {
+ setupLocked();
+ }
putComponent(KeyguardViewMediator.class, this);
}
@@ -760,12 +786,14 @@ public class KeyguardViewMediator extends SystemUI {
if (DEBUG) Log.d(TAG, "remembering to reshow, hiding keyguard, "
+ "disabling status bar expansion");
mNeedToReshowWhenReenabled = true;
+ updateInputRestrictedLocked();
hideLocked();
} else if (enabled && mNeedToReshowWhenReenabled) {
// reenabled after previously hidden, reshow
if (DEBUG) Log.d(TAG, "previously hidden, reshowing, reenabling "
+ "status bar expansion");
mNeedToReshowWhenReenabled = false;
+ updateInputRestrictedLocked();
if (mExitSecureCallback != null) {
if (DEBUG) Log.d(TAG, "onKeyguardExitResult(false), resetting");
@@ -837,17 +865,6 @@ public class KeyguardViewMediator extends SystemUI {
}
/**
- * Is the keyguard currently showing?
- */
- public boolean isShowing() {
- return mShowing;
- }
-
- public boolean isOccluded() {
- return mOccluded;
- }
-
- /**
* Is the keyguard currently showing and not being force hidden?
*/
public boolean isShowingAndNotOccluded() {
@@ -897,6 +914,26 @@ public class KeyguardViewMediator extends SystemUI {
return mShowing || mNeedToReshowWhenReenabled || shouldWaitForProvisioning();
}
+ private void updateInputRestricted() {
+ synchronized (this) {
+ updateInputRestrictedLocked();
+ }
+ }
+ private void updateInputRestrictedLocked() {
+ boolean inputRestricted = isInputRestricted();
+ if (mInputRestricted != inputRestricted) {
+ mInputRestricted = inputRestricted;
+ try {
+ int size = mKeyguardStateCallbacks.size();
+ for (int i = 0; i < size; i++) {
+ mKeyguardStateCallbacks.get(i).onInputRestrictedStateChanged(inputRestricted);
+ }
+ } catch (RemoteException e) {
+ Slog.w(TAG, "Failed to call onDeviceProvisioned", e);
+ }
+ }
+ }
+
/**
* Enable the keyguard if the settings are appropriate.
*/
@@ -947,7 +984,7 @@ public class KeyguardViewMediator extends SystemUI {
if (mLockPatternUtils.checkVoldPassword()) {
if (DEBUG) Log.d(TAG, "Not showing lock screen since just decrypted");
// Without this, settings is not enabled until the lock screen first appears
- setShowing(false);
+ setShowingLocked(false);
hideLocked();
return;
}
@@ -1168,6 +1205,7 @@ public class KeyguardViewMediator extends SystemUI {
// the keyguard when they've released the lock
mExternallyEnabled = true;
mNeedToReshowWhenReenabled = false;
+ updateInputRestricted();
}
}
@@ -1263,9 +1301,9 @@ public class KeyguardViewMediator extends SystemUI {
if (DEBUG) Log.d(TAG, "handleShow");
}
+ setShowingLocked(true);
mStatusBarKeyguardViewManager.show(options);
mHiding = false;
- setShowing(true);
resetKeyguardDonePendingLocked();
mHideAnimationRun = false;
updateActivityLockScreenState();
@@ -1343,8 +1381,8 @@ public class KeyguardViewMediator extends SystemUI {
playSounds(false);
}
+ setShowingLocked(false);
mStatusBarKeyguardViewManager.hide(startTime, fadeoutDuration);
- setShowing(false);
resetKeyguardDonePendingLocked();
mHideAnimationRun = false;
updateActivityLockScreenState();
@@ -1404,8 +1442,8 @@ public class KeyguardViewMediator extends SystemUI {
private void handleVerifyUnlock() {
synchronized (KeyguardViewMediator.this) {
if (DEBUG) Log.d(TAG, "handleVerifyUnlock");
+ setShowingLocked(true);
mStatusBarKeyguardViewManager.verifyUnlock();
- setShowing(true);
updateActivityLockScreenState();
}
}
@@ -1432,15 +1470,6 @@ public class KeyguardViewMediator extends SystemUI {
}
}
- public boolean isDismissable() {
- return mKeyguardDonePending || !isSecure();
- }
-
- private boolean isAssistantAvailable() {
- return mSearchManager != null
- && mSearchManager.getAssistIntent(mContext, false, UserHandle.USER_CURRENT) != null;
- }
-
private void resetKeyguardDonePendingLocked() {
mKeyguardDonePending = false;
mHandler.removeMessages(KEYGUARD_DONE_PENDING_TIMEOUT);
@@ -1488,11 +1517,31 @@ public class KeyguardViewMediator extends SystemUI {
}
}
- private void setShowing(boolean showing) {
- boolean changed = (showing != mShowing);
- mShowing = showing;
- if (changed) {
+ private void setShowingLocked(boolean showing) {
+ if (showing != mShowing) {
+ mShowing = showing;
+ try {
+ int size = mKeyguardStateCallbacks.size();
+ for (int i = 0; i < size; i++) {
+ mKeyguardStateCallbacks.get(i).onShowingStateChanged(showing);
+ }
+ } catch (RemoteException e) {
+ Slog.w(TAG, "Failed to call onShowingStateChanged", e);
+ }
+ updateInputRestrictedLocked();
mTrustManager.reportKeyguardShowingChanged();
}
}
+
+ public void addStateMonitorCallback(IKeyguardStateCallback callback) {
+ synchronized (this) {
+ mKeyguardStateCallbacks.add(callback);
+ try {
+ callback.onSimSecureStateChanged(mUpdateMonitor.isSimPinSecure());
+ callback.onShowingStateChanged(mShowing);
+ } catch (RemoteException e) {
+ Slog.w(TAG, "Failed to call onShowingStateChanged or onSimSecureStateChanged", e);
+ }
+ }
+ }
}