Merge "Fix dismissing window showing" into nyc-mr1-dev
This commit is contained in:
@@ -140,6 +140,7 @@ import android.view.animation.Animation;
|
|||||||
import android.view.animation.AnimationSet;
|
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.annotations.GuardedBy;
|
||||||
import com.android.internal.logging.MetricsLogger;
|
import com.android.internal.logging.MetricsLogger;
|
||||||
import com.android.internal.policy.PhoneWindow;
|
import com.android.internal.policy.PhoneWindow;
|
||||||
import com.android.internal.policy.IShortcutService;
|
import com.android.internal.policy.IShortcutService;
|
||||||
@@ -590,6 +591,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
private static final int DISMISS_KEYGUARD_CONTINUE = 2; // Keyguard has been dismissed.
|
private static final int DISMISS_KEYGUARD_CONTINUE = 2; // Keyguard has been dismissed.
|
||||||
int mDismissKeyguard = DISMISS_KEYGUARD_NONE;
|
int mDismissKeyguard = DISMISS_KEYGUARD_NONE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates that we asked the Keyguard to be dismissed and we just wait for the Keyguard to
|
||||||
|
* dismiss itself.
|
||||||
|
*/
|
||||||
|
@GuardedBy("Lw")
|
||||||
|
private boolean mCurrentlyDismissingKeyguard;
|
||||||
|
|
||||||
/** The window that is currently dismissing the keyguard. Dismissing the keyguard must only
|
/** The window that is currently dismissing the keyguard. Dismissing the keyguard must only
|
||||||
* be done once per window. */
|
* be done once per window. */
|
||||||
private WindowState mWinDismissingKeyguard;
|
private WindowState mWinDismissingKeyguard;
|
||||||
@@ -3590,10 +3598,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canShowDismissingWindowWhileLockedLw() {
|
public boolean canShowDismissingWindowWhileLockedLw() {
|
||||||
// If the keyguard is trusted, it will unlock without a challange. Therefore, windows with
|
// If the keyguard is trusted, it will unlock without a challenge. Therefore, if we are in
|
||||||
// FLAG_DISMISS_KEYGUARD don't need to be force hidden, as they will unlock the phone right
|
// the process of dismissing Keyguard, we don't need to hide them as the phone will be
|
||||||
// away anyways.
|
// unlocked right away in any case.
|
||||||
return mKeyguardDelegate != null && mKeyguardDelegate.isTrusted();
|
return mKeyguardDelegate != null && mKeyguardDelegate.isTrusted()
|
||||||
|
&& mCurrentlyDismissingKeyguard;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void launchAssistLongPressAction() {
|
private void launchAssistLongPressAction() {
|
||||||
@@ -5300,22 +5309,27 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
}
|
}
|
||||||
} else if (mDismissKeyguard != DISMISS_KEYGUARD_NONE) {
|
} else if (mDismissKeyguard != DISMISS_KEYGUARD_NONE) {
|
||||||
mKeyguardHidden = false;
|
mKeyguardHidden = false;
|
||||||
|
boolean willDismiss = false;
|
||||||
|
if (mDismissKeyguard == DISMISS_KEYGUARD_START) {
|
||||||
final boolean trusted = mKeyguardDelegate.isTrusted();
|
final boolean trusted = mKeyguardDelegate.isTrusted();
|
||||||
if (trusted) {
|
willDismiss = trusted && mKeyguardOccluded && mKeyguardDelegate != null
|
||||||
// No need to un-occlude keyguard - we'll dimiss it right away anyways.
|
&& mKeyguardDelegate.isShowing();
|
||||||
} else if (setKeyguardOccludedLw(false)) {
|
if (willDismiss) {
|
||||||
|
mCurrentlyDismissingKeyguard = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only launch the next keyguard unlock window once per window.
|
||||||
|
mHandler.post(() -> mKeyguardDelegate.dismiss(
|
||||||
|
trusted /* allowWhileOccluded */));
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we are currently dismissing Keyguard, there is no need to unocclude it.
|
||||||
|
if (!mCurrentlyDismissingKeyguard) {
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
if (mDismissKeyguard == DISMISS_KEYGUARD_START) {
|
|
||||||
// Only launch the next keyguard unlock window once per window.
|
|
||||||
mHandler.post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
mKeyguardDelegate.dismiss(trusted /* allowWhileOccluded */);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mWinDismissingKeyguard = null;
|
mWinDismissingKeyguard = null;
|
||||||
@@ -5370,6 +5384,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onKeyguardShowingStateChanged(boolean showing) {
|
||||||
|
if (!showing) {
|
||||||
|
synchronized (mWindowManagerFuncs.getWindowManagerLock()) {
|
||||||
|
mCurrentlyDismissingKeyguard = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isStatusBarKeyguard() {
|
private boolean isStatusBarKeyguard() {
|
||||||
return mStatusBar != null
|
return mStatusBar != null
|
||||||
&& (mStatusBar.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0;
|
&& (mStatusBar.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0;
|
||||||
@@ -6908,7 +6930,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public void systemReady() {
|
public void systemReady() {
|
||||||
mKeyguardDelegate = new KeyguardServiceDelegate(mContext);
|
mKeyguardDelegate = new KeyguardServiceDelegate(mContext,
|
||||||
|
this::onKeyguardShowingStateChanged);
|
||||||
mKeyguardDelegate.onSystemReady();
|
mKeyguardDelegate.onSystemReady();
|
||||||
|
|
||||||
readCameraLensCoverState();
|
readCameraLensCoverState();
|
||||||
@@ -7989,6 +8012,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
pw.print(" mForceStatusBarFromKeyguard=");
|
pw.print(" mForceStatusBarFromKeyguard=");
|
||||||
pw.println(mForceStatusBarFromKeyguard);
|
pw.println(mForceStatusBarFromKeyguard);
|
||||||
pw.print(prefix); pw.print("mDismissKeyguard="); pw.print(mDismissKeyguard);
|
pw.print(prefix); pw.print("mDismissKeyguard="); pw.print(mDismissKeyguard);
|
||||||
|
pw.print(" mCurrentlyDismissingKeyguard="); pw.println(mCurrentlyDismissingKeyguard);
|
||||||
pw.print(" mWinDismissingKeyguard="); pw.print(mWinDismissingKeyguard);
|
pw.print(" mWinDismissingKeyguard="); pw.print(mWinDismissingKeyguard);
|
||||||
pw.print(" mHomePressed="); pw.println(mHomePressed);
|
pw.print(" mHomePressed="); pw.println(mHomePressed);
|
||||||
pw.print(prefix); pw.print("mAllowLockscreenWhenOn="); pw.print(mAllowLockscreenWhenOn);
|
pw.print(prefix); pw.print("mAllowLockscreenWhenOn="); pw.print(mAllowLockscreenWhenOn);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.android.internal.policy.IKeyguardDrawnCallback;
|
|||||||
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.server.UiThread;
|
import com.android.server.UiThread;
|
||||||
|
import com.android.server.policy.keyguard.KeyguardStateMonitor.OnShowingStateChangedCallback;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
@@ -49,6 +50,7 @@ public class KeyguardServiceDelegate {
|
|||||||
private final Handler mScrimHandler;
|
private final Handler mScrimHandler;
|
||||||
private final KeyguardState mKeyguardState = new KeyguardState();
|
private final KeyguardState mKeyguardState = new KeyguardState();
|
||||||
private DrawnListener mDrawnListenerWhenConnect;
|
private DrawnListener mDrawnListenerWhenConnect;
|
||||||
|
private final OnShowingStateChangedCallback mShowingStateChangedCallback;
|
||||||
|
|
||||||
private static final class KeyguardState {
|
private static final class KeyguardState {
|
||||||
KeyguardState() {
|
KeyguardState() {
|
||||||
@@ -116,9 +118,11 @@ public class KeyguardServiceDelegate {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public KeyguardServiceDelegate(Context context) {
|
public KeyguardServiceDelegate(Context context,
|
||||||
|
OnShowingStateChangedCallback showingStateChangedCallback) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mScrimHandler = UiThread.getHandler();
|
mScrimHandler = UiThread.getHandler();
|
||||||
|
mShowingStateChangedCallback = showingStateChangedCallback;
|
||||||
mScrim = createScrim(context, mScrimHandler);
|
mScrim = createScrim(context, mScrimHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,7 +158,7 @@ public class KeyguardServiceDelegate {
|
|||||||
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(mContext,
|
mKeyguardService = new KeyguardServiceWrapper(mContext,
|
||||||
IKeyguardService.Stub.asInterface(service));
|
IKeyguardService.Stub.asInterface(service), mShowingStateChangedCallback);
|
||||||
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.
|
||||||
mKeyguardService.onSystemReady();
|
mKeyguardService.onSystemReady();
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import com.android.internal.policy.IKeyguardDrawnCallback;
|
|||||||
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.IKeyguardStateCallback;
|
import com.android.internal.policy.IKeyguardStateCallback;
|
||||||
|
import com.android.server.policy.keyguard.KeyguardStateMonitor.OnShowingStateChangedCallback;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
@@ -39,9 +40,11 @@ public class KeyguardServiceWrapper implements IKeyguardService {
|
|||||||
private IKeyguardService mService;
|
private IKeyguardService mService;
|
||||||
private String TAG = "KeyguardServiceWrapper";
|
private String TAG = "KeyguardServiceWrapper";
|
||||||
|
|
||||||
public KeyguardServiceWrapper(Context context, IKeyguardService service) {
|
public KeyguardServiceWrapper(Context context, IKeyguardService service,
|
||||||
|
OnShowingStateChangedCallback showingStateChangedCallback) {
|
||||||
mService = service;
|
mService = service;
|
||||||
mKeyguardStateMonitor = new KeyguardStateMonitor(context, service);
|
mKeyguardStateMonitor = new KeyguardStateMonitor(context, service,
|
||||||
|
showingStateChangedCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // Binder interface
|
@Override // Binder interface
|
||||||
|
|||||||
@@ -49,10 +49,13 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
|
|||||||
private int mCurrentUserId;
|
private int mCurrentUserId;
|
||||||
|
|
||||||
private final LockPatternUtils mLockPatternUtils;
|
private final LockPatternUtils mLockPatternUtils;
|
||||||
|
private final OnShowingStateChangedCallback mOnShowingStateChangedCallback;
|
||||||
|
|
||||||
public KeyguardStateMonitor(Context context, IKeyguardService service) {
|
public KeyguardStateMonitor(Context context, IKeyguardService service,
|
||||||
|
OnShowingStateChangedCallback showingStateChangedCallback) {
|
||||||
mLockPatternUtils = new LockPatternUtils(context);
|
mLockPatternUtils = new LockPatternUtils(context);
|
||||||
mCurrentUserId = ActivityManager.getCurrentUser();
|
mCurrentUserId = ActivityManager.getCurrentUser();
|
||||||
|
mOnShowingStateChangedCallback = showingStateChangedCallback;
|
||||||
try {
|
try {
|
||||||
service.addStateMonitorCallback(this);
|
service.addStateMonitorCallback(this);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -83,6 +86,7 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
|
|||||||
@Override // Binder interface
|
@Override // Binder interface
|
||||||
public void onShowingStateChanged(boolean showing) {
|
public void onShowingStateChanged(boolean showing) {
|
||||||
mIsShowing = showing;
|
mIsShowing = showing;
|
||||||
|
mOnShowingStateChangedCallback.onShowingStateChanged(showing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // Binder interface
|
@Override // Binder interface
|
||||||
@@ -122,4 +126,8 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
|
|||||||
pw.println(prefix + "mTrusted=" + mTrusted);
|
pw.println(prefix + "mTrusted=" + mTrusted);
|
||||||
pw.println(prefix + "mCurrentUserId=" + mCurrentUserId);
|
pw.println(prefix + "mCurrentUserId=" + mCurrentUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface OnShowingStateChangedCallback {
|
||||||
|
void onShowingStateChanged(boolean showing);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user