Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9a105318 authored by Selim Cinek's avatar Selim Cinek
Browse files

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
parent c48e304b
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -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);