diff --git a/src/biz/bokhorst/xprivacy/PrivacyManager.java b/src/biz/bokhorst/xprivacy/PrivacyManager.java index 919da0dab..02415441b 100644 --- a/src/biz/bokhorst/xprivacy/PrivacyManager.java +++ b/src/biz/bokhorst/xprivacy/PrivacyManager.java @@ -139,7 +139,7 @@ public class PrivacyManager { static { // Scan meta data try { - File in = new File(Util.getDataDirectory() + File.separator + "meta.xml"); + File in = new File(Util.getUserDataDirectory() + File.separator + "meta.xml"); Util.log(null, Log.INFO, "Reading meta=" + in.getAbsolutePath()); FileInputStream fis = null; try { diff --git a/src/biz/bokhorst/xprivacy/PrivacyProvider.java b/src/biz/bokhorst/xprivacy/PrivacyProvider.java index 4bedf903c..5f28f63a9 100644 --- a/src/biz/bokhorst/xprivacy/PrivacyProvider.java +++ b/src/biz/bokhorst/xprivacy/PrivacyProvider.java @@ -512,8 +512,7 @@ public static void flush() { // Helper methods private void enforcePermission() throws SecurityException { - int uid = Util.getAppId(Binder.getCallingUid()); - if (uid != Process.myUid()) + if (Binder.getCallingUid() != Process.myUid()) throw new SecurityException(); } @@ -566,7 +565,7 @@ private static String getSettingName(String settingKey) { } private void writeMetaData() throws IOException, FileNotFoundException { - File out = new File(Util.getDataDirectory() + File.separator + "meta.xml"); + File out = new File(Util.getUserDataDirectory() + File.separator + "meta.xml"); Util.log(null, Log.INFO, "Writing meta=" + out.getAbsolutePath()); InputStream is = getContext().getAssets().open("meta.xml"); OutputStream os = new FileOutputStream(out.getAbsolutePath()); diff --git a/src/biz/bokhorst/xprivacy/Util.java b/src/biz/bokhorst/xprivacy/Util.java index 5c72582eb..55abc1808 100644 --- a/src/biz/bokhorst/xprivacy/Util.java +++ b/src/biz/bokhorst/xprivacy/Util.java @@ -174,11 +174,6 @@ public static int getUserId(int uid) { return userId; } - public static String getDataDirectory() { - return Environment.getDataDirectory() + File.separator + "data" + File.separator - + Util.class.getPackage().getName(); - } - public static String getUserDataDirectory() { // Build data directory String dataDir = Environment.getDataDirectory() + File.separator; diff --git a/src/biz/bokhorst/xprivacy/XPackageManagerService.java b/src/biz/bokhorst/xprivacy/XPackageManagerService.java deleted file mode 100644 index b4a59d0a6..000000000 --- a/src/biz/bokhorst/xprivacy/XPackageManagerService.java +++ /dev/null @@ -1,70 +0,0 @@ -package biz.bokhorst.xprivacy; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -import android.content.pm.PackageManager; -import android.os.Build; -import android.util.Log; - -import de.robv.android.xposed.XC_MethodHook.MethodHookParam; - -public class XPackageManagerService extends XHook { - private Methods mMethod; - private static String INTERACT_ACROSS_USERS = "android.permission.INTERACT_ACROSS_USERS"; - - private XPackageManagerService(Methods method, String restrictionName) { - super(restrictionName, method.name(), null); - mMethod = method; - } - - public String getClassName() { - return "com.android.server.pm.PackageManagerService"; - } - - // public int checkUidPermission(String permName, int uid) - // frameworks/base/services/java/com/android/server/pm/PackageManagerService.java - - private enum Methods { - checkUidPermission - }; - - public static List getInstances() { - List listHook = new ArrayList(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) - listHook.add(new XPackageManagerService(Methods.checkUidPermission, null)); - return listHook; - } - - @Override - protected void before(MethodHookParam param) throws Throwable { - if (mMethod == Methods.checkUidPermission) { - if (param.args.length >= 2) - try { - String permissionName = (String) param.args[0]; - int uid = (Integer) param.args[1]; - if (INTERACT_ACROSS_USERS.equals(permissionName)) { - // public String[] getPackagesForUid(int uid) - Method method = param.thisObject.getClass().getDeclaredMethod("getPackagesForUid", int.class); - String[] packageName = (String[]) method.invoke(param.thisObject, uid); - if (packageName != null && packageName.length > 0) { - String self = XPackageManagerService.class.getPackage().getName(); - if (self.equals(packageName[0])) { - Util.log(this, Log.WARN, "Allowing single user uid=" + uid); - param.setResult(PackageManager.PERMISSION_GRANTED); - } - } - } - } catch (Throwable ex) { - Util.bug(this, ex); - } - } else - Util.log(this, Log.WARN, "Unknown method=" + param.method.getName()); - } - - @Override - protected void after(MethodHookParam param) throws Throwable { - // Do nothing - } -} diff --git a/src/biz/bokhorst/xprivacy/XPackageParser.java b/src/biz/bokhorst/xprivacy/XPackageParser.java deleted file mode 100644 index e768ebaf8..000000000 --- a/src/biz/bokhorst/xprivacy/XPackageParser.java +++ /dev/null @@ -1,74 +0,0 @@ -package biz.bokhorst.xprivacy; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; - -import android.annotation.TargetApi; -import android.content.pm.ProviderInfo; -import android.os.Build; -import android.util.Log; - -import de.robv.android.xposed.XC_MethodHook.MethodHookParam; - -public class XPackageParser extends XHook { - private Methods mMethod; - - private XPackageParser(Methods method, String restrictionName) { - super(restrictionName, method.name(), null); - mMethod = method; - } - - public String getClassName() { - return "android.content.pm.PackageParser"; - } - - public boolean isVisible() { - return false; - } - - // private Provider parseProvider(Package owner, ...) - // frameworks/base/core/java/android/content/pm/PackageParser.java - - private enum Methods { - parseProvider - }; - - public static List getInstances() { - List listHook = new ArrayList(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) - listHook.add(new XPackageParser(Methods.parseProvider, null)); - return listHook; - } - - @Override - protected void before(MethodHookParam param) throws Throwable { - // Do nothing - } - - @Override - @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) - protected void after(MethodHookParam param) throws Throwable { - if (mMethod == Methods.parseProvider) { - if (param.args.length > 0) - try { - // Package: public String packageName; - Field fieldPackageName = param.args[0].getClass().getDeclaredField("packageName"); - String packageName = (String) fieldPackageName.get(param.args[0]); - String self = XPackageParser.class.getPackage().getName(); - if (self.equals(packageName)) { - Object provider = param.getResult(); - // Provider: public final ProviderInfo info; - Field fieldInfo = provider.getClass().getDeclaredField("info"); - ProviderInfo providerInfo = (ProviderInfo) fieldInfo.get(provider); - providerInfo.flags |= ProviderInfo.FLAG_SINGLE_USER; - providerInfo.exported = true; - Util.log(this, Log.WARN, "Privacy provider single user"); - } - } catch (Throwable ex) { - Util.bug(this, ex); - } - } else - Util.log(this, Log.WARN, "Unknown method=" + param.method.getName()); - } -} diff --git a/src/biz/bokhorst/xprivacy/XPrivacy.java b/src/biz/bokhorst/xprivacy/XPrivacy.java index d3cd5711e..55aaaa0f9 100644 --- a/src/biz/bokhorst/xprivacy/XPrivacy.java +++ b/src/biz/bokhorst/xprivacy/XPrivacy.java @@ -96,12 +96,6 @@ public void initZygote(StartupParam startupParam) throws Throwable { // Runtime hookAll(XRuntime.getInstances()); - // Package manager service - hookAll(XPackageManagerService.getInstances()); - - // Package parser - hookAll(XPackageParser.getInstances()); - // Service hookAll(XService.getInstances());