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

Block another way to retrieve the Device ID #135

Merged
merged 1 commit into from
Jul 4, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/biz/bokhorst/xprivacy/PrivacyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public class PrivacyManager {
mPermissions.get(cCalling).add("CALL_PHONE");
mPermissions.get(cContacts).add("READ_CONTACTS");
mPermissions.get(cDictionary).add("READ_USER_DICTIONARY");
mPermissions.get(cIdentification).add("READ_GSERVICES");
mPermissions.get(cInternet).add("INTERNET");
mPermissions.get(cInternet).add("ACCESS_NETWORK_STATE");
mPermissions.get(cLocation).add("ACCESS_COARSE_LOCATION");
Expand Down Expand Up @@ -250,6 +251,7 @@ public class PrivacyManager {
mMethods.get(cMessages).add("MmsProvider");
mMethods.get(cMessages).add("MmsSmsProvider");
mMethods.get(cPhone).add("TelephonyProvider");
mMethods.get(cIdentification).add("GservicesProvider");
}

// Data
Expand Down
10 changes: 10 additions & 0 deletions src/biz/bokhorst/xprivacy/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.security.PublicKey;
import java.security.Signature;
import java.security.spec.X509EncodedKeySpec;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -193,4 +194,13 @@ public static Resources getXResources(Context context) throws Throwable {
public static String getXString(Context context, int id) throws Throwable {
return getXResources(context).getString(id);
}

public static boolean containsIgnoreCase(List<String> strings, String value) {
for (String s : strings) {
if (s.equalsIgnoreCase(value))
return true;
}

return false;
}
}
13 changes: 13 additions & 0 deletions src/biz/bokhorst/xprivacy/XContentProvider.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package biz.bokhorst.xprivacy;

import java.util.Arrays;
import java.util.List;

import android.content.ContentProvider;
import android.content.ContentResolver;
import android.content.Context;
Expand Down Expand Up @@ -54,6 +57,16 @@ protected void after(MethodHookParam param) throws Throwable {
// Check uri
Uri uri = (Uri) param.args[0];
if (mUriStart == null || uri.toString().startsWith(mUriStart)) {

// If that's the Google services provider, block only the android_id
if (uri.toString().toLowerCase().startsWith("content://com.google.android.gsf.gservices")) {
List<String> selectionArgs = Arrays.asList((String[]) param.args[3]);

// checking just selectionArgs might not be enough but should suffice for now
if (!Util.containsIgnoreCase(selectionArgs, "android_id"))
return;
}

// Return empty cursor
Cursor cursor = (Cursor) param.getResult();
if (cursor != null)
Expand Down
8 changes: 8 additions & 0 deletions src/biz/bokhorst/xprivacy/XPrivacy.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
false))
XposedHelpers.setStaticObjectField(Build.class, "SERIAL", PrivacyManager.getDefacedProp("SERIAL"));


// Google services provider
if (lpparam.packageName.equals("com.google.android.gsf")) {
hook(new XContentProvider(PrivacyManager.cIdentification,
new String[] { "READ_GSERVICES" }, "GservicesProvider"),
lpparam.classLoader, "com.google.android.gsf.gservices.GservicesProvider");
}

// Browser provider
if (lpparam.packageName.equals("com.android.browser")) {
hook(new XContentProvider(PrivacyManager.cBrowser,
Expand Down