赞
踩
1.禁止第三方APP打开Camera
frameworks/base/core/java/android/hardware/Camera.java
public static Camera open(int cameraId) { // add if(SystemProperties.get("persist.sys.disablecamera").equals("true")){ return null; } // end return new Camera(cameraId); } public static Camera open() { //add if(SystemProperties.get("persist.sys.disablecamera").equals("true")){ return null; } // end int numberOfCameras = getNumberOfCameras(); CameraInfo cameraInfo = new CameraInfo(); for (int i = 0; i < numberOfCameras; i++) { getCameraInfo(i, cameraInfo); if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) { return new Camera(i); } } return null; } public static Camera openLegacy(int cameraId, int halVersion) { if (halVersion < CAMERA_HAL_API_VERSION_1_0) { throw new IllegalArgumentException("Invalid HAL version " + halVersion); } // add if(SystemProperties.get("persist.sys.disablecamera").equals("true")){ return null; } // end return new Camera(cameraId, halVersion); } public static Camera openUninitialized() { // add if(SystemProperties.get("persist.sys.disablecamera").equals("true")){ return null; } //end return new Camera(); }
2.禁止打开系统Camera
frameworks/base/core/java/android/hardware/camera2/CameraManager.java
import android.os.SystemProperties;//add private CameraDevice openCameraDeviceUserAsync(String cameraId, CameraDevice.StateCallback callback, Executor executor, final int uid) throws CameraAccessException { CameraCharacteristics characteristics = getCameraCharacteristics(cameraId); CameraDevice device = null; //add if(SystemProperties.get("persist.sys.disablecamera").equals("true")){ return null; } // end synchronized (mLock) { ICameraDeviceUser cameraUser = null;
3.可以通过设置"persist.sys.disablecamera"的值来控制是否禁用Camera。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。