错误log如下
05-13 09:22:38.192 W/System.err( 4471): android.hardware.camera2.CameraAccessException: CAMERA_DISABLED (1): connectHelper:1735: Camera "0" disabled by policy
05-13 09:22:38.192 W/System.err( 4471): at android.hardware.camera2.CameraManager.throwAsPublicException(CameraManager.java:1012)
05-13 09:22:38.193 W/System.err( 4471): at android.hardware.camera2.CameraManager.openCameraDeviceUserAsync(CameraManager.java:547)
05-13 09:22:38.193 W/System.err( 4471): at android.hardware.camera2.CameraManager.openCameraForUid(CameraManager.java:728)
05-13 09:22:38.194 W/System.err( 4471): at android.hardware.camera2.CameraManager.openCamera(CameraManager.java:656)
05-13 09:22:38.194 W/System.err( 4471): at com.android.camera.CaptureModule.openCamera(CaptureModule.java:4199)
05-13 09:22:38.194 W/System.err( 4471): at com.android.camera.CaptureModule.access$11600(CaptureModule.java:158)
05-13 09:22:38.195 W/System.err( 4471): at com.android.camera.CaptureModule$MyCameraHandler.handleMessage(CaptureModule.java:8502)
05-13 09:22:38.195 W/System.err( 4471): at android.os.Handler.dispatchMessage(Handler.java:106)
05-13 09:22:38.195 W/System.err( 4471): at android.os.Looper.loop(Looper.java:223)
05-13 09:22:38.195 W/System.err( 4471): at android.os.HandlerThread.run(HandlerThread.java:67)
diff --git a/frameworks/base/services/core/java/com/android/server/appop/AppOpsService.java b/frameworks/base/services/core/java/com/android/server/appop/AppOpsService.java
old mode 100644
new mode 100755
index 6eab022..7a9e035
--- a/frameworks/base/services/core/java/com/android/server/appop/AppOpsService.java
+++ b/frameworks/base/services/core/java/com/android/server/appop/AppOpsService.java
@@ -257,7 +257,9 @@ public class AppOpsService extends IAppOpsService.Stub {
final AtomicFile mFile;
private final @Nullable File mNoteOpCallerStacktracesFile;
final Handler mHandler;
-
+ //<!--jicong.wang modify for bug 21737,set app Capability if need
+ private final static String CAPABILITIES_FULL_PKGS = "org.codeaurora.snapcam;";
+ //jicong.wang modify for bug 21737,set app Capability if need-->
/** Pool for {@link OpEventProxyInfoPool} to avoid to constantly reallocate new objects */
@GuardedBy("this")
private final OpEventProxyInfoPool mOpEventProxyInfoPool = new OpEventProxyInfoPool();
@@ -1812,7 +1814,22 @@ public class AppOpsService extends IAppOpsService.Stub {
updatePendingStateIfNeededLocked(mUidStates.get(uid));
}
}
-
+ //<!--jicong.wang modify for bug21737,set app Capability if need
+ /**
+ * set full Capability
+ * @param uidState
+ */
+ private void setCapabilityIfneed(UidState uidState){
+ if (uidState.pkgOps != null) {
+ ArrayMap<String, Ops> pkgOpss = uidState.pkgOps;
+ for (int i = 0; i < pkgOpss.size(); i++) {
+ if (CAPABILITIES_FULL_PKGS.contains(pkgOpss.valueAt(i).packageName)) {
+ uidState.pendingCapability = PROCESS_CAPABILITY_FOREGROUND_LOCATION | PROCESS_CAPABILITY_FOREGROUND_CAMERA | PROCESS_CAPABILITY_FOREGROUND_MICROPHONE;
+ }
+ }
+ }
+ }
+ //jicong.wang modify for bug21737,set app Capability if need-->
public void updateUidProcState(int uid, int procState,
@ActivityManager.ProcessCapability int capability) {
synchronized (this) {
@@ -1823,6 +1840,9 @@ public class AppOpsService extends IAppOpsService.Stub {
final int oldPendingState = uidState.pendingState;
uidState.pendingState = newState;
uidState.pendingCapability = capability;
+ //<!--jicong.wang modify for bug 21737,set app Capability if need
+ setCapabilityIfneed(uidState);
+ //jicong.wang modify for bug 21737,set app Capability if need-->
if (newState < uidState.state
|| (newState <= UID_STATE_MAX_LAST_NON_RESTRICTED
&& uidState.state > UID_STATE_MAX_LAST_NON_RESTRICTED)) {