From 3a87823c8cb89af54143f14e69a1fb75ad32273e Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 14 Dec 2015 16:13:30 +0100 Subject: [PATCH] Remove speed graph for Play store installs --- app/src/main/java/eu/faircode/netguard/ActivitySettings.java | 3 +++ app/src/main/java/eu/faircode/netguard/SinkholeService.java | 2 +- app/src/main/java/eu/faircode/netguard/Util.java | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/netguard/ActivitySettings.java b/app/src/main/java/eu/faircode/netguard/ActivitySettings.java index c2742c4a..4221d1c7 100644 --- a/app/src/main/java/eu/faircode/netguard/ActivitySettings.java +++ b/app/src/main/java/eu/faircode/netguard/ActivitySettings.java @@ -130,6 +130,9 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere pref_stats_base.setTitle(getString(R.string.setting_stats_base, prefs.getString("stats_base", "5"))); pref_stats_frequency.setTitle(getString(R.string.setting_stats_frequency, prefs.getString("stats_frequency", "1000"))); pref_stats_samples.setTitle(getString(R.string.setting_stats_samples, prefs.getString("stats_samples", "90"))); + PreferenceCategory stats = (PreferenceCategory) screen.findPreference("category_stats"); + if (Util.isPlayStoreInstall(this)) + screen.removePreference(stats); // Handle export Preference pref_export = screen.findPreference("export"); diff --git a/app/src/main/java/eu/faircode/netguard/SinkholeService.java b/app/src/main/java/eu/faircode/netguard/SinkholeService.java index 98746eae..964d32e5 100644 --- a/app/src/main/java/eu/faircode/netguard/SinkholeService.java +++ b/app/src/main/java/eu/faircode/netguard/SinkholeService.java @@ -269,7 +269,7 @@ public class SinkholeService extends VpnService { private void startStats() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(SinkholeService.this); - boolean enabled = (!stats && prefs.getBoolean("show_stats", false)); + boolean enabled = (!stats && prefs.getBoolean("show_stats", false) && !Util.isPlayStoreInstall(SinkholeService.this)); Log.i(TAG, "Stats start enabled=" + enabled); if (enabled) { t = -1; diff --git a/app/src/main/java/eu/faircode/netguard/Util.java b/app/src/main/java/eu/faircode/netguard/Util.java index aa6eba57..dbdb0a01 100644 --- a/app/src/main/java/eu/faircode/netguard/Util.java +++ b/app/src/main/java/eu/faircode/netguard/Util.java @@ -281,6 +281,10 @@ public class Util { return ((context.getApplicationContext().getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0); } + public static boolean isPlayStoreInstall(Context context) { + return "com.android.vending".equals(context.getPackageManager().getInstallerPackageName(context.getPackageName())); + } + public static boolean hasValidFingerprint(Context context) { try { PackageManager pm = context.getPackageManager();