From 9a105318da2df1e7ea51fa198c15e052a5f7af51 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Fri, 21 Jul 2017 17:16:05 -0700 Subject: [PATCH] Fixed an issue where the lock icon could be invisible Because the state wasn't properly initialized after reinflation, the lockicon could be invisible. This also fixes an issue where we were leaking the view after reinflation. Change-Id: Ic01e488319d8650fac07c35642a4bba62311c1e8 Fixes: 62411136 Test: manual, switch user twice, observe --- .../phone/KeyguardBottomAreaView.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) 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 3e183b6575017..cdba24ca205cd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java @@ -238,10 +238,12 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL mEnterpriseDisclosure = findViewById( R.id.keyguard_indication_enterprise_disclosure); mIndicationText = findViewById(R.id.keyguard_indication_text); - watchForCameraPolicyChanges(); updateCameraVisibility(); mUnlockMethodCache = UnlockMethodCache.getInstance(getContext()); mUnlockMethodCache.addListener(this); + KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext); + mLockIcon.setScreenOn(updateMonitor.isScreenOn()); + mLockIcon.setDeviceInteractive(updateMonitor.isDeviceInteractive()); mLockIcon.update(); setClipChildren(false); setClipToPadding(false); @@ -278,6 +280,11 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL .withDefault(() -> new DefaultLeftButton()) .withCallback(button -> setLeftButton(button)) .build(); + final IntentFilter filter = new IntentFilter(); + filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED); + getContext().registerReceiverAsUser(mDevicePolicyReceiver, + UserHandle.ALL, filter, null, null); + KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateMonitorCallback); } @Override @@ -286,6 +293,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL mAccessibilityController.removeStateChangedCallback(this); mRightExtension.destroy(); mLeftExtension.destroy(); + getContext().unregisterReceiver(mDevicePolicyReceiver); + KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mUpdateMonitorCallback); } private void initAccessibility() { @@ -401,14 +410,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL && pm.resolveActivity(PHONE_INTENT, 0) != null; } - private void watchForCameraPolicyChanges() { - final IntentFilter filter = new IntentFilter(); - filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED); - getContext().registerReceiverAsUser(mDevicePolicyReceiver, - UserHandle.ALL, filter, null, null); - KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateMonitorCallback); - } - @Override public void onStateChanged(boolean accessibilityEnabled, boolean touchExplorationEnabled) { mRightAffordanceView.setClickable(touchExplorationEnabled);