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

Commit c863ce56 authored by Esteban Talavera's avatar Esteban Talavera Committed by android-build-merger
Browse files

Merge "Enforce policy for camera gesture in keyguard" into oc-dr1-dev am: daa1539a

am: 1f439e4b

Change-Id: I99b1d51c154bcda4121fd818ec17a3c90431443d
parents ee146170 1f439e4b
Loading
Loading
Loading
Loading
+2 −19
Original line number Diff line number Diff line
@@ -401,24 +401,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
                && pm.resolveActivity(PHONE_INTENT, 0) != null;
    }

    private boolean isCameraDisabledByDpm() {
        final DevicePolicyManager dpm =
                (DevicePolicyManager) getContext().getSystemService(Context.DEVICE_POLICY_SERVICE);
        if (dpm != null && mStatusBar != null) {
            try {
                final int userId = ActivityManager.getService().getCurrentUser().id;
                final int disabledFlags = dpm.getKeyguardDisabledFeatures(null, userId);
                final  boolean disabledBecauseKeyguardSecure =
                        (disabledFlags & DevicePolicyManager.KEYGUARD_DISABLE_SECURE_CAMERA) != 0
                                && mStatusBar.isKeyguardSecure();
                return dpm.getCameraDisabled(null) || disabledBecauseKeyguardSecure;
            } catch (RemoteException e) {
                Log.e(TAG, "Can't get userId", e);
            }
        }
        return false;
    }

    private void watchForCameraPolicyChanges() {
        final IntentFilter filter = new IntentFilter();
        filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
@@ -871,7 +853,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
        @Override
        public IconState getIcon() {
            ResolveInfo resolved = resolveCameraIntent();
            mIconState.isVisible = !isCameraDisabledByDpm() && resolved != null
            boolean isCameraDisabled = (mStatusBar != null) && !mStatusBar.isCameraAllowedByAdmin();
            mIconState.isVisible = !isCameraDisabled && resolved != null
                    && getResources().getBoolean(R.bool.config_keyguardShowCameraAffordance)
                    && mUserSetupComplete;
            mIconState.drawable = mContext.getDrawable(R.drawable.ic_camera_alt_24dp);
+4 −0
Original line number Diff line number Diff line
@@ -2499,6 +2499,10 @@ public class NotificationPanelView extends PanelView implements
     * @param keyguardIsShowing whether keyguard is being shown
     */
    public boolean canCameraGestureBeLaunched(boolean keyguardIsShowing) {
        if (!mStatusBar.isCameraAllowedByAdmin()) {
            return false;
        }

        ResolveInfo resolveInfo = mKeyguardBottomArea.resolveCameraIntent();
        String packageToLaunch = (resolveInfo == null || resolveInfo.activityInfo == null)
                ? null : resolveInfo.activityInfo.packageName;
+16 −2
Original line number Diff line number Diff line


/*
 * Copyright (C) 2010 The Android Open Source Project
 *
@@ -5281,6 +5279,18 @@ public class StatusBar extends SystemUI implements DemoMode,
        }
    }

    boolean isCameraAllowedByAdmin() {
        if (mDevicePolicyManager.getCameraDisabled(null, mCurrentUserId)) {
            return false;
        } else if (isKeyguardShowing() && isKeyguardSecure()) {
            // Check if the admin has disabled the camera specifically for the keyguard
            return (mDevicePolicyManager.getKeyguardDisabledFeatures(null, mCurrentUserId)
                    & DevicePolicyManager.KEYGUARD_DISABLE_SECURE_CAMERA) == 0;
        }

        return true;
    }

    public void notifyFpAuthModeChanged() {
        updateDozing();
    }
@@ -5304,6 +5314,10 @@ public class StatusBar extends SystemUI implements DemoMode,
    }

    public boolean isKeyguardShowing() {
        if (mStatusBarKeyguardViewManager == null) {
            Slog.i(TAG, "isKeyguardShowing() called before startKeyguard(), returning true");
            return true;
        }
        return mStatusBarKeyguardViewManager.isShowing();
    }