Fix potential bug with the in-app updater.
This commit is contained in:
parent
8c255256c9
commit
750825b3c3
2 changed files with 12 additions and 2 deletions
|
@ -15,6 +15,7 @@ import org.signal.core.util.StreamUtil
|
|||
import org.signal.core.util.getDownloadManager
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.jobs.ApkUpdateJob
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.util.Environment
|
||||
import org.thoughtcrime.securesms.util.FileUtils
|
||||
|
@ -38,7 +39,9 @@ object ApkUpdateInstaller {
|
|||
*/
|
||||
fun installOrPromptForInstall(context: Context, downloadId: Long, userInitiated: Boolean) {
|
||||
if (downloadId != SignalStore.apkUpdate().downloadId) {
|
||||
Log.w(TAG, "DownloadId doesn't match the one we're waiting for! We likely have newer data. Ignoring.")
|
||||
Log.w(TAG, "DownloadId doesn't match the one we're waiting for (current: $downloadId, expected: ${SignalStore.apkUpdate().downloadId})! We likely have newer data. Ignoring.")
|
||||
ApkUpdateNotifications.dismissInstallPrompt(context)
|
||||
ApplicationDependencies.getJobManager().add(ApkUpdateJob())
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ object ApkUpdateNotifications {
|
|||
*/
|
||||
@SuppressLint("LaunchActivityFromNotification")
|
||||
fun showInstallPrompt(context: Context, downloadId: Long) {
|
||||
Log.d(TAG, "Showing install prompt. DownloadId: $downloadId")
|
||||
ServiceUtil.getNotificationManager(context).cancel(NotificationIds.APK_UPDATE_FAILED_INSTALL)
|
||||
|
||||
val pendingIntent = PendingIntent.getBroadcast(
|
||||
|
@ -39,7 +40,7 @@ object ApkUpdateNotifications {
|
|||
action = ApkUpdateNotificationReceiver.ACTION_INITIATE_INSTALL
|
||||
putExtra(ApkUpdateNotificationReceiver.EXTRA_DOWNLOAD_ID, downloadId)
|
||||
},
|
||||
PendingIntentFlags.immutable()
|
||||
PendingIntentFlags.updateCurrent()
|
||||
)
|
||||
|
||||
val notification = NotificationCompat.Builder(context, NotificationChannels.getInstance().APP_UPDATES)
|
||||
|
@ -54,7 +55,13 @@ object ApkUpdateNotifications {
|
|||
ServiceUtil.getNotificationManager(context).notify(NotificationIds.APK_UPDATE_PROMPT_INSTALL, notification)
|
||||
}
|
||||
|
||||
fun dismissInstallPrompt(context: Context) {
|
||||
Log.d(TAG, "Dismissing install prompt.")
|
||||
ServiceUtil.getNotificationManager(context).cancel(NotificationIds.APK_UPDATE_PROMPT_INSTALL)
|
||||
}
|
||||
|
||||
fun showInstallFailed(context: Context, reason: FailureReason) {
|
||||
Log.d(TAG, "Showing failed notification. Reason: $reason")
|
||||
ServiceUtil.getNotificationManager(context).cancel(NotificationIds.APK_UPDATE_PROMPT_INSTALL)
|
||||
|
||||
val pendingIntent = PendingIntent.getActivity(
|
||||
|
|
Loading…
Add table
Reference in a new issue