@@ -36,7 +36,7 @@ public void doHook() throws Throwable {
3636 XposedBridge .hookMethod (onCallReceivedMethod , new XC_MethodHook () {
3737 @ Override
3838 protected void beforeHookedMethod (MethodHookParam param ) throws Throwable {
39- Object callinfo = null ;
39+ Object callinfo ;
4040 Class <?> callInfoClass = XposedHelpers .findClass ("com.whatsapp.voipcalling.CallInfo" , classLoader );
4141 if (param .args [0 ] instanceof Message ) {
4242 callinfo = ((Message ) param .args [0 ]).obj ;
@@ -99,12 +99,11 @@ public CallPrivacy(@NonNull ClassLoader loader, @NonNull XSharedPreferences pref
9999 }
100100
101101 public boolean checkCallBlock (Object userJid , PrivacyType type ) throws IllegalAccessException , InvocationTargetException {
102- var jid = WppCore .stripJID (WppCore .getRawString (userJid ));
103- logDebug ("checkCallBlock: " + jid );
104- logDebug ("checkCallBlock: " + type );
105- if (jid == null ) return false ;
102+ var phoneNumber = WppCore .stripJID (WppCore .getRawString (userJid ));
106103
107- var customprivacy = CustomPrivacy .getJSON (jid );
104+ if (phoneNumber == null ) return false ;
105+
106+ var customprivacy = CustomPrivacy .getJSON (phoneNumber );
108107
109108 if (type == PrivacyType .ALL_BLOCKED ) {
110109 return customprivacy .optBoolean ("BlockCall" , true );
@@ -114,21 +113,18 @@ public boolean checkCallBlock(Object userJid, PrivacyType type) throws IllegalAc
114113 return customprivacy .optBoolean ("BlockCall" , false );
115114 }
116115
117- if (type == PrivacyType .ONLY_UNKNOWN && customprivacy .optBoolean ("BlockCall" , false )) {
118- return true ;
119- }
120-
121116 switch (type ) {
122117 case ONLY_UNKNOWN :
123- jid += "@s.whatsapp.net" ;
124- var contactName = WppCore . getSContactName ( WppCore . createUserJid ( jid ), true ) ;
125- logDebug ( " contactName: " + contactName );
126- return TextUtils .isEmpty (contactName ) || contactName .equals (jid );
118+ if ( customprivacy . optBoolean ( "BlockCall" , false )) return true ;
119+ phoneNumber += "@s.whatsapp.net" ;
120+ var contactName = WppCore . getSContactName ( WppCore . createUserJid ( phoneNumber ), true );
121+ return TextUtils .isEmpty (contactName ) || contactName .equals (phoneNumber );
127122 case BACKLIST :
123+ if (customprivacy .optBoolean ("BlockCall" , true )) return true ;
128124 var callBlockList = prefs .getString ("call_block_contacts" , "[]" );
129125 var blockList = Arrays .stream (callBlockList .substring (1 , callBlockList .length () - 1 ).split (", " )).map (String ::trim ).collect (Collectors .toCollection (ArrayList ::new ));
130126 for (var blockNumber : blockList ) {
131- if (!TextUtils .isEmpty (blockNumber ) && jid .contains (blockNumber )) {
127+ if (!TextUtils .isEmpty (blockNumber ) && phoneNumber .contains (blockNumber )) {
132128 return true ;
133129 }
134130 }
@@ -137,7 +133,7 @@ public boolean checkCallBlock(Object userJid, PrivacyType type) throws IllegalAc
137133 var callWhiteList = prefs .getString ("call_white_contacts" , "[]" );
138134 var whiteList = Arrays .stream (callWhiteList .substring (1 , callWhiteList .length () - 1 ).split (", " )).map (String ::trim ).collect (Collectors .toCollection (ArrayList ::new ));
139135 for (var whiteNumber : whiteList ) {
140- if (!TextUtils .isEmpty (whiteNumber ) && jid .contains (whiteNumber )) {
136+ if (!TextUtils .isEmpty (whiteNumber ) && phoneNumber .contains (whiteNumber )) {
141137 return false ;
142138 }
143139 }
0 commit comments