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
This commit is contained in:
Selim Cinek
2017-07-21 17:16:05 -07:00
parent c48e304bbf
commit 9a105318da

View File

@@ -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);