diff options
| author | 2021-02-03 13:27:17 -0500 | |
|---|---|---|
| committer | 2021-02-03 14:28:39 -0500 | |
| commit | 5c21885fee05b7aa5f2b82baa072ccb15bd17d90 (patch) | |
| tree | 15f24d8cbcce587f895a4f07fe688ff274abcfcf | |
| parent | 1135dae87aed9fcf1991be9183e0cc98211896a3 (diff) | |
Keyguard - Don't recreate KeyguardPresentation
Do not hide and then reconstruct a new KeyguardPresentation on every
display change. Reuse and update the existing presentation.
Fixes: 178613948
Test: atest KeyguardDisplayManagerTest
Change-Id: I0a352ba8f518de18d7292501849e2f88f6c64f7b
| -rw-r--r-- | packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java b/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java index 85e9ca05d428..276036c400e1 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java @@ -74,16 +74,7 @@ public class KeyguardDisplayManager { @Override public void onDisplayChanged(int displayId) { - if (displayId == DEFAULT_DISPLAY) return; - final Presentation presentation = mPresentations.get(displayId); - if (presentation != null && mShowing) { - hidePresentation(displayId); - // update DisplayInfo. - final Display display = mDisplayService.getDisplay(displayId); - if (display != null) { - showPresentation(display); - } - } + } @Override @@ -305,15 +296,16 @@ public class KeyguardDisplayManager { } @Override + public void onDisplayChanged() { + updateBounds(); + getWindow().getDecorView().requestLayout(); + } + + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - final Rect bounds = getWindow().getWindowManager().getMaximumWindowMetrics() - .getBounds(); - mUsableWidth = VIDEO_SAFE_REGION * bounds.width() / 100; - mUsableHeight = VIDEO_SAFE_REGION * bounds.height() / 100; - mMarginLeft = (100 - VIDEO_SAFE_REGION) * bounds.width() / 200; - mMarginTop = (100 - VIDEO_SAFE_REGION) * bounds.height() / 200; + updateBounds(); setContentView(LayoutInflater.from(mContext) .inflate(R.layout.keyguard_presentation, null)); @@ -338,5 +330,14 @@ public class KeyguardDisplayManager { mKeyguardClockSwitchController.init(); } + + private void updateBounds() { + final Rect bounds = getWindow().getWindowManager().getMaximumWindowMetrics() + .getBounds(); + mUsableWidth = VIDEO_SAFE_REGION * bounds.width() / 100; + mUsableHeight = VIDEO_SAFE_REGION * bounds.height() / 100; + mMarginLeft = (100 - VIDEO_SAFE_REGION) * bounds.width() / 200; + mMarginTop = (100 - VIDEO_SAFE_REGION) * bounds.height() / 200; + } } } |