Conversation
Bnyro
reviewed
Oct 1, 2026
Comment on lines
+96
to
+100
| if (tempFile.renameTo(targetFile)) { | ||
| targetFile | ||
| } else { | ||
| tempFile | ||
| } |
Contributor
There was a problem hiding this comment.
Why should this rename fail? In case it's because targetFile could still exist, we should delete targetFile first.
Bnyro
reviewed
Oct 1, 2026
Comment on lines
+120
to
+126
| val installParams = | ||
| PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL) | ||
|
|
||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
| installParams.setRequireUserAction(PackageInstaller.SessionParams.USER_ACTION_NOT_REQUIRED) | ||
| } | ||
| installParams.setSize(length) |
Contributor
There was a problem hiding this comment.
Suggested change
| val installParams = | |
| PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL) | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | |
| installParams.setRequireUserAction(PackageInstaller.SessionParams.USER_ACTION_NOT_REQUIRED) | |
| } | |
| installParams.setSize(length) | |
| val installParams = | |
| PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL) | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | |
| installParams.setRequireUserAction(PackageInstaller.SessionParams.USER_ACTION_NOT_REQUIRED) | |
| } | |
| installParams.setSize(length) |
Please properly group code.
Bnyro
reviewed
Oct 1, 2026
|
|
||
| // If automated background search, download the update APK silently in advance | ||
| if (!fromUser) { | ||
| val activity = com.lagradost.cloudstream3.CommonActivity.activity |
Contributor
There was a problem hiding this comment.
Suggested change
| val activity = com.lagradost.cloudstream3.CommonActivity.activity | |
| val activity = CommonActivity.activity |
Bnyro
reviewed
Oct 1, 2026
| ) | ||
|
|
||
| private fun deleteCachedApk(tagName: String) { | ||
| val activity = com.lagradost.cloudstream3.CommonActivity.activity |
Contributor
There was a problem hiding this comment.
Suggested change
| val activity = com.lagradost.cloudstream3.CommonActivity.activity | |
| val activity = CommonActivity.activity |
Bnyro
reviewed
Oct 1, 2026
Comment on lines
+136
to
+143
|
|
||
| val receiverIntent = Intent(activity, PackageInstallerStatusReceiver::class.java) | ||
| val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
| PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT | ||
| } else { | ||
| PendingIntent.FLAG_UPDATE_CURRENT | ||
| } | ||
| val receiverPendingIntent = PendingIntent.getBroadcast(activity, 0, receiverIntent, flags) |
Contributor
There was a problem hiding this comment.
Maybe it's possible to use PendingIntentCompat instead to simplify the code?
Bnyro
reviewed
Oct 1, 2026
Comment on lines
+117
to
+151
| var sessionId: Int? = null | ||
| val packageInstaller = activity.packageManager.packageInstaller | ||
| try { | ||
| val installParams = | ||
| PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL) | ||
|
|
||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
| installParams.setRequireUserAction(PackageInstaller.SessionParams.USER_ACTION_NOT_REQUIRED) | ||
| } | ||
| installParams.setSize(length) | ||
|
|
||
| sessionId = packageInstaller.createSession(installParams) | ||
| val session = packageInstaller.openSession(sessionId) | ||
|
|
||
| session.openWrite(activity.packageName, 0, length) | ||
| .use { writeStream -> | ||
| transfer(writeStream, inputStream, length, installProgress, null) | ||
| session.fsync(writeStream) | ||
| } | ||
|
|
||
| val receiverIntent = Intent(activity, PackageInstallerStatusReceiver::class.java) | ||
| val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
| PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT | ||
| } else { | ||
| PendingIntent.FLAG_UPDATE_CURRENT | ||
| } | ||
| val receiverPendingIntent = PendingIntent.getBroadcast(activity, 0, receiverIntent, flags) | ||
| session.commit(receiverPendingIntent.intentSender) | ||
| session.close() | ||
| } catch (t: Throwable) { | ||
| sessionId?.let { id -> | ||
| packageInstaller.abandonSession(id) | ||
| } | ||
| throw t | ||
| } |
Contributor
There was a problem hiding this comment.
This is all just copy and paste from packageInstallerDownloader, you should move it into a new, shared method instead of copy and pasting.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Builds directly on top of the newly merged Compose updater (#3204) by introducing silent background pre-downloading and immediate installation from cached APKs with real-time in-app progress.
What this adds to the Compose updater
Silent Background Pre-download:
Instant Installation from Cache:
In-App Installation Progress in Compose:
Cache Clean-up on Skip:
Verification