-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: install button not appearing on android 8 #3333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -117,29 +117,33 @@ class PatcherWorker( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // This does not always show up for some reason. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| createNotificationChannel() // Safe to call multiple times | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The channel ID |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setForeground(getForegroundInfo()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (e: Exception) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Log.d(tag, "Failed to set foreground info:", e) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Log.e(tag, "Failed to set foreground info:", e) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // On Android 8, if this fails, the job is likely doomed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return Result.failure() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| val wakeLock: PowerManager.WakeLock = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (applicationContext.getSystemService(Context.POWER_SERVICE) as PowerManager) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "$tag::Patcher") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .apply { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| acquire(10 * 60 * 1000L) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Log.d(tag, "Acquired wakelock.") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing the |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| val args = workerRepository.claimInput(this) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runPatcher(args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } finally { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| wakeLock.release() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runPatcher(args) // WorkManager holds its own WakeLock internally | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+120
to
+131
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the change here? The code looks exactly the same.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah the suggestion does look kinda weird.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. iirc, WorkManager doesn't holds WakeLock
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assumed the statement in the comment was true. Is it documented anywhere?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See conversation in #2147 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (e: Exception) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Log.e(tag, "Patcher encountered an error", e) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Result.failure() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returning |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private fun createNotificationChannel() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| val channel = NotificationChannel( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "patcher_channel", "Patcher Service", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NotificationManager.IMPORTANCE_LOW | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| val manager = applicationContext.getSystemService(NotificationManager::class.java) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| manager.createNotificationChannel(channel) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private suspend fun runPatcher(args: Args): Result { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| val patchedApk = fs.tempDir.resolve("patched.apk") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating the notification channel here should be unnecessary, as it has already been done within the
createNotification()method above that is called fromgetForegroundInfo().Also, if you have really confirmed that creating a notification channel twice here fixes the problem, use the same method within createNotification().
The ID of the notification channel created by the new method is different from the one that is actually being used.
This change will make a duplicate notification channel.