diff --git a/CHANGELOG.md b/CHANGELOG.md index df3a2b0c7..384197040 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ Changelog **Next release** +* Fixed null pointer in storage/option +* Fixed restricting GSF ID in some cases ([issue](/../../issues/1374)) + [Open issues](https://github.com/M66B/XPrivacy/issues?state=open) **Version 1.99.46 TEST** diff --git a/src/biz/bokhorst/xprivacy/Util.java b/src/biz/bokhorst/xprivacy/Util.java index cb11cef37..77b85493e 100644 --- a/src/biz/bokhorst/xprivacy/Util.java +++ b/src/biz/bokhorst/xprivacy/Util.java @@ -22,7 +22,6 @@ 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; @@ -469,13 +468,6 @@ public static boolean isDebuggable(Context context) { return ((context.getApplicationContext().getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0); } - public static boolean containsIgnoreCase(List strings, String value) { - for (String string : strings) - if (string.equalsIgnoreCase(value)) - return true; - return false; - } - public static boolean isIntentAvailable(Context context, Intent intent) { PackageManager packageManager = context.getPackageManager(); return (packageManager.queryIntentActivities(intent, PackageManager.GET_ACTIVITIES).size() > 0); diff --git a/src/biz/bokhorst/xprivacy/XContentResolver.java b/src/biz/bokhorst/xprivacy/XContentResolver.java index 602138ee4..d1c9bab83 100644 --- a/src/biz/bokhorst/xprivacy/XContentResolver.java +++ b/src/biz/bokhorst/xprivacy/XContentResolver.java @@ -170,15 +170,27 @@ private void handleUriAfter(MethodHookParam param) throws Throwable { // Google services provider: block only android_id if (param.args.length > 3 && param.args[3] != null) { List selectionArgs = Arrays.asList((String[]) param.args[3]); - if (Util.containsIgnoreCase(selectionArgs, "android_id")) - if (isRestrictedExtra(param, PrivacyManager.cIdentification, "GservicesProvider", uri)) { - MatrixCursor gsfCursor = new MatrixCursor(cursor.getColumnNames()); - gsfCursor.addRow(new Object[] { "android_id", - PrivacyManager.getDefacedProp(Binder.getCallingUid(), "GSF_ID") }); - gsfCursor.respond(cursor.getExtras()); - param.setResult(gsfCursor); - cursor.close(); - } + if (selectionArgs.contains("android_id")) { + int ikey = cursor.getColumnIndex("key"); + int ivalue = cursor.getColumnIndex("value"); + if (ikey == 0 && ivalue == 1 && cursor.getColumnCount() == 2) { + if (isRestrictedExtra(param, PrivacyManager.cIdentification, "GservicesProvider", uri)) { + MatrixCursor result = new MatrixCursor(cursor.getColumnNames()); + while (cursor.moveToNext()) { + if ("android_id".equals(cursor.getString(ikey))) + result.addRow(new Object[] { "android_id", + PrivacyManager.getDefacedProp(Binder.getCallingUid(), "GSF_ID") }); + else + copyColumns(cursor, result); + } + result.respond(cursor.getExtras()); + param.setResult(result); + cursor.close(); + } + } else + Util.log(this, Log.ERROR, + "Unexpected result uri=" + uri + " columns=" + cursor.getColumnNames()); + } } } else if (uri.startsWith("content://com.android.contacts/contacts")