From 7cd2c427887d7b47e5c99b1559c0e92d33d2c5c7 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 25 May 2015 09:36:47 +0200 Subject: [PATCH] AOSP mode on Lollipop for stock ROM only Fixes #2201 --- README.md | 2 ++ .../bokhorst/xprivacy/ActivitySettings.java | 3 +-- src/biz/bokhorst/xprivacy/Hook.java | 21 +++++++++++++++++-- src/biz/bokhorst/xprivacy/XPrivacy.java | 9 +++++--- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e997c417e..8a248e2f9 100644 --- a/README.md +++ b/README.md @@ -1170,6 +1170,7 @@ Nevertheless, the most sensitive data, like contacts and your location, can safe * [Android Revolution HD](http://forum.xda-developers.com/showthread.php?t=1925402) * [Mahdi ROM](https://plus.google.com/u/0/communities/116540622179206449806) * [Omega ROM](http://omegadroid.co/omega-roms/) +* AOSP mode = vanilla (Google) Android Lollipop * Compatibility mode = all other Android versions/variants *About* will show if XPrivacy 3 is running in compatibility mode, which means XPrivacy 3 is behaving as XPrivay 2. @@ -1177,6 +1178,7 @@ If there is no message about compatibility mode, XPrivacy 3 is running in AOSP m XPrivacy 3 will always run in compatibility mode on Android versions before KitKat. You can force XPrivacy 3 into AOSP mode using the main settings. +This will work on Lollipop when SELinux is disabled or in permissive mode only. There is no need to force AOSP mode if XPrivacy recognizes your ROM as a compatible ROM. If you force AOSP mode, privacy sensitive data may leak. diff --git a/src/biz/bokhorst/xprivacy/ActivitySettings.java b/src/biz/bokhorst/xprivacy/ActivitySettings.java index 401d20501..0eff53819 100644 --- a/src/biz/bokhorst/xprivacy/ActivitySettings.java +++ b/src/biz/bokhorst/xprivacy/ActivitySettings.java @@ -283,8 +283,7 @@ protected void onCreate(Bundle savedInstanceState) { } cbExpert.setChecked(expert); - if (PrivacyManager.cVersion3 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT - && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) + if (PrivacyManager.cVersion3 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) cbAOSP.setVisibility(View.VISIBLE); if (expert) { diff --git a/src/biz/bokhorst/xprivacy/Hook.java b/src/biz/bokhorst/xprivacy/Hook.java index bbd26056a..cc3165b6f 100644 --- a/src/biz/bokhorst/xprivacy/Hook.java +++ b/src/biz/bokhorst/xprivacy/Hook.java @@ -162,8 +162,25 @@ public static boolean isAOSP(int sdk) { return true; if (Build.DISPLAY == null || Build.HOST == null) return false; - return (isAOSP() || isCyanogenMod() || isOmni() || isMIUI() || isSlim() || isParanoidAndroid() - || isCarbon() || isDirtyUnicorns() || isLiquidSmooth() || isAndroidRevolutionHD() || isMahdi() || isOmega()); + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) + // @formatter:off + return ( + isAOSP() || + isCyanogenMod() || + isOmni() || + isMIUI() || + isSlim() || + isParanoidAndroid() || + isCarbon() || + isDirtyUnicorns() || + isLiquidSmooth() || + isAndroidRevolutionHD() || + isMahdi() || + isOmega() + ); + // @formatter:on + else + return isAOSP(); } else return false; } diff --git a/src/biz/bokhorst/xprivacy/XPrivacy.java b/src/biz/bokhorst/xprivacy/XPrivacy.java index aabc15d0e..8e181822f 100644 --- a/src/biz/bokhorst/xprivacy/XPrivacy.java +++ b/src/biz/bokhorst/xprivacy/XPrivacy.java @@ -17,9 +17,9 @@ import android.os.Build; import android.os.Process; import android.util.Log; - import de.robv.android.xposed.IXposedHookZygoteInit; import de.robv.android.xposed.IXposedHookLoadPackage; +import de.robv.android.xposed.SELinuxHelper; import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam; import de.robv.android.xposed.XposedBridge; import de.robv.android.xposed.XC_MethodHook; @@ -42,8 +42,11 @@ public void initZygote(StartupParam startupParam) throws Throwable { // Generate secret mSecret = Long.toHexString(new Random().nextLong()); + // Reading files with SELinux enabled can result in bootloops + boolean selinux = (SELinuxHelper.isSELinuxEnabled() && SELinuxHelper.isSELinuxEnforced()); + // Read list of disabled hooks - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && mListDisabled.size() == 0) { + if (mListDisabled.size() == 0 && !selinux) { File disabled = new File("/data/system/xprivacy/disabled"); if (disabled.exists() && disabled.canRead()) try { @@ -71,7 +74,7 @@ public void initZygote(StartupParam startupParam) throws Throwable { } // AOSP mode override - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && !selinux) try { Class libcore = Class.forName("libcore.io.Libcore"); Field fOs = libcore.getDeclaredField("os");