Fix jank when pin/pattern is shown
- Only update layout params of status bar window when needed - Do not update security method all the time, only when needed (only when reset gets called) - Check for actual used security method when updating states for bouncer Bug: 18505838 Change-Id: Ib3d0021c0cc364fa5598e06e0a2bae059ae79cbe
This commit is contained in:
@@ -399,8 +399,6 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
|
||||
showPrimarySecurityScreen(false);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
showPrimarySecurityScreen(false);
|
||||
}
|
||||
if (finish) {
|
||||
mSecurityCallback.finish();
|
||||
@@ -556,6 +554,10 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
|
||||
return mSecurityModel.getSecurityMode();
|
||||
}
|
||||
|
||||
public SecurityMode getCurrentSecurityMode() {
|
||||
return mCurrentSecuritySelection;
|
||||
}
|
||||
|
||||
public void verifyUnlock() {
|
||||
mIsVerifyUnlockOnly = true;
|
||||
showSecurityScreen(getSecurityMode());
|
||||
|
||||
@@ -112,7 +112,7 @@ public abstract class KeyguardViewBase extends FrameLayout implements SecurityCa
|
||||
/**
|
||||
* Called when the view needs to be shown.
|
||||
*/
|
||||
public void show() {
|
||||
public void showPrimarySecurityScreen() {
|
||||
if (DEBUG) Log.d(TAG, "show()");
|
||||
mSecurityContainer.showPrimarySecurityScreen(false);
|
||||
}
|
||||
@@ -224,7 +224,6 @@ public abstract class KeyguardViewBase extends FrameLayout implements SecurityCa
|
||||
*/
|
||||
public void onResume() {
|
||||
if (DEBUG) Log.d(TAG, "screen on, instance " + Integer.toHexString(hashCode()));
|
||||
mSecurityContainer.showPrimarySecurityScreen(false);
|
||||
mSecurityContainer.onResume(KeyguardSecurityView.SCREEN_ON);
|
||||
requestFocus();
|
||||
}
|
||||
@@ -473,6 +472,10 @@ public abstract class KeyguardViewBase extends FrameLayout implements SecurityCa
|
||||
return mSecurityContainer.getSecurityMode();
|
||||
}
|
||||
|
||||
public SecurityMode getCurrentSecurityMode() {
|
||||
return mSecurityContainer.getCurrentSecurityMode();
|
||||
}
|
||||
|
||||
protected abstract void onUserSwitching(boolean switching);
|
||||
|
||||
protected abstract void onCreateOptions(Bundle options);
|
||||
|
||||
@@ -957,6 +957,7 @@ public class KeyguardViewMediator extends SystemUI {
|
||||
// if the keyguard is already showing, don't bother
|
||||
if (mStatusBarKeyguardViewManager.isShowing()) {
|
||||
if (DEBUG) Log.d(TAG, "doKeyguard: not showing because it is already showing");
|
||||
resetStateLocked();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,13 +57,14 @@ public class KeyguardBouncer {
|
||||
mWindowManager = windowManager;
|
||||
}
|
||||
|
||||
public void show() {
|
||||
public void show(boolean resetSecuritySelection) {
|
||||
ensureView();
|
||||
if (resetSecuritySelection) {
|
||||
// showPrimarySecurityScreen() updates the current security method. This is needed in
|
||||
// case we are already showing and the current security method changed.
|
||||
mKeyguardView.showPrimarySecurityScreen();
|
||||
}
|
||||
if (mRoot.getVisibility() == View.VISIBLE || mShowingSoon) {
|
||||
|
||||
// show() updates the current security method. This is needed in case we are already
|
||||
// showing and the current security method changed.
|
||||
mKeyguardView.show();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -74,7 +75,7 @@ public class KeyguardBouncer {
|
||||
|
||||
// Split up the work over multiple frames.
|
||||
mChoreographer.postCallbackDelayed(Choreographer.CALLBACK_ANIMATION, mShowRunnable,
|
||||
null, 48);
|
||||
null, 16);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +97,7 @@ public class KeyguardBouncer {
|
||||
public void showWithDismissAction(OnDismissAction r) {
|
||||
ensureView();
|
||||
mKeyguardView.setOnDismissAction(r);
|
||||
show();
|
||||
show(false /* resetSecuritySelection */);
|
||||
}
|
||||
|
||||
public void hide(boolean destroyView) {
|
||||
@@ -152,7 +153,11 @@ public class KeyguardBouncer {
|
||||
}
|
||||
|
||||
public void prepare() {
|
||||
boolean wasInitialized = mRoot != null;
|
||||
ensureView();
|
||||
if (wasInitialized) {
|
||||
mKeyguardView.showPrimarySecurityScreen();
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureView() {
|
||||
@@ -184,14 +189,25 @@ public class KeyguardBouncer {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if and only if the current security method should be shown before showing
|
||||
* the notifications on Keyguard, like SIM PIN/PUK.
|
||||
* @return True if and only if the security method should be shown before showing the
|
||||
* notifications on Keyguard, like SIM PIN/PUK.
|
||||
*/
|
||||
public boolean needsFullscreenBouncer() {
|
||||
if (mKeyguardView != null) {
|
||||
SecurityMode mode = mKeyguardView.getSecurityMode();
|
||||
return mode == SecurityMode.SimPin
|
||||
|| mode == SecurityMode.SimPuk;
|
||||
return mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Like {@link #needsFullscreenBouncer}, but uses the currently visible security method, which
|
||||
* makes this method much faster.
|
||||
*/
|
||||
public boolean isFullscreenBouncer() {
|
||||
if (mKeyguardView != null) {
|
||||
SecurityMode mode = mKeyguardView.getCurrentSecurityMode();
|
||||
return mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class StatusBarKeyguardViewManager {
|
||||
|
||||
// The keyguard might be showing (already). So we need to hide it.
|
||||
mPhoneStatusBar.hideKeyguard();
|
||||
mBouncer.show();
|
||||
mBouncer.show(true /* resetSecuritySelection */);
|
||||
} else {
|
||||
mPhoneStatusBar.showKeyguard();
|
||||
mBouncer.hide(false /* destroyView */);
|
||||
@@ -120,7 +120,7 @@ public class StatusBarKeyguardViewManager {
|
||||
|
||||
private void showBouncer() {
|
||||
if (mShowing) {
|
||||
mBouncer.show();
|
||||
mBouncer.show(false /* resetSecuritySelection */);
|
||||
}
|
||||
updateStates();
|
||||
}
|
||||
@@ -130,7 +130,7 @@ public class StatusBarKeyguardViewManager {
|
||||
if (!afterKeyguardGone) {
|
||||
mBouncer.showWithDismissAction(r);
|
||||
} else {
|
||||
mBouncer.show();
|
||||
mBouncer.show(false /* resetSecuritySelection */);
|
||||
mAfterKeyguardGoneAction = r;
|
||||
}
|
||||
}
|
||||
@@ -354,7 +354,7 @@ public class StatusBarKeyguardViewManager {
|
||||
boolean showing = mShowing;
|
||||
boolean occluded = mOccluded;
|
||||
boolean bouncerShowing = mBouncer.isShowing();
|
||||
boolean bouncerDismissible = !mBouncer.needsFullscreenBouncer();
|
||||
boolean bouncerDismissible = !mBouncer.isFullscreenBouncer();
|
||||
|
||||
if ((bouncerDismissible || !showing) != (mLastBouncerDismissible || !mLastShowing)
|
||||
|| mFirstUpdate) {
|
||||
|
||||
@@ -39,6 +39,7 @@ public class StatusBarWindowManager {
|
||||
private final WindowManager mWindowManager;
|
||||
private View mStatusBarView;
|
||||
private WindowManager.LayoutParams mLp;
|
||||
private WindowManager.LayoutParams mLpChanged;
|
||||
private int mBarHeight;
|
||||
private final boolean mKeyguardScreenRotation;
|
||||
|
||||
@@ -85,41 +86,43 @@ public class StatusBarWindowManager {
|
||||
mStatusBarView = statusBarView;
|
||||
mBarHeight = barHeight;
|
||||
mWindowManager.addView(mStatusBarView, mLp);
|
||||
mLpChanged = new WindowManager.LayoutParams();
|
||||
mLpChanged.copyFrom(mLp);
|
||||
}
|
||||
|
||||
private void applyKeyguardFlags(State state) {
|
||||
if (state.keyguardShowing) {
|
||||
mLp.flags |= WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
|
||||
mLp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
|
||||
mLpChanged.flags |= WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
|
||||
mLpChanged.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
|
||||
} else {
|
||||
mLp.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
|
||||
mLp.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
|
||||
mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
|
||||
mLpChanged.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
|
||||
}
|
||||
}
|
||||
|
||||
private void adjustScreenOrientation(State state) {
|
||||
if (state.isKeyguardShowingAndNotOccluded()) {
|
||||
if (mKeyguardScreenRotation) {
|
||||
mLp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_USER;
|
||||
mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_USER;
|
||||
} else {
|
||||
mLp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
|
||||
mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
|
||||
}
|
||||
} else {
|
||||
mLp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
||||
mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
||||
}
|
||||
}
|
||||
|
||||
private void applyFocusableFlag(State state) {
|
||||
if (state.isKeyguardShowingAndNotOccluded() && state.keyguardNeedsInput
|
||||
&& state.bouncerShowing) {
|
||||
mLp.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
||||
mLp.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
|
||||
mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
||||
mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
|
||||
} else if (state.isKeyguardShowingAndNotOccluded() || state.statusBarFocusable) {
|
||||
mLp.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
||||
mLp.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
|
||||
mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
||||
mLpChanged.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
|
||||
} else {
|
||||
mLp.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
||||
mLp.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
|
||||
mLpChanged.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
||||
mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,9 +130,9 @@ public class StatusBarWindowManager {
|
||||
boolean expanded = state.isKeyguardShowingAndNotOccluded() || state.statusBarExpanded
|
||||
|| state.keyguardFadingAway || state.bouncerShowing;
|
||||
if (expanded) {
|
||||
mLp.height = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
mLpChanged.height = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
} else {
|
||||
mLp.height = mBarHeight;
|
||||
mLpChanged.height = mBarHeight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,9 +144,9 @@ public class StatusBarWindowManager {
|
||||
if (state.isKeyguardShowingAndNotOccluded()
|
||||
&& state.statusBarState == StatusBarState.KEYGUARD
|
||||
&& !state.qsExpanded) {
|
||||
mLp.userActivityTimeout = state.keyguardUserActivityTimeout;
|
||||
mLpChanged.userActivityTimeout = state.keyguardUserActivityTimeout;
|
||||
} else {
|
||||
mLp.userActivityTimeout = -1;
|
||||
mLpChanged.userActivityTimeout = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,9 +154,11 @@ public class StatusBarWindowManager {
|
||||
if (state.isKeyguardShowingAndNotOccluded()
|
||||
&& state.statusBarState == StatusBarState.KEYGUARD
|
||||
&& !state.qsExpanded) {
|
||||
mLp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_DISABLE_USER_ACTIVITY;
|
||||
mLpChanged.inputFeatures |=
|
||||
WindowManager.LayoutParams.INPUT_FEATURE_DISABLE_USER_ACTIVITY;
|
||||
} else {
|
||||
mLp.inputFeatures &= ~WindowManager.LayoutParams.INPUT_FEATURE_DISABLE_USER_ACTIVITY;
|
||||
mLpChanged.inputFeatures &=
|
||||
~WindowManager.LayoutParams.INPUT_FEATURE_DISABLE_USER_ACTIVITY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,7 +170,9 @@ public class StatusBarWindowManager {
|
||||
applyUserActivityTimeout(state);
|
||||
applyInputFeatures(state);
|
||||
applyFitsSystemWindows(state);
|
||||
mWindowManager.updateViewLayout(mStatusBarView, mLp);
|
||||
if (mLp.copyFrom(mLpChanged) != 0) {
|
||||
mWindowManager.updateViewLayout(mStatusBarView, mLp);
|
||||
}
|
||||
}
|
||||
|
||||
public void setKeyguardShowing(boolean showing) {
|
||||
|
||||
Reference in New Issue
Block a user