summaryrefslogtreecommitdiff
path: root/app/src/main/java/se
diff options
context:
space:
mode:
authorcyberta <cyberta@riseup.net>2022-08-08 23:30:32 +0000
committercyberta <cyberta@riseup.net>2022-08-08 23:30:32 +0000
commit8e0fa913e098087d73f8ce63888b2213c2c63741 (patch)
tree1f5865a9e30286f726ee0751e535572f3c4fee2d /app/src/main/java/se
parent8d06c86a2fedf7a758801ac0b029b53b54977bd7 (diff)
parent6d705263bf0fd616926d2c64ada98e2ee7740024 (diff)
Merge branch 'update_dependencies' into 'master'
update API version and dependencies Closes #9057 See merge request leap/bitmask_android!206
Diffstat (limited to 'app/src/main/java/se')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/BitmaskApp.java46
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/fragments/NavigationDrawerFragment.java30
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/utils/ConfigHelper.java9
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/VpnNotificationManager.java11
4 files changed, 40 insertions, 56 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/BitmaskApp.java b/app/src/main/java/se/leap/bitmaskclient/base/BitmaskApp.java
index 3f73e49d..828ef27d 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/BitmaskApp.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/BitmaskApp.java
@@ -17,6 +17,15 @@
package se.leap.bitmaskclient.base;
+import static android.content.Intent.CATEGORY_DEFAULT;
+import static se.leap.bitmaskclient.appUpdate.DownloadBroadcastReceiver.ACTION_DOWNLOAD;
+import static se.leap.bitmaskclient.appUpdate.DownloadServiceCommand.CHECK_VERSION_FILE;
+import static se.leap.bitmaskclient.appUpdate.DownloadServiceCommand.DOWNLOAD_UPDATE;
+import static se.leap.bitmaskclient.base.models.Constants.BROADCAST_DOWNLOAD_SERVICE_EVENT;
+import static se.leap.bitmaskclient.base.models.Constants.SHARED_PREFERENCES;
+import static se.leap.bitmaskclient.base.utils.ConfigHelper.isCalyxOSWithTetheringSupport;
+import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getSavedProviderFromSharedPreferences;
+
import android.content.Context;
import android.content.IntentFilter;
import android.content.SharedPreferences;
@@ -25,27 +34,14 @@ import androidx.appcompat.app.AppCompatDelegate;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.multidex.MultiDexApplication;
-import com.squareup.leakcanary.LeakCanary;
-import com.squareup.leakcanary.RefWatcher;
-
import se.leap.bitmaskclient.BuildConfig;
import se.leap.bitmaskclient.appUpdate.DownloadBroadcastReceiver;
-import se.leap.bitmaskclient.eip.EipSetupObserver;
import se.leap.bitmaskclient.base.models.ProviderObservable;
-import se.leap.bitmaskclient.tethering.TetheringStateManager;
import se.leap.bitmaskclient.base.utils.PRNGFixes;
-import se.leap.bitmaskclient.tor.TorNotificationManager;
+import se.leap.bitmaskclient.eip.EipSetupObserver;
+import se.leap.bitmaskclient.tethering.TetheringStateManager;
import se.leap.bitmaskclient.tor.TorStatusObservable;
-import static android.content.Intent.CATEGORY_DEFAULT;
-import static se.leap.bitmaskclient.base.models.Constants.BROADCAST_DOWNLOAD_SERVICE_EVENT;
-import static se.leap.bitmaskclient.base.models.Constants.SHARED_PREFERENCES;
-import static se.leap.bitmaskclient.appUpdate.DownloadBroadcastReceiver.ACTION_DOWNLOAD;
-import static se.leap.bitmaskclient.appUpdate.DownloadServiceCommand.CHECK_VERSION_FILE;
-import static se.leap.bitmaskclient.appUpdate.DownloadServiceCommand.DOWNLOAD_UPDATE;
-import static se.leap.bitmaskclient.base.utils.ConfigHelper.isCalyxOSWithTetheringSupport;
-import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getSavedProviderFromSharedPreferences;
-
/**
* Created by cyberta on 24.10.17.
*/
@@ -53,7 +49,6 @@ import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getSavedProvider
public class BitmaskApp extends MultiDexApplication {
private final static String TAG = BitmaskApp.class.getSimpleName();
- private RefWatcher refWatcher;
private ProviderObservable providerObservable;
private DownloadBroadcastReceiver downloadBroadcastReceiver;
private TorStatusObservable torStatusObservable;
@@ -62,12 +57,6 @@ public class BitmaskApp extends MultiDexApplication {
@Override
public void onCreate() {
super.onCreate();
- if (LeakCanary.isInAnalyzerProcess(this)) {
- // This process is dedicated to LeakCanary for heap analysis.
- // You should not init your app in this process.
- return;
- }
- refWatcher = LeakCanary.install(this);
// Normal app init code...*/
PRNGFixes.apply();
SharedPreferences preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
@@ -89,17 +78,4 @@ public class BitmaskApp extends MultiDexApplication {
LocalBroadcastManager.getInstance(this.getApplicationContext()).registerReceiver(downloadBroadcastReceiver, intentFilter);
}
}
-
- /**
- * Use this method to get a RefWatcher object that checks for memory leaks in the given context.
- * Call refWatcher.watch(this) to check if all references get garbage collected.
- * @param context
- * @return the RefWatcher object
- */
- public static RefWatcher getRefWatcher(Context context) {
- BitmaskApp application = (BitmaskApp) context.getApplicationContext();
- return application.refWatcher;
- }
-
-
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/NavigationDrawerFragment.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/NavigationDrawerFragment.java
index c5593bf7..cdfee7b2 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/NavigationDrawerFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/NavigationDrawerFragment.java
@@ -17,6 +17,20 @@
package se.leap.bitmaskclient.base.fragments;
+import static android.content.Context.MODE_PRIVATE;
+import static android.view.View.GONE;
+import static android.view.View.VISIBLE;
+import static se.leap.bitmaskclient.base.models.Constants.DONATION_URL;
+import static se.leap.bitmaskclient.base.models.Constants.ENABLE_DONATION;
+import static se.leap.bitmaskclient.base.models.Constants.PREFERRED_CITY;
+import static se.leap.bitmaskclient.base.models.Constants.PROVIDER_KEY;
+import static se.leap.bitmaskclient.base.models.Constants.REQUEST_CODE_SWITCH_PROVIDER;
+import static se.leap.bitmaskclient.base.models.Constants.SHARED_PREFERENCES;
+import static se.leap.bitmaskclient.base.utils.ConfigHelper.isDefaultBitmask;
+import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getPreferredCity;
+import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getSaveBattery;
+import static se.leap.bitmaskclient.base.utils.PreferenceHelper.saveBattery;
+
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -56,21 +70,6 @@ import se.leap.bitmaskclient.eip.EipStatus;
import se.leap.bitmaskclient.providersetup.ProviderListActivity;
import se.leap.bitmaskclient.tethering.TetheringObservable;
-import static android.content.Context.MODE_PRIVATE;
-import static android.view.View.GONE;
-import static android.view.View.VISIBLE;
-import static se.leap.bitmaskclient.base.BitmaskApp.getRefWatcher;
-import static se.leap.bitmaskclient.base.models.Constants.DONATION_URL;
-import static se.leap.bitmaskclient.base.models.Constants.ENABLE_DONATION;
-import static se.leap.bitmaskclient.base.models.Constants.PREFERRED_CITY;
-import static se.leap.bitmaskclient.base.models.Constants.PROVIDER_KEY;
-import static se.leap.bitmaskclient.base.models.Constants.REQUEST_CODE_SWITCH_PROVIDER;
-import static se.leap.bitmaskclient.base.models.Constants.SHARED_PREFERENCES;
-import static se.leap.bitmaskclient.base.utils.ConfigHelper.isDefaultBitmask;
-import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getPreferredCity;
-import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getSaveBattery;
-import static se.leap.bitmaskclient.base.utils.PreferenceHelper.saveBattery;
-
/**
* Fragment used for managing interactions for and presentation of a navigation drawer.
* See the <a href="https://developer.android.com/design/patterns/navigation-drawer.html#Interaction">
@@ -433,7 +432,6 @@ public class NavigationDrawerFragment extends Fragment implements SharedPreferen
@Override
public void onDestroy() {
super.onDestroy();
- getRefWatcher(getActivity()).watch(this);
preferences.unregisterOnSharedPreferenceChangeListener(this);
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/utils/ConfigHelper.java b/app/src/main/java/se/leap/bitmaskclient/base/utils/ConfigHelper.java
index dbcb55b0..d65f6b52 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/utils/ConfigHelper.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/utils/ConfigHelper.java
@@ -18,6 +18,7 @@ package se.leap.bitmaskclient.base.utils;
import static se.leap.bitmaskclient.base.models.Constants.DEFAULT_BITMASK;
+import android.app.PendingIntent;
import android.content.Context;
import android.content.res.Resources;
import android.os.Build;
@@ -312,4 +313,12 @@ public class ConfigHelper {
return BuildConfig.obfsvpn_use_kcp;
}
}
+
+ public static int getPendingIntentFlags() {
+ int flags = PendingIntent.FLAG_CANCEL_CURRENT;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
+ flags |= PendingIntent.FLAG_IMMUTABLE;
+ }
+ return flags;
+ }
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/VpnNotificationManager.java b/app/src/main/java/se/leap/bitmaskclient/eip/VpnNotificationManager.java
index a869210e..31893fb1 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/VpnNotificationManager.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/VpnNotificationManager.java
@@ -55,6 +55,7 @@ import static se.leap.bitmaskclient.base.MainActivity.ACTION_SHOW_VPN_FRAGMENT;
import static se.leap.bitmaskclient.base.models.Constants.ASK_TO_CANCEL_VPN;
import static se.leap.bitmaskclient.base.models.Constants.EIP_ACTION_START;
import static se.leap.bitmaskclient.base.models.Constants.EIP_ACTION_STOP_BLOCKING_VPN;
+import static se.leap.bitmaskclient.base.utils.ConfigHelper.getPendingIntentFlags;
/**
* Created by cyberta on 14.01.18.
@@ -305,19 +306,19 @@ public class VpnNotificationManager {
private PendingIntent getMainActivityIntent() {
Intent startActivity = new Intent(context, StartActivity.class);
- return PendingIntent.getActivity(context, 0, startActivity, PendingIntent.FLAG_CANCEL_CURRENT);
+ return PendingIntent.getActivity(context, 0, startActivity, getPendingIntentFlags());
}
private PendingIntent getStartOpenvpnIntent() {
Intent startIntent = new Intent(context, EIP.class);
startIntent.setAction(EIP_ACTION_START);
- return PendingIntent.getService(context, 0, startIntent, PendingIntent.FLAG_CANCEL_CURRENT);
+ return PendingIntent.getService(context, 0, startIntent, getPendingIntentFlags());
}
private PendingIntent getStopVoidVpnIntent() {
Intent stopVoidVpnIntent = new Intent (context, VoidVpnService.class);
stopVoidVpnIntent.setAction(EIP_ACTION_STOP_BLOCKING_VPN);
- return PendingIntent.getService(context, 0, stopVoidVpnIntent, PendingIntent.FLAG_CANCEL_CURRENT);
+ return PendingIntent.getService(context, 0, stopVoidVpnIntent, getPendingIntentFlags());
}
private PendingIntent getDisconnectIntent() {
@@ -325,7 +326,7 @@ public class VpnNotificationManager {
disconnectVPN.setAction(ACTION_SHOW_VPN_FRAGMENT);
disconnectVPN.putExtra(ASK_TO_CANCEL_VPN, true);
disconnectVPN.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
- return PendingIntent.getActivity(context, 0, disconnectVPN, PendingIntent.FLAG_CANCEL_CURRENT);
+ return PendingIntent.getActivity(context, 0, disconnectVPN, getPendingIntentFlags());
}
private PendingIntent getUserInputIntent(String needed) {
@@ -334,7 +335,7 @@ public class VpnNotificationManager {
intent.putExtra("need", needed);
Bundle b = new Bundle();
b.putString("need", needed);
- PendingIntent pIntent = PendingIntent.getActivity(context, 12, intent, 0);
+ PendingIntent pIntent = PendingIntent.getActivity(context, 12, intent, getPendingIntentFlags());
return pIntent;
}