(ClassLoader rtLoader)
| 38 | } |
| 39 | |
| 40 | public void doInit(ClassLoader rtLoader) { |
| 41 | // our minSdk is 21 so there is no need to wait for MultiDex to initialize |
| 42 | if (sPre1Initialized) { |
| 43 | return; |
| 44 | } |
| 45 | if (rtLoader == null) { |
| 46 | throw new AssertionError("StartupHook.doInit: rtLoader == null"); |
| 47 | } |
| 48 | Class<?> applicationClass = null; |
| 49 | try { |
| 50 | applicationClass = rtLoader.loadClass("org.telegram.messenger.ApplicationLoader"); |
| 51 | } catch (ClassNotFoundException ignored) { |
| 52 | } |
| 53 | if (applicationClass == null) { |
| 54 | try { |
| 55 | applicationClass = rtLoader.loadClass("org.thunderdog.challegram.BaseApplication"); |
| 56 | } catch (ClassNotFoundException ignored) { |
| 57 | } |
| 58 | } |
| 59 | if (applicationClass == null) { |
| 60 | throw new AssertionError("StartupHook.doInit: unable to find ApplicationLoader"); |
| 61 | } |
| 62 | XposedHelpers.findAndHookMethod(applicationClass, "onCreate", new XC_MethodHook(51) { |
| 63 | @Override |
| 64 | protected void beforeHookedMethod(MethodHookParam param) { |
| 65 | Application app = (Application) param.thisObject; |
| 66 | if (app == null) { |
| 67 | throw new AssertionError("app == null"); |
| 68 | } |
| 69 | NativeLoader.loadAllSharedLibraries(app); |
| 70 | if (!NativeLoader.isNativeLibraryLoaded()) { |
| 71 | throw new AssertionError("NativeLoader.isNativeLibraryLoaded() == false"); |
| 72 | } |
| 73 | StartupRoutine.execPreStartupInit(app, null, false); |
| 74 | } |
| 75 | |
| 76 | @Override |
| 77 | protected void afterHookedMethod(MethodHookParam param) { |
| 78 | if (sPost2Initialized) { |
| 79 | return; |
| 80 | } |
| 81 | StartupRoutine.execPostStartupInit(); |
| 82 | sPost2Initialized = true; |
| 83 | } |
| 84 | }); |
| 85 | sPre1Initialized = true; |
| 86 | } |
| 87 | } |
no test coverage detected