diff options
author | Tony Mak <tonymak@google.com> | 2017-07-28 11:53:56 +0100 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-09-28 17:12:40 +0000 |
commit | aafeb72ef4ac267149661fe43d54825b0c580c8c (patch) | |
tree | 11079d8b7c2b30a1a0ef4d486b04b4a213c33562 | |
parent | c505f55d9243b1a961813685d6f02f5af2029b71 (diff) | |
download | base-aafeb72ef4ac267149661fe43d54825b0c580c8c.tar.gz |
Enforce policy for camera gesture in keyguard
Test:
1. Set lock screen, set keyguard policy. Lock the device.
Observe that double tap is not showing camera
2. Set lock screen, unset the keyguard policy. Lock the device.
Observe that double tap is showing camera
3. Unset lock screen (swipe), set the keyguard policy. Lock the device.
Observe that double tap is showing camera.
4. Unset lock screen (swipe), unset the keyguard policy. Lock the device.
Observe that double tap is showing camera.
Bug: 63787722
Merged-In: I104688eaad719528376e2851f837d5956a6a1169
Change-Id: I42e6d9015682998176fe41971356bde22e1b37b2
(cherry picked from commit 5b064e03bd28c734a6f6022e2cbdff14410dc59a)
3 files changed, 28 insertions, 19 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 9d22b4a9f280..7639b3d32aae 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -2679,4 +2679,23 @@ public abstract class BaseStatusBar extends SystemUI implements mAssistManager.startAssist(args); } } + + public 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 boolean isKeyguardShowing() { + if (mStatusBarKeyguardViewManager == null) { + Slog.i(TAG, "isKeyguardShowing() called before startKeyguard(), returning true"); + return true; + } + return mStatusBarKeyguardViewManager.isShowing(); + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java index 4d0e5d34761b..c674a82d6090 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java @@ -305,7 +305,10 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL return; } ResolveInfo resolved = resolveCameraIntent(); - boolean visible = !isCameraDisabledByDpm() && resolved != null + boolean isCameraDisabled = + (mPhoneStatusBar != null) && !mPhoneStatusBar.isCameraAllowedByAdmin(); + boolean visible = !isCameraDisabled + && resolved != null && getResources().getBoolean(R.bool.config_keyguardShowCameraAffordance) && mUserSetupComplete; mCameraImageView.setVisibility(visible ? View.VISIBLE : View.GONE); @@ -339,24 +342,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 && mPhoneStatusBar != null) { - try { - final int userId = ActivityManagerNative.getDefault().getCurrentUser().id; - final int disabledFlags = dpm.getKeyguardDisabledFeatures(null, userId); - final boolean disabledBecauseKeyguardSecure = - (disabledFlags & DevicePolicyManager.KEYGUARD_DISABLE_SECURE_CAMERA) != 0 - && mPhoneStatusBar.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); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index 9c700b4280e3..ca08ab15e657 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -31,6 +31,7 @@ import android.graphics.Paint; import android.graphics.Rect; import android.util.AttributeSet; import android.util.MathUtils; +import android.util.EventLog; import android.view.MotionEvent; import android.view.VelocityTracker; import android.view.View; @@ -2330,6 +2331,10 @@ public class NotificationPanelView extends PanelView implements * @param keyguardIsShowing whether keyguard is being shown */ public boolean canCameraGestureBeLaunched(boolean keyguardIsShowing) { + if (!mStatusBar.isCameraAllowedByAdmin()) { + EventLog.writeEvent(0x534e4554, "63787722", -1, ""); + return false; + } ResolveInfo resolveInfo = mKeyguardBottomArea.resolveCameraIntent(); String packageToLaunch = (resolveInfo == null || resolveInfo.activityInfo == null) ? null : resolveInfo.activityInfo.packageName; |