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

Commit c8add513 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Avoid IPCs on KeyguardBottomAreaView

isSecure is available on UnlockMethodCache, and there's no need
to check if the intent can be resolved if the view will never be
visible.

Test: adb logcat | grep StrictMode
Fixes: 140057230
Change-Id: I5003d047285eccb87f25486c75eff0a8ccaa4fd0
parent 7459ad0a
Loading
Loading
Loading
Loading
+11 −15
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.systemui.statusbar.phone;
import static android.view.accessibility.AccessibilityNodeInfo.ACTION_CLICK;
import static android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;

import static com.android.systemui.DejankUtils.whitelistIpcs;
import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInOffset;
import static com.android.systemui.tuner.LockscreenFragment.LOCKSCREEN_LEFT_BUTTON;
import static com.android.systemui.tuner.LockscreenFragment.LOCKSCREEN_LEFT_UNLOCK;
@@ -117,6 +116,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
    private static final int DOZE_ANIMATION_STAGGER_DELAY = 48;
    private static final int DOZE_ANIMATION_ELEMENT_DURATION = 250;

    private final UnlockMethodCache mUnlockMethodCache;
    private KeyguardAffordanceView mRightAffordanceView;
    private KeyguardAffordanceView mLeftAffordanceView;
    private ViewGroup mIndicationArea;
@@ -129,7 +129,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
    private View mCameraPreview;

    private ActivityStarter mActivityStarter;
    private UnlockMethodCache mUnlockMethodCache;
    private LockPatternUtils mLockPatternUtils;
    private FlashlightController mFlashlightController;
    private PreviewInflater mPreviewInflater;
@@ -185,6 +184,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
    public KeyguardBottomAreaView(Context context, AttributeSet attrs, int defStyleAttr,
            int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        mUnlockMethodCache = UnlockMethodCache.getInstance(getContext());
    }

    private AccessibilityDelegate mAccessibilityDelegate = new AccessibilityDelegate() {
@@ -242,8 +242,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
        mBurnInYOffset = getResources().getDimensionPixelSize(
                R.dimen.default_burn_in_prevention_offset);
        updateCameraVisibility();
        mUnlockMethodCache = UnlockMethodCache.getInstance(getContext());
        mUnlockMethodCache.addListener(this);
        setClipChildren(false);
        setClipToPadding(false);
        inflateCameraPreview();
@@ -281,11 +279,13 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
        getContext().registerReceiverAsUser(mDevicePolicyReceiver,
                UserHandle.ALL, filter, null, null);
        KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateMonitorCallback);
        mUnlockMethodCache.addListener(this);
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        mUnlockMethodCache.removeListener(this);
        mAccessibilityController.removeStateChangedCallback(this);
        mRightExtension.destroy();
        mLeftExtension.destroy();
@@ -365,11 +365,9 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
     * Resolves the intent to launch the camera application.
     */
    public ResolveInfo resolveCameraIntent() {
        // TODO(b/140057230)
        return whitelistIpcs(() ->
                mContext.getPackageManager().resolveActivityAsUser(getCameraIntent(),
        return mContext.getPackageManager().resolveActivityAsUser(getCameraIntent(),
                PackageManager.MATCH_DEFAULT_ONLY,
                    KeyguardUpdateMonitor.getCurrentUser()));
                KeyguardUpdateMonitor.getCurrentUser());
    }

    private void updateCameraVisibility() {
@@ -806,11 +804,11 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL

        @Override
        public IconState getIcon() {
            ResolveInfo resolved = resolveCameraIntent();
            boolean isCameraDisabled = (mStatusBar != null) && !mStatusBar.isCameraAllowedByAdmin();
            mIconState.isVisible = !isCameraDisabled && resolved != null
            mIconState.isVisible = !isCameraDisabled
                    && getResources().getBoolean(R.bool.config_keyguardShowCameraAffordance)
                    && mUserSetupComplete;
                    && mUserSetupComplete
                    && resolveCameraIntent() != null;
            mIconState.drawable = mContext.getDrawable(R.drawable.ic_camera_alt_24dp);
            mIconState.contentDescription =
                    mContext.getString(R.string.accessibility_camera_button);
@@ -822,9 +820,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
            KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
            boolean canSkipBouncer = updateMonitor.getUserCanSkipBouncer(
                    KeyguardUpdateMonitor.getCurrentUser());
            // TODO(b/140057230)
            boolean secure = whitelistIpcs(() ->
                    mLockPatternUtils.isSecure(KeyguardUpdateMonitor.getCurrentUser()));
            boolean secure = mUnlockMethodCache.isMethodSecure();
            return (secure && !canSkipBouncer) ? SECURE_CAMERA_INTENT : INSECURE_CAMERA_INTENT;
        }
    }