|
79 | 79 | import com.wmods.wppenhacer.xposed.features.privacy.ViewOnce; |
80 | 80 | import com.wmods.wppenhacer.xposed.spoofer.HookBL; |
81 | 81 | import com.wmods.wppenhacer.xposed.utils.DesignUtils; |
| 82 | +import com.wmods.wppenhacer.xposed.utils.ReflectionUtils; |
82 | 83 | import com.wmods.wppenhacer.xposed.utils.ResId; |
83 | 84 | import com.wmods.wppenhacer.xposed.utils.Utils; |
84 | 85 |
|
85 | 86 | import java.util.ArrayList; |
86 | 87 | import java.util.Arrays; |
| 88 | +import java.util.Calendar; |
| 89 | +import java.util.Date; |
87 | 90 | import java.util.List; |
88 | 91 | import java.util.Objects; |
89 | 92 | import java.util.concurrent.CompletableFuture; |
@@ -131,20 +134,28 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { |
131 | 134 | XposedBridge.log(packageInfo.versionName); |
132 | 135 | currentVersion = packageInfo.versionName; |
133 | 136 | supportedVersions = Arrays.asList(mApp.getResources().getStringArray(Objects.equals(mApp.getPackageName(), FeatureLoader.PACKAGE_WPP) ? ResId.array.supported_versions_wpp : ResId.array.supported_versions_business)); |
| 137 | + mApp.registerActivityLifecycleCallbacks(new WaCallback()); |
| 138 | + registerReceivers(); |
134 | 139 | try { |
135 | | - |
136 | 140 | var timemillis = System.currentTimeMillis(); |
137 | | - if (supportedVersions.stream().noneMatch(s -> packageInfo.versionName.startsWith(s.replace(".xx", ""))) && !pref.getBoolean("bypass_version_check", false)) { |
138 | | - throw new Exception("Unsupported version: " + packageInfo.versionName); |
| 141 | + boolean isSupported = supportedVersions.stream().anyMatch(s -> packageInfo.versionName.startsWith(s.replace(".xx", ""))); |
| 142 | + if (!isSupported) { |
| 143 | + disableExpirationVersion(mApp.getClassLoader()); |
| 144 | + if (!pref.getBoolean("bypass_version_check", false)) { |
| 145 | + StringBuilder sb = new StringBuilder() |
| 146 | + .append("Unsupported version: ") |
| 147 | + .append(packageInfo.versionName) |
| 148 | + .append("\n") |
| 149 | + .append("Only the function of ignoring the expiration of the WhatsApp version has been applied!"); |
| 150 | + throw new Exception(sb.toString()); |
| 151 | + } |
139 | 152 | } |
140 | 153 | SharedPreferencesWrapper.hookInit(mApp.getClassLoader()); |
141 | 154 | UnobfuscatorCache.init(mApp); |
142 | 155 | WppCore.Initialize(loader, pref); |
143 | 156 | DesignUtils.setPrefs(pref); |
144 | 157 | initComponents(loader, pref); |
145 | 158 | plugins(loader, pref, packageInfo.versionName); |
146 | | - registerReceivers(); |
147 | | - mApp.registerActivityLifecycleCallbacks(new WaCallback()); |
148 | 159 | sendEnabledBroadcast(mApp); |
149 | 160 | // XposedHelpers.setStaticIntField(XposedHelpers.findClass("com.whatsapp.util.Log", loader), "level", 5); |
150 | 161 | var timemillis2 = System.currentTimeMillis() - timemillis; |
@@ -187,6 +198,19 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { |
187 | 198 | }); |
188 | 199 | } |
189 | 200 |
|
| 201 | + private static void disableExpirationVersion(ClassLoader classLoader) { |
| 202 | + var expirationClass = Unobfuscator.loadExpirationClass(classLoader); |
| 203 | + var method = ReflectionUtils.findMethodUsingFilter(expirationClass, m -> m.getReturnType().equals(Date.class)); |
| 204 | + XposedBridge.hookMethod(method, new XC_MethodHook() { |
| 205 | + @Override |
| 206 | + protected void beforeHookedMethod(MethodHookParam param) throws Throwable { |
| 207 | + var calendar = Calendar.getInstance(); |
| 208 | + calendar.set(2099, 12, 31); |
| 209 | + param.setResult(calendar.getTime()); |
| 210 | + } |
| 211 | + }); |
| 212 | + } |
| 213 | + |
190 | 214 | private static void initComponents(ClassLoader loader, XSharedPreferences pref) throws Exception { |
191 | 215 | AlertDialogWpp.initDialog(loader); |
192 | 216 | FMessageWpp.initialize(loader); |
|
0 commit comments