diff options
author | cyberta <cyberta@riseup.net> | 2022-07-18 21:57:07 +0000 |
---|---|---|
committer | cyberta <cyberta@riseup.net> | 2022-07-18 21:57:07 +0000 |
commit | abd8c8d06f01cc5b794a18779c2ea36b9317b4e3 (patch) | |
tree | 3bf4274594bc45c879093adbab58c2ec7a142146 /app/src/fatweb/java/se.leap.bitmaskclient | |
parent | f90e72fb3e90d561a433278f251ee27297b42001 (diff) | |
parent | 6ad47f6665312cfbc5c9b9e9bae1088d91b8dc99 (diff) |
Merge branch 'eip-service.json_updates' into 'master'
Fix auto-check issues after successful connection attempt
Closes #9093
See merge request leap/bitmask_android!197
Diffstat (limited to 'app/src/fatweb/java/se.leap.bitmaskclient')
3 files changed, 36 insertions, 5 deletions
diff --git a/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadNotificationManager.java b/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadNotificationManager.java index 1a88000b..336802c6 100644 --- a/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadNotificationManager.java +++ b/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadNotificationManager.java @@ -84,6 +84,7 @@ public class DownloadNotificationManager { notificationBuilder .setDefaults(Notification.DEFAULT_ALL) .setAutoCancel(false) + .setNotificationSilent() .setOngoing(true) .setSmallIcon(android.R.drawable.stat_sys_download) .setContentTitle(context.getString(R.string.version_update_apk_description, context.getString(R.string.app_name))) diff --git a/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadServiceCommand.java b/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadServiceCommand.java index 4e0d9079..41efd621 100644 --- a/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadServiceCommand.java +++ b/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadServiceCommand.java @@ -18,6 +18,7 @@ package se.leap.bitmaskclient.appUpdate; import android.content.Context; import android.content.Intent; +import android.os.Bundle; import android.os.ResultReceiver; import androidx.annotation.NonNull; @@ -31,18 +32,27 @@ public class DownloadServiceCommand { CHECK_VERSION_FILE = "checkVersionFile", DOWNLOAD_UPDATE = "downloadUpdate"; - private Context context; - private String action; - private ResultReceiver resultReceiver; + private final Context context; + private final String action; + private Bundle parameters; + private final ResultReceiver resultReceiver; private DownloadServiceCommand(@NonNull Context context, @NonNull String action) { - this(context.getApplicationContext(), action, null); + this(context.getApplicationContext(), action, null, null); } + private DownloadServiceCommand(@NonNull Context context, @NonNull String action, @Nullable Bundle parameters) { + this(context.getApplicationContext(), action, parameters, null); + } private DownloadServiceCommand(@NonNull Context context, @NonNull String action, @Nullable ResultReceiver resultReceiver) { + this(context.getApplicationContext(), action, null, resultReceiver); + } + + private DownloadServiceCommand(@NonNull Context context, @NonNull String action, @Nullable Bundle parameters, @Nullable ResultReceiver resultReceiver) { super(); this.context = context; this.action = action; + this.parameters = parameters; this.resultReceiver = resultReceiver; } @@ -53,6 +63,10 @@ public class DownloadServiceCommand { if (resultReceiver != null) { command.putExtra(ProviderAPI.RECEIVER_KEY, resultReceiver); } + if (parameters == null) { + parameters = Bundle.EMPTY; + } + command.putExtra(ProviderAPI.PARAMETERS, parameters); return command; } @@ -73,7 +87,12 @@ public class DownloadServiceCommand { command.execute(); } - public static void execute(Context context, String action, ResultReceiver resultReceiver) { + public static void execute(Context context, String action, Bundle parameters) { + DownloadServiceCommand command = new DownloadServiceCommand(context, action, parameters); + command.execute(); + } + + public static void execute(Context context, String action, Bundle parameters, ResultReceiver resultReceiver) { DownloadServiceCommand command = new DownloadServiceCommand(context, action, resultReceiver); command.execute(); } diff --git a/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/UpdateDownloadManager.java b/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/UpdateDownloadManager.java index b50c587c..109164c5 100644 --- a/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/UpdateDownloadManager.java +++ b/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/UpdateDownloadManager.java @@ -48,6 +48,8 @@ import static se.leap.bitmaskclient.base.models.Constants.BROADCAST_DOWNLOAD_SER import static se.leap.bitmaskclient.base.models.Constants.BROADCAST_RESULT_CODE; import static se.leap.bitmaskclient.base.models.Constants.BROADCAST_RESULT_KEY; import static se.leap.bitmaskclient.base.utils.FileHelper.readPublicKey; +import static se.leap.bitmaskclient.providersetup.ProviderAPI.DELAY; +import static se.leap.bitmaskclient.providersetup.ProviderAPI.PARAMETERS; import static se.leap.bitmaskclient.providersetup.ProviderAPI.RECEIVER_KEY; public class UpdateDownloadManager implements Logger, DownloadConnector.DownloadProgress { @@ -93,6 +95,15 @@ public class UpdateDownloadManager implements Logger, DownloadConnector.Download receiver = command.getParcelableExtra(RECEIVER_KEY); } String action = command.getAction(); + Bundle parameters = command.getBundleExtra(PARAMETERS); + + if (parameters.containsKey(DELAY)) { + try { + Thread.sleep(parameters.getLong(DELAY)); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } Bundle result = new Bundle(); switch (action) { |