Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
Added restriction for camera2 device (Android "L")
Browse files Browse the repository at this point in the history
Refs #1757
  • Loading branch information
M66B committed Jun 29, 2014
1 parent ed83b24 commit eb9081b
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/biz/bokhorst/xprivacy/Meta.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ public static List<Hook> 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));
Expand Down
56 changes: 56 additions & 0 deletions src/biz/bokhorst/xprivacy/XCameraDevice2.java
Original file line number Diff line number Diff line change
@@ -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<CaptureRequest> requests, CaptureListener listener, Handler handler)
// public int setRepeatingRequest(CaptureRequest request, CaptureListener listener, Handler handler)
// public int setRepeatingBurst(List<CaptureRequest> 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<XHook> getInstances() {
List<XHook> listHook = new ArrayList<XHook>();
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
}
}
3 changes: 3 additions & 0 deletions src/biz/bokhorst/xprivacy/XPrivacy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit eb9081b

Please sign in to comment.