Merge "Make IKeyguardService interface asynchronous" into lmp-mr1-dev

This commit is contained in:
Jorim Jaggi
2014-11-26 14:07:19 +00:00
committed by Android (Google) Code Review
15 changed files with 339 additions and 536 deletions

View File

@@ -273,6 +273,7 @@ LOCAL_SRC_FILES += \
core/java/com/android/internal/policy/IKeyguardShowCallback.aidl \ core/java/com/android/internal/policy/IKeyguardShowCallback.aidl \
core/java/com/android/internal/policy/IKeyguardExitCallback.aidl \ core/java/com/android/internal/policy/IKeyguardExitCallback.aidl \
core/java/com/android/internal/policy/IKeyguardService.aidl \ core/java/com/android/internal/policy/IKeyguardService.aidl \
core/java/com/android/internal/policy/IKeyguardStateCallback.aidl \
core/java/com/android/internal/os/IDropBoxManagerService.aidl \ core/java/com/android/internal/os/IDropBoxManagerService.aidl \
core/java/com/android/internal/os/IParcelFileDescriptorFactory.aidl \ core/java/com/android/internal/os/IParcelFileDescriptorFactory.aidl \
core/java/com/android/internal/os/IResultReceiver.aidl \ core/java/com/android/internal/os/IResultReceiver.aidl \

View File

@@ -15,47 +15,34 @@
*/ */
package com.android.internal.policy; package com.android.internal.policy;
import android.view.MotionEvent;
import com.android.internal.policy.IKeyguardShowCallback; import com.android.internal.policy.IKeyguardShowCallback;
import com.android.internal.policy.IKeyguardStateCallback;
import com.android.internal.policy.IKeyguardExitCallback; import com.android.internal.policy.IKeyguardExitCallback;
import android.os.Bundle; import android.os.Bundle;
interface IKeyguardService { oneway interface IKeyguardService {
boolean isShowing();
boolean isSecure();
boolean isShowingAndNotOccluded();
boolean isInputRestricted();
boolean isDismissable();
oneway void verifyUnlock(IKeyguardExitCallback callback);
oneway void keyguardDone(boolean authenticated, boolean wakeup);
/** /**
* Sets the Keyguard as occluded when a window dismisses the Keyguard with flag * Sets the Keyguard as occluded when a window dismisses the Keyguard with flag
* FLAG_SHOW_ON_LOCK_SCREEN. * FLAG_SHOW_ON_LOCK_SCREEN.
* *
* @param isOccluded Whether the Keyguard is occluded by another window. * @param isOccluded Whether the Keyguard is occluded by another window.
* @return See IKeyguardServiceConstants.KEYGUARD_SERVICE_SET_OCCLUDED_*. This is needed because
* PhoneWindowManager needs to set these flags immediately and can't wait for the
* Keyguard thread to pick it up. In the hidden case, PhoneWindowManager is solely
* responsible to make sure that the flags are unset.
*/ */
int setOccluded(boolean isOccluded); void setOccluded(boolean isOccluded);
oneway void dismiss(); void addStateMonitorCallback(IKeyguardStateCallback callback);
oneway void onDreamingStarted(); void verifyUnlock(IKeyguardExitCallback callback);
oneway void onDreamingStopped(); void keyguardDone(boolean authenticated, boolean wakeup);
oneway void onScreenTurnedOff(int reason); void dismiss();
oneway void onScreenTurnedOn(IKeyguardShowCallback callback); void onDreamingStarted();
oneway void setKeyguardEnabled(boolean enabled); void onDreamingStopped();
oneway void onSystemReady(); void onScreenTurnedOff(int reason);
oneway void doKeyguardTimeout(in Bundle options); void onScreenTurnedOn(IKeyguardShowCallback callback);
oneway void setCurrentUser(int userId); void setKeyguardEnabled(boolean enabled);
oneway void showAssistant(); void onSystemReady();
oneway void dispatch(in MotionEvent event); void doKeyguardTimeout(in Bundle options);
oneway void launchCamera(); void setCurrentUser(int userId);
oneway void onBootCompleted(); void onBootCompleted();
/** /**
* Notifies that the activity behind has now been drawn and it's safe to remove the wallpaper * Notifies that the activity behind has now been drawn and it's safe to remove the wallpaper
@@ -64,11 +51,11 @@ interface IKeyguardService {
* @param startTime the start time of the animation in uptime milliseconds * @param startTime the start time of the animation in uptime milliseconds
* @param fadeoutDuration the duration of the exit animation, in milliseconds * @param fadeoutDuration the duration of the exit animation, in milliseconds
*/ */
oneway void startKeyguardExitAnimation(long startTime, long fadeoutDuration); void startKeyguardExitAnimation(long startTime, long fadeoutDuration);
/** /**
* Notifies the Keyguard that the activity that was starting has now been drawn and it's safe * Notifies the Keyguard that the activity that was starting has now been drawn and it's safe
* to start the keyguard dismiss sequence. * to start the keyguard dismiss sequence.
*/ */
oneway void onActivityDrawn(); void onActivityDrawn();
} }

View File

@@ -1,41 +0,0 @@
/*
* Copyright (C) 2014 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package com.android.internal.policy;
/**
* @hide
*/
public class IKeyguardServiceConstants {
/**
* Constant for {@link com.android.internal.policy.IKeyguardService#setHidden(boolean)}:
* Don't change the keyguard window flags.
*/
public static final int KEYGUARD_SERVICE_SET_OCCLUDED_RESULT_NONE = 0;
/**
* Constant for {@link com.android.internal.policy.IKeyguardService#setHidden(boolean)}:
* Set the keyguard window flags to FLAG_SHOW_WALLPAPER and PRIVATE_FLAG_KEYGUARD.
*/
public static final int KEYGUARD_SERVICE_SET_OCCLUDED_RESULT_SET_FLAGS = 1;
/**
* Constant for {@link com.android.internal.policy.IKeyguardService#setHidden(boolean)}:
* Unset the keyguard window flags to FLAG_SHOW_WALLPAPER and PRIVATE_FLAG_KEYGUARD.
*/
public static final int KEYGUARD_SERVICE_SET_OCCLUDED_RESULT_UNSET_FLAGS = 2;
}

View File

@@ -0,0 +1,22 @@
/*
* Copyright (C) 2014 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.internal.policy;
interface IKeyguardStateCallback {
void onShowingStateChanged(boolean showing);
void onSimSecureStateChanged(boolean simSecure);
void onInputRestrictedStateChanged(boolean inputRestricted);
}

View File

@@ -71,4 +71,10 @@ public interface ViewMediatorCallback {
* Play the "device trusted" sound. * Play the "device trusted" sound.
*/ */
void playTrustedSound(); void playTrustedSound();
/**
* @return true if and only if Keyguard is showing or if Keyguard is disabled by an external app
* (legacy API)
*/
boolean isInputRestricted();
} }

View File

@@ -24,12 +24,11 @@ import android.os.Debug;
import android.os.IBinder; import android.os.IBinder;
import android.os.Process; import android.os.Process;
import android.util.Log; import android.util.Log;
import android.view.MotionEvent;
import com.android.internal.policy.IKeyguardExitCallback; import com.android.internal.policy.IKeyguardExitCallback;
import com.android.internal.policy.IKeyguardService; import com.android.internal.policy.IKeyguardService;
import com.android.internal.policy.IKeyguardServiceConstants;
import com.android.internal.policy.IKeyguardShowCallback; import com.android.internal.policy.IKeyguardShowCallback;
import com.android.internal.policy.IKeyguardStateCallback;
import com.android.systemui.SystemUIApplication; import com.android.systemui.SystemUIApplication;
import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.content.pm.PackageManager.PERMISSION_GRANTED;
@@ -66,142 +65,84 @@ public class KeyguardService extends Service {
private final IKeyguardService.Stub mBinder = new IKeyguardService.Stub() { private final IKeyguardService.Stub mBinder = new IKeyguardService.Stub() {
private boolean mIsOccluded; @Override // Binder interface
public void addStateMonitorCallback(IKeyguardStateCallback callback) {
@Override checkPermission();
public boolean isShowing() { mKeyguardViewMediator.addStateMonitorCallback(callback);
return mKeyguardViewMediator.isShowing();
} }
@Override @Override // Binder interface
public boolean isSecure() {
return mKeyguardViewMediator.isSecure();
}
@Override
public boolean isShowingAndNotOccluded() {
return mKeyguardViewMediator.isShowingAndNotOccluded();
}
@Override
public boolean isInputRestricted() {
return mKeyguardViewMediator.isInputRestricted();
}
@Override
public void verifyUnlock(IKeyguardExitCallback callback) { public void verifyUnlock(IKeyguardExitCallback callback) {
checkPermission(); checkPermission();
mKeyguardViewMediator.verifyUnlock(callback); mKeyguardViewMediator.verifyUnlock(callback);
} }
@Override @Override // Binder interface
public void keyguardDone(boolean authenticated, boolean wakeup) { public void keyguardDone(boolean authenticated, boolean wakeup) {
checkPermission(); checkPermission();
mKeyguardViewMediator.keyguardDone(authenticated, wakeup); mKeyguardViewMediator.keyguardDone(authenticated, wakeup);
} }
@Override @Override // Binder interface
public int setOccluded(boolean isOccluded) { public void setOccluded(boolean isOccluded) {
checkPermission(); checkPermission();
synchronized (this) { mKeyguardViewMediator.setOccluded(isOccluded);
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 @Override // Binder interface
public void dismiss() { public void dismiss() {
checkPermission(); checkPermission();
mKeyguardViewMediator.dismiss(); mKeyguardViewMediator.dismiss();
} }
@Override @Override // Binder interface
public void onDreamingStarted() { public void onDreamingStarted() {
checkPermission(); checkPermission();
mKeyguardViewMediator.onDreamingStarted(); mKeyguardViewMediator.onDreamingStarted();
} }
@Override @Override // Binder interface
public void onDreamingStopped() { public void onDreamingStopped() {
checkPermission(); checkPermission();
mKeyguardViewMediator.onDreamingStopped(); mKeyguardViewMediator.onDreamingStopped();
} }
@Override @Override // Binder interface
public void onScreenTurnedOff(int reason) { public void onScreenTurnedOff(int reason) {
checkPermission(); checkPermission();
mKeyguardViewMediator.onScreenTurnedOff(reason); mKeyguardViewMediator.onScreenTurnedOff(reason);
} }
@Override @Override // Binder interface
public void onScreenTurnedOn(IKeyguardShowCallback callback) { public void onScreenTurnedOn(IKeyguardShowCallback callback) {
checkPermission(); checkPermission();
mKeyguardViewMediator.onScreenTurnedOn(callback); mKeyguardViewMediator.onScreenTurnedOn(callback);
} }
@Override @Override // Binder interface
public void setKeyguardEnabled(boolean enabled) { public void setKeyguardEnabled(boolean enabled) {
checkPermission(); checkPermission();
mKeyguardViewMediator.setKeyguardEnabled(enabled); mKeyguardViewMediator.setKeyguardEnabled(enabled);
} }
@Override @Override // Binder interface
public boolean isDismissable() {
return mKeyguardViewMediator.isDismissable();
}
@Override
public void onSystemReady() { public void onSystemReady() {
checkPermission(); checkPermission();
mKeyguardViewMediator.onSystemReady(); mKeyguardViewMediator.onSystemReady();
} }
@Override @Override // Binder interface
public void doKeyguardTimeout(Bundle options) { public void doKeyguardTimeout(Bundle options) {
checkPermission(); checkPermission();
mKeyguardViewMediator.doKeyguardTimeout(options); mKeyguardViewMediator.doKeyguardTimeout(options);
} }
@Override @Override // Binder interface
public void setCurrentUser(int userId) { public void setCurrentUser(int userId) {
checkPermission(); checkPermission();
mKeyguardViewMediator.setCurrentUser(userId); mKeyguardViewMediator.setCurrentUser(userId);
} }
@Override
public void showAssistant() {
checkPermission();
}
@Override
public void dispatch(MotionEvent event) {
checkPermission();
}
@Override
public void launchCamera() {
checkPermission();
}
@Override @Override
public void onBootCompleted() { public void onBootCompleted() {
checkPermission(); checkPermission();

View File

@@ -56,6 +56,7 @@ import android.view.animation.Animation;
import android.view.animation.AnimationUtils; import android.view.animation.AnimationUtils;
import com.android.internal.policy.IKeyguardExitCallback; import com.android.internal.policy.IKeyguardExitCallback;
import com.android.internal.policy.IKeyguardShowCallback; import com.android.internal.policy.IKeyguardShowCallback;
import com.android.internal.policy.IKeyguardStateCallback;
import com.android.internal.telephony.IccCardConstants; import com.android.internal.telephony.IccCardConstants;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardConstants; 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.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.phone.StatusBarWindowManager; import com.android.systemui.statusbar.phone.StatusBarWindowManager;
import java.util.ArrayList;
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT; 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) // answer whether the input should be restricted)
private boolean mShowing; private boolean mShowing;
/** Cached value of #isInputRestricted */
private boolean mInputRestricted;
// true if the keyguard is hidden by another window // true if the keyguard is hidden by another window
private boolean mOccluded = false; private boolean mOccluded = false;
@@ -293,6 +299,8 @@ public class KeyguardViewMediator extends SystemUI {
*/ */
private KeyguardDisplayManager mKeyguardDisplayManager; private KeyguardDisplayManager mKeyguardDisplayManager;
private final ArrayList<IKeyguardStateCallback> mKeyguardStateCallbacks = new ArrayList<>();
KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() { KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() {
@Override @Override
@@ -360,6 +368,7 @@ public class KeyguardViewMediator extends SystemUI {
@Override @Override
public void onDeviceProvisioned() { public void onDeviceProvisioned() {
sendUserPresentBroadcast(); sendUserPresentBroadcast();
updateInputRestricted();
} }
@Override @Override
@@ -370,6 +379,16 @@ public class KeyguardViewMediator extends SystemUI {
+ ",state=" + simState + ")"); + ",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) { switch (simState) {
case NOT_READY: case NOT_READY:
case ABSENT: case ABSENT:
@@ -377,7 +396,7 @@ public class KeyguardViewMediator extends SystemUI {
// gone through setup wizard // gone through setup wizard
synchronized (this) { synchronized (this) {
if (shouldWaitForProvisioning()) { if (shouldWaitForProvisioning()) {
if (!isShowing()) { if (!mShowing) {
if (DEBUG_SIM_STATES) Log.d(TAG, "ICC_ABSENT isn't showing," if (DEBUG_SIM_STATES) Log.d(TAG, "ICC_ABSENT isn't showing,"
+ " we need to show the keyguard since the " + " we need to show the keyguard since the "
+ "device isn't provisioned yet."); + "device isn't provisioned yet.");
@@ -391,7 +410,7 @@ public class KeyguardViewMediator extends SystemUI {
case PIN_REQUIRED: case PIN_REQUIRED:
case PUK_REQUIRED: case PUK_REQUIRED:
synchronized (this) { synchronized (this) {
if (!isShowing()) { if (!mShowing) {
if (DEBUG_SIM_STATES) Log.d(TAG, if (DEBUG_SIM_STATES) Log.d(TAG,
"INTENT_VALUE_ICC_LOCKED and keygaurd isn't " "INTENT_VALUE_ICC_LOCKED and keygaurd isn't "
+ "showing; need to show keyguard so user can enter sim pin"); + "showing; need to show keyguard so user can enter sim pin");
@@ -403,7 +422,7 @@ public class KeyguardViewMediator extends SystemUI {
break; break;
case PERM_DISABLED: case PERM_DISABLED:
synchronized (this) { synchronized (this) {
if (!isShowing()) { if (!mShowing) {
if (DEBUG_SIM_STATES) Log.d(TAG, "PERM_DISABLED and " if (DEBUG_SIM_STATES) Log.d(TAG, "PERM_DISABLED and "
+ "keygaurd isn't showing."); + "keygaurd isn't showing.");
doKeyguardLocked(null); doKeyguardLocked(null);
@@ -416,7 +435,7 @@ public class KeyguardViewMediator extends SystemUI {
break; break;
case READY: case READY:
synchronized (this) { synchronized (this) {
if (isShowing()) { if (mShowing) {
resetStateLocked(); resetStateLocked();
} }
} }
@@ -488,13 +507,18 @@ public class KeyguardViewMediator extends SystemUI {
public void playTrustedSound() { public void playTrustedSound() {
KeyguardViewMediator.this.playTrustedSound(); KeyguardViewMediator.this.playTrustedSound();
} }
@Override
public boolean isInputRestricted() {
return KeyguardViewMediator.this.isInputRestricted();
}
}; };
public void userActivity() { public void userActivity() {
mPM.userActivity(SystemClock.uptimeMillis(), false); mPM.userActivity(SystemClock.uptimeMillis(), false);
} }
private void setup() { private void setupLocked() {
mPM = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); mPM = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
mWM = WindowManagerGlobal.getWindowManagerService(); mWM = WindowManagerGlobal.getWindowManagerService();
mTrustManager = (TrustManager) mContext.getSystemService(Context.TRUST_SERVICE); mTrustManager = (TrustManager) mContext.getSystemService(Context.TRUST_SERVICE);
@@ -514,7 +538,7 @@ public class KeyguardViewMediator extends SystemUI {
mLockPatternUtils.setCurrentUser(ActivityManager.getCurrentUser()); mLockPatternUtils.setCurrentUser(ActivityManager.getCurrentUser());
// Assume keyguard is showing (unless it's disabled) until we know for sure... // Assume keyguard is showing (unless it's disabled) until we know for sure...
mShowing = !shouldWaitForProvisioning() && !mLockPatternUtils.isLockScreenDisabled(); setShowingLocked(!shouldWaitForProvisioning() && !mLockPatternUtils.isLockScreenDisabled());
mTrustManager.reportKeyguardShowingChanged(); mTrustManager.reportKeyguardShowingChanged();
mStatusBarKeyguardViewManager = new StatusBarKeyguardViewManager(mContext, mStatusBarKeyguardViewManager = new StatusBarKeyguardViewManager(mContext,
@@ -556,7 +580,9 @@ public class KeyguardViewMediator extends SystemUI {
@Override @Override
public void start() { public void start() {
setup(); synchronized (this) {
setupLocked();
}
putComponent(KeyguardViewMediator.class, this); putComponent(KeyguardViewMediator.class, this);
} }
@@ -760,12 +786,14 @@ public class KeyguardViewMediator extends SystemUI {
if (DEBUG) Log.d(TAG, "remembering to reshow, hiding keyguard, " if (DEBUG) Log.d(TAG, "remembering to reshow, hiding keyguard, "
+ "disabling status bar expansion"); + "disabling status bar expansion");
mNeedToReshowWhenReenabled = true; mNeedToReshowWhenReenabled = true;
updateInputRestrictedLocked();
hideLocked(); hideLocked();
} else if (enabled && mNeedToReshowWhenReenabled) { } else if (enabled && mNeedToReshowWhenReenabled) {
// reenabled after previously hidden, reshow // reenabled after previously hidden, reshow
if (DEBUG) Log.d(TAG, "previously hidden, reshowing, reenabling " if (DEBUG) Log.d(TAG, "previously hidden, reshowing, reenabling "
+ "status bar expansion"); + "status bar expansion");
mNeedToReshowWhenReenabled = false; mNeedToReshowWhenReenabled = false;
updateInputRestrictedLocked();
if (mExitSecureCallback != null) { if (mExitSecureCallback != null) {
if (DEBUG) Log.d(TAG, "onKeyguardExitResult(false), resetting"); if (DEBUG) Log.d(TAG, "onKeyguardExitResult(false), resetting");
@@ -836,17 +864,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? * Is the keyguard currently showing and not being force hidden?
*/ */
@@ -897,6 +914,26 @@ public class KeyguardViewMediator extends SystemUI {
return mShowing || mNeedToReshowWhenReenabled || shouldWaitForProvisioning(); 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. * Enable the keyguard if the settings are appropriate.
*/ */
@@ -947,7 +984,7 @@ public class KeyguardViewMediator extends SystemUI {
if (mLockPatternUtils.checkVoldPassword()) { if (mLockPatternUtils.checkVoldPassword()) {
if (DEBUG) Log.d(TAG, "Not showing lock screen since just decrypted"); if (DEBUG) Log.d(TAG, "Not showing lock screen since just decrypted");
// Without this, settings is not enabled until the lock screen first appears // Without this, settings is not enabled until the lock screen first appears
setShowing(false); setShowingLocked(false);
hideLocked(); hideLocked();
return; return;
} }
@@ -1168,6 +1205,7 @@ public class KeyguardViewMediator extends SystemUI {
// the keyguard when they've released the lock // the keyguard when they've released the lock
mExternallyEnabled = true; mExternallyEnabled = true;
mNeedToReshowWhenReenabled = false; mNeedToReshowWhenReenabled = false;
updateInputRestricted();
} }
} }
@@ -1263,9 +1301,9 @@ public class KeyguardViewMediator extends SystemUI {
if (DEBUG) Log.d(TAG, "handleShow"); if (DEBUG) Log.d(TAG, "handleShow");
} }
setShowingLocked(true);
mStatusBarKeyguardViewManager.show(options); mStatusBarKeyguardViewManager.show(options);
mHiding = false; mHiding = false;
setShowing(true);
resetKeyguardDonePendingLocked(); resetKeyguardDonePendingLocked();
mHideAnimationRun = false; mHideAnimationRun = false;
updateActivityLockScreenState(); updateActivityLockScreenState();
@@ -1343,8 +1381,8 @@ public class KeyguardViewMediator extends SystemUI {
playSounds(false); playSounds(false);
} }
setShowingLocked(false);
mStatusBarKeyguardViewManager.hide(startTime, fadeoutDuration); mStatusBarKeyguardViewManager.hide(startTime, fadeoutDuration);
setShowing(false);
resetKeyguardDonePendingLocked(); resetKeyguardDonePendingLocked();
mHideAnimationRun = false; mHideAnimationRun = false;
updateActivityLockScreenState(); updateActivityLockScreenState();
@@ -1404,8 +1442,8 @@ public class KeyguardViewMediator extends SystemUI {
private void handleVerifyUnlock() { private void handleVerifyUnlock() {
synchronized (KeyguardViewMediator.this) { synchronized (KeyguardViewMediator.this) {
if (DEBUG) Log.d(TAG, "handleVerifyUnlock"); if (DEBUG) Log.d(TAG, "handleVerifyUnlock");
setShowingLocked(true);
mStatusBarKeyguardViewManager.verifyUnlock(); mStatusBarKeyguardViewManager.verifyUnlock();
setShowing(true);
updateActivityLockScreenState(); 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() { private void resetKeyguardDonePendingLocked() {
mKeyguardDonePending = false; mKeyguardDonePending = false;
mHandler.removeMessages(KEYGUARD_DONE_PENDING_TIMEOUT); mHandler.removeMessages(KEYGUARD_DONE_PENDING_TIMEOUT);
@@ -1488,11 +1517,31 @@ public class KeyguardViewMediator extends SystemUI {
} }
} }
private void setShowing(boolean showing) { private void setShowingLocked(boolean showing) {
boolean changed = (showing != mShowing); if (showing != mShowing) {
mShowing = showing; mShowing = showing;
if (changed) { 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(); 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);
}
}
}
} }

View File

@@ -92,7 +92,6 @@ import com.android.systemui.SearchPanelView;
import com.android.systemui.SwipeHelper; import com.android.systemui.SwipeHelper;
import com.android.systemui.SystemUI; import com.android.systemui.SystemUI;
import com.android.systemui.statusbar.NotificationData.Entry; import com.android.systemui.statusbar.NotificationData.Entry;
import com.android.systemui.statusbar.phone.KeyguardTouchDelegate;
import com.android.systemui.statusbar.phone.NavigationBarView; import com.android.systemui.statusbar.phone.NavigationBarView;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.policy.HeadsUpNotificationView; import com.android.systemui.statusbar.policy.HeadsUpNotificationView;
@@ -2090,13 +2089,13 @@ public abstract class BaseStatusBar extends SystemUI implements
boolean accessibilityForcesLaunch = isFullscreen boolean accessibilityForcesLaunch = isFullscreen
&& mAccessibilityManager.isTouchExplorationEnabled(); && mAccessibilityManager.isTouchExplorationEnabled();
final KeyguardTouchDelegate keyguard = KeyguardTouchDelegate.getInstance(mContext);
boolean interrupt = (isFullscreen || (isHighPriority && (isNoisy || hasTicker))) boolean interrupt = (isFullscreen || (isHighPriority && (isNoisy || hasTicker)))
&& isAllowed && isAllowed
&& !accessibilityForcesLaunch && !accessibilityForcesLaunch
&& mPowerManager.isScreenOn() && mPowerManager.isScreenOn()
&& !keyguard.isShowingAndNotOccluded() && (!mStatusBarKeyguardViewManager.isShowing()
&& !keyguard.isInputRestricted(); || mStatusBarKeyguardViewManager.isOccluded())
&& !mStatusBarKeyguardViewManager.isInputRestricted();
try { try {
interrupt = interrupt && !mDreamManager.isDreaming(); interrupt = interrupt && !mDreamManager.isDreaming();
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -2106,10 +2105,6 @@ public abstract class BaseStatusBar extends SystemUI implements
return interrupt; return interrupt;
} }
public boolean inKeyguardRestrictedInputMode() {
return KeyguardTouchDelegate.getInstance(mContext).isInputRestricted();
}
public void setInteracting(int barWindow, boolean interacting) { public void setInteracting(int barWindow, boolean interacting) {
// hook for subclasses // hook for subclasses
} }
@@ -2167,4 +2162,8 @@ public abstract class BaseStatusBar extends SystemUI implements
// Ignore. // Ignore.
} }
} }
public boolean isKeyguardSecure() {
return mStatusBarKeyguardViewManager.isSecure();
}
} }

View File

@@ -257,7 +257,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
final int disabledFlags = dpm.getKeyguardDisabledFeatures(null, userId); final int disabledFlags = dpm.getKeyguardDisabledFeatures(null, userId);
final boolean disabledBecauseKeyguardSecure = final boolean disabledBecauseKeyguardSecure =
(disabledFlags & DevicePolicyManager.KEYGUARD_DISABLE_SECURE_CAMERA) != 0 (disabledFlags & DevicePolicyManager.KEYGUARD_DISABLE_SECURE_CAMERA) != 0
&& KeyguardTouchDelegate.getInstance(getContext()).isSecure(); && mPhoneStatusBar.isKeyguardSecure();
return dpm.getCameraDisabled(null) || disabledBecauseKeyguardSecure; return dpm.getCameraDisabled(null) || disabledBecauseKeyguardSecure;
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Can't get userId", e); Log.e(TAG, "Can't get userId", e);

View File

@@ -1,208 +0,0 @@
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.statusbar.phone;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.UserHandle;
import android.util.Slog;
import android.view.MotionEvent;
import com.android.internal.policy.IKeyguardService;
import java.util.ArrayList;
import java.util.List;
/**
* Facilitates event communication between navigation bar and keyguard. Currently used to
* control WidgetPager in keyguard to expose the camera widget.
*
*/
public class KeyguardTouchDelegate {
// TODO: propagate changes to these to {@link KeyguardServiceDelegate}
static final String KEYGUARD_PACKAGE = "com.android.systemui";
static final String KEYGUARD_CLASS = "com.android.systemui.keyguard.KeyguardService";
private static KeyguardTouchDelegate sInstance;
private static final List<OnKeyguardConnectionListener> sConnectionListeners =
new ArrayList<OnKeyguardConnectionListener>();
private volatile IKeyguardService mService;
protected static final boolean DEBUG = false;
protected static final String TAG = "KeyguardTouchDelegate";
private final ServiceConnection mKeyguardConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
Slog.v(TAG, "Connected to keyguard");
mService = IKeyguardService.Stub.asInterface(service);
for (int i = 0; i < sConnectionListeners.size(); i++) {
OnKeyguardConnectionListener listener = sConnectionListeners.get(i);
listener.onKeyguardServiceConnected(KeyguardTouchDelegate.this);
}
}
@Override
public void onServiceDisconnected(ComponentName name) {
Slog.v(TAG, "Disconnected from keyguard");
mService = null;
sInstance = null; // force reconnection if this goes away
for (int i = 0; i < sConnectionListeners.size(); i++) {
OnKeyguardConnectionListener listener = sConnectionListeners.get(i);
listener.onKeyguardServiceDisconnected(KeyguardTouchDelegate.this);
}
}
};
private KeyguardTouchDelegate(Context context) {
Intent intent = new Intent();
intent.setClassName(KEYGUARD_PACKAGE, KEYGUARD_CLASS);
if (!context.bindServiceAsUser(intent, mKeyguardConnection,
Context.BIND_AUTO_CREATE, UserHandle.OWNER)) {
if (DEBUG) Slog.v(TAG, "*** Keyguard: can't bind to " + KEYGUARD_CLASS);
} else {
if (DEBUG) Slog.v(TAG, "*** Keyguard started");
}
}
public static KeyguardTouchDelegate getInstance(Context context) {
KeyguardTouchDelegate instance = sInstance;
if (instance == null) {
instance = sInstance = new KeyguardTouchDelegate(context);
}
return instance;
}
public boolean isSecure() {
final IKeyguardService service = mService;
if (service != null) {
try {
return service.isSecure();
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException calling keyguard.isSecure()!", e);
}
} else {
Slog.w(TAG, "isSecure(): NO SERVICE!");
}
return false;
}
public boolean dispatch(MotionEvent event) {
final IKeyguardService service = mService;
if (service != null) {
try {
service.dispatch(event);
return true;
} catch (RemoteException e) {
// What to do?
Slog.e(TAG, "RemoteException sending event to keyguard!", e);
}
} else {
Slog.w(TAG, "dispatch(event): NO SERVICE!");
}
return false;
}
public boolean isInputRestricted() {
final IKeyguardService service = mService;
if (service != null) {
try {
return service.isInputRestricted();
} catch (RemoteException e) {
Slog.w(TAG , "Remote Exception", e);
}
} else {
Slog.w(TAG, "isInputRestricted(): NO SERVICE!");
}
return false;
}
public boolean isShowingAndNotOccluded() {
final IKeyguardService service = mService;
if (service != null) {
try {
return service.isShowingAndNotOccluded();
} catch (RemoteException e) {
Slog.w(TAG , "Remote Exception", e);
}
} else {
Slog.w(TAG, "isShowingAndNotOccluded(): NO SERVICE!");
}
return false;
}
public void showAssistant() {
final IKeyguardService service = mService;
if (service != null) {
try {
service.showAssistant();
} catch (RemoteException e) {
// What to do?
Slog.e(TAG, "RemoteException launching assistant!", e);
}
} else {
Slog.w(TAG, "showAssistant(event): NO SERVICE!");
}
}
public void launchCamera() {
final IKeyguardService service = mService;
if (service != null) {
try {
service.launchCamera();
} catch (RemoteException e) {
// What to do?
Slog.e(TAG, "RemoteException launching camera!", e);
}
} else {
Slog.w(TAG, "launchCamera(): NO SERVICE!");
}
}
public void dismiss() {
final IKeyguardService service = mService;
if (service != null) {
try {
service.dismiss();
} catch (RemoteException e) {
// What to do?
Slog.e(TAG, "RemoteException dismissing keyguard!", e);
}
} else {
Slog.w(TAG, "dismiss(): NO SERVICE!");
}
}
public static void addListener(OnKeyguardConnectionListener listener) {
sConnectionListeners.add(listener);
}
public interface OnKeyguardConnectionListener {
void onKeyguardServiceConnected(KeyguardTouchDelegate keyguardTouchDelegate);
void onKeyguardServiceDisconnected(KeyguardTouchDelegate keyguardTouchDelegate);
}
}

View File

@@ -430,4 +430,8 @@ public class StatusBarKeyguardViewManager {
public boolean isSecure(int userId) { public boolean isSecure(int userId) {
return mBouncer.isSecure() || mLockPatternUtils.isSecure(userId); return mBouncer.isSecure() || mLockPatternUtils.isSecure(userId);
} }
public boolean isInputRestricted() {
return mViewMediatorCallback.isInputRestricted();
}
} }

View File

@@ -103,8 +103,6 @@ import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils; import android.view.animation.AnimationUtils;
import com.android.internal.R; import com.android.internal.R;
import com.android.internal.policy.IKeyguardService;
import com.android.internal.policy.IKeyguardServiceConstants;
import com.android.internal.policy.PolicyManager; import com.android.internal.policy.PolicyManager;
import com.android.internal.policy.impl.keyguard.KeyguardServiceDelegate; import com.android.internal.policy.impl.keyguard.KeyguardServiceDelegate;
import com.android.internal.policy.impl.keyguard.KeyguardServiceDelegate.ShowListener; import com.android.internal.policy.impl.keyguard.KeyguardServiceDelegate.ShowListener;
@@ -483,6 +481,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
boolean mShowingLockscreen; boolean mShowingLockscreen;
boolean mShowingDream; boolean mShowingDream;
boolean mDreamingLockscreen; boolean mDreamingLockscreen;
boolean mKeyguardSecure;
boolean mKeyguardSecureIncludingHidden;
volatile boolean mKeyguardOccluded;
boolean mHomePressed; boolean mHomePressed;
boolean mHomeConsumed; boolean mHomeConsumed;
boolean mHomeDoubleTapPending; boolean mHomeDoubleTapPending;
@@ -1108,7 +1109,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (mGlobalActions == null) { if (mGlobalActions == null) {
mGlobalActions = new GlobalActions(mContext, mWindowManagerFuncs); mGlobalActions = new GlobalActions(mContext, mWindowManagerFuncs);
} }
final boolean keyguardShowing = keyguardIsShowingTq(); final boolean keyguardShowing = isKeyguardShowingAndNotOccluded();
mGlobalActions.showDialog(keyguardShowing, isDeviceProvisioned()); mGlobalActions.showDialog(keyguardShowing, isDeviceProvisioned());
if (keyguardShowing) { if (keyguardShowing) {
// since it took two seconds of long press to bring this up, // since it took two seconds of long press to bring this up,
@@ -1973,7 +1974,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
@Override @Override
public boolean isForceHiding(WindowManager.LayoutParams attrs) { public boolean isForceHiding(WindowManager.LayoutParams attrs) {
return (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0 || return (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0 ||
(isKeyguardHostWindow(attrs) && isKeyguardSecureIncludingHidden()) || (isKeyguardHostWindow(attrs) &&
(mKeyguardDelegate != null && mKeyguardDelegate.isShowing())) ||
(attrs.type == TYPE_KEYGUARD_SCRIM); (attrs.type == TYPE_KEYGUARD_SCRIM);
} }
@@ -2377,7 +2379,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} }
boolean keyguardOn() { boolean keyguardOn() {
return keyguardIsShowingTq() || inKeyguardRestrictedKeyInputMode(); return isKeyguardShowingAndNotOccluded() || inKeyguardRestrictedKeyInputMode();
} }
private static final int[] WINDOW_TYPES_WHERE_HOME_DOESNT_WORK = { private static final int[] WINDOW_TYPES_WHERE_HOME_DOESNT_WORK = {
@@ -2961,7 +2963,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
* given the situation with the keyguard. * given the situation with the keyguard.
*/ */
void launchHomeFromHotKey() { void launchHomeFromHotKey() {
if (mKeyguardDelegate != null && mKeyguardDelegate.isShowingAndNotOccluded()) { if (isKeyguardShowingAndNotOccluded()) {
// don't launch home if keyguard showing // don't launch home if keyguard showing
} else if (!mHideLockScreen && mKeyguardDelegate.isInputRestricted()) { } else if (!mHideLockScreen && mKeyguardDelegate.isInputRestricted()) {
// when in keyguard restricted mode, must first verify unlock // when in keyguard restricted mode, must first verify unlock
@@ -3995,6 +3997,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mShowingLockscreen = false; mShowingLockscreen = false;
mShowingDream = false; mShowingDream = false;
mWinShowWhenLocked = null; mWinShowWhenLocked = null;
mKeyguardSecure = isKeyguardSecure();
mKeyguardSecureIncludingHidden = mKeyguardSecure
&& (mKeyguardDelegate != null && mKeyguardDelegate.isShowing());
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@@ -4039,7 +4044,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
final boolean showWhenLocked = (fl & FLAG_SHOW_WHEN_LOCKED) != 0; final boolean showWhenLocked = (fl & FLAG_SHOW_WHEN_LOCKED) != 0;
final boolean dismissKeyguard = (fl & FLAG_DISMISS_KEYGUARD) != 0; final boolean dismissKeyguard = (fl & FLAG_DISMISS_KEYGUARD) != 0;
final boolean secureKeyguard = isKeyguardSecure();
final IApplicationToken appToken = win.getAppToken(); final IApplicationToken appToken = win.getAppToken();
// For app windows that are not attached, we decide if all windows in the app they // For app windows that are not attached, we decide if all windows in the app they
@@ -4050,13 +4054,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// Remove any previous windows with the same appToken. // Remove any previous windows with the same appToken.
mAppsToBeHidden.remove(appToken); mAppsToBeHidden.remove(appToken);
mAppsThatDismissKeyguard.remove(appToken); mAppsThatDismissKeyguard.remove(appToken);
if (mAppsToBeHidden.isEmpty() && isKeyguardSecureIncludingHidden()) { if (mAppsToBeHidden.isEmpty() && mKeyguardSecureIncludingHidden) {
mWinShowWhenLocked = win; mWinShowWhenLocked = win;
mHideLockScreen = true; mHideLockScreen = true;
mForceStatusBarFromKeyguard = false; mForceStatusBarFromKeyguard = false;
} }
} else if (dismissKeyguard) { } else if (dismissKeyguard) {
if (secureKeyguard) { if (mKeyguardSecure) {
mAppsToBeHidden.add(appToken); mAppsToBeHidden.add(appToken);
} else { } else {
mAppsToBeHidden.remove(appToken); mAppsToBeHidden.remove(appToken);
@@ -4077,7 +4081,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mDismissKeyguard = mWinDismissingKeyguard == win ? mDismissKeyguard = mWinDismissingKeyguard == win ?
DISMISS_KEYGUARD_CONTINUE : DISMISS_KEYGUARD_START; DISMISS_KEYGUARD_CONTINUE : DISMISS_KEYGUARD_START;
mWinDismissingKeyguard = win; mWinDismissingKeyguard = win;
mForceStatusBarFromKeyguard = mShowingLockscreen && secureKeyguard; mForceStatusBarFromKeyguard = mShowingLockscreen && mKeyguardSecure;
} else if (mAppsToBeHidden.isEmpty() && showWhenLocked) { } else if (mAppsToBeHidden.isEmpty() && showWhenLocked) {
if (DEBUG_LAYOUT) Slog.v(TAG, if (DEBUG_LAYOUT) Slog.v(TAG,
"Setting mHideLockScreen to true by win " + win); "Setting mHideLockScreen to true by win " + win);
@@ -4188,9 +4192,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (mKeyguardDelegate != null && mStatusBar != null) { if (mKeyguardDelegate != null && mStatusBar != null) {
if (localLOGV) Slog.v(TAG, "finishPostLayoutPolicyLw: mHideKeyguard=" if (localLOGV) Slog.v(TAG, "finishPostLayoutPolicyLw: mHideKeyguard="
+ mHideLockScreen); + mHideLockScreen);
if (mDismissKeyguard != DISMISS_KEYGUARD_NONE && !isKeyguardSecure()) { if (mDismissKeyguard != DISMISS_KEYGUARD_NONE && !mKeyguardSecure) {
mKeyguardHidden = true; mKeyguardHidden = true;
if (processKeyguardSetHiddenResultLw(mKeyguardDelegate.setOccluded(true))) { if (setKeyguardOccludedLw(true)) {
changes |= FINISH_LAYOUT_REDO_LAYOUT changes |= FINISH_LAYOUT_REDO_LAYOUT
| FINISH_LAYOUT_REDO_CONFIG | FINISH_LAYOUT_REDO_CONFIG
| FINISH_LAYOUT_REDO_WALLPAPER; | FINISH_LAYOUT_REDO_WALLPAPER;
@@ -4205,7 +4209,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} }
} else if (mHideLockScreen) { } else if (mHideLockScreen) {
mKeyguardHidden = true; mKeyguardHidden = true;
if (processKeyguardSetHiddenResultLw(mKeyguardDelegate.setOccluded(true))) { if (setKeyguardOccludedLw(true)) {
changes |= FINISH_LAYOUT_REDO_LAYOUT changes |= FINISH_LAYOUT_REDO_LAYOUT
| FINISH_LAYOUT_REDO_CONFIG | FINISH_LAYOUT_REDO_CONFIG
| FINISH_LAYOUT_REDO_WALLPAPER; | FINISH_LAYOUT_REDO_WALLPAPER;
@@ -4215,7 +4219,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (mDismissKeyguard == DISMISS_KEYGUARD_START) { if (mDismissKeyguard == DISMISS_KEYGUARD_START) {
// Only launch the next keyguard unlock window once per window. // Only launch the next keyguard unlock window once per window.
mKeyguardHidden = false; mKeyguardHidden = false;
if (processKeyguardSetHiddenResultLw(mKeyguardDelegate.setOccluded(false))) { if (setKeyguardOccludedLw(false)) {
changes |= FINISH_LAYOUT_REDO_LAYOUT changes |= FINISH_LAYOUT_REDO_LAYOUT
| FINISH_LAYOUT_REDO_CONFIG | FINISH_LAYOUT_REDO_CONFIG
| FINISH_LAYOUT_REDO_WALLPAPER; | FINISH_LAYOUT_REDO_WALLPAPER;
@@ -4230,7 +4234,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} else { } else {
mWinDismissingKeyguard = null; mWinDismissingKeyguard = null;
mKeyguardHidden = false; mKeyguardHidden = false;
if (processKeyguardSetHiddenResultLw(mKeyguardDelegate.setOccluded(false))) { if (setKeyguardOccludedLw(false)) {
changes |= FINISH_LAYOUT_REDO_LAYOUT changes |= FINISH_LAYOUT_REDO_LAYOUT
| FINISH_LAYOUT_REDO_CONFIG | FINISH_LAYOUT_REDO_CONFIG
| FINISH_LAYOUT_REDO_WALLPAPER; | FINISH_LAYOUT_REDO_WALLPAPER;
@@ -4250,23 +4254,22 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} }
/** /**
* Processes the result code of {@link IKeyguardService#setOccluded}. This is needed because we * Updates the occluded state of the Keyguard.
* immediately need to put the wallpaper directly behind the Keyguard when a window with flag
* {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WHEN_LOCKED} gets dismissed. If we
* would wait for Keyguard to change the flags, that would be running asynchronously and thus be
* too late so the user might see the window behind.
* *
* @param setHiddenResult The result code from {@link IKeyguardService#setOccluded}.
* @return Whether the flags have changed and we have to redo the layout. * @return Whether the flags have changed and we have to redo the layout.
*/ */
private boolean processKeyguardSetHiddenResultLw(int setHiddenResult) { private boolean setKeyguardOccludedLw(boolean isOccluded) {
if (setHiddenResult boolean wasOccluded = mKeyguardOccluded;
== IKeyguardServiceConstants.KEYGUARD_SERVICE_SET_OCCLUDED_RESULT_SET_FLAGS) { boolean showing = mKeyguardDelegate.isShowing();
if (wasOccluded && !isOccluded && showing) {
mKeyguardOccluded = false;
mKeyguardDelegate.setOccluded(false);
mStatusBar.getAttrs().privateFlags |= PRIVATE_FLAG_KEYGUARD; mStatusBar.getAttrs().privateFlags |= PRIVATE_FLAG_KEYGUARD;
mStatusBar.getAttrs().flags |= FLAG_SHOW_WALLPAPER; mStatusBar.getAttrs().flags |= FLAG_SHOW_WALLPAPER;
return true; return true;
} else if (setHiddenResult } else if (!wasOccluded && isOccluded && showing) {
== IKeyguardServiceConstants.KEYGUARD_SERVICE_SET_OCCLUDED_RESULT_UNSET_FLAGS) { mKeyguardOccluded = true;
mKeyguardDelegate.setOccluded(true);
mStatusBar.getAttrs().privateFlags &= ~PRIVATE_FLAG_KEYGUARD; mStatusBar.getAttrs().privateFlags &= ~PRIVATE_FLAG_KEYGUARD;
mStatusBar.getAttrs().flags &= ~FLAG_SHOW_WALLPAPER; mStatusBar.getAttrs().flags &= ~FLAG_SHOW_WALLPAPER;
return true; return true;
@@ -4477,7 +4480,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// when the keyguard is hidden by another activity. // when the keyguard is hidden by another activity.
final boolean keyguardActive = (mKeyguardDelegate == null ? false : final boolean keyguardActive = (mKeyguardDelegate == null ? false :
(interactive ? (interactive ?
mKeyguardDelegate.isShowingAndNotOccluded() : isKeyguardShowingAndNotOccluded() :
mKeyguardDelegate.isShowing())); mKeyguardDelegate.isShowing()));
if (DEBUG_INPUT) { if (DEBUG_INPUT) {
@@ -4817,7 +4820,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
private boolean shouldDispatchInputWhenNonInteractive() { private boolean shouldDispatchInputWhenNonInteractive() {
// Send events to keyguard while the screen is on. // Send events to keyguard while the screen is on.
if (keyguardIsShowingTq() && mDisplay != null && mDisplay.getState() != Display.STATE_OFF) { if (isKeyguardShowingAndNotOccluded() && mDisplay != null
&& mDisplay.getState() != Display.STATE_OFF) {
return true; return true;
} }
@@ -5189,12 +5193,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} }
} }
private boolean keyguardIsShowingTq() { private boolean isKeyguardShowingAndNotOccluded() {
if (mKeyguardDelegate == null) return false; if (mKeyguardDelegate == null) return false;
return mKeyguardDelegate.isShowingAndNotOccluded(); return mKeyguardDelegate.isShowing() && !mKeyguardOccluded;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public boolean isKeyguardLocked() { public boolean isKeyguardLocked() {
@@ -5208,11 +5211,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
return mKeyguardDelegate.isSecure(); return mKeyguardDelegate.isSecure();
} }
// Returns true if keyguard is currently locked whether or not it is currently hidden.
private boolean isKeyguardSecureIncludingHidden() {
return mKeyguardDelegate.isSecure() && mKeyguardDelegate.isShowing();
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public boolean inKeyguardRestrictedKeyInputMode() { public boolean inKeyguardRestrictedKeyInputMode() {
@@ -5527,7 +5525,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void systemReady() { public void systemReady() {
mKeyguardDelegate = new KeyguardServiceDelegate(mContext, null); mKeyguardDelegate = new KeyguardServiceDelegate(mContext);
mKeyguardDelegate.onSystemReady(); mKeyguardDelegate.onSystemReady();
readCameraLensCoverState(); readCameraLensCoverState();
@@ -5974,7 +5972,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
@Override @Override
public void keepScreenOnStoppedLw() { public void keepScreenOnStoppedLw() {
if (mKeyguardDelegate != null && !mKeyguardDelegate.isShowingAndNotOccluded()) { if (isKeyguardShowingAndNotOccluded()) {
mPowerManager.userActivity(SystemClock.uptimeMillis(), false); mPowerManager.userActivity(SystemClock.uptimeMillis(), false);
} }
} }

View File

@@ -18,9 +18,8 @@ import android.view.WindowManager;
import android.view.WindowManagerPolicy.OnKeyguardExitResult; import android.view.WindowManagerPolicy.OnKeyguardExitResult;
import com.android.internal.policy.IKeyguardExitCallback; import com.android.internal.policy.IKeyguardExitCallback;
import com.android.internal.policy.IKeyguardShowCallback;
import com.android.internal.policy.IKeyguardService; import com.android.internal.policy.IKeyguardService;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.policy.IKeyguardShowCallback;
/** /**
* A local class that keeps a cache of keyguard state that can be restored in the event * A local class that keeps a cache of keyguard state that can be restored in the event
@@ -28,15 +27,16 @@ import com.android.internal.widget.LockPatternUtils;
* local or remote instances of keyguard. * local or remote instances of keyguard.
*/ */
public class KeyguardServiceDelegate { public class KeyguardServiceDelegate {
// TODO: propagate changes to these to {@link KeyguardTouchDelegate}
public static final String KEYGUARD_PACKAGE = "com.android.systemui"; public static final String KEYGUARD_PACKAGE = "com.android.systemui";
public static final String KEYGUARD_CLASS = "com.android.systemui.keyguard.KeyguardService"; public static final String KEYGUARD_CLASS = "com.android.systemui.keyguard.KeyguardService";
private static final String TAG = "KeyguardServiceDelegate"; private static final String TAG = "KeyguardServiceDelegate";
private static final boolean DEBUG = true; private static final boolean DEBUG = true;
protected KeyguardServiceWrapper mKeyguardService; protected KeyguardServiceWrapper mKeyguardService;
private View mScrim; // shown if keyguard crashes private final Context mContext;
private KeyguardState mKeyguardState = new KeyguardState(); private final View mScrim; // shown if keyguard crashes
private final KeyguardState mKeyguardState = new KeyguardState();
/* package */ static final class KeyguardState { /* package */ static final class KeyguardState {
KeyguardState() { KeyguardState() {
@@ -101,7 +101,8 @@ public class KeyguardServiceDelegate {
} }
}; };
public KeyguardServiceDelegate(Context context, LockPatternUtils lockPatternUtils) { public KeyguardServiceDelegate(Context context) {
mContext = context;
mScrim = createScrim(context); mScrim = createScrim(context);
} }
@@ -123,7 +124,7 @@ public class KeyguardServiceDelegate {
@Override @Override
public void onServiceConnected(ComponentName name, IBinder service) { public void onServiceConnected(ComponentName name, IBinder service) {
if (DEBUG) Log.v(TAG, "*** Keyguard connected (yay!)"); if (DEBUG) Log.v(TAG, "*** Keyguard connected (yay!)");
mKeyguardService = new KeyguardServiceWrapper( mKeyguardService = new KeyguardServiceWrapper(mContext,
IKeyguardService.Stub.asInterface(service)); IKeyguardService.Stub.asInterface(service));
if (mKeyguardState.systemIsReady) { if (mKeyguardState.systemIsReady) {
// If the system is ready, it means keyguard crashed and restarted. // If the system is ready, it means keyguard crashed and restarted.
@@ -151,13 +152,6 @@ public class KeyguardServiceDelegate {
return mKeyguardState.showing; return mKeyguardState.showing;
} }
public boolean isShowingAndNotOccluded() {
if (mKeyguardService != null) {
mKeyguardState.showingAndNotOccluded = mKeyguardService.isShowingAndNotOccluded();
}
return mKeyguardState.showingAndNotOccluded;
}
public boolean isInputRestricted() { public boolean isInputRestricted() {
if (mKeyguardService != null) { if (mKeyguardService != null) {
mKeyguardState.inputRestricted = mKeyguardService.isInputRestricted(); mKeyguardState.inputRestricted = mKeyguardService.isInputRestricted();
@@ -177,13 +171,11 @@ public class KeyguardServiceDelegate {
} }
} }
public int setOccluded(boolean isOccluded) { public void setOccluded(boolean isOccluded) {
int result = 0;
if (mKeyguardService != null) { if (mKeyguardService != null) {
result = mKeyguardService.setOccluded(isOccluded); mKeyguardService.setOccluded(isOccluded);
} }
mKeyguardState.occluded = isOccluded; mKeyguardState.occluded = isOccluded;
return result;
} }
public void dismiss() { public void dismiss() {
@@ -242,13 +234,6 @@ public class KeyguardServiceDelegate {
mKeyguardState.enabled = enabled; mKeyguardState.enabled = enabled;
} }
public boolean isDismissable() {
if (mKeyguardService != null) {
mKeyguardState.dismissable = mKeyguardService.isDismissable();
}
return mKeyguardState.dismissable;
}
public void onSystemReady() { public void onSystemReady() {
if (mKeyguardService != null) { if (mKeyguardService != null) {
mKeyguardService.onSystemReady(); mKeyguardService.onSystemReady();
@@ -263,12 +248,6 @@ public class KeyguardServiceDelegate {
} }
} }
public void showAssistant() {
if (mKeyguardService != null) {
mKeyguardService.showAssistant();
}
}
public void setCurrentUser(int newUserId) { public void setCurrentUser(int newUserId) {
if (mKeyguardService != null) { if (mKeyguardService != null) {
mKeyguardService.setCurrentUser(newUserId); mKeyguardService.setCurrentUser(newUserId);

View File

@@ -16,16 +16,16 @@
package com.android.internal.policy.impl.keyguard; package com.android.internal.policy.impl.keyguard;
import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
import android.os.RemoteException; import android.os.RemoteException;
import android.util.Slog; import android.util.Slog;
import android.view.MotionEvent;
import com.android.internal.policy.IKeyguardServiceConstants;
import com.android.internal.policy.IKeyguardShowCallback;
import com.android.internal.policy.IKeyguardExitCallback; import com.android.internal.policy.IKeyguardExitCallback;
import com.android.internal.policy.IKeyguardService; import com.android.internal.policy.IKeyguardService;
import com.android.internal.policy.IKeyguardShowCallback;
import com.android.internal.policy.IKeyguardStateCallback;
/** /**
* A wrapper class for KeyguardService. It implements IKeyguardService to ensure the interface * A wrapper class for KeyguardService. It implements IKeyguardService to ensure the interface
@@ -33,58 +33,16 @@ import com.android.internal.policy.IKeyguardService;
* *
*/ */
public class KeyguardServiceWrapper implements IKeyguardService { public class KeyguardServiceWrapper implements IKeyguardService {
private KeyguardStateMonitor mKeyguardStateMonitor;
private IKeyguardService mService; private IKeyguardService mService;
private String TAG = "KeyguardServiceWrapper"; private String TAG = "KeyguardServiceWrapper";
public KeyguardServiceWrapper(IKeyguardService service) { public KeyguardServiceWrapper(Context context, IKeyguardService service) {
mService = service; mService = service;
mKeyguardStateMonitor = new KeyguardStateMonitor(context, service);
} }
public boolean isShowing() { @Override // Binder interface
try {
return mService.isShowing();
} catch (RemoteException e) {
Slog.w(TAG , "Remote Exception", e);
}
return false;
}
public boolean isSecure() {
try {
return mService.isSecure();
} catch (RemoteException e) {
Slog.w(TAG , "Remote Exception", e);
}
return false; // TODO cache state
}
public boolean isShowingAndNotOccluded() {
try {
return mService.isShowingAndNotOccluded();
} catch (RemoteException e) {
Slog.w(TAG , "Remote Exception", e);
}
return false; // TODO cache state
}
public boolean isInputRestricted() {
try {
return mService.isInputRestricted();
} catch (RemoteException e) {
Slog.w(TAG , "Remote Exception", e);
}
return false; // TODO cache state
}
public boolean isDismissable() {
try {
return mService.isDismissable();
} catch (RemoteException e) {
Slog.w(TAG , "Remote Exception", e);
}
return true; // TODO cache state
}
public void verifyUnlock(IKeyguardExitCallback callback) { public void verifyUnlock(IKeyguardExitCallback callback) {
try { try {
mService.verifyUnlock(callback); mService.verifyUnlock(callback);
@@ -93,6 +51,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
} }
} }
@Override // Binder interface
public void keyguardDone(boolean authenticated, boolean wakeup) { public void keyguardDone(boolean authenticated, boolean wakeup) {
try { try {
mService.keyguardDone(authenticated, wakeup); mService.keyguardDone(authenticated, wakeup);
@@ -101,15 +60,25 @@ public class KeyguardServiceWrapper implements IKeyguardService {
} }
} }
public int setOccluded(boolean isOccluded) { @Override // Binder interface
public void setOccluded(boolean isOccluded) {
try { try {
return mService.setOccluded(isOccluded); mService.setOccluded(isOccluded);
} catch (RemoteException e) { } catch (RemoteException e) {
Slog.w(TAG , "Remote Exception", e); Slog.w(TAG , "Remote Exception", e);
return IKeyguardServiceConstants.KEYGUARD_SERVICE_SET_OCCLUDED_RESULT_NONE;
} }
} }
@Override
public void addStateMonitorCallback(IKeyguardStateCallback callback) {
try {
mService.addStateMonitorCallback(callback);
} catch (RemoteException e) {
Slog.w(TAG , "Remote Exception", e);
}
}
@Override // Binder interface
public void dismiss() { public void dismiss() {
try { try {
mService.dismiss(); mService.dismiss();
@@ -118,6 +87,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
} }
} }
@Override // Binder interface
public void onDreamingStarted() { public void onDreamingStarted() {
try { try {
mService.onDreamingStarted(); mService.onDreamingStarted();
@@ -126,6 +96,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
} }
} }
@Override // Binder interface
public void onDreamingStopped() { public void onDreamingStopped() {
try { try {
mService.onDreamingStopped(); mService.onDreamingStopped();
@@ -134,6 +105,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
} }
} }
@Override // Binder interface
public void onScreenTurnedOff(int reason) { public void onScreenTurnedOff(int reason) {
try { try {
mService.onScreenTurnedOff(reason); mService.onScreenTurnedOff(reason);
@@ -142,6 +114,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
} }
} }
@Override // Binder interface
public void onScreenTurnedOn(IKeyguardShowCallback result) { public void onScreenTurnedOn(IKeyguardShowCallback result) {
try { try {
mService.onScreenTurnedOn(result); mService.onScreenTurnedOn(result);
@@ -150,6 +123,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
} }
} }
@Override // Binder interface
public void setKeyguardEnabled(boolean enabled) { public void setKeyguardEnabled(boolean enabled) {
try { try {
mService.setKeyguardEnabled(enabled); mService.setKeyguardEnabled(enabled);
@@ -158,6 +132,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
} }
} }
@Override // Binder interface
public void onSystemReady() { public void onSystemReady() {
try { try {
mService.onSystemReady(); mService.onSystemReady();
@@ -166,6 +141,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
} }
} }
@Override // Binder interface
public void doKeyguardTimeout(Bundle options) { public void doKeyguardTimeout(Bundle options) {
try { try {
mService.doKeyguardTimeout(options); mService.doKeyguardTimeout(options);
@@ -174,7 +150,9 @@ public class KeyguardServiceWrapper implements IKeyguardService {
} }
} }
@Override // Binder interface
public void setCurrentUser(int userId) { public void setCurrentUser(int userId) {
mKeyguardStateMonitor.setCurrentUser(userId);
try { try {
mService.setCurrentUser(userId); mService.setCurrentUser(userId);
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -182,6 +160,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
} }
} }
@Override // Binder interface
public void onBootCompleted() { public void onBootCompleted() {
try { try {
mService.onBootCompleted(); mService.onBootCompleted();
@@ -190,6 +169,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
} }
} }
@Override // Binder interface
public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) { public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) {
try { try {
mService.startKeyguardExitAnimation(startTime, fadeoutDuration); mService.startKeyguardExitAnimation(startTime, fadeoutDuration);
@@ -198,6 +178,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
} }
} }
@Override // Binder interface
public void onActivityDrawn() { public void onActivityDrawn() {
try { try {
mService.onActivityDrawn(); mService.onActivityDrawn();
@@ -206,21 +187,20 @@ public class KeyguardServiceWrapper implements IKeyguardService {
} }
} }
public void showAssistant() { @Override // Binder interface
// Not used by PhoneWindowManager
}
public void dispatch(MotionEvent event) {
// Not used by PhoneWindowManager. See code in {@link NavigationBarView}
}
public void launchCamera() {
// Not used by PhoneWindowManager. See code in {@link NavigationBarView}
}
@Override
public IBinder asBinder() { public IBinder asBinder() {
return mService.asBinder(); return mService.asBinder();
} }
public boolean isShowing() {
return mKeyguardStateMonitor.isShowing();
}
public boolean isSecure() {
return mKeyguardStateMonitor.isSecure();
}
public boolean isInputRestricted() {
return mKeyguardStateMonitor.isInputRestricted();
}
} }

View File

@@ -0,0 +1,86 @@
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.internal.policy.impl.keyguard;
import android.app.ActivityManager;
import android.content.Context;
import android.os.RemoteException;
import android.util.Slog;
import com.android.internal.policy.IKeyguardService;
import com.android.internal.policy.IKeyguardStateCallback;
import com.android.internal.widget.LockPatternUtils;
/**
* Maintains a cached copy of Keyguard's state.
* @hide
*/
public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
private static final String TAG = "KeyguardStateMonitor";
// These cache the current state of Keyguard to improve performance and avoid deadlock. After
// Keyguard changes its state, it always triggers a layout in window manager. Because
// IKeyguardStateCallback is synchronous and because these states are declared volatile, it's
// guaranteed that window manager picks up the new state all the time in the layout caused by
// the state change of Keyguard.
private volatile boolean mIsShowing;
private volatile boolean mSimSecure;
private volatile boolean mInputRestricted;
private final LockPatternUtils mLockPatternUtils;
public KeyguardStateMonitor(Context context, IKeyguardService service) {
mLockPatternUtils = new LockPatternUtils(context);
mLockPatternUtils.setCurrentUser(ActivityManager.getCurrentUser());
try {
service.addStateMonitorCallback(this);
} catch (RemoteException e) {
Slog.w(TAG, "Remote Exception", e);
}
}
public boolean isShowing() {
return mIsShowing;
}
public boolean isSecure() {
return mLockPatternUtils.isSecure() || mSimSecure;
}
public boolean isInputRestricted() {
return mInputRestricted;
}
@Override // Binder interface
public void onShowingStateChanged(boolean showing) {
mIsShowing = showing;
}
@Override // Binder interface
public void onSimSecureStateChanged(boolean simSecure) {
mSimSecure = simSecure;
}
public void setCurrentUser(int userId) {
mLockPatternUtils.setCurrentUser(userId);
}
@Override // Binder interface
public void onInputRestrictedStateChanged(boolean inputRestricted) {
mInputRestricted = inputRestricted;
}
}