mirror of
https://github.com/meowarex/rl-mobile.git
synced 2026-06-17 21:13:11 +10:00
Merge pull request #10 from meowarex/dev
Manager: full split-APK merge support
This commit is contained in:
@@ -56,19 +56,11 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$tidal_src" == *.apkm ]]; then
|
||||
echo "Extracting & merging splits from $tidal_src"
|
||||
workdir=$(mktemp -d)
|
||||
unzip -q "$tidal_src" -d "$workdir"
|
||||
ls "$workdir"
|
||||
dist_abs=$(realpath ./dist)/tidal-stock.apk
|
||||
|
||||
javac scripts/MergeApk.java -d scripts
|
||||
splits=("$workdir"/split_*.apk)
|
||||
java -cp scripts MergeApk "$dist_abs" "$workdir/base.apk" "${splits[@]}"
|
||||
|
||||
rm -rf "$workdir"
|
||||
echo "Merging splits from $tidal_src via APKEditor"
|
||||
curl -sLo /tmp/APKEditor.jar https://github.com/REAndroid/APKEditor/releases/download/V1.4.3/APKEditor-1.4.3.jar
|
||||
java -jar /tmp/APKEditor.jar m -i "$tidal_src" -o ./dist/tidal-stock.apk
|
||||
echo "Merged tidal-stock.apk:"
|
||||
ls -la "$dist_abs"
|
||||
ls -la ./dist/tidal-stock.apk
|
||||
else
|
||||
cp "$tidal_src" ./dist/tidal-stock.apk
|
||||
fi
|
||||
|
||||
@@ -12,8 +12,9 @@ import kotlinx.parcelize.Parcelize
|
||||
* that is captured by a receiver into something human readable.
|
||||
*/
|
||||
@Parcelize
|
||||
data class PMInstallerError(val status: Int) : InstallerResult.Error(), Parcelable {
|
||||
override fun getDebugReason() = when (status) {
|
||||
data class PMInstallerError(val status: Int, val message: String? = null) : InstallerResult.Error(), Parcelable {
|
||||
override fun getDebugReason(): String {
|
||||
val reason = when (status) {
|
||||
PackageInstaller.STATUS_FAILURE -> "Unknown failure"
|
||||
PackageInstaller.STATUS_FAILURE_BLOCKED -> "Blocked"
|
||||
PackageInstaller.STATUS_FAILURE_INVALID -> "Invalid package"
|
||||
@@ -23,6 +24,8 @@ data class PMInstallerError(val status: Int) : InstallerResult.Error(), Parcelab
|
||||
/* PackageInstaller.STATUS_FAILURE_TIMEOUT */ 8 -> "Operation timeout"
|
||||
else -> "Unknown code ($status)"
|
||||
}
|
||||
return if (message != null) "$reason: $message" else reason
|
||||
}
|
||||
|
||||
override fun getLocalizedReason(context: Context): String {
|
||||
val string = when (status) {
|
||||
|
||||
@@ -60,13 +60,14 @@ class PMIntentReceiver : BroadcastReceiver() {
|
||||
PackageInstaller.STATUS_FAILURE_ABORTED -> InstallerResult.Cancelled(systemTriggered = true)
|
||||
|
||||
else -> {
|
||||
Log.w(BuildConfig.TAG, "PM failed with error code $status")
|
||||
val message = intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE)
|
||||
Log.w(BuildConfig.TAG, "PM failed with error code $status: $message")
|
||||
|
||||
if (status <= PackageInstaller.STATUS_SUCCESS) {
|
||||
// Unknown status code (not an error)
|
||||
return
|
||||
} else {
|
||||
PMInstallerError(status).also {
|
||||
PMInstallerError(status, message).also {
|
||||
Toast.makeText(
|
||||
/* context = */ context,
|
||||
/* text = */ it.getLocalizedReason(context),
|
||||
|
||||
+15
-1
@@ -38,11 +38,25 @@ class SmaliPatchStep : Step(), IDexProvider, KoinComponent {
|
||||
|
||||
val patches = mutableListOf<LoadedPatch>()
|
||||
|
||||
// Load and parse all the patches from the smali patch archive
|
||||
// Load and parse all the patches from the smali patch archive.
|
||||
// Extension classes (extension/**/*.smali) are extracted into smaliDir
|
||||
// so they get assembled into the new dex alongside patched classes.
|
||||
container.log("Loading patches from smali patch archive: ${patchesZip.absolutePath}")
|
||||
smaliDir.mkdirs()
|
||||
ZipReader(patchesZip).use { zip ->
|
||||
for (patchFile in zip.entryNames) {
|
||||
container.log("Parsing patch file $patchFile")
|
||||
if (patchFile.endsWith("/")) continue
|
||||
|
||||
if (patchFile.endsWith(".smali") && patchFile.startsWith("extension/")) {
|
||||
val relative = patchFile.removePrefix("extension/")
|
||||
val out = smaliDir.resolve(relative)
|
||||
out.parentFile?.mkdirs()
|
||||
out.writeBytes(zip.openEntry(patchFile)!!.read())
|
||||
container.log("Extracted extension smali: $relative")
|
||||
continue
|
||||
}
|
||||
|
||||
if (!patchFile.endsWith(".patch")) continue
|
||||
|
||||
val lines = zip.openEntry(patchFile)!!.read()
|
||||
|
||||
@@ -15,6 +15,9 @@ object ManifestPatcher {
|
||||
private const val PACKAGE = "package"
|
||||
private const val COMPILE_SDK_VERSION = "compileSdkVersion"
|
||||
private const val COMPILE_SDK_VERSION_CODENAME = "compileSdkVersionCodename"
|
||||
private const val IS_SPLIT_REQUIRED = "isSplitRequired"
|
||||
private const val REQUIRED_SPLIT_TYPES = "requiredSplitTypes"
|
||||
private const val SPLIT_TYPES = "splitTypes"
|
||||
|
||||
fun patchManifest(
|
||||
manifestBytes: ByteArray,
|
||||
@@ -22,6 +25,18 @@ object ManifestPatcher {
|
||||
appName: String,
|
||||
debuggable: Boolean,
|
||||
): ByteArray {
|
||||
// Extract original package name so we can rewrite every reference to it
|
||||
// (permissions, provider authorities) to the new packageName.
|
||||
var originalPackage: String? = null
|
||||
AxmlReader(manifestBytes).accept(object : AxmlVisitor() {
|
||||
override fun child(ns: String?, name: String?) = object : NodeVisitor() {
|
||||
override fun attr(ns: String?, name: String?, resourceId: Int, type: Int, value: Any?) {
|
||||
if (name == PACKAGE && value is String) originalPackage = value
|
||||
}
|
||||
}
|
||||
})
|
||||
val origPkg = originalPackage ?: "com.aspiro.tidal"
|
||||
|
||||
val reader = AxmlReader(manifestBytes)
|
||||
val writer = AxmlWriter()
|
||||
|
||||
@@ -42,6 +57,11 @@ object ManifestPatcher {
|
||||
COMPILE_SDK_VERSION_CODENAME to "6.0-2438415"
|
||||
)
|
||||
) {
|
||||
// Drop split-only manifest attributes — we merged all splits into one APK
|
||||
override fun attr(ns: String?, name: String, resourceId: Int, type: Int, value: Any?) {
|
||||
if (name == IS_SPLIT_REQUIRED || name == REQUIRED_SPLIT_TYPES || name == SPLIT_TYPES) return
|
||||
super.attr(ns, name, resourceId, type, value)
|
||||
}
|
||||
private var addExternalStoragePerm = false
|
||||
|
||||
override fun child(ns: String?, name: String): NodeVisitor {
|
||||
@@ -84,7 +104,7 @@ object ManifestPatcher {
|
||||
super.attr(
|
||||
ns, name, resourceId, type,
|
||||
when (name) {
|
||||
"name" -> (value as String).replace("com.tidal.android", packageName)
|
||||
"name" -> (value as String).replace(origPkg, packageName)
|
||||
else -> value
|
||||
}
|
||||
)
|
||||
@@ -135,7 +155,7 @@ object ManifestPatcher {
|
||||
super.attr(
|
||||
ns, name, resourceId, type,
|
||||
if (name == "authorities") {
|
||||
(value as String).replace("com.tidal.android", packageName)
|
||||
(value as String).replace(origPkg, packageName)
|
||||
} else {
|
||||
value
|
||||
}
|
||||
|
||||
@@ -9,11 +9,17 @@ A Manager app for Android that patches TIDAL to bring the Radiant Lyrics experie
|
||||
- Hides the ugly cover art when in lyrics mode
|
||||
- Syllable Level lyrics (SoonTM)
|
||||
|
||||
|
||||
### Disclaimer
|
||||
|
||||
This project is not affiliated with TIDAL in any way. Use at your own risk.
|
||||
- I can't guarantee using this project won't result in any platform enforcement **(Bans)**
|
||||
|
||||
## Installation
|
||||
|
||||
### Batteries <3
|
||||
- Android 8.0+
|
||||
- TIDAL app (v2.192.0 / build 9089)
|
||||
- Android 10.0+ & >340 DPI
|
||||
- Paid TIDAL Account
|
||||
|
||||
### Steps
|
||||
1. Download the latest `rl-manager.apk` from [Releases](../../releases/latest)
|
||||
|
||||
Reference in New Issue
Block a user