@@ -110,7 +110,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
110110 logDebug (Unobfuscator .getMethodDescriptor (getStatusUser ));
111111 var sendPresenceMethod = Unobfuscator .loadSendPresenceMethod (classLoader );
112112 logDebug (Unobfuscator .getMethodDescriptor (sendPresenceMethod ));
113-
113+ var tcTokenMethod = Unobfuscator . loadTcTokenMethod ( classLoader );
114114 var absViewHolderClass = Unobfuscator .loadAbsViewHolder (classLoader );
115115
116116
@@ -128,6 +128,11 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
128128 }
129129 });
130130
131+ // load methods
132+ var tokenClass = sendPresenceMethod .getParameterTypes ()[2 ];
133+ var fieldTokenDBInstance = ReflectionUtils .getFieldByExtendType (sendPresenceMethod .getDeclaringClass (), tcTokenMethod .getDeclaringClass ());
134+
135+
131136 XposedBridge .hookMethod (onChangeStatus , new XC_MethodHook () {
132137 @ Override
133138 @ SuppressLint ("ResourceType" )
@@ -148,15 +153,12 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
148153 var jidObject = jidFiled .get (object );
149154 var jid = WppCore .getRawString (jidObject );
150155 if (WppCore .isGroup (jid )) return ;
151- Class <?> JidClass = classLoader .loadClass ("com.whatsapp.jid.Jid" );
152- var method = ReflectionUtils .findMethodUsingFilter (sendPresenceMethod .getDeclaringClass (), method1 -> method1 .getParameterCount () == 2 && JidClass .isAssignableFrom (method1 .getParameterTypes ()[0 ]) && method1 .getParameterTypes ()[1 ] == sendPresenceMethod .getDeclaringClass ());
153- var instance = ReflectionUtils .callMethod (method , null , jidObject , mInstancePresence ); //XposedHelpers.newInstance(clazz, new Object[]{null, null});
154- // for 22.xx, the parameter count is 4
155- if (sendPresenceMethod .getParameterCount () == 4 ) {
156- sendPresenceMethod .invoke (null , jidObject , null , instance , mInstancePresence );
157- } else {
158- sendPresenceMethod .invoke (null , jidObject , instance , mInstancePresence );
159- }
156+
157+ var tokenDBInstance = fieldTokenDBInstance .get (mInstancePresence );
158+ var tokenData = ReflectionUtils .callMethod (tcTokenMethod , tokenDBInstance , jidObject );
159+ var tokenObj = tokenClass .getConstructors ()[0 ].newInstance (tokenData == null ? null : XposedHelpers .getObjectField (tokenData , "A01" ));
160+ sendPresenceMethod .invoke (null , jidObject , null , tokenObj , mInstancePresence );
161+
160162 var status = (String ) ReflectionUtils .callMethod (getStatusUser , mStatusUser , object , false );
161163 var currentPosition = (int ) ReflectionUtils .callMethod (getAdapterPositionMethod , viewHolder );
162164 if (currentPosition != position ) return ;
0 commit comments