Skip to content

Commit

Permalink
Simplify bluetooth hooking
Browse files Browse the repository at this point in the history
  • Loading branch information
M66B committed Jan 15, 2014
1 parent e0bf14b commit 1536fc7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 27 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Test and beta releases will have experimental functions enabled by default.

**Version 1.11.13 EXPERIMENTAL**

* Experimental: restriction for direct interprocess communication (System/IPC)
* Experimental: restriction for direct inter-process communication (System/IPC)
* Experimental: new, faster way of getting restrictions/settings

**Version 1.11.12 BETA**
Expand All @@ -48,7 +48,7 @@ Test and beta releases will have experimental functions enabled by default.
**Version 1.11.9 TEST**

* Fixed usage data with a dot in the name
* Added an easter egg (don't ask)
* Added an Easter egg (don't ask)
* Added cell location restrictions within the phone process
* Added phone/network type restrictions within the phone process
* Added phone property restrictions (static phone info)
Expand Down
4 changes: 2 additions & 2 deletions assets/meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@
<Hook restriction="messages" method="android.provider.Telephony.SMS_RECEIVED" permissions="RECEIVE_SMS" sdk="19" />
<Hook restriction="messages" method="android.provider.Telephony.WAP_PUSH_RECEIVED" permissions="RECEIVE_WAP_PUSH" sdk="19" />

<Hook restriction="network" method="getAddress" permissions="BLUETOOTH" sdk="10" />
<Hook restriction="network" method="getBondedDevices" permissions="BLUETOOTH" sdk="10" />
<Hook restriction="network" method="getAddress" permissions="BLUETOOTH" sdk="5" />
<Hook restriction="network" method="getBondedDevices" permissions="BLUETOOTH" sdk="5" />
<Hook restriction="network" method="getHardwareAddress" permissions="ACCESS_NETWORK_STATE" sdk="10" />
<Hook restriction="network" method="getInetAddresses" permissions="ACCESS_NETWORK_STATE" sdk="10" />
<Hook restriction="network" method="getInterfaceAddresses" permissions="ACCESS_NETWORK_STATE" sdk="10" />
Expand Down
1 change: 0 additions & 1 deletion src/biz/bokhorst/xprivacy/XBinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public class XBinder extends XHook {
public static List<String> cListService = Arrays.asList(new String[] {
"android.accounts.IAccountManager",
"android.app.IActivityManager",
"android.bluetooth.IBluetoothManager",
"android.content.IClipboard",
"android.net.IConnectivityManager",
"android.location.ILocationManager",
Expand Down
18 changes: 4 additions & 14 deletions src/biz/bokhorst/xprivacy/XBluetoothAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,20 @@

import android.bluetooth.BluetoothDevice;
import android.os.Binder;
import android.os.Build;
import android.util.Log;

import de.robv.android.xposed.XC_MethodHook.MethodHookParam;

public class XBluetoothAdapter extends XHook {
private Methods mMethod;
private String mClassName;

private XBluetoothAdapter(Methods method, String restrictionName, String className) {
private XBluetoothAdapter(Methods method, String restrictionName) {
super(restrictionName, method.name(), null);
mMethod = method;
mClassName = className;
}

public String getClassName() {
return mClassName;
return "android.bluetooth.BluetoothAdapter";
}

// public String getAddress()
Expand All @@ -37,16 +34,9 @@ private enum Methods {
};

public static List<XHook> getInstances() {
return getInstances(null);
}

public static List<XHook> getInstances(Object instance) {
List<XHook> listHook = new ArrayList<XHook>();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
String className = (instance == null ? "android.bluetooth.BluetoothAdapter" : instance.getClass().getName());
listHook.add(new XBluetoothAdapter(Methods.getAddress, PrivacyManager.cNetwork, className));
listHook.add(new XBluetoothAdapter(Methods.getBondedDevices, PrivacyManager.cNetwork, className));
}
listHook.add(new XBluetoothAdapter(Methods.getAddress, PrivacyManager.cNetwork));
listHook.add(new XBluetoothAdapter(Methods.getBondedDevices, PrivacyManager.cNetwork));
return listHook;
}

Expand Down
9 changes: 1 addition & 8 deletions src/biz/bokhorst/xprivacy/XPrivacy.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {

private static boolean mAccountManagerHooked = false;
private static boolean mActivityManagerHooked = false;
private static boolean mBluetoothAdapterHooked = false;
private static boolean mClipboardManagerHooked = false;
private static boolean mConnectivityManagerHooked = false;
private static boolean mLocationManagerHooked = false;
Expand All @@ -206,12 +205,6 @@ public static void handleGetSystemService(XHook hook, String name, Object instan
hookAll(XActivityManager.getInstances(instance));
mActivityManagerHooked = true;
}
} else if (name.equals(Context.BLUETOOTH_SERVICE)) {
// Bluetooth adapter
if (!mBluetoothAdapterHooked) {
hookAll(XBluetoothAdapter.getInstances(instance));
mBluetoothAdapterHooked = true;
}
} else if (name.equals(Context.CLIPBOARD_SERVICE)) {
// Clipboard manager
if (!mClipboardManagerHooked) {
Expand Down Expand Up @@ -337,7 +330,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
hookClass.getName(), hook.getMethodName());
Util.log(hook, Log.ERROR, message);
for (Method declared : hookClass.getDeclaredMethods())
Util.log(hook, Log.ERROR, "method=" + declared);
Util.log(hook, Log.ERROR, "Declared method=" + declared);
return;
}

Expand Down

0 comments on commit 1536fc7

Please sign in to comment.