From 70af0919256c4634b13f7e981b57382a0c50be42 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 14 Aug 2014 08:04:25 +0200 Subject: [PATCH] Improved media restrictions --- CHANGELOG.md | 9 +++++-- res/values/functions.xml | 5 ++++ src/biz/bokhorst/xprivacy/Meta.java | 27 ++++++++++++++----- src/biz/bokhorst/xprivacy/XAudioRecord.java | 17 +++++++----- src/biz/bokhorst/xprivacy/XCamera.java | 21 +++++++++++++-- src/biz/bokhorst/xprivacy/XMediaRecorder.java | 14 +++++++++- 6 files changed, 75 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52a73d9a5..bab1ceb30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,12 @@ Changelog **Next release** -* Added restriction *MediaRecorder.setOutputFile* ([issue](/../../issues/1874)) +* Restored restriction *MediaRecorder.setOutputFile* ([issue](/../../issues/1874)) +* Restored restriction *Camera.setPreviewCallback* +* Added restrictions *Camera.setPreviewCallbackWithBuffer*, *Camera.setPreviewDisplay*, *Camera.setPreviewTexture* and *Camera.setOneShotPreviewCallback* +* Handling *Camera.stopPreview* +* Handling *MediaRecorder.prepare* and *MediaRecorder.stop* +* Handling *Audio.stop* * Updated Japanese translation [Open issues](https://github.com/M66B/XPrivacy/issues?state=open) @@ -49,7 +54,7 @@ Version 2.99.x and version 3.x will be available with a [pro license](http://www **Version 2.99.20 BETA** -* Added restriction *MediaRecorder.setOutputFile* ([issue](/../../issues/1874)) +* Restored restriction *MediaRecorder.setOutputFile* ([issue](/../../issues/1874)) **Version 2.99.19 BETA** diff --git a/res/values/functions.xml b/res/values/functions.xml index 5aceaa2dc..c642f0637 100644 --- a/res/values/functions.xml +++ b/res/values/functions.xml @@ -174,6 +174,11 @@ Google documentation]]> + Google documentation]]> + Google documentation]]> + Google documentation]]> + Google documentation]]> + Google documentation]]> Google documentation]]> Google documentation]]> Google documentation]]> diff --git a/src/biz/bokhorst/xprivacy/Meta.java b/src/biz/bokhorst/xprivacy/Meta.java index bc9e0082f..cf285d234 100644 --- a/src/biz/bokhorst/xprivacy/Meta.java +++ b/src/biz/bokhorst/xprivacy/Meta.java @@ -237,6 +237,11 @@ public static List get() { mListHook.add(new Hook("location", "MapV2.setOnMyLocationChangeListener", "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 1, "2.1.25", null).unsafe().optional()); mListHook.add(new Hook("media", "Audio.startRecording", "RECORD_AUDIO", 3, "2.2.3", "startRecording").unsafe().doNotify()); + mListHook.add(new Hook("media", "Camera.setPreviewCallback", "CAMERA", 1, "2.99.21", "setPreviewCallback").unsafe().doNotify()); + mListHook.add(new Hook("media", "Camera.setPreviewCallbackWithBuffer", "CAMERA", 8, "2.99.21", null).unsafe().doNotify()); + mListHook.add(new Hook("media", "Camera.setPreviewDisplay", "CAMERA", 1, "2.99.21", null).unsafe().doNotify()); + mListHook.add(new Hook("media", "Camera.setPreviewTexture", "CAMERA", 11, "2.99.21", null).unsafe().doNotify()); + mListHook.add(new Hook("media", "Camera.setOneShotPreviewCallback", "CAMERA", 11, "2.99.21", null).unsafe().doNotify()); mListHook.add(new Hook("media", "Camera.startPreview", "CAMERA", 1, "2.2.3", "setPreviewCallback").unsafe().doNotify()); mListHook.add(new Hook("media", "Camera.takePicture", "CAMERA", 1, "2.2.3", "takePicture").unsafe().doNotify()); mListHook.add(new Hook("media", "MediaRecorder.start", "RECORD_AUDIO,RECORD_VIDEO", 1, "2.2.3", "setOutputFile").unsafe().doNotify()); @@ -475,7 +480,7 @@ public static List get() { mListHook.add(new Hook(null, "startActivityIfNeeded", "", 1, null, null).notAOSP(19)); mListHook.add(new Hook(null, "startNextMatchingActivity", "", 1, null, null).notAOSP(19)); - // ActivityManager // ActivityManagerService + // ActivityManager(Service) mListHook.add(new Hook(null, "Srv_startActivities", "", 19, null, null).AOSP(19)); mListHook.add(new Hook(null, "Srv_startActivity", "", 19, null, null).AOSP(19)); mListHook.add(new Hook(null, "Srv_startActivityAsUser", "", 19, null, null).AOSP(19)); @@ -494,19 +499,25 @@ public static List get() { // Application mListHook.add(new Hook(null, "onCreate", "", 1, null, null)); + // AudioRecord + mListHook.add(new Hook(null, "Audio.stop", "", 3, null, null)); + // Binder mListHook.add(new Hook(null, "execTransact", "", 1, null, null).notAOSP(19)); mListHook.add(new Hook(null, "transact", "", 1, null, null).notAOSP(19)); - // ClipboardManager / ClipboardService + // ClipboardManager/Service mListHook.add(new Hook(null, "removePrimaryClipChangedListener", "", 11, null, null)); mListHook.add(new Hook(null, "Srv_removePrimaryClipChangedListener", "", 11, null, null)); - // Provider + // Content resolvers mListHook.add(new Hook(null, "query", "", 1, null, null).notAOSP(19)); mListHook.add(new Hook(null, "Srv_call", "", 1, null, null).AOSP(19)); mListHook.add(new Hook(null, "Srv_query", "", 1, null, null).AOSP(19)); + // Camera + mListHook.add(new Hook(null, "Camera.stopPreview", "", 1, null, null)); + // ContextImpl mListHook.add(new Hook(null, "getPackageManager", "", 1, null, null).notAOSP(19)); @@ -516,13 +527,17 @@ public static List get() { // IntentFirewall mListHook.add(new Hook(null, "checkIntent", "", 19, null, null)); - // LocationManager / LocationManagerService + // LocationManager/Service mListHook.add(new Hook(null, "removeUpdates", "", 3, null, null)); mListHook.add(new Hook(null, "Srv_removeUpdates", "", 19, null, null)); mListHook.add(new Hook(null, "Srv_removeGeofence", "", 19, null, null)); mListHook.add(new Hook(null, "Srv_removeGpsStatusListener", "", 19, null, null)); mListHook.add(new Hook(null, "MapV1.disableMyLocation", "", 1, null, null).optional()); + // MediaRecorder + mListHook.add(new Hook(null, "MediaRecorder.prepare", "", 1, null, null)); + mListHook.add(new Hook(null, "MediaRecorder.stop", "", 1, null, null)); + // Resources mListHook.add(new Hook(null, "updateConfiguration", "", 1, null, null)); @@ -537,10 +552,8 @@ public static List get() { mListHook.add(new Hook(null, "removeView", "", 1, null, null)); mListHook.add(new Hook(null, "updateViewLayout", "", 1, null, null)); - // ActivityRecognitionClient + // LocationClient / ActivityRecognitionClient mListHook.add(new Hook(null, "GMS.removeActivityUpdates", "", 1, null, null)); - - // LocationClient mListHook.add(new Hook(null, "GMS.removeGeofences", "", 1, null, null).optional()); mListHook.add(new Hook(null, "GMS.removeLocationUpdates", "", 1, null, null).optional()); diff --git a/src/biz/bokhorst/xprivacy/XAudioRecord.java b/src/biz/bokhorst/xprivacy/XAudioRecord.java index 68d17b228..87149369e 100644 --- a/src/biz/bokhorst/xprivacy/XAudioRecord.java +++ b/src/biz/bokhorst/xprivacy/XAudioRecord.java @@ -3,8 +3,6 @@ import java.util.ArrayList; import java.util.List; -import android.util.Log; - public class XAudioRecord extends XHook { private Methods mMethod; @@ -19,27 +17,34 @@ public String getClassName() { // public void startRecording() // public void startRecording(MediaSyncEvent syncEvent) + // public void stop() // frameworks/base/media/java/android/media/AudioRecord.java // http://developer.android.com/reference/android/media/AudioRecord.html private enum Methods { - startRecording + startRecording, stop }; public static List getInstances() { List listHook = new ArrayList(); listHook.add(new XAudioRecord(Methods.startRecording, PrivacyManager.cMedia)); + listHook.add(new XAudioRecord(Methods.stop, null)); return listHook; } @Override protected void before(XParam param) throws Throwable { - if (mMethod == Methods.startRecording) { + switch (mMethod) { + case startRecording: if (isRestricted(param)) param.setResult(null); + break; - } else - Util.log(this, Log.WARN, "Unknown method=" + param.method.getName()); + case stop: + if (isRestricted(param, PrivacyManager.cMedia, "Audio.startRecording")) + param.setResult(null); + break; + } } @Override diff --git a/src/biz/bokhorst/xprivacy/XCamera.java b/src/biz/bokhorst/xprivacy/XCamera.java index f4ffb72af..0b2edefb1 100644 --- a/src/biz/bokhorst/xprivacy/XCamera.java +++ b/src/biz/bokhorst/xprivacy/XCamera.java @@ -17,7 +17,13 @@ public String getClassName() { // @formatter:off + // public void setPreviewCallback(Camera.PreviewCallback cb) + // public void setPreviewCallbackWithBuffer(Camera.PreviewCallback cb) + // public void setPreviewDisplay(SurfaceHolder holder) + // public void setPreviewTexture(SurfaceTexture surfaceTexture) + // public final void setOneShotPreviewCallback (Camera.PreviewCallback cb) // public native final void startPreview() + // public void stopPreview() // public final void takePicture(ShutterCallback shutter, PictureCallback raw, PictureCallback jpeg) // public final void takePicture(ShutterCallback shutter, PictureCallback raw, PictureCallback postview, PictureCallback jpeg) // frameworks/base/core/java/android/hardware/Camera.java @@ -26,23 +32,34 @@ public String getClassName() { // @formatter:on private enum Methods { - startPreview, takePicture + setPreviewCallback, setPreviewCallbackWithBuffer, setPreviewDisplay, setPreviewTexture, setOneShotPreviewCallback, startPreview, stopPreview, takePicture }; public static List getInstances() { List listHook = new ArrayList(); for (Methods cam : Methods.values()) - listHook.add(new XCamera(cam, PrivacyManager.cMedia)); + listHook.add(new XCamera(cam, cam == Methods.stopPreview ? null : PrivacyManager.cMedia)); return listHook; } @Override protected void before(XParam param) throws Throwable { switch (mMethod) { + case setPreviewCallback: + case setPreviewCallbackWithBuffer: + case setPreviewDisplay: + case setPreviewTexture: + case setOneShotPreviewCallback: case startPreview: case takePicture: if (isRestricted(param)) param.setResult(null); + break; + + case stopPreview: + if (isRestricted(param, PrivacyManager.cMedia, "Camera.stopPreview")) + param.setResult(null); + break; } } diff --git a/src/biz/bokhorst/xprivacy/XMediaRecorder.java b/src/biz/bokhorst/xprivacy/XMediaRecorder.java index 239062b88..51a7a1548 100644 --- a/src/biz/bokhorst/xprivacy/XMediaRecorder.java +++ b/src/biz/bokhorst/xprivacy/XMediaRecorder.java @@ -15,18 +15,24 @@ public String getClassName() { return "android.media.MediaRecorder"; } + // void setOutputFile(FileDescriptor fd) + // void setOutputFile(String path) + // public prepare() // public native void start() + // void stop() // frameworks/base/media/java/android/media/MediaRecorder.java // http://developer.android.com/reference/android/media/MediaRecorder.html private enum Methods { - setOutputFile, start + setOutputFile, prepare, start, stop }; public static List getInstances() { List listHook = new ArrayList(); listHook.add(new XMediaRecorder(Methods.setOutputFile, PrivacyManager.cMedia)); + listHook.add(new XMediaRecorder(Methods.prepare, null)); listHook.add(new XMediaRecorder(Methods.start, PrivacyManager.cMedia)); + listHook.add(new XMediaRecorder(Methods.stop, null)); return listHook; } @@ -38,6 +44,12 @@ protected void before(XParam param) throws Throwable { if (isRestricted(param)) param.setResult(null); break; + + case prepare: + case stop: + if (isRestricted(param, PrivacyManager.cMedia, "MediaRecorder.start")) + param.setResult(null); + break; } }