Merge "Ensure bouncer in correct position on swipe. Remove orientationlistener." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a1398df0b0
@@ -487,5 +487,9 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView>
|
|||||||
mView.setLayoutParams(lp);
|
mView.setLayoutParams(lp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mKeyguardSecurityContainerController != null) {
|
||||||
|
mKeyguardSecurityContainerController.updateResources();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import android.util.MathUtils;
|
|||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.OrientationEventListener;
|
|
||||||
import android.view.VelocityTracker;
|
import android.view.VelocityTracker;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
@@ -107,7 +106,6 @@ public class KeyguardSecurityContainer extends FrameLayout {
|
|||||||
private boolean mOneHandedMode = false;
|
private boolean mOneHandedMode = false;
|
||||||
private SecurityMode mSecurityMode = SecurityMode.Invalid;
|
private SecurityMode mSecurityMode = SecurityMode.Invalid;
|
||||||
private ViewPropertyAnimator mRunningOneHandedAnimator;
|
private ViewPropertyAnimator mRunningOneHandedAnimator;
|
||||||
private final OrientationEventListener mOrientationEventListener;
|
|
||||||
|
|
||||||
private final WindowInsetsAnimation.Callback mWindowInsetsAnimationCallback =
|
private final WindowInsetsAnimation.Callback mWindowInsetsAnimationCallback =
|
||||||
new WindowInsetsAnimation.Callback(DISPATCH_MODE_STOP) {
|
new WindowInsetsAnimation.Callback(DISPATCH_MODE_STOP) {
|
||||||
@@ -247,13 +245,6 @@ public class KeyguardSecurityContainer extends FrameLayout {
|
|||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
mSpringAnimation = new SpringAnimation(this, DynamicAnimation.Y);
|
mSpringAnimation = new SpringAnimation(this, DynamicAnimation.Y);
|
||||||
mViewConfiguration = ViewConfiguration.get(context);
|
mViewConfiguration = ViewConfiguration.get(context);
|
||||||
|
|
||||||
mOrientationEventListener = new OrientationEventListener(context) {
|
|
||||||
@Override
|
|
||||||
public void onOrientationChanged(int orientation) {
|
|
||||||
updateLayoutForSecurityMode(mSecurityMode);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void onResume(SecurityMode securityMode, boolean faceAuthEnabled) {
|
void onResume(SecurityMode securityMode, boolean faceAuthEnabled) {
|
||||||
@@ -262,7 +253,6 @@ public class KeyguardSecurityContainer extends FrameLayout {
|
|||||||
updateBiometricRetry(securityMode, faceAuthEnabled);
|
updateBiometricRetry(securityMode, faceAuthEnabled);
|
||||||
|
|
||||||
updateLayoutForSecurityMode(securityMode);
|
updateLayoutForSecurityMode(securityMode);
|
||||||
mOrientationEventListener.enable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateLayoutForSecurityMode(SecurityMode securityMode) {
|
void updateLayoutForSecurityMode(SecurityMode securityMode) {
|
||||||
@@ -385,7 +375,6 @@ public class KeyguardSecurityContainer extends FrameLayout {
|
|||||||
mAlertDialog = null;
|
mAlertDialog = null;
|
||||||
}
|
}
|
||||||
mSecurityViewFlipper.setWindowInsetsAnimationCallback(null);
|
mSecurityViewFlipper.setWindowInsetsAnimationCallback(null);
|
||||||
mOrientationEventListener.disable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -663,6 +652,15 @@ public class KeyguardSecurityContainer extends FrameLayout {
|
|||||||
childState << MEASURED_HEIGHT_STATE_SHIFT));
|
childState << MEASURED_HEIGHT_STATE_SHIFT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||||
|
super.onLayout(changed, left, top, right, bottom);
|
||||||
|
|
||||||
|
// After a layout pass, we need to re-place the inner bouncer, as our bounds may have
|
||||||
|
// changed.
|
||||||
|
updateSecurityViewLocation(/* animate= */false);
|
||||||
|
}
|
||||||
|
|
||||||
void showAlmostAtWipeDialog(int attempts, int remaining, int userType) {
|
void showAlmostAtWipeDialog(int attempts, int remaining, int userType) {
|
||||||
String message = null;
|
String message = null;
|
||||||
switch (userType) {
|
switch (userType) {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import static com.android.systemui.DejankUtils.whitelistIpcs;
|
|||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.metrics.LogMaker;
|
import android.metrics.LogMaker;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -74,6 +75,8 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
|
|||||||
private final SecurityCallback mSecurityCallback;
|
private final SecurityCallback mSecurityCallback;
|
||||||
private final ConfigurationController mConfigurationController;
|
private final ConfigurationController mConfigurationController;
|
||||||
|
|
||||||
|
private int mLastOrientation = Configuration.ORIENTATION_UNDEFINED;
|
||||||
|
|
||||||
private SecurityMode mCurrentSecurityMode = SecurityMode.Invalid;
|
private SecurityMode mCurrentSecurityMode = SecurityMode.Invalid;
|
||||||
|
|
||||||
private final Gefingerpoken mGlobalTouchListener = new Gefingerpoken() {
|
private final Gefingerpoken mGlobalTouchListener = new Gefingerpoken() {
|
||||||
@@ -212,6 +215,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
|
|||||||
mAdminSecondaryLockScreenController = adminSecondaryLockScreenControllerFactory.create(
|
mAdminSecondaryLockScreenController = adminSecondaryLockScreenControllerFactory.create(
|
||||||
mKeyguardSecurityCallback);
|
mKeyguardSecurityCallback);
|
||||||
mConfigurationController = configurationController;
|
mConfigurationController = configurationController;
|
||||||
|
mLastOrientation = getResources().getConfiguration().orientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -498,6 +502,19 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
|
|||||||
return getCurrentSecurityController();
|
return getCurrentSecurityController();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply keyguard configuration from the currently active resources. This can be called when the
|
||||||
|
* device configuration changes, to re-apply some resources that are qualified on the device
|
||||||
|
* configuration.
|
||||||
|
*/
|
||||||
|
public void updateResources() {
|
||||||
|
int newOrientation = getResources().getConfiguration().orientation;
|
||||||
|
if (newOrientation != mLastOrientation) {
|
||||||
|
mLastOrientation = newOrientation;
|
||||||
|
mView.updateLayoutForSecurityMode(mCurrentSecurityMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static class Factory {
|
static class Factory {
|
||||||
|
|
||||||
private final KeyguardSecurityContainer mView;
|
private final KeyguardSecurityContainer mView;
|
||||||
|
|||||||
@@ -25,9 +25,11 @@ import static org.mockito.ArgumentMatchers.eq;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.testing.AndroidTestingRunner;
|
import android.testing.AndroidTestingRunner;
|
||||||
import android.testing.TestableLooper;
|
import android.testing.TestableLooper;
|
||||||
@@ -96,6 +98,9 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
|
|||||||
private ConfigurationController mConfigurationController;
|
private ConfigurationController mConfigurationController;
|
||||||
@Mock
|
@Mock
|
||||||
private EmergencyButtonController mEmergencyButtonController;
|
private EmergencyButtonController mEmergencyButtonController;
|
||||||
|
@Mock
|
||||||
|
private Resources mResources;
|
||||||
|
private Configuration mConfiguration;
|
||||||
|
|
||||||
private KeyguardSecurityContainerController mKeyguardSecurityContainerController;
|
private KeyguardSecurityContainerController mKeyguardSecurityContainerController;
|
||||||
private KeyguardPasswordViewController mKeyguardPasswordViewController;
|
private KeyguardPasswordViewController mKeyguardPasswordViewController;
|
||||||
@@ -103,6 +108,11 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
|
mConfiguration = new Configuration();
|
||||||
|
mConfiguration.setToDefaults(); // Defaults to ORIENTATION_UNDEFINED.
|
||||||
|
|
||||||
|
when(mResources.getConfiguration()).thenReturn(mConfiguration);
|
||||||
|
when(mView.getResources()).thenReturn(mResources);
|
||||||
when(mAdminSecondaryLockScreenControllerFactory.create(any(KeyguardSecurityCallback.class)))
|
when(mAdminSecondaryLockScreenControllerFactory.create(any(KeyguardSecurityCallback.class)))
|
||||||
.thenReturn(mAdminSecondaryLockScreenController);
|
.thenReturn(mAdminSecondaryLockScreenController);
|
||||||
when(mSecurityViewFlipper.getWindowInsetsController()).thenReturn(mWindowInsetsController);
|
when(mSecurityViewFlipper.getWindowInsetsController()).thenReturn(mWindowInsetsController);
|
||||||
@@ -154,4 +164,17 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
|
|||||||
verify(mWindowInsetsController).controlWindowInsetsAnimation(
|
verify(mWindowInsetsController).controlWindowInsetsAnimation(
|
||||||
eq(ime()), anyLong(), any(), any(), any());
|
eq(ime()), anyLong(), any(), any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onResourcesUpdate_callsThroughOnRotationChange() {
|
||||||
|
// Rotation is the same, shouldn't cause an update
|
||||||
|
mKeyguardSecurityContainerController.updateResources();
|
||||||
|
verify(mView, times(0)).updateLayoutForSecurityMode(any());
|
||||||
|
|
||||||
|
// Update rotation. Should trigger update
|
||||||
|
mConfiguration.orientation = Configuration.ORIENTATION_LANDSCAPE;
|
||||||
|
|
||||||
|
mKeyguardSecurityContainerController.updateResources();
|
||||||
|
verify(mView, times(1)).updateLayoutForSecurityMode(any());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user