Skip to content

Commit

Permalink
Merge pull request icegreentee#436 from segfault-bilibili/rollup-7.1.9
Browse files Browse the repository at this point in the history
【7.1.9】减速降调修正适配32位
  • Loading branch information
segfault-bilibili committed May 16, 2023
2 parents c140c68 + 0fa2f7d commit b08dbd4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 17 deletions.
52 changes: 38 additions & 14 deletions floatUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -12259,7 +12259,7 @@ function algo_init() {
try {
privShell("id");
} catch (e) {
toastLog("需要root或shizuku adb权限\n请确保永久授权,若已授权请再试一次");
dialogs.alert("需要root或shizuku adb权限\n请确保永久授权,若已授权请再试一次");
return;
}
let dialogResult = dialogs.confirm("绕过GooglePlay检测",
Expand Down Expand Up @@ -12642,6 +12642,7 @@ function algo_init() {
fileNames.push(newName);
}
zipfile.close();
if (fileNames.length == 0) throw new Error("extracted nothing");
log("解压完成");

const libParentPath = apkPath.replace(/\/[^\/]+\.apk$/, "/");
Expand Down Expand Up @@ -13137,7 +13138,7 @@ function algo_init() {
try {
privShell("id");
} catch (e) {
toastLog("需要root或shizuku adb权限\n请确保永久授权,若已授权请再试一次");
dialogs.alert("需要root或shizuku adb权限\n请确保永久授权,若已授权请再试一次");
return;
}

Expand Down Expand Up @@ -13171,18 +13172,30 @@ function algo_init() {
}

const extractDir = files.join(files.cwd(), "audio_sr_fix");
const libFileName = "lib/arm64-v8a/libmadomagi_native.so";
const searchPatterns = [
//3.0.2
{
abi: "arm64-v8a",
pattern: "\x08\x7A\x00\xD0\x00\x51\x4F\xB9\xC0\x03\x5F\xD6",
replace: "\x08\x7A\x00\xD0\x00\x70\x97\x52\xC0\x03\x5F\xD6"
},
{
abi: "armeabi-v7a",
pattern: "\x04\x00\x9F\xE5\x00\x00\x9F\xE7\x1E\xFF\x2F\xE1\xDC\x41\xBC\x00",
replace: "\x04\x00\x9F\xE5\x80\x0B\x0B\xE3\x1E\xFF\x2F\xE1\xDC\x41\xBC\x00"
},
]

let fileNames = [];
try {
let fileNames = [];
files.ensureDir(files.join(extractDir, "lib"));
let zipfile = java.util.zip.ZipFile(apkPath);
let zipentries = zipfile.entries();
while (zipentries.hasMoreElements()) {
let entry = zipentries.nextElement();
let name = entry.getName();

if (name !== libFileName) continue;
let searchPattern = searchPatterns.find((p) => name === "lib/" + p.abi + "/libmadomagi_native.so");
if (searchPattern == null) continue;
if (entry.isDirectory()) continue;

let path = files.join(extractDir, name);
Expand All @@ -13204,18 +13217,20 @@ function algo_init() {
if (isRevert) {
log("keep file as-is");
} else if (name.match(/\.so$/)) {
let count = binaryReplaceText(bytes,
"\x08\x7A\x00\xD0\x00\x51\x4F\xB9\xC0\x03\x5F\xD6",
"\x08\x7A\x00\xD0\x00\x70\x97\x52\xC0\x03\x5F\xD6"
);
let count = binaryReplaceText(bytes, searchPattern.pattern, searchPattern.replace);
log("replaced "+count+" occurrences in ["+name+"]");
if (count == 0) {
dialogs.alert("未找到特征", "请等待脚本更新适配");
return;
}
}

files.writeBytes(path, bytes);
log("written to ["+path+"]");
fileNames.push(name);
}
zipfile.close();
if (fileNames.length == 0) throw new Error("extracted nothing");
log("解压完成");
} catch (e) {
logException(e);
Expand All @@ -13224,10 +13239,19 @@ function algo_init() {
}

try {
const binaryCopyFromPath = files.join(extractDir, libFileName);
const binaryCopyToPath = apkPath.replace(/\/[^\/]+\.apk$/, "/" + libFileName.replace("arm64-v8a", "arm64"));
let result = privShell("cat " + getPathArg(binaryCopyFromPath) + " > " + getPathArg(binaryCopyToPath));
if (result.code != 0) throw new Error("result.code != 0");
fileNames.forEach((libFileName) => {
const binaryCopyFromPath = files.join(extractDir, libFileName);
const binaryCopyToPath = apkPath.replace(/\/[^\/]+\.apk$/,
"/" + libFileName
.replace("arm64-v8a", "arm64")
.replace("armeabi-v7a", "arm")
);
let result = privShell("ls " + getPathArg(binaryCopyToPath));
if (result.code == 0) {
let result = privShell("cat " + getPathArg(binaryCopyFromPath) + " > " + getPathArg(binaryCopyToPath));
if (result.code != 0) throw new Error("result.code != 0");
}
});
log("文件已覆盖");

files.removeDir(extractDir);
Expand Down
2 changes: 1 addition & 1 deletion project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"build"
],
"packageName": "top.momoe.auto",
"versionName": "7.1.8",
"versionName": "7.1.9",
"versionInfo": "",
"versionCode": 1,
"icon":"./images/icon.png",
Expand Down
Loading

0 comments on commit b08dbd4

Please sign in to comment.