Fix nightly updates.
This commit is contained in:
parent
e486a4baef
commit
2dd0899a3d
9 changed files with 111 additions and 8 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -3,6 +3,7 @@ captures/
|
|||
project.properties
|
||||
keystore.debug.properties
|
||||
keystore.staging.properties
|
||||
nightly-url.txt
|
||||
.project
|
||||
.settings
|
||||
bin/
|
||||
|
@ -28,4 +29,4 @@ jni/libspeex/.deps/
|
|||
pkcs11.password
|
||||
dev.keystore
|
||||
maps.key
|
||||
local/
|
||||
local/
|
||||
|
|
|
@ -333,8 +333,8 @@ android {
|
|||
|
||||
nightly {
|
||||
def apkUpdateManifestUrl = "<unset>"
|
||||
if (project.hasProperty('nightlyApkUpdateManifestUrl')) {
|
||||
apkUpdateManifestUrl = project.getProperty('nightlyApkUpdateManifestUrl')
|
||||
if (file("${project.rootDir}/nightly-url.txt").exists()) {
|
||||
apkUpdateManifestUrl = file("${project.rootDir}/nightly-url.txt").text.trim()
|
||||
}
|
||||
dimension 'distribution'
|
||||
versionNameSuffix "-nightly-untagged-${getDateSuffix()}"
|
||||
|
@ -675,8 +675,9 @@ project.tasks.configureEach { task ->
|
|||
tasks.register('checkNightlyParams') {
|
||||
doFirst {
|
||||
if (project.gradle.startParameter.taskNames.any { it.toLowerCase().contains("nightly") }) {
|
||||
if (!project.hasProperty('nightlyApkUpdateManifestUrl')) {
|
||||
throw new GradleException("Required command-line parameter 'nightlyApkUpdateManifestUrl' not found for nightly build!")
|
||||
|
||||
if (!file("${project.rootDir}/nightly-url.txt").exists()) {
|
||||
throw new GradleException("Cannot fine 'nightly-url.txt' for nightly build! It must exist in the root of this project and contain the location of the nightly manifest.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.thoughtcrime.securesms.keyvalue.SignalStore
|
|||
import org.thoughtcrime.securesms.phonenumbers.PhoneNumberFormatter
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.registration.RegistrationNavigationActivity
|
||||
import org.thoughtcrime.securesms.util.Environment
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags
|
||||
import org.thoughtcrime.securesms.util.PlayStoreUtil
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
|
@ -232,6 +233,16 @@ class AppSettingsFragment : DSLSettingsFragment(
|
|||
}
|
||||
)
|
||||
|
||||
if (Environment.IS_NIGHTLY) {
|
||||
clickPref(
|
||||
title = DSLSettingsText.from("App updates"),
|
||||
icon = DSLSettingsIcon.from(R.drawable.symbol_calendar_24),
|
||||
onClick = {
|
||||
findNavController().safeNavigate(R.id.action_appSettingsFragment_to_appUpdatesSettingsFragment)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
dividerPref()
|
||||
|
||||
if (SignalStore.paymentsValues().paymentsAvailability.showPaymentsMenu()) {
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright 2023 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.thoughtcrime.securesms.components.settings.app.updates
|
||||
|
||||
import android.os.Build
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.components.settings.DSLConfiguration
|
||||
import org.thoughtcrime.securesms.components.settings.DSLSettingsFragment
|
||||
import org.thoughtcrime.securesms.components.settings.DSLSettingsText
|
||||
import org.thoughtcrime.securesms.components.settings.configure
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.jobs.ApkUpdateJob
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.util.adapter.mapping.MappingAdapter
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* Settings around app updates. Only shown for builds that manage their own app updates.
|
||||
*/
|
||||
class AppUpdatesSettingsFragment : DSLSettingsFragment(R.string.preferences_app_updates__title) {
|
||||
|
||||
override fun bindAdapter(adapter: MappingAdapter) {
|
||||
adapter.submitList(getConfiguration().toMappingModelList())
|
||||
}
|
||||
|
||||
private fun getConfiguration(): DSLConfiguration {
|
||||
return configure {
|
||||
if (Build.VERSION.SDK_INT >= 31) {
|
||||
switchPref(
|
||||
title = DSLSettingsText.from("Automatic updates"),
|
||||
summary = DSLSettingsText.from("Automatically download and install app updates"),
|
||||
isChecked = SignalStore.apkUpdate().autoUpdate,
|
||||
onClick = {
|
||||
SignalStore.apkUpdate().autoUpdate = !SignalStore.apkUpdate().autoUpdate
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
clickPref(
|
||||
title = DSLSettingsText.from("Check for updates"),
|
||||
summary = DSLSettingsText.from("Last checked on: $lastSuccessfulUpdateString"),
|
||||
onClick = {
|
||||
ApplicationDependencies.getJobManager().add(ApkUpdateJob())
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private val lastSuccessfulUpdateString: String
|
||||
get() {
|
||||
val lastUpdateTime = SignalStore.apkUpdate().lastSuccessfulCheck
|
||||
|
||||
return if (lastUpdateTime > 0) {
|
||||
val dateFormat = SimpleDateFormat("MMMM dd, yyyy 'at' h:mma", Locale.US)
|
||||
dateFormat.format(Date(lastUpdateTime))
|
||||
} else {
|
||||
"Never"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -60,7 +60,7 @@ class ApkUpdateJob private constructor(parameters: Parameters) : BaseJob(paramet
|
|||
return
|
||||
}
|
||||
|
||||
Log.i(TAG, "Checking for APK update...")
|
||||
Log.d(TAG, "Checking for APK update at ${BuildConfig.APK_UPDATE_MANIFEST_URL}")
|
||||
|
||||
val client = OkHttpClient()
|
||||
val request = Request.Builder().url(BuildConfig.APK_UPDATE_MANIFEST_URL).build()
|
||||
|
@ -78,10 +78,11 @@ class ApkUpdateJob private constructor(parameters: Parameters) : BaseJob(paramet
|
|||
Log.w(TAG, "Invalid update descriptor! $updateDescriptor")
|
||||
return
|
||||
} else {
|
||||
Log.i(TAG, "Got descriptor: $updateDescriptor")
|
||||
Log.d(TAG, "Got descriptor: $updateDescriptor")
|
||||
}
|
||||
|
||||
if (updateDescriptor.versionCode > getCurrentAppVersionCode()) {
|
||||
Log.i(TAG, "Newer version code available. Current: ${getCurrentAppVersionCode()}, Update: ${updateDescriptor.versionCode}")
|
||||
val digest: ByteArray = Hex.fromStringCondensed(updateDescriptor.digest)
|
||||
val downloadStatus: DownloadStatus = getDownloadStatus(updateDescriptor.url, digest)
|
||||
|
||||
|
@ -94,7 +95,11 @@ class ApkUpdateJob private constructor(parameters: Parameters) : BaseJob(paramet
|
|||
Log.i(TAG, "Download status missing, starting download...")
|
||||
handleDownloadStart(updateDescriptor.url, updateDescriptor.versionName, digest)
|
||||
}
|
||||
} else {
|
||||
Log.d(TAG, "Version code is the same or older than our own. Current: ${getCurrentAppVersionCode()}, Update: ${updateDescriptor.versionCode}")
|
||||
}
|
||||
|
||||
SignalStore.apkUpdate().lastSuccessfulCheck = System.currentTimeMillis()
|
||||
}
|
||||
|
||||
public override fun onShouldRetry(e: Exception): Boolean {
|
||||
|
|
|
@ -10,6 +10,7 @@ internal class ApkUpdateValues(store: KeyValueStore) : SignalStoreValues(store)
|
|||
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"
|
||||
private const val LAST_SUCCESSFUL_CHECK = "apk_update.last_successful_check"
|
||||
}
|
||||
|
||||
override fun onFirstEverAppLaunch() = Unit
|
||||
|
@ -17,7 +18,8 @@ internal class ApkUpdateValues(store: KeyValueStore) : SignalStoreValues(store)
|
|||
|
||||
val downloadId: Long by longValue(DOWNLOAD_ID, -2)
|
||||
val digest: ByteArray? get() = store.getBlob(DIGEST, null)
|
||||
val autoUpdate: Boolean by booleanValue(AUTO_UPDATE, true)
|
||||
var autoUpdate: Boolean by booleanValue(AUTO_UPDATE, true)
|
||||
var lastSuccessfulCheck: Long by longValue(LAST_SUCCESSFUL_CHECK, 0)
|
||||
|
||||
fun setDownloadAttributes(id: Long, digest: ByteArray?) {
|
||||
store
|
||||
|
|
|
@ -91,6 +91,9 @@ public class LogSectionSystemInfo implements LogSection {
|
|||
builder.append("User-Agent : ").append(StandardUserAgentInterceptor.USER_AGENT).append("\n");
|
||||
builder.append("SlowNotifications : ").append(SlowNotificationHeuristics.isHavingDelayedNotifications()).append("\n");
|
||||
builder.append("PotentiallyBattery: ").append(SlowNotificationHeuristics.isPotentiallyCausedByBatteryOptimizations()).append("\n");
|
||||
if (BuildConfig.MANAGES_APP_UPDATES) {
|
||||
builder.append("ApkManifestUrl : ").append(BuildConfig.APK_UPDATE_MANIFEST_URL).append("\n");
|
||||
}
|
||||
builder.append("App : ");
|
||||
|
||||
try {
|
||||
|
|
|
@ -106,6 +106,13 @@
|
|||
app:exitAnim="@anim/fragment_open_exit"
|
||||
app:popEnterAnim="@anim/fragment_close_enter"
|
||||
app:popExitAnim="@anim/fragment_close_exit" />
|
||||
<action
|
||||
android:id="@+id/action_appSettingsFragment_to_appUpdatesSettingsFragment"
|
||||
app:destination="@id/appUpdatesFragment"
|
||||
app:enterAnim="@anim/fragment_open_enter"
|
||||
app:exitAnim="@anim/fragment_open_exit"
|
||||
app:popEnterAnim="@anim/fragment_close_enter"
|
||||
app:popExitAnim="@anim/fragment_close_exit" />
|
||||
<action
|
||||
android:id="@+id/action_appSettingsFragment_to_internalSettingsFragment"
|
||||
app:destination="@id/internalSettingsFragment"
|
||||
|
@ -644,6 +651,13 @@
|
|||
|
||||
<!-- endregion -->
|
||||
|
||||
<!-- App updates -->
|
||||
|
||||
<fragment
|
||||
android:id="@+id/appUpdatesFragment"
|
||||
android:name="org.thoughtcrime.securesms.components.settings.app.updates.AppUpdatesSettingsFragment"
|
||||
android:label="app_update_fragment" />
|
||||
|
||||
<!-- Subscriptions -->
|
||||
<fragment
|
||||
android:id="@+id/manageDonationsFragment"
|
||||
|
|
|
@ -3018,6 +3018,7 @@
|
|||
<!-- Privacy settings payments section title -->
|
||||
<string name="preferences_app_protection__payments">Payments</string>
|
||||
<string name="preferences_chats__chats">Chats</string>
|
||||
<string name="preferences_app_updates__title">App updates</string>
|
||||
<string name="preferences_data_and_storage__manage_storage">Manage storage</string>
|
||||
<string name="preferences_data_and_storage__use_less_data_for_calls">Use less data for calls</string>
|
||||
<string name="preferences_data_and_storage__never">Never</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue