2626import com .wmods .wppenhacer .xposed .utils .Utils ;
2727
2828import org .json .JSONObject ;
29- import org .luckypray .dexkit .query .enums .StringMatchType ;
3029
3130import java .io .File ;
3231import java .lang .reflect .Field ;
3332import java .lang .reflect .Method ;
34- import java .lang .reflect .Modifier ;
3533import java .util .Arrays ;
3634import java .util .Collections ;
3735import java .util .HashSet ;
@@ -49,7 +47,6 @@ public class WppCore {
4947 static final HashSet <ActivityChangeState > listenerAcitivity = new HashSet <>();
5048 @ SuppressLint ("StaticFieldLeak" )
5149 static Activity mCurrentActivity ;
52- private static Class <?> mGenJidClass ;
5350 private static Method mGenJidMethod ;
5451 private static Class bottomDialog ;
5552 private static SharedPreferences privPrefs ;
@@ -71,16 +68,12 @@ public class WppCore {
7168
7269 public static void Initialize (ClassLoader loader , XSharedPreferences pref ) throws Exception {
7370 privPrefs = Utils .getApplication ().getSharedPreferences ("WaGlobal" , Context .MODE_PRIVATE );
71+
72+
7473 // init UserJID
75- var mSendReadClass = Unobfuscator .findFirstClassUsingName (loader , StringMatchType .EndsWith ,
76- "SendReadReceiptJob" );
77- var subClass = ReflectionUtils
78- .findConstructorUsingFilter (mSendReadClass , (constructor ) -> constructor .getParameterCount () == 8 )
79- .getParameterTypes ()[0 ];
80- mGenJidClass = ReflectionUtils
81- .findFieldUsingFilter (subClass , (field ) -> Modifier .isStatic (field .getModifiers ())).getType ();
82- mGenJidMethod = ReflectionUtils .findMethodUsingFilter (mGenJidClass ,
83- (method ) -> method .getParameterCount () == 1 && !Modifier .isStatic (method .getModifiers ()));
74+ var companionField = FMessageWpp .UserJid .TYPE_JID .getDeclaredField ("Companion" );
75+ mGenJidMethod = ReflectionUtils .findMethodUsingFilter (companionField .getType (), m -> m .getParameterCount () == 1 && String .class .equals (m .getParameterTypes ()[0 ]) && FMessageWpp .UserJid .TYPE_JID .equals (m .getReturnType ()));
76+
8477 // Bottom Dialog
8578 bottomDialog = Unobfuscator .loadDialogViewClass (loader );
8679
@@ -183,7 +176,7 @@ public static Object getUserJidFromPhoneJid(Object userJid) {
183176 public static void initBridge (Context context ) throws Exception {
184177 var prefsCacheHooks = UnobfuscatorCache .getInstance ().sPrefsCacheHooks ;
185178 int preferredOrder = prefsCacheHooks .getInt ("preferredOrder" , 1 ); // 0 for ProviderClient first, 1 for
186- // BridgeClient first
179+ // BridgeClient first
187180
188181 boolean connected = false ;
189182 if (preferredOrder == 0 ) {
@@ -257,7 +250,7 @@ public static void sendReaction(String s, Object objMessage) {
257250 try {
258251 var senderMethod = ReflectionUtils .findMethodUsingFilter (actionUser ,
259252 (method ) -> method .getParameterCount () == 3 && Arrays .equals (method .getParameterTypes (),
260- new Class [] { FMessageWpp .TYPE , String .class , boolean .class }));
253+ new Class []{ FMessageWpp .TYPE , String .class , boolean .class }));
261254 senderMethod .invoke (getActionUser (), objMessage , s , !TextUtils .isEmpty (s ));
262255 } catch (Exception e ) {
263256 Utils .showToast ("Error in sending reaction:" + e .getMessage (), Toast .LENGTH_SHORT );
@@ -357,7 +350,7 @@ public synchronized static Class getDataUsageActivityClass(@NonNull ClassLoader
357350 }
358351
359352 public synchronized static Class getTextStatusComposerFragmentClass (@ NonNull ClassLoader loader ) throws Exception {
360- var classes = new String [] {
353+ var classes = new String []{
361354 "com.whatsapp.status.composer.TextStatusComposerFragment" ,
362355 "com.whatsapp.statuscomposer.composer.TextStatusComposerFragment"
363356 };
@@ -370,7 +363,7 @@ public synchronized static Class getTextStatusComposerFragmentClass(@NonNull Cla
370363 }
371364
372365 public synchronized static Class getVoipManagerClass (@ NonNull ClassLoader loader ) throws Exception {
373- var classes = new String [] {
366+ var classes = new String []{
374367 "com.whatsapp.voipcalling.Voip" ,
375368 "com.whatsapp.calling.voipcalling.Voip"
376369 };
@@ -383,7 +376,7 @@ public synchronized static Class getVoipManagerClass(@NonNull ClassLoader loader
383376 }
384377
385378 public synchronized static Class getVoipCallInfoClass (@ NonNull ClassLoader loader ) throws Exception {
386- var classes = new String [] {
379+ var classes = new String []{
387380 "com.whatsapp.voipcalling.CallInfo" ,
388381 "com.whatsapp.calling.infra.voipcalling.CallInfo"
389382 };
@@ -442,8 +435,8 @@ public static String getSContactName(FMessageWpp.UserJid userJid, boolean saveOn
442435 }
443436 String name = null ;
444437 var rawJid = userJid .getPhoneRawString ();
445- var cursor = mWaDatabase .query ("wa_contacts" , new String [] { "display_name" }, selection ,
446- new String [] { rawJid }, null , null , null );
438+ var cursor = mWaDatabase .query ("wa_contacts" , new String []{ "display_name" }, selection ,
439+ new String []{ rawJid }, null , null , null );
447440 if (cursor .moveToFirst ()) {
448441 name = cursor .getString (0 );
449442 cursor .close ();
@@ -458,8 +451,8 @@ public static String getWppContactName(FMessageWpp.UserJid userJid) {
458451 return "" ;
459452 String name = null ;
460453 var rawJid = userJid .getPhoneRawString ();
461- var cursor2 = mWaDatabase .query ("wa_vnames" , new String [] { "verified_name" }, "jid = ?" ,
462- new String [] { rawJid }, null , null , null );
454+ var cursor2 = mWaDatabase .query ("wa_vnames" , new String []{ "verified_name" }, "jid = ?" ,
455+ new String []{ rawJid }, null , null , null );
463456 if (cursor2 .moveToFirst ()) {
464457 name = cursor2 .getString (0 );
465458 cursor2 .close ();
@@ -486,9 +479,8 @@ public static Object getFMessageFromKey(Object messageKey) {
486479 public static Object createUserJid (@ Nullable String rawjid ) {
487480 if (rawjid == null )
488481 return null ;
489- var genInstance = XposedHelpers .newInstance (mGenJidClass );
490482 try {
491- return mGenJidMethod .invoke (genInstance , rawjid );
483+ return mGenJidMethod .invoke (null , rawjid );
492484 } catch (Exception e ) {
493485 XposedBridge .log (e );
494486 }
0 commit comments