Skip to content

Commit 898306b

Browse files
committed
feat: enhance video quality processing with new methods and encoder capabilities
1 parent f3aba13 commit 898306b

File tree

3 files changed

+427
-21
lines changed

3 files changed

+427
-21
lines changed

app/src/main/java/com/wmods/wppenhacer/xposed/core/devkit/Unobfuscator.java

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2636,4 +2636,79 @@ public static Method loadSetPinnedLimitMethod(ClassLoader classLoader) throws Ex
26362636
return method;
26372637
});
26382638
}
2639+
2640+
public static Method loadManualProcessVideoQualityMethod(ClassLoader classLoader) throws Exception {
2641+
return UnobfuscatorCache.getInstance().getMethod(classLoader, () -> {
2642+
var processVideoQuality = Unobfuscator.loadProcessVideoQualityClass(classLoader);
2643+
var methods = dexkit.findMethod(FindMethod.create().matcher(MethodMatcher.create().addUsingString("dimensions_are_zero").returnType(processVideoQuality)));
2644+
if (methods.isEmpty())
2645+
throw new NoSuchMethodException("ManualProcessVideoQuality method not found");
2646+
return methods.get(0).getMethodInstance(classLoader);
2647+
});
2648+
2649+
}
2650+
2651+
public static Method loadAutoProcessVideoQualityMethod(ClassLoader classLoader) throws Exception {
2652+
return UnobfuscatorCache.getInstance().getMethod(classLoader, () -> {
2653+
var processVideoQuality = Unobfuscator.loadProcessVideoQualityClass(classLoader);
2654+
var methods = dexkit.findMethod(FindMethod.create().matcher(MethodMatcher.create().addUsingString("min_bandwidth").addUsingString("network_types").returnType(processVideoQuality)));
2655+
if (methods.isEmpty())
2656+
throw new NoSuchMethodException("ManualProcessVideoQuality method not found");
2657+
return methods.get(0).getMethodInstance(classLoader);
2658+
});
2659+
2660+
}
2661+
2662+
2663+
public static HashMap<String, Field> getAllMapFields(Class<?> clazz) throws Exception {
2664+
var cache = UnobfuscatorCache.getInstance();
2665+
var classLoader = clazz.getClassLoader();
2666+
if (cache != null && classLoader != null) {
2667+
var cacheKey = "getAllMapFields:" + clazz.getName();
2668+
return cache.getMapField(classLoader, cacheKey, () -> buildAllMapFields(clazz));
2669+
}
2670+
return buildAllMapFields(clazz);
2671+
}
2672+
2673+
private static HashMap<String, Field> buildAllMapFields(Class<?> clazz) throws Exception {
2674+
Method methodString;
2675+
try {
2676+
methodString = clazz.getDeclaredMethod("toString");
2677+
} catch (Exception e) {
2678+
return new HashMap<>();
2679+
}
2680+
var methodData = dexkit.getMethodData(methodString);
2681+
var usingFields = Objects.requireNonNull(methodData).getUsingFields();
2682+
var usingStrings = Objects.requireNonNull(methodData).getUsingStrings();
2683+
var result = new HashMap<String, Field>();
2684+
var idxFields = 0;
2685+
for (int i = 0; i < usingStrings.size(); i++) {
2686+
if (idxFields == usingFields.size()) break;
2687+
var raw = usingStrings.get(i);
2688+
if (raw == null) continue;
2689+
var string = raw.strip();
2690+
if (string.isEmpty()) continue;
2691+
int eq = string.lastIndexOf('=');
2692+
if (eq < 0) continue;
2693+
int start = 0;
2694+
for (int j = eq - 1; j >= 0; j--) {
2695+
char c = string.charAt(j);
2696+
if (c == '\'' || c == ',' || c == ' ' || c == '(' || c == ')' || c == ':' || c == '{' || c == '}') {
2697+
start = j + 1;
2698+
break;
2699+
}
2700+
}
2701+
if (start >= eq) continue;
2702+
var name = string.substring(start, eq);
2703+
var field = usingFields.get(idxFields).getField().getFieldInstance(clazz.getClassLoader());
2704+
result.put(name, field);
2705+
idxFields++;
2706+
}
2707+
return result;
2708+
}
2709+
2710+
public static Class<?> loadMediaDataVideoConfigurationClass(ClassLoader classLoader) throws Exception {
2711+
return UnobfuscatorCache.getInstance().getClass(classLoader, () -> findFirstClassUsingStrings(classLoader, StringMatchType.Contains, "MediaDataVideoConfiguration("));
2712+
}
2713+
26392714
}

app/src/main/java/com/wmods/wppenhacer/xposed/core/devkit/UnobfuscatorCache.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,10 @@ public Class<?>[] getClasses(ClassLoader loader, FunctionCall<Class<?>[]> functi
333333
}
334334

335335
public HashMap<String, Field> getMapField(ClassLoader loader, FunctionCall<HashMap<String, Field>> functionCall) throws Exception {
336-
var key = getKeyName();
336+
return getMapField(loader, getKeyName(), functionCall);
337+
}
338+
339+
public HashMap<String, Field> getMapField(ClassLoader loader, String key, FunctionCall<HashMap<String, Field>> functionCall) throws Exception {
337340
String value = sPrefsCacheHooks.getString(key, null);
338341
if (value == null) {
339342
try {

0 commit comments

Comments
 (0)