Skip to content

Commit 5cafd1e

Browse files
committed
ui: use debug key in debug builds
Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 5199132 commit 5cafd1e

File tree

1 file changed

+8
-6
lines changed
  • ui/src/main/java/com/wireguard/android/updater

1 file changed

+8
-6
lines changed

ui/src/main/java/com/wireguard/android/updater/Updater.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@ import kotlin.time.Duration.Companion.seconds
4444

4545
object Updater {
4646
private const val TAG = "WireGuard/Updater"
47-
private const val LATEST_VERSION_URL = "https://download.wireguard.com/android-client/latest.sig"
48-
private const val APK_PATH_URL = "https://download.wireguard.com/android-client/%s"
49-
private val APK_NAME_PREFIX = BuildConfig.APPLICATION_ID.removeSuffix(".debug") + "-"
47+
private const val UPDATE_URL_FMT = "https://download.wireguard.com/android-client/%s"
48+
private const val APK_NAME_PREFIX = BuildConfig.APPLICATION_ID + "-"
5049
private const val APK_NAME_SUFFIX = ".apk"
51-
private const val RELEASE_PUBLIC_KEY_BASE64 = "RWTAzwGRYr3EC9px0Ia3fbttz8WcVN6wrOwWp2delz4el6SI8XmkKSMp"
5250
private val CURRENT_VERSION = Version(BuildConfig.VERSION_NAME.removeSuffix("-debug"))
51+
private val LATEST_FILE = if (BuildConfig.DEBUG) "latest-debug.sig" else "latest.sig"
52+
private val RELEASE_PUBLIC_KEY_BASE64 =
53+
if (BuildConfig.DEBUG) "RWTKFCNaLimMkuolGwAw12XT6sx+nnS7KE1wmhJ7YHXvAPedtPR/rofU"
54+
else "RWTAzwGRYr3EC9px0Ia3fbttz8WcVN6wrOwWp2delz4el6SI8XmkKSMp"
5355

5456
private val updaterScope = CoroutineScope(Job() + Dispatchers.IO)
5557

@@ -213,7 +215,7 @@ object Updater {
213215
}
214216

215217
private fun checkForUpdates(): Update? {
216-
val connection = URL(LATEST_VERSION_URL).openConnection() as HttpURLConnection
218+
val connection = URL(UPDATE_URL_FMT.format(LATEST_FILE)).openConnection() as HttpURLConnection
217219
connection.setRequestProperty("User-Agent", Application.USER_AGENT)
218220
connection.connect()
219221
if (connection.responseCode != HttpURLConnection.HTTP_OK)
@@ -249,7 +251,7 @@ object Updater {
249251
}
250252

251253
emitProgress(Progress.Downloading(0UL, 0UL), true)
252-
val connection = URL(APK_PATH_URL.format(update.fileName)).openConnection() as HttpURLConnection
254+
val connection = URL(UPDATE_URL_FMT.format(update.fileName)).openConnection() as HttpURLConnection
253255
connection.setRequestProperty("User-Agent", Application.USER_AGENT)
254256
connection.connect()
255257
if (connection.responseCode != HttpURLConnection.HTTP_OK)

0 commit comments

Comments
 (0)