From 15dedf8adbc60872c5a377edfefe4e51ed89a89e Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 23 May 2015 09:12:44 +0200 Subject: [PATCH] Do not read /data/system/xprivacy/aosp on Lollipop to prevent triggering SELinux policies --- .../bokhorst/xprivacy/ActivitySettings.java | 3 +- src/biz/bokhorst/xprivacy/XPrivacy.java | 30 +++++++++---------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/biz/bokhorst/xprivacy/ActivitySettings.java b/src/biz/bokhorst/xprivacy/ActivitySettings.java index 0eff53819..401d20501 100644 --- a/src/biz/bokhorst/xprivacy/ActivitySettings.java +++ b/src/biz/bokhorst/xprivacy/ActivitySettings.java @@ -283,7 +283,8 @@ protected void onCreate(Bundle savedInstanceState) { } cbExpert.setChecked(expert); - if (PrivacyManager.cVersion3 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) + if (PrivacyManager.cVersion3 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT + && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) cbAOSP.setVisibility(View.VISIBLE); if (expert) { diff --git a/src/biz/bokhorst/xprivacy/XPrivacy.java b/src/biz/bokhorst/xprivacy/XPrivacy.java index 2983f0482..85a19c7db 100644 --- a/src/biz/bokhorst/xprivacy/XPrivacy.java +++ b/src/biz/bokhorst/xprivacy/XPrivacy.java @@ -133,22 +133,22 @@ private void bootstrapZygote() throws Throwable { } catch (Throwable ex) { Log.w("XPrivacy", ex.toString()); } - } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) - try { - Class libcore = Class.forName("libcore.io.Libcore"); - Field fOs = libcore.getDeclaredField("os"); - fOs.setAccessible(true); - Object os = fOs.get(null); - Method setenv = os.getClass().getMethod("setenv", String.class, String.class, boolean.class); - setenv.setAccessible(true); - boolean aosp = new File("/data/system/xprivacy/aosp").exists(); - setenv.invoke(os, "XPrivacy.AOSP", Boolean.toString(aosp), false); - Util.log(null, Log.WARN, "AOSP mode forced=" + aosp); - } catch (Throwable ex) { - Util.bug(null, ex); - } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) + try { + Class libcore = Class.forName("libcore.io.Libcore"); + Field fOs = libcore.getDeclaredField("os"); + fOs.setAccessible(true); + Object os = fOs.get(null); + Method setenv = os.getClass().getMethod("setenv", String.class, String.class, boolean.class); + setenv.setAccessible(true); + boolean aosp = new File("/data/system/xprivacy/aosp").exists(); + setenv.invoke(os, "XPrivacy.AOSP", Boolean.toString(aosp), false); + Util.log(null, Log.WARN, "AOSP mode forced=" + aosp); + } catch (Throwable ex) { + Util.bug(null, ex); + } + } /* * Add nixed User Space / System Server hooks