fast4x / RiMusic

A multilingual Android application for streaming music from YouTube Music.
https://rimusic.xyz
GNU General Public License v3.0
2.63k stars 134 forks source link

[Feature]: Delta Patch Update, for New Patches and Version #4406

Open M-505 opened 2 weeks ago

M-505 commented 2 weeks ago

Description

Introduce, https://en.wikipedia.org/wiki/Delta_update

Suggested Solution

this prevent to download the whole apk to install, especially in certain area, there are some limitation as my phone don't allow external apk due to work profile, this causes inconvenience to download the whole APK once again, I suggest adding a delta patch, which allow

`// Example to download a patch file (delta update) using Kotlin
fun downloadDeltaUpdate(patchUrl: String, outputPath: String) {
    val url = URL(patchUrl)
    val connection = url.openConnection() as HttpURLConnection
    connection.requestMethod = "GET"
    connection.connect()

    val inputStream = connection.inputStream
    val outputStream = FileOutputStream(outputPath)

    val buffer = ByteArray(1024)
    var length: Int
    while (inputStream.read(buffer).also { length = it } != -1) {
        outputStream.write(buffer, 0, length)
    }

    inputStream.close()
    outputStream.close()
}

// Applying the delta update (patch)
fun applyDeltaPatch(originalApk: String, patchFile: String, outputApk: String) {
    // Use a library like xdelta or bsdiff to apply the patch
    val command = arrayOf("xdelta3", "-d", "-s", originalApk, patchFile, outputApk)
    val process = Runtime.getRuntime().exec(command)
    process.waitFor() // Wait for the process to complete
}
` 

Alternatives

No response

Additional Context

No response

fast4x commented 2 weeks ago

Hi thanks but this require external command execution and isn't secure.