From 73efd90a7bb170481ae827e8ae0523daed992b40 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Mon, 28 Dec 2020 18:43:33 +0100 Subject: no need to use onActivityResult in InstallActivity during installation it won't be called --- .../se.leap.bitmaskclient/appUpdate/InstallActivity.java | 16 ++-------------- app/src/main/java/se/leap/bitmaskclient/Constants.java | 3 +-- 2 files changed, 3 insertions(+), 16 deletions(-) (limited to 'app') 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 028f47bc..6629425c 100644 --- a/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/InstallActivity.java +++ b/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/InstallActivity.java @@ -31,7 +31,6 @@ import java.io.File; import se.leap.bitmaskclient.R; import se.leap.bitmaskclient.utils.PreferenceHelper; -import static se.leap.bitmaskclient.Constants.REQUEST_CODE_INSTALL_UPDATE; import static se.leap.bitmaskclient.Constants.REQUEST_CODE_REQUEST_UPDATE; import static se.leap.bitmaskclient.appUpdate.DownloadConnector.APP_TYPE; import static se.leap.bitmaskclient.appUpdate.FileProviderUtil.getUriFor; @@ -46,7 +45,6 @@ public class InstallActivity extends Activity { requestPermissionAndInstall(); } - private void requestPermissionAndInstall() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !this.getPackageManager().canRequestPackageInstalls()) { startActivityForResult(new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, Uri.parse("package:"+getPackageName())), @@ -65,7 +63,8 @@ public class InstallActivity extends Activity { installIntent.setDataAndType(getUriFor(this.getApplicationContext(), update), APP_TYPE); installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); installIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); - this.startActivityForResult(installIntent, REQUEST_CODE_INSTALL_UPDATE); + this.startActivity(installIntent); + finish(); } } @@ -79,17 +78,6 @@ public class InstallActivity extends Activity { Toast.makeText(this, getString(R.string.version_update_error_permissions), Toast.LENGTH_LONG).show(); finish(); } - } else if (requestCode == REQUEST_CODE_INSTALL_UPDATE) { - switch (resultCode) { - case RESULT_OK: - Toast.makeText(this, "Update successful.", Toast.LENGTH_LONG).show(); - break; - case RESULT_CANCELED: - case RESULT_FIRST_USER: - Toast.makeText(this, getString(R.string.version_update_error), Toast.LENGTH_LONG).show(); - break; - } - finish(); } } } diff --git a/app/src/main/java/se/leap/bitmaskclient/Constants.java b/app/src/main/java/se/leap/bitmaskclient/Constants.java index 5fcaba2f..1d364074 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Constants.java +++ b/app/src/main/java/se/leap/bitmaskclient/Constants.java @@ -49,8 +49,7 @@ public interface Constants { int REQUEST_CODE_SWITCH_PROVIDER = 1; int REQUEST_CODE_LOG_IN = 2; int REQUEST_CODE_ADD_PROVIDER = 3; - int REQUEST_CODE_INSTALL_UPDATE = 4; - int REQUEST_CODE_REQUEST_UPDATE = 5; + int REQUEST_CODE_REQUEST_UPDATE = 4; ////////////////////////////////////////////// -- cgit v1.2.3