tune README
[noFUDroid.git] / app / src / main / java / de / ralfj / xposed / nofudroid / Mod5.java
1 package de.ralfj.xposed.nofudroid;
2
3 import de.robv.android.xposed.IXposedHookLoadPackage;
4 import de.robv.android.xposed.XC_MethodReplacement;
5 import de.robv.android.xposed.XposedBridge;
6 import de.robv.android.xposed.XposedHelpers;
7 import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
8
9 /* "Network May Be Monitored" blocker for Android 5. */
10
11 public class Mod5 implements IXposedHookLoadPackage {
12     // Just a helper function, useful to figure out package names
13     private void tryToLoad(String className, ClassLoader loader) {
14         try {
15             XposedHelpers.findClass(className, loader);
16             XposedBridge.log("  Found " + className);
17         }
18         catch (Throwable t) {}
19     }
20
21     public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
22         if (!lpparam.packageName.equals("android"))
23             return;
24         
25         final Class<?> userHandle = XposedHelpers.findClass("android.os.UserHandle", lpparam.classLoader);
26         final Class<?> notifyTask = XposedHelpers.findClass("com.android.server.devicepolicy.DevicePolicyManagerService$MonitoringCertNotificationTask", lpparam.classLoader);
27         
28         XposedHelpers.findAndHookMethod(notifyTask, "manageNotification", userHandle,
29             new XC_MethodReplacement() {
30                 @Override
31                 protected Object replaceHookedMethod(MethodHookParam methodHookParam) throws Throwable {
32                     XposedBridge.log("Not showing FUD notification");
33                     return null;
34                 }
35         });
36     }
37 }