diff --git a/CHANGELOG.md b/CHANGELOG.md index 008ef05b3..026e14765 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ Changelog * Applying template will not apply to disabled restrictions anymore ([issue](/../../issues/1747)) * Displaying changed state when all restrictions are cleared ([issue](/../../issues/1748)) * The application state is shown with a color left in the application list +* Added restrictions for [UsbDevice](http://developer.android.com/reference/android/bluetooth/BluetoothDevice.html) ([issue](/../../issues/1750)) * Updated Slovak translation **Please send the support info when asked for** diff --git a/src/biz/bokhorst/xprivacy/Meta.java b/src/biz/bokhorst/xprivacy/Meta.java index 13aadc71f..00a8d1392 100644 --- a/src/biz/bokhorst/xprivacy/Meta.java +++ b/src/biz/bokhorst/xprivacy/Meta.java @@ -102,6 +102,9 @@ public static List get() { mListHook.add(new Hook("identification", "GservicesProvider", "com.google.android.providers.gsf.permission.READ_GSERVICES,com.google.android.providers.gsf.permission.WRITE_GSERVICES", 1, null, null).dangerous()); mListHook.add(new Hook("identification", "SERIAL", "", 1, null, null).restart().noUsageData()); + mListHook.add(new Hook("identification", "USB.getDeviceId", "", 12, "2.1.7", null)); + mListHook.add(new Hook("identification", "USB.getDeviceName", "", 12, "2.1.7", null)); + mListHook.add(new Hook("internet", "getAllByName", "INTERNET", 1, "0.0", null).dangerous()); mListHook.add(new Hook("internet", "getByAddress", "INTERNET", 1, "0.0", null).dangerous()); mListHook.add(new Hook("internet", "getByName", "INTERNET", 1, "0.0", null).dangerous()); @@ -147,6 +150,7 @@ public static List get() { mListHook.add(new Hook("ipc", "IBluetoothManager", "", 1, "2.1.7", null).dangerous()); mListHook.add(new Hook("ipc", "IInputManager", "", 1, "2.1.7", null).dangerous()); mListHook.add(new Hook("ipc", "SensorServer", "", 1, "2.1.7", null).dangerous()); + mListHook.add(new Hook("ipc", "IUsbManager", "", 1, "2.1.7", null).dangerous()); mListHook.add(new Hook("ipc", "Reflection", "", 1, "2.1.7", null).dangerous()); diff --git a/src/biz/bokhorst/xprivacy/XBinder.java b/src/biz/bokhorst/xprivacy/XBinder.java index 2529022c8..ae2becbbd 100644 --- a/src/biz/bokhorst/xprivacy/XBinder.java +++ b/src/biz/bokhorst/xprivacy/XBinder.java @@ -50,7 +50,8 @@ public class XBinder extends XHook { "appwidget", "bluetooth_manager", "input", - "sensorservice" + "sensorservice", + "usb" }); // @formatter:on @@ -75,7 +76,8 @@ public class XBinder extends XHook { "com.android.internal.appwidget.IAppWidgetService", "android.bluetooth.IBluetoothManager", "android.hardware.input.IInputManager", - "android.gui.SensorServer" + "android.gui.SensorServer", + "android.hardware.usb.IUsbManager" }); // @formatter:on @@ -100,7 +102,8 @@ public class XBinder extends XHook { "android.appwidget.AppWidgetManager", "android.bluetooth.BluetoothAdapter,android.bluetooth.BluetoothDevice", "android.hardware.input.InputManager", - "android.hardware.SystemSensorManager" + "android.hardware.SystemSensorManager", + "android.hardware.usb.UsbManager" }); // @formatter:on diff --git a/src/biz/bokhorst/xprivacy/XPrivacy.java b/src/biz/bokhorst/xprivacy/XPrivacy.java index 1e294c7a9..9b8535df8 100644 --- a/src/biz/bokhorst/xprivacy/XPrivacy.java +++ b/src/biz/bokhorst/xprivacy/XPrivacy.java @@ -241,6 +241,9 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { // Telephone service hookAll(XTelephonyManager.getInstances(null), null, mSecret); + // USB device + hookAll(XUsbDevice.getInstances(), null, mSecret); + // Web view hookAll(XWebView.getInstances(), null, mSecret); diff --git a/src/biz/bokhorst/xprivacy/XUsbDevice.java b/src/biz/bokhorst/xprivacy/XUsbDevice.java new file mode 100644 index 000000000..9c583957d --- /dev/null +++ b/src/biz/bokhorst/xprivacy/XUsbDevice.java @@ -0,0 +1,57 @@ +package biz.bokhorst.xprivacy; + +import java.util.ArrayList; +import java.util.List; + +import android.util.Log; + +import biz.bokhorst.xprivacy.XHook; + +public class XUsbDevice extends XHook { + private Methods mMethod; + + private XUsbDevice(Methods method, String restrictionName) { + super(restrictionName, method.name(), "USB." + method.name()); + mMethod = method; + } + + public String getClassName() { + return "android.hardware.usb.UsbDevice"; + } + + // public static int getDeviceId(String name) + // public int getDeviceId() + // public String getDeviceName() + // public static String getDeviceName(int id) + // http://developer.android.com/reference/android/bluetooth/BluetoothDevice.html + + private enum Methods { + getDeviceId, getDeviceName + }; + + public static List getInstances() { + List listHook = new ArrayList(); + listHook.add(new XUsbDevice(Methods.getDeviceId, PrivacyManager.cIdentification)); + listHook.add(new XUsbDevice(Methods.getDeviceName, PrivacyManager.cIdentification)); + return listHook; + } + + @Override + protected void before(XParam param) throws Throwable { + if (mMethod == Methods.getDeviceId) { + if (isRestricted(param)) + param.setResult(0); + + } else if (mMethod == Methods.getDeviceName) { + if (isRestricted(param)) + param.setResult(null); + + } else + Util.log(this, Log.WARN, "Unknown method=" + param.method.getName()); + } + + @Override + protected void after(XParam param) throws Throwable { + // Do nothing + } +}