From 3704d53fe1303cee029b633c665dff5a4ed6e621 Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Thu, 18 Apr 2019 19:23:06 -0700 Subject: [PATCH] Do not unnecessarily re-inflate camera preview Camera preview inflation was happening every time the keyguard visibility changed, causing jank and making sysui drop frames. Ultimately, the symptom was AOD flashing after pressing power. Fixes: 130878131 Test: press power to go from and to AOD Test: double tap power to launch camera (preview is still available) Test: press power to lock device from launcher Change-Id: Id3df83d59dcd123a71b37297e9ab70a1e8a52c90 --- .../statusbar/KeyguardAffordanceView.java | 10 ++++++++++ .../statusbar/phone/KeyguardBottomAreaView.java | 15 ++++++++------- .../statusbar/phone/NotificationPanelView.java | 1 - 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardAffordanceView.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardAffordanceView.java index 2da68249d8c40..6adaa0ddbfd2c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardAffordanceView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardAffordanceView.java @@ -149,6 +149,13 @@ public class KeyguardAffordanceView extends ImageView { updateIconColor(); } + /** + * If current drawable should be tinted. + */ + public boolean shouldTint() { + return mShouldTint; + } + @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); @@ -168,6 +175,9 @@ public class KeyguardAffordanceView extends ImageView { } public void setPreviewView(View v) { + if (mPreviewView == v) { + return; + } View oldPreviewView = mPreviewView; mPreviewView = v; if (mPreviewView != null) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java index a924680b7043a..85dbe671dd902 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java @@ -365,7 +365,10 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL private void updateRightAffordanceIcon() { IconState state = mRightButton.getIcon(); mRightAffordanceView.setVisibility(!mDozing && state.isVisible ? View.VISIBLE : View.GONE); - mRightAffordanceView.setImageDrawable(state.drawable, state.tint); + if (state.drawable != mRightAffordanceView.getDrawable() + || state.tint != mRightAffordanceView.shouldTint()) { + mRightAffordanceView.setImageDrawable(state.drawable, state.tint); + } mRightAffordanceView.setContentDescription(state.contentDescription); } @@ -417,7 +420,10 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL private void updateLeftAffordanceIcon() { IconState state = mLeftButton.getIcon(); mLeftAffordanceView.setVisibility(!mDozing && state.isVisible ? View.VISIBLE : View.GONE); - mLeftAffordanceView.setImageDrawable(state.drawable, state.tint); + if (state.drawable != mLeftAffordanceView.getDrawable() + || state.tint != mLeftAffordanceView.shouldTint()) { + mLeftAffordanceView.setImageDrawable(state.drawable, state.tint); + } mLeftAffordanceView.setContentDescription(state.contentDescription); } @@ -811,11 +817,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL updateLeftPreview(); } - public void onKeyguardShowingChanged() { - updateLeftAffordance(); - inflateCameraPreview(); - } - private void setRightButton(IntentButton button) { mRightButton = button; updateRightAffordanceIcon(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index ab13149f31513..383400da38e5a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -1308,7 +1308,6 @@ public class NotificationPanelView extends PanelView implements mKeyguardStatusBar.setAlpha(1f); mKeyguardStatusBar.setVisibility(keyguardShowing ? View.VISIBLE : View.INVISIBLE); if (keyguardShowing && oldState != mBarState) { - mKeyguardBottomArea.onKeyguardShowingChanged(); if (mQs != null) { mQs.hideImmediately(); }