this should now work both on Android 4 and Android 5
authorRalf Jung <post@ralfj.de>
Sun, 7 Feb 2016 19:40:24 +0000 (20:40 +0100)
committerRalf Jung <post@ralfj.de>
Sun, 7 Feb 2016 19:55:49 +0000 (20:55 +0100)
README.md
app/src/main/assets/xposed_init
app/src/main/java/it/skarafaz/xposed/nwmonblocker/Mod.java
app/src/main/java/it/skarafaz/xposed/nwmonblocker/Mod5.java [new file with mode: 0644]

index d7667086262806a4473d0304527a1aedd1f9cda7..583c62c2fd3a5c02bebe1da967a84b6f853d7a0d 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
-Network Monitored Blocker (KitKat)
-=======================
+Network Monitored Blocker
+=========================
 
 Simple [Xposed Module](http://repo.xposed.info/module/it.skarafaz.xposed.nwmonblocker) which gets rid of the annoying *Network may be monitored* warning 
 
 Simple [Xposed Module](http://repo.xposed.info/module/it.skarafaz.xposed.nwmonblocker) which gets rid of the annoying *Network may be monitored* warning 
-triggered by adding a CA cert to the key store in **KitKat**.
+triggered by adding a CA cert to the key store.
 
 ## Notes:
 * Notification removed.
 
 ## Notes:
 * Notification removed.
@@ -10,5 +10,4 @@ triggered by adding a CA cert to the key store in **KitKat**.
 * Warning icon next to *Security* settings menu removed.
 
 ## Requirements:
 * Warning icon next to *Security* settings menu removed.
 
 ## Requirements:
-* Android **KitKat** (yes, I said **KitKat** God!).
 * Xposed Framework v54+.
 * Xposed Framework v54+.
index dc5beb8a8a4cd1676ab9a34e1eb82ece696bf878..2555e38f0ba7147c6216d20104bf3b8282d0746a 100644 (file)
@@ -1 +1,2 @@
-it.skarafaz.xposed.nwmonblocker.Mod
\ No newline at end of file
+it.skarafaz.xposed.nwmonblocker.Mod
+it.skarafaz.xposed.nwmonblocker.Mod5
\ No newline at end of file
index bd2818cd593759dfd459f01e84a6a914c8f9889d..cae346fc97012fe1e3b3fa7b26514e3148c489f8 100644 (file)
@@ -1,35 +1,23 @@
 package it.skarafaz.xposed.nwmonblocker;
 
 package it.skarafaz.xposed.nwmonblocker;
 
-import de.robv.android.xposed.IXposedHookLoadPackage;
+import de.robv.android.xposed.IXposedHookZygoteInit;
 import de.robv.android.xposed.XC_MethodReplacement;
 import de.robv.android.xposed.XC_MethodReplacement;
-import de.robv.android.xposed.XposedBridge;
 import de.robv.android.xposed.XposedHelpers;
 import de.robv.android.xposed.XposedHelpers;
-import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
 
 
-public class Mod implements IXposedHookLoadPackage {
-    // Just a helper function, useful to figure out package names
-    private void tryToLoad(String className, ClassLoader loader) {
-        try {
-            XposedHelpers.findClass(className, loader);
-            XposedBridge.log("  Found " + className);
-        }
-        catch (Throwable t) {}
-    }
+/* "Network May Be Monitored" blocker for Android 4.4. */
+
+public class Mod implements IXposedHookZygoteInit {
+    private static final String CLASS_DEVICE_POLICY_MANAGER = "android.app.admin.DevicePolicyManager";
+
+    @Override
+    public void initZygote(StartupParam startupParam) throws Throwable {
+        final Class<?> devicePolicyManager = XposedHelpers.findClass(CLASS_DEVICE_POLICY_MANAGER, null);
 
 
-    public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
-        if (!lpparam.packageName.equals("android"))
-            return;
-        
-        final Class<?> userHandle = XposedHelpers.findClass("android.os.UserHandle", lpparam.classLoader);
-        final Class<?> notifyTask = XposedHelpers.findClass("com.android.server.devicepolicy.DevicePolicyManagerService$MonitoringCertNotificationTask", lpparam.classLoader);
-        
-        XposedHelpers.findAndHookMethod(notifyTask, "manageNotification", userHandle,
-            new XC_MethodReplacement() {
-                @Override
-                protected Object replaceHookedMethod(MethodHookParam methodHookParam) throws Throwable {
-                    XposedBridge.log("Not showing FUD notification");
-                    return null;
-                }
+        XposedHelpers.findAndHookMethod(devicePolicyManager, "hasAnyCaCertsInstalled", new XC_MethodReplacement() {
+            @Override
+            protected Object replaceHookedMethod(MethodHookParam methodHookParam) throws Throwable {
+                return false;
+            }
         });
     }
 }
         });
     }
 }
diff --git a/app/src/main/java/it/skarafaz/xposed/nwmonblocker/Mod5.java b/app/src/main/java/it/skarafaz/xposed/nwmonblocker/Mod5.java
new file mode 100644 (file)
index 0000000..f04d1eb
--- /dev/null
@@ -0,0 +1,37 @@
+package it.skarafaz.xposed.nwmonblocker;
+
+import de.robv.android.xposed.IXposedHookLoadPackage;
+import de.robv.android.xposed.XC_MethodReplacement;
+import de.robv.android.xposed.XposedBridge;
+import de.robv.android.xposed.XposedHelpers;
+import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
+
+/* "Network May Be Monitored" blocker for Android 5. */
+
+public class Mod5 implements IXposedHookLoadPackage {
+    // Just a helper function, useful to figure out package names
+    private void tryToLoad(String className, ClassLoader loader) {
+        try {
+            XposedHelpers.findClass(className, loader);
+            XposedBridge.log("  Found " + className);
+        }
+        catch (Throwable t) {}
+    }
+
+    public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
+        if (!lpparam.packageName.equals("android"))
+            return;
+        
+        final Class<?> userHandle = XposedHelpers.findClass("android.os.UserHandle", lpparam.classLoader);
+        final Class<?> notifyTask = XposedHelpers.findClass("com.android.server.devicepolicy.DevicePolicyManagerService$MonitoringCertNotificationTask", lpparam.classLoader);
+        
+        XposedHelpers.findAndHookMethod(notifyTask, "manageNotification", userHandle,
+            new XC_MethodReplacement() {
+                @Override
+                protected Object replaceHookedMethod(MethodHookParam methodHookParam) throws Throwable {
+                    XposedBridge.log("Not showing FUD notification");
+                    return null;
+                }
+        });
+    }
+}