Add additional logging around apk updates.

This commit is contained in:
Greyson Parrelli 2023-11-10 08:56:21 -05:00
parent fcf36c4bc0
commit a0792d166b
3 changed files with 21 additions and 5 deletions

View file

@ -36,9 +36,13 @@ class ApkUpdatePackageInstallerReceiver : BroadcastReceiver() {
when (statusCode) {
PackageInstaller.STATUS_SUCCESS -> {
Log.i(TAG, "Update installed successfully!")
SignalStore.apkUpdate().lastApkUploadTime = SignalStore.apkUpdate().pendingApkUploadTime
ApkUpdateNotifications.showAutoUpdateSuccess(context)
if (SignalStore.apkUpdate().lastApkUploadTime != SignalStore.apkUpdate().pendingApkUploadTime) {
Log.i(TAG, "Update installed successfully! Updating our lastApkUploadTime to ${SignalStore.apkUpdate().pendingApkUploadTime}")
SignalStore.apkUpdate().lastApkUploadTime = SignalStore.apkUpdate().pendingApkUploadTime
ApkUpdateNotifications.showAutoUpdateSuccess(context)
} else {
Log.i(TAG, "Spurious 'success' notification?")
}
}
PackageInstaller.STATUS_PENDING_USER_ACTION -> handlePendingUserAction(context, userInitiated, intent!!)
PackageInstaller.STATUS_FAILURE_ABORTED -> ApkUpdateNotifications.showInstallFailed(context, FailureReason.ABORTED)

View file

@ -2,7 +2,6 @@ package org.thoughtcrime.securesms.components.settings.app.usernamelinks.colorpi
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.Image
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column

View file

@ -5,8 +5,12 @@
package org.thoughtcrime.securesms.keyvalue
import org.signal.core.util.logging.Log
internal class ApkUpdateValues(store: KeyValueStore) : SignalStoreValues(store) {
companion object {
private val TAG = Log.tag(ApkUpdateValues::class.java)
private const val DOWNLOAD_ID = "apk_update.download_id"
private const val DIGEST = "apk_update.digest"
private const val AUTO_UPDATE = "apk_update.auto_update"
@ -24,12 +28,19 @@ internal class ApkUpdateValues(store: KeyValueStore) : SignalStoreValues(store)
var lastSuccessfulCheck: Long by longValue(LAST_SUCCESSFUL_CHECK, 0)
/** The upload of the last APK we installed */
var lastApkUploadTime: Long by longValue(LAST_APK_UPLOAD_TIME, 0)
var lastApkUploadTime: Long
get() = getLong(LAST_APK_UPLOAD_TIME, 0)
set(value) {
Log.d(TAG, "Setting lastApkUploadTime to $value")
store.beginWrite().putLong(LAST_APK_UPLOAD_TIME, value).commit()
}
/** The upload time of the APK we're trying to install */
val pendingApkUploadTime: Long by longValue(PENDING_APK_UPLOAD_TIME, 0)
fun setDownloadAttributes(id: Long, digest: ByteArray?, apkUploadTime: Long) {
Log.d(TAG, "Saving download attributes. id: $id, apkUploadTime: $apkUploadTime")
store
.beginWrite()
.putLong(DOWNLOAD_ID, id)
@ -39,6 +50,8 @@ internal class ApkUpdateValues(store: KeyValueStore) : SignalStoreValues(store)
}
fun clearDownloadAttributes() {
Log.d(TAG, "Clearing download attributes.")
store
.beginWrite()
.putLong(DOWNLOAD_ID, -1)