diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a0271cde..d8fa22b44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ Changelog * Added parameter user agent to *getUserAgentString* * Added parameter device name to *USB.getDeviceId* * Added white list to *getAllByName*, *getByAddress* and *getByName* +* Added restriction for camera2 device (Android "L") ([issue](/../../issues/1757)) * Updated Italian translation [Open issues](https://github.com/M66B/XPrivacy/issues?state=open) diff --git a/src/biz/bokhorst/xprivacy/Meta.java b/src/biz/bokhorst/xprivacy/Meta.java index 3075e747e..46360fe6c 100644 --- a/src/biz/bokhorst/xprivacy/Meta.java +++ b/src/biz/bokhorst/xprivacy/Meta.java @@ -197,6 +197,10 @@ public static List get() { mListHook.add(new Hook("media", "android.media.action.IMAGE_CAPTURE", "CAMERA", 3, null, null).doNotify()); mListHook.add(new Hook("media", "android.media.action.IMAGE_CAPTURE_SECURE", "CAMERA", 17, null, null).doNotify()); mListHook.add(new Hook("media", "android.media.action.VIDEO_CAPTURE", "CAMERA", 3, null, null).doNotify()); + mListHook.add(new Hook("media", "Camera2.capture", "CAMERA", 20, null, null).doNotify()); + mListHook.add(new Hook("media", "Camera2.captureBurst", "CAMERA", 20, null, null).doNotify()); + mListHook.add(new Hook("media", "Camera2.setRepeatingRequest", "CAMERA", 20, null, null).doNotify()); + mListHook.add(new Hook("media", "Camera2.setRepeatingBurst", "CAMERA", 20, null, null).doNotify()); mListHook.add(new Hook("messages", "getAllMessagesFromIcc", "RECEIVE_SMS", 10, null, null)); mListHook.add(new Hook("messages", "SmsProvider", "READ_SMS", 1, null, null)); diff --git a/src/biz/bokhorst/xprivacy/XCameraDevice2.java b/src/biz/bokhorst/xprivacy/XCameraDevice2.java new file mode 100644 index 000000000..3f13737d6 --- /dev/null +++ b/src/biz/bokhorst/xprivacy/XCameraDevice2.java @@ -0,0 +1,56 @@ +package biz.bokhorst.xprivacy; + +import java.util.ArrayList; +import java.util.List; + +import android.util.Log; + +public class XCameraDevice2 extends XHook { + private Methods mMethod; + + private XCameraDevice2(Methods method, String restrictionName) { + super(restrictionName, method.name(), "Camera2." + method.name()); + mMethod = method; + } + + public String getClassName() { + return "android.hardware.camera2.impl.CameraDevice"; + } + + // @formatter:off + + // public int capture(CaptureRequest request, CaptureListener listener, Handler handler) + // public int captureBurst(List requests, CaptureListener listener, Handler handler) + // public int setRepeatingRequest(CaptureRequest request, CaptureListener listener, Handler handler) + // public int setRepeatingBurst(List requests, CaptureListener listener, Handler handler) + // frameworks/base/core/java/android/hardware/camera2/impl/CameraDevice.java + // http://developer.android.com/reference/android/hardware/camera2/CameraDevice.html + + // @formatter:on + + private enum Methods { + capture, captureBurst, setRepeatingRequest, setRepeatingBurst + }; + + public static List getInstances() { + List listHook = new ArrayList(); + for (Methods cam : Methods.values()) + listHook.add(new XCameraDevice2(cam, PrivacyManager.cMedia)); + return listHook; + } + + @Override + protected void before(XParam param) throws Throwable { + if (mMethod == Methods.capture || mMethod == Methods.captureBurst) { + if (isRestricted(param)) + param.setResult(0); + + } else + Util.log(this, Log.WARN, "Unknown method=" + param.method.getName()); + } + + @Override + protected void after(XParam param) throws Throwable { + // Do nothing + } +} diff --git a/src/biz/bokhorst/xprivacy/XPrivacy.java b/src/biz/bokhorst/xprivacy/XPrivacy.java index ded6833b5..14a36c978 100644 --- a/src/biz/bokhorst/xprivacy/XPrivacy.java +++ b/src/biz/bokhorst/xprivacy/XPrivacy.java @@ -197,6 +197,9 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { // Camera hookAll(XCamera.getInstances(), null, mSecret); + // Camera2 device + hookAll(XCameraDevice2.getInstances(), null, mSecret); + // Clipboard manager hookAll(XClipboardManager.getInstances(null), null, mSecret);