@@ -59,13 +59,12 @@ public class WppCore {
5959 private static Object mActionUser ;
6060 private static SQLiteDatabase mWaDatabase ;
6161 public static BaseClient client ;
62- private static boolean isBridgeInitialized ;
62+ private static Object mCachedMessageStore ;
6363
6464
6565 public static void Initialize (ClassLoader loader ) throws Exception {
6666 privPrefs = Utils .getApplication ().getSharedPreferences ("WaGlobal" , Context .MODE_PRIVATE );
6767
68-
6968 // init UserJID
7069 var mSendReadClass = XposedHelpers .findClass ("com.whatsapp.jobqueue.job.SendReadReceiptJob" , loader );
7170 var subClass = ReflectionUtils .findConstructorUsingFilter (mSendReadClass , (constructor ) -> constructor .getParameterCount () == 8 ).getParameterTypes ()[0 ];
@@ -86,13 +85,24 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
8685 }
8786 });
8887
88+ // ActionUser
8989 var actionUser = Unobfuscator .loadActionUser (loader );
9090 XposedBridge .hookAllConstructors (actionUser , new XC_MethodHook () {
9191 @ Override
9292 protected void afterHookedMethod (MethodHookParam param ) throws Throwable {
9393 mActionUser = param .thisObject ;
9494 }
9595 });
96+
97+ // CachedMessageStore
98+ var cachedMessageStore = Unobfuscator .loadCachedMessageStore (loader );
99+ XposedBridge .hookAllConstructors (cachedMessageStore , new XC_MethodHook () {
100+ @ Override
101+ protected void afterHookedMethod (MethodHookParam param ) throws Throwable {
102+ mCachedMessageStore = param .thisObject ;
103+ }
104+ });
105+
96106 // Load wa database
97107 loadWADatabase ();
98108 initBridge (Utils .getApplication ());
@@ -135,7 +145,6 @@ private static boolean tryConnectBridge(BaseClient baseClient) throws Exception
135145 CompletableFuture <Boolean > canLoadFuture = baseClient .connect ();
136146 Boolean canLoad = canLoadFuture .get ();
137147 if (!canLoad ) throw new Exception ();
138- isBridgeInitialized = true ;
139148 } catch (Exception e ) {
140149 return false ;
141150 }
@@ -258,6 +267,17 @@ public static String getWppContactName(Object userJid) {
258267 return name == null ? "" : name ;
259268 }
260269
270+ public static Object getFMessageFromKey (Object messageKey ) {
271+ if (messageKey == null ) return null ;
272+ try {
273+ var methodResult = ReflectionUtils .findMethodUsingFilter (mCachedMessageStore .getClass (), (method ) -> method .getParameterCount () == 1 && FMessageWpp .Key .TYPE .isAssignableFrom (method .getParameterTypes ()[0 ]));
274+ return ReflectionUtils .callMethod (methodResult , mCachedMessageStore , messageKey );
275+ } catch (Exception e ) {
276+ XposedBridge .log (e );
277+ return null ;
278+ }
279+ }
280+
261281
262282 public static Object createUserJid (String rawjid ) {
263283 var genInstance = XposedHelpers .newInstance (mGenJidClass );
@@ -356,7 +376,8 @@ public static Activity getCurrentConversation() {
356376 // for tablet UI, they're using HomeActivity instead of Conversation
357377 // TODO: Add more checks for ConversationFragment
358378 Class <?> home = XposedHelpers .findClass ("com.whatsapp.HomeActivity" , mCurrentActivity .getClassLoader ());
359- if (mCurrentActivity .getResources ().getConfiguration ().smallestScreenWidthDp >= 600 && home .isInstance (mCurrentActivity )) return mCurrentActivity ;
379+ if (mCurrentActivity .getResources ().getConfiguration ().smallestScreenWidthDp >= 600 && home .isInstance (mCurrentActivity ))
380+ return mCurrentActivity ;
360381 return null ;
361382 }
362383
0 commit comments