xiongzhu 10 місяців тому
батько
коміт
3713852d8d

+ 30 - 13
app/src/main/java/com/example/modifiermodule/HookSystem.java

@@ -102,22 +102,39 @@ public class HookSystem extends BaseHook {
                             }
                         });
 
-                    } else if (name.equals("com.android.server.ConnectivityServiceInitializer") || name.equals("com.android.server.ConnectivityServiceInitializer")) {
+                    } else if (name.equals("com.android.server.ConnectivityServiceInitializer")) {
                         ClassLoader classLoader = (ClassLoader) param.args[1];
-                        Class<?> ConnectivityService = XposedHelpers.findClass("com.android.server.ConnectivityService", classLoader);
-                        XposedHelpers.findAndHookMethod(ConnectivityService, "getNetworkInfo", int.class, new XC_MethodHook() {
-                            @Override
-                            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
-                                int networkType = (int) param.args[0];
-                                log(String.format("getNetworkInfo(%d)", networkType));
-                                if (networkType == ConnectivityManager.TYPE_ETHERNET && param.getResult() != null) {
-                                    NetworkInfo networkInfo = (NetworkInfo) param.getResult();
-//                                    String mac = getProperty(PROP_ETH_MAC, networkInfo.getExtraInfo());
-                                    log(String.format("  .extra: %s -> null", networkInfo.getExtraInfo()));
-                                    XposedHelpers.setObjectField(networkInfo, "mExtraInfo", null);
+                        try {
+                            Class<?> ConnectivityService = null;
+                            try {
+                                ConnectivityService = XposedHelpers.findClass("com.android.server.ConnectivityService", classLoader);
+                            } catch (Exception e1) {
+                                e1.printStackTrace();
+                                try {
+                                    ConnectivityService = XposedHelpers.findClass("android.net.connectivity.com.android.server.ConnectivityService", classLoader);
+                                } catch (Exception e2) {
+                                    e2.printStackTrace();
                                 }
                             }
-                        });
+                            if (ConnectivityService != null) {
+                                XposedHelpers.findAndHookMethod(ConnectivityService, "getNetworkInfo", int.class, new XC_MethodHook() {
+                                    @Override
+                                    protected void afterHookedMethod(MethodHookParam param) throws Throwable {
+                                        int networkType = (int) param.args[0];
+                                        log(String.format("getNetworkInfo(%d)", networkType));
+                                        if (networkType == ConnectivityManager.TYPE_ETHERNET && param.getResult() != null) {
+                                            NetworkInfo networkInfo = (NetworkInfo) param.getResult();
+//                                          String mac = getProperty(PROP_ETH_MAC, networkInfo.getExtraInfo());
+                                            log(String.format("  .extra: %s -> null", networkInfo.getExtraInfo()));
+                                            XposedHelpers.setObjectField(networkInfo, "mExtraInfo", null);
+                                        }
+                                    }
+                                });
+                            }
+
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
                     }
                 }
             });