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

Commit

Permalink
Added restrictions for UsbDevice
Browse files Browse the repository at this point in the history
Fixed #1750
  • Loading branch information
M66B committed Jun 24, 2014
1 parent 1961d7d commit adb4aff
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
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 @@ -102,6 +102,9 @@ public static List<Hook> 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());
Expand Down Expand Up @@ -147,6 +150,7 @@ public static List<Hook> 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());

Expand Down
9 changes: 6 additions & 3 deletions src/biz/bokhorst/xprivacy/XBinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public class XBinder extends XHook {
"appwidget",
"bluetooth_manager",
"input",
"sensorservice"
"sensorservice",
"usb"
});
// @formatter:on

Expand All @@ -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

Expand All @@ -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

Expand Down
3 changes: 3 additions & 0 deletions src/biz/bokhorst/xprivacy/XPrivacy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
57 changes: 57 additions & 0 deletions src/biz/bokhorst/xprivacy/XUsbDevice.java
Original file line number Diff line number Diff line change
@@ -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<XHook> getInstances() {
List<XHook> listHook = new ArrayList<XHook>();
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
}
}

0 comments on commit adb4aff

Please sign in to comment.