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

Commit

Permalink
Restrict Google advertising ID
Browse files Browse the repository at this point in the history
Fixes #731
  • Loading branch information
M66B committed Nov 9, 2013
1 parent 8a3a4a3 commit 6272dd4
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
**Next release**

* Restrict access to sensors ([issue](https://github.com/M66B/XPrivacy/issues/723))
* Restrict Google advertising ID ([issue](https://github.com/M66B/XPrivacy/issues/731))

**Version 1.10.4 BETA**

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ For easy usage, data is restricted by category:
* return a fake host name
* return a fake Google services framework ID
* return file not found for folder /proc
* Return a fake Google advertising ID
* Internet
* revoke access to the internet
* return fake disconnected state
Expand Down
3 changes: 2 additions & 1 deletion assets/meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
<Hook restriction="identification" method="getString" permissions="" sdk="14" />
<Hook restriction="identification" method="GservicesProvider" dangerous="true" permissions="READ_GSERVICES" sdk="14" />
<Hook restriction="identification" method="SERIAL" permissions="" sdk="14" />

<Hook restriction="identification" method="AdvertisingId" permissions="" sdk="14" />

<Hook restriction="internet" method="getAllByName" permissions="INTERNET" sdk="14" />
<Hook restriction="internet" method="getByAddress" permissions="INTERNET" sdk="14" />
<Hook restriction="internet" method="getByName" permissions="INTERNET" sdk="14" />
Expand Down
3 changes: 3 additions & 0 deletions src/biz/bokhorst/xprivacy/PrivacyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,9 @@ public static Object getDefacedProp(int uid, String name) {
return getSetting(null, null, uid, cSettingUa,
"Mozilla/5.0 (Linux; U; Android; en-us) AppleWebKit/999+ (KHTML, like Gecko) Safari/999.9", true);

if (name.equals("AdvertisingId"))
return "DEFACE00-0000-0000-0000-000000000000";

// Fallback
Util.log(null, Log.WARN, "Fallback value name=" + name);
return cDeface;
Expand Down
53 changes: 53 additions & 0 deletions src/biz/bokhorst/xprivacy/XAdvertisingIdClientInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package biz.bokhorst.xprivacy;

import java.util.ArrayList;
import java.util.List;

import android.os.Binder;
import android.util.Log;

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

public class XAdvertisingIdClientInfo extends XHook {
private Methods mMethod;

private XAdvertisingIdClientInfo(Methods method, String restrictionName, String specifier) {
super(restrictionName, method.name(), specifier);
mMethod = method;
}

public String getClassName() {
return "com.google.android.gms.ads.identifier.AdvertisingIdClient$Info";
}

// @formatter:off

// String getId()
// http://developer.android.com/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient.Info.html

// @formatter:on

private enum Methods {
getId
};

public static List<XHook> getInstances() {
List<XHook> listHook = new ArrayList<XHook>();
listHook.add(new XAdvertisingIdClientInfo(Methods.getId, PrivacyManager.cIdentification, "AdvertisingId"));
return listHook;
}

@Override
protected void before(MethodHookParam param) throws Throwable {
if (mMethod == Methods.getId) {
if (isRestricted(param))
param.setResult(PrivacyManager.getDefacedProp(Binder.getCallingUid(), "AdvertisingId"));
} else
Util.log(this, Log.WARN, "Unknown method=" + param.method.getName());
}

@Override
protected void after(MethodHookParam param) throws Throwable {
// Do nothing
}
}
7 changes: 7 additions & 0 deletions src/biz/bokhorst/xprivacy/XPrivacy.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
// Providers
hookAll(XContentProvider.getInstances(lpparam.packageName), lpparam.classLoader);

// Advertising Id
try {
Class.forName("com.google.android.gms.ads.identifier.AdvertisingIdClient$Info", false, lpparam.classLoader);
hookAll(XAdvertisingIdClientInfo.getInstances(), lpparam.classLoader);
} catch (Throwable ex) {
}

// Google auth
try {
Class.forName("com.google.android.gms.auth.GoogleAuthUtil", false, lpparam.classLoader);
Expand Down

0 comments on commit 6272dd4

Please sign in to comment.