Merge "Apply new keyguard orientation when it becomes non-rotatable" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
aa6d81514c
@@ -26,6 +26,7 @@ import static com.android.systemui.statusbar.NotificationRemoteInputManager.ENAB
|
|||||||
import android.app.IActivityManager;
|
import android.app.IActivityManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
import android.graphics.Region;
|
import android.graphics.Region;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
@@ -117,6 +118,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
|
|||||||
* @see #batchApplyWindowLayoutParams(Runnable)
|
* @see #batchApplyWindowLayoutParams(Runnable)
|
||||||
*/
|
*/
|
||||||
private int mDeferWindowLayoutParams;
|
private int mDeferWindowLayoutParams;
|
||||||
|
private boolean mLastKeyguardRotationAllowed;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public NotificationShadeWindowControllerImpl(Context context, WindowManager windowManager,
|
public NotificationShadeWindowControllerImpl(Context context, WindowManager windowManager,
|
||||||
@@ -143,7 +145,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
|
|||||||
mScreenOffAnimationController = screenOffAnimationController;
|
mScreenOffAnimationController = screenOffAnimationController;
|
||||||
dumpManager.registerDumpable(getClass().getName(), this);
|
dumpManager.registerDumpable(getClass().getName(), this);
|
||||||
mAuthController = authController;
|
mAuthController = authController;
|
||||||
|
mLastKeyguardRotationAllowed = mKeyguardStateController.isKeyguardScreenRotationAllowed();
|
||||||
mLockScreenDisplayTimeout = context.getResources()
|
mLockScreenDisplayTimeout = context.getResources()
|
||||||
.getInteger(R.integer.config_lockScreenDisplayTimeout);
|
.getInteger(R.integer.config_lockScreenDisplayTimeout);
|
||||||
((SysuiStatusBarStateController) statusBarStateController)
|
((SysuiStatusBarStateController) statusBarStateController)
|
||||||
@@ -779,6 +781,17 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
|
|||||||
setKeyguardDark(useDarkText);
|
setKeyguardDark(useDarkText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfigChanged(Configuration newConfig) {
|
||||||
|
final boolean newScreenRotationAllowed = mKeyguardStateController
|
||||||
|
.isKeyguardScreenRotationAllowed();
|
||||||
|
|
||||||
|
if (mLastKeyguardRotationAllowed != newScreenRotationAllowed) {
|
||||||
|
apply(mCurrentState);
|
||||||
|
mLastKeyguardRotationAllowed = newScreenRotationAllowed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When keyguard will be dismissed but didn't start animation yet.
|
* When keyguard will be dismissed but didn't start animation yet.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ import static org.mockito.Mockito.verify;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.app.IActivityManager;
|
import android.app.IActivityManager;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.testing.AndroidTestingRunner;
|
import android.testing.AndroidTestingRunner;
|
||||||
import android.testing.TestableLooper.RunWithLooper;
|
import android.testing.TestableLooper.RunWithLooper;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -227,6 +229,36 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase {
|
|||||||
assertThat((mLayoutParameters.getValue().flags & FLAG_ALT_FOCUSABLE_IM) == 0).isTrue();
|
assertThat((mLayoutParameters.getValue().flags & FLAG_ALT_FOCUSABLE_IM) == 0).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void rotationBecameAllowed_layoutParamsUpdated() {
|
||||||
|
mNotificationShadeWindowController.setKeyguardShowing(true);
|
||||||
|
when(mKeyguardStateController.isKeyguardScreenRotationAllowed()).thenReturn(false);
|
||||||
|
mNotificationShadeWindowController.onConfigChanged(new Configuration());
|
||||||
|
clearInvocations(mWindowManager);
|
||||||
|
|
||||||
|
when(mKeyguardStateController.isKeyguardScreenRotationAllowed()).thenReturn(true);
|
||||||
|
mNotificationShadeWindowController.onConfigChanged(new Configuration());
|
||||||
|
|
||||||
|
verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture());
|
||||||
|
assertThat(mLayoutParameters.getValue().screenOrientation)
|
||||||
|
.isEqualTo(ActivityInfo.SCREEN_ORIENTATION_USER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void rotationBecameNotAllowed_layoutParamsUpdated() {
|
||||||
|
mNotificationShadeWindowController.setKeyguardShowing(true);
|
||||||
|
when(mKeyguardStateController.isKeyguardScreenRotationAllowed()).thenReturn(true);
|
||||||
|
mNotificationShadeWindowController.onConfigChanged(new Configuration());
|
||||||
|
clearInvocations(mWindowManager);
|
||||||
|
|
||||||
|
when(mKeyguardStateController.isKeyguardScreenRotationAllowed()).thenReturn(false);
|
||||||
|
mNotificationShadeWindowController.onConfigChanged(new Configuration());
|
||||||
|
|
||||||
|
verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture());
|
||||||
|
assertThat(mLayoutParameters.getValue().screenOrientation)
|
||||||
|
.isEqualTo(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void batchApplyWindowLayoutParams_doesNotDispatchEvents() {
|
public void batchApplyWindowLayoutParams_doesNotDispatchEvents() {
|
||||||
mNotificationShadeWindowController.setForceDozeBrightness(true);
|
mNotificationShadeWindowController.setForceDozeBrightness(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user