mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-15 07:28:30 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f44b9b1680 | ||
|
|
a1ba051407 | ||
|
|
0ef39afaef | ||
|
|
9360db176b | ||
|
|
cd8c75bc78 |
@@ -34,14 +34,14 @@ ktlint {
|
||||
}
|
||||
|
||||
def canonicalVersionCode = 1361
|
||||
def canonicalVersionName = "6.40.4"
|
||||
def canonicalVersionName = "6.40.5"
|
||||
|
||||
def postFixSize = 100
|
||||
def abiPostFix = ['universal' : 0,
|
||||
'armeabi-v7a' : 1,
|
||||
'arm64-v8a' : 2,
|
||||
'x86' : 3,
|
||||
'x86_64' : 4]
|
||||
def abiPostFix = ['universal' : 5,
|
||||
'armeabi-v7a' : 6,
|
||||
'arm64-v8a' : 7,
|
||||
'x86' : 8,
|
||||
'x86_64' : 9]
|
||||
|
||||
def keystores = [ 'debug' : loadKeystoreProperties('keystore.debug.properties') ]
|
||||
|
||||
|
||||
@@ -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,9 @@ 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(
|
||||
context,
|
||||
1,
|
||||
@@ -37,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)
|
||||
@@ -52,7 +55,15 @@ 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(
|
||||
context,
|
||||
0,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -127,6 +127,7 @@ public class PhoneNumberFormatter {
|
||||
}
|
||||
|
||||
if (isShortCode(bareNumber, localCountryCode)) {
|
||||
Log.i(TAG, "Shortcode detected.");
|
||||
return bareNumber;
|
||||
}
|
||||
|
||||
@@ -165,7 +166,7 @@ public class PhoneNumberFormatter {
|
||||
private boolean isShortCode(@NonNull String bareNumber, String localCountryCode) {
|
||||
try {
|
||||
Phonenumber.PhoneNumber parsedNumber = phoneNumberUtil.parse(bareNumber, localCountryCode);
|
||||
return ShortNumberInfo.getInstance().isPossibleShortNumberForRegion(parsedNumber, localCountryCode);
|
||||
return ShortNumberInfo.getInstance().isValidShortNumberForRegion(parsedNumber, localCountryCode);
|
||||
} catch (NumberParseException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user