summaryrefslogtreecommitdiff
path: root/app/src/fatweb/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/fatweb/java')
-rw-r--r--app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadService.java6
-rw-r--r--app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/InstallActivity.java12
-rw-r--r--app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/UpdateDownloadManager.java53
3 files changed, 48 insertions, 23 deletions
diff --git a/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadService.java b/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadService.java
index 46c0457b..9fd3dfb3 100644
--- a/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadService.java
+++ b/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadService.java
@@ -60,6 +60,12 @@ public class DownloadService extends JobIntentService implements UpdateDownloadM
updateDownloadManager.handleIntent(intent);
}
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ updateDownloadManager.onDestroy();
+ }
+
/**
* Convenience method for enqueuing work in to this service.
*/
diff --git a/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/InstallActivity.java b/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/InstallActivity.java
index 92291a43..b0e6b392 100644
--- a/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/InstallActivity.java
+++ b/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/InstallActivity.java
@@ -75,8 +75,16 @@ public class InstallActivity extends Activity {
if (resultCode == RESULT_OK) {
installUpdate();
} else {
- Toast.makeText(this, getString(R.string.version_update_error_permissions), Toast.LENGTH_LONG).show();
- finish();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ if (this.getPackageManager().canRequestPackageInstalls()) {
+ installUpdate();
+ } else {
+ Toast.makeText(this, getString(R.string.version_update_error_permissions), Toast.LENGTH_LONG).show();
+ finish();
+ }
+ } else {
+ finish();
+ }
}
}
}
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 109164c5..5907b8fa 100644
--- a/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/UpdateDownloadManager.java
+++ b/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/UpdateDownloadManager.java
@@ -16,21 +16,6 @@
*/
package se.leap.bitmaskclient.appUpdate;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.ResultReceiver;
-import android.util.Log;
-
-import java.io.File;
-
-import okhttp3.OkHttpClient;
-import pgpverify.Logger;
-import pgpverify.PgpVerifier;
-import se.leap.bitmaskclient.BuildConfig;
-import se.leap.bitmaskclient.R;
-import se.leap.bitmaskclient.providersetup.connectivity.OkHttpClientGenerator;
-
import static android.text.TextUtils.isEmpty;
import static se.leap.bitmaskclient.appUpdate.DownloadService.DOWNLOAD_FAILED;
import static se.leap.bitmaskclient.appUpdate.DownloadService.DOWNLOAD_PROGRESS;
@@ -52,6 +37,22 @@ 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;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.ResultReceiver;
+import android.util.Log;
+
+import java.io.File;
+
+import de.blinkt.openvpn.core.VpnStatus;
+import okhttp3.OkHttpClient;
+import pgpverify.Logger;
+import pgpverify.PgpVerifier;
+import se.leap.bitmaskclient.BuildConfig;
+import se.leap.bitmaskclient.R;
+import se.leap.bitmaskclient.providersetup.connectivity.OkHttpClientGenerator;
+
public class UpdateDownloadManager implements Logger, DownloadConnector.DownloadProgress {
@@ -63,7 +64,7 @@ public class UpdateDownloadManager implements Logger, DownloadConnector.Download
private Context context;
- private PgpVerifier pgpVerifier;
+ private final PgpVerifier pgpVerifier;
private DownloadServiceCallback serviceCallback;
OkHttpClientGenerator clientGenerator;
@@ -76,10 +77,17 @@ public class UpdateDownloadManager implements Logger, DownloadConnector.Download
serviceCallback = callback;
}
+ public void onDestroy() {
+ serviceCallback = null;
+ context = null;
+ }
+
//pgpverify Logger interface
@Override
public void log(String s) {
-
+ if (BuildConfig.DEBUG_MODE) {
+ VpnStatus.logInfo("[PGP VERIFY] " + s);
+ }
}
@Override
@@ -106,23 +114,26 @@ public class UpdateDownloadManager implements Logger, DownloadConnector.Download
}
Bundle result = new Bundle();
+ if (action == null) {
+ return;
+ }
switch (action) {
- case CHECK_VERSION_FILE:
+ case CHECK_VERSION_FILE -> {
result = checkVersionFile(result);
if (result.getBoolean(BROADCAST_RESULT_KEY)) {
sendToReceiverOrBroadcast(receiver, UPDATE_FOUND, result);
} else {
sendToReceiverOrBroadcast(receiver, UPDATE_NOT_FOUND, result);
}
- break;
- case DOWNLOAD_UPDATE:
+ }
+ case DOWNLOAD_UPDATE -> {
result = downloadUpdate(result);
if (result.getBoolean(BROADCAST_RESULT_KEY)) {
sendToReceiverOrBroadcast(receiver, UPDATE_DOWNLOADED, result);
} else {
sendToReceiverOrBroadcast(receiver, UPDATE_DOWNLOAD_FAILED, result);
}
- break;
+ }
}
}