Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev4Mod committed Nov 14, 2024
2 parents 1a63a4c + 81e19b3 commit 87bb8a0
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ public static String getCurrentRawJID() {
var conversation = getCurrentConversation();
if (conversation == null) return null;
var chatField = XposedHelpers.getObjectField(conversation, convChatField.getName());
if (chatField == null) return null;
var chatJidObj = XposedHelpers.getObjectField(chatField, chatJidField.getName());
if (chatJidObj == null) return null;
return getRawString(chatJidObj);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,38 @@ public synchronized static Method loadIconTabMethod(ClassLoader classLoader) thr
});
}

public synchronized static Field loadPreIconTabField(ClassLoader classLoader) throws Exception {
return UnobfuscatorCache.getInstance().getField(classLoader, () -> {
Class<?> cls = loadIconTabMethod(classLoader).getDeclaringClass();
Class<?> clsType = findFirstClassUsingStringsFilter(classLoader, "X.", StringMatchType.Contains, "Tried to set badge");
if (clsType == null) throw new Exception("PreIconTabField not found");
Field result = null;
for (var field1 : cls.getFields()) {
Object checkResult = Arrays.stream(field1.getType().getFields()).filter(f -> f.getType().equals(clsType)).findFirst().orElse(null);
if (checkResult != null) {
result = field1;
break;
}
}
if (result == null) throw new Exception("PreIconTabField not found 2");
return result;
});
}

public synchronized static Field loadIconTabField(ClassLoader classLoader) throws Exception {
return UnobfuscatorCache.getInstance().getField(classLoader, () -> {
Class<?> cls = loadIconTabMethod(classLoader).getDeclaringClass();
Class<?> clsType = findFirstClassUsingStringsFilter(classLoader, "X.", StringMatchType.Contains, "Tried to set badge");
if (clsType == null) throw new Exception("IconTabField not found");
var result = Arrays.stream(cls.getFields()).filter(f -> f.getType().equals(clsType)).findFirst().orElse(null);
if (result == null) throw new Exception("IconTabField not found");
// for 23.xx, the result is null
if (result == null) {
for (var field1 : cls.getFields()) {
result = Arrays.stream(field1.getType().getFields()).filter(f -> f.getType().equals(clsType)).findFirst().orElse(null);
if (result != null) break;
}
}
if (result == null) throw new Exception("IconTabField not found 2");
return result;
});
}
Expand Down Expand Up @@ -845,7 +871,7 @@ public synchronized static Method loadSendPresenceMethod(ClassLoader loader) thr
.matcher(MethodMatcher.create().returnType(groupJidClass)))
.singleOrNull();
if (classCheckMethod == null) {
var newMethod = methodData.getCallers().firstOrNull();
var newMethod = methodData.getCallers().singleOrNull(method1 -> method1.getParamCount() == 4);
if (newMethod == null) throw new Exception("SendPresence method not found 2");
return newMethod.getMethodInstance(loader);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,17 @@ private void setFilter(int position) {
var list = (List<Object>) ReflectionUtils.getObjectField(listField, mFilterInstance);
if (list == null) return;
var name = position == 0 ? "CONTACTS_FILTER" : "GROUP_FILTER";
var result = list.stream().filter(item -> Objects.equals(XposedHelpers.getObjectField(item, "A01"), name)).findFirst();
if (result.isEmpty()) return;
var index = list.indexOf(result.get());
Object result = null;
for (var item : list) {
for (var field : item.getClass().getFields()) {
if (Objects.equals(XposedHelpers.getObjectField(item, field.getName()), name)) {
result = item;
break;
}
}
}
if (result == null) return;
var index = list.indexOf(result);
ReflectionUtils.callMethod(methodSetFilter, mFilterInstance, index);
} catch (Exception e) {
logDebug(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,26 @@ private void hookTabIcon() throws Exception {
@SuppressLint("ResourceType")
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
var superClass = param.thisObject.getClass().getSuperclass();
if (superClass != null && superClass == iconTabMethod.getDeclaringClass()) {
var field1 = superClass.getDeclaredField(iconField.getName()).get(param.thisObject);
var field2 = getObjectField(field1, iconFrameField.getName());
if (field2 == null) return;
var menu = (Menu) getObjectField(field2, iconMenuField.getName());
if (menu == null) return;
// add Icon to menu
var menuItem = (MenuItem) menu.findItem(GROUPS);
if (menuItem != null) {
menuItem.setIcon(Utils.getID("home_tab_communities_selector", "drawable"));
}
var obj = param.thisObject;
var superClass = obj.getClass().getSuperclass();

// for 23.xx, superClass != iconTabMethod.getDeclaringClass()
if (!(superClass != null && superClass == iconTabMethod.getDeclaringClass())) {
var preIconTabField = Unobfuscator.loadPreIconTabField(classLoader);
var field0 = getObjectField(obj, preIconTabField.getName());
superClass = field0.getClass().getSuperclass();
obj = field0;
}

var field1 = superClass.getDeclaredField(iconField.getName()).get(obj);
var field2 = getObjectField(field1, iconFrameField.getName());
if (field2 == null) return;
var menu = (Menu) getObjectField(field2, iconMenuField.getName());
if (menu == null) return;
// add Icon to menu
var menuItem = (MenuItem) menu.findItem(GROUPS);
if (menuItem != null) {
menuItem.setIcon(Utils.getID("home_tab_communities_selector", "drawable"));
}
}
});
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
<item>2.24.20.xx</item>
<item>2.24.21.xx</item>
<item>2.24.22.xx</item>
<item>2.24.23.xx</item>
</string-array>
<string-array name="supported_versions_business">
<item>2.24.16.xx</item>
Expand All @@ -131,6 +132,7 @@
<item>2.24.20.xx</item>
<item>2.24.21.xx</item>
<item>2.24.22.xx</item>
<item>2.24.23.xx</item>
</string-array>
<string-array name="image_picker">
<item>image/*</item>
Expand Down

0 comments on commit 87bb8a0

Please sign in to comment.