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

Commit 07433909 authored by Roman Birg's avatar Roman Birg Committed by Steve Kondik
Browse files

SystemUI: don't display protected lockscreen shortcuts



If an app was protected, do not display that app in the lockscreen.

Change-Id: I301a43c8f512e358d47f559320fef490751571ca
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent 6be1e356
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -328,6 +328,20 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
    private boolean updateVisibilityCheck(boolean visible, LockscreenShortcutsHelper.Shortcuts
            shortcut) {
        boolean customTarget = mShortcutHelper.isTargetCustom(shortcut);
        if (customTarget) {
            if (isProtected(mShortcutHelper.getIntent(shortcut))) {
                return false;
            }
        } else if (shortcut == LockscreenShortcutsHelper.Shortcuts.LEFT_SHORTCUT
                && isProtected(PHONE_INTENT)) {
            // is dialer protected?
            return false;
        } else if (shortcut == LockscreenShortcutsHelper.Shortcuts.RIGHT_SHORTCUT
                && isProtected(getCameraIntent())) {
            // is camera protected?
            return false;
        }

        if (customTarget) {
            boolean isEmpty = mShortcutHelper.isTargetEmpty(shortcut);
            if (visible && isEmpty) {
@@ -339,6 +353,23 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
        return visible;
    }

    private boolean isProtected(Intent intent) {
        ResolveInfo resolved = mContext.getPackageManager().resolveActivityAsUser(intent,
                PackageManager.MATCH_DEFAULT_ONLY,
                mLockPatternUtils.getCurrentUser());
        if (resolved != null) {
            try {
                boolean protect = mContext.getPackageManager().getApplicationInfo(
                        resolved.activityInfo.packageName, 0).protect;
                return protect;
            } catch (PackageManager.NameNotFoundException e) {
                return false;
            }
        }

        return false;
    }

    private void updatePhoneVisibility() {
        boolean visible = isPhoneVisible();
        visible = updateVisibilityCheck(visible,