summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEsteban Talavera <etalavera@google.com>2017-07-14 16:14:07 +0100
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-08-23 18:46:48 +0000
commit16c306123c2af4d080711b73647bcf7bc26b59b7 (patch)
treea520e5fbfcbbce21fea276ff6d14400a58d7630e
parent05eb6495efd01f2490b9d721b2bf75c82a0891b4 (diff)
downloadbase-16c306123c2af4d080711b73647bcf7bc26b59b7.tar.gz
Enforce policy for camera gesture in keyguard
If the admin has disabled the camera for secure keyguards, in addition to removing the bottom-right hand corner camera button do not allow the camera to be opened via the camera gesture either. Bug: 63334090 Merged-In: I104688eaad719528376e2851f837d5956a6a1169 Test: Manually tested launching the camera on secure and non-secure keyguard and non-keyguard, both via camera icon and gesture Change-Id: I104688eaad719528376e2851f837d5956a6a1169 (cherry picked from commit 98ec92375d75630c10595bfcbae184ad7350e2d3)
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java21
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java18
3 files changed, 24 insertions, 21 deletions
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 6fe8827c4c87..e9f6e95b2f48 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
@@ -397,24 +397,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);
@@ -865,7 +847,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);
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 6aab8e10543e..54c12a187dc2 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.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
+import android.util.EventLog;
import android.util.FloatProperty;
import android.util.MathUtils;
import android.view.MotionEvent;
@@ -2440,6 +2441,11 @@ 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;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index f58fe8290a43..d2994bd4fca1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -1,5 +1,3 @@
-
-
/*
* Copyright (C) 2010 The Android Open Source Project
*
@@ -5040,6 +5038,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();
}
@@ -5062,6 +5072,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();
}