Skip to content

Commit 22fc60b

Browse files
committed
Refactor MediaQuality and Unobfuscator for improved video handling
Signed-off-by: Dev4Mod <[email protected]>
1 parent 6802053 commit 22fc60b

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,12 @@ public synchronized static HashMap<String, Field> loadMediaQualityVideoFields(Cl
534534

535535
public synchronized static HashMap<String, Field> loadMediaQualityOriginalVideoFields(ClassLoader classLoader) throws Exception {
536536
var method = loadMediaQualityVideoMethod2(classLoader);
537-
var methodString = method.getParameterTypes()[0].getDeclaredMethod("toString");
537+
Method methodString;
538+
try {
539+
methodString = method.getParameterTypes()[0].getDeclaredMethod("toString");
540+
} catch (Exception e) {
541+
return new HashMap<>();
542+
}
538543
var methodData = dexkit.getMethodData(methodString);
539544
var usingFields = Objects.requireNonNull(methodData).getUsingFields();
540545
var usingStrings = Objects.requireNonNull(methodData).getUsingStrings();

app/src/main/java/com/wmods/wppenhacer/xposed/features/media/MediaQuality.java

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,38 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
8888
@Override
8989
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
9090
var resizeVideo = param.getResult();
91-
if ((int) param.args[1] == 3) {
91+
boolean isHighResolution;
92+
boolean isEnum = false;
93+
if (param.args[0] instanceof Enum<?>) {
94+
isEnum = true;
95+
var hightResolution = Enum.valueOf((Class<Enum>) param.args[0].getClass(), "RESOLUTION_1080P");
96+
isHighResolution = hightResolution == param.args[0];
97+
} else {
98+
isHighResolution = (int) param.args[1] == 3;
99+
}
100+
if (isHighResolution) {
92101

93102
if (realResolution) {
94-
var width = mediaFields.get("widthPx").getInt(param.args[0]);
95-
var height = mediaFields.get("heightPx").getInt(param.args[0]);
96-
var rotationAngle = mediaFields.get("rotationAngle").getInt(param.args[0]);
97-
103+
int width;
104+
int height;
105+
int rotationAngle;
106+
107+
if (mediaFields.isEmpty()) {
108+
if (isEnum) {
109+
width = (int) param.args[3];
110+
height = (int) param.args[4];
111+
rotationAngle = (int) param.args[5];
112+
} else {
113+
JSONObject mediaFields = (JSONObject) XposedHelpers.callMethod(param.args[0], "A00");
114+
width = mediaFields.getInt("widthPx");
115+
height = mediaFields.getInt("heightPx");
116+
rotationAngle = mediaFields.getInt("rotationAngle");
117+
}
118+
} else {
119+
width = mediaFields.get("widthPx").getInt(param.args[0]);
120+
height = mediaFields.get("heightPx").getInt(param.args[0]);
121+
rotationAngle = mediaFields.get("rotationAngle").getInt(param.args[0]);
122+
}
98123
var targetWidthField = mediaTranscodeParams.get("targetWidth");
99124
var targetHeightField = mediaTranscodeParams.get("targetHeight");
100125

0 commit comments

Comments
 (0)