Skip to content

Commit

Permalink
Privacy improvements (#415)
Browse files Browse the repository at this point in the history
* Change defaults

* Remove optional Firebase Analytics

* acceptDefaultSettings function

* reloadConsents after onboarding

* Remove Countly crash collection for fdroid

* Update version
  • Loading branch information
lorenzoPrimi authored Feb 11, 2021
1 parent 7d60653 commit f536646
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
5 changes: 2 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId 'org.openobservatory.ooniprobe'
minSdkVersion 21
targetSdkVersion 29
versionName '2.9.2'
versionCode 71
versionName '2.9.3'
versionCode 72
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField 'String', 'OONI_ORCHESTRATE_BASE_URL', '"https://orchestrate.ooni.io/"'
buildConfigField 'String', 'OONI_API_BASE_URL', '"https://api.ooni.io/"'
Expand Down Expand Up @@ -112,7 +112,6 @@ dependencies {
// Flavor
fullImplementation platform('com.google.firebase:firebase-bom:26.3.0')
fullImplementation 'com.google.firebase:firebase-messaging'
fullImplementation 'com.google.firebase:firebase-analytics'
fullImplementation 'com.google.firebase:firebase-crashlytics'

// Testing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ public static void onCreate(Application app) {
}

public static void reloadCrashConsent(Context ctx, PreferenceManager preferenceManager) {
Countly.sharedInstance().consent().setConsent(CountlyManager.crashFeatures, preferenceManager.isSendCrash());
}
}
4 changes: 2 additions & 2 deletions app/src/fdroid/res/xml/preferences_global.xml
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,11 @@
android:key="@string/upload_results"
android:title="@string/Settings_Sharing_UploadResults" />
<androidx.preference.SwitchPreferenceCompat
android:defaultValue="true"
android:defaultValue="false"
android:key="@string/send_analytics"
android:title="@string/Settings_Privacy_CollectAnalytics" />
<androidx.preference.SwitchPreferenceCompat
android:defaultValue="true"
android:defaultValue="false"
android:key="@string/send_crash"
android:title="@string/Settings_Privacy_SendCrashReports" />
</androidx.preference.PreferenceScreen>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.content.Context;

import com.google.firebase.FirebaseApp;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.firebase.crashlytics.FirebaseCrashlytics;

class FlavorApplication {
Expand All @@ -14,7 +13,6 @@ public static void onCreate(Application app) {
}

public static void reloadCrashConsent(Context ctx, PreferenceManager preferenceManager) {
FirebaseAnalytics.getInstance(ctx).setAnalyticsCollectionEnabled(preferenceManager.isSendAnalytics());
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(preferenceManager.isSendCrash());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ public static void register(Context ctx, PreferenceManager preferenceManager){

public static String[] getConsentsEnabled(PreferenceManager preferenceManager) {
List<String> consents = new ArrayList(Arrays.asList(basicFeatures));
if (preferenceManager.isSendCrash() && BuildConfig.FLAVOR_license.equals("fdroid"))
consents.addAll(Arrays.asList(crashFeatures));
if (preferenceManager.isSendAnalytics())
consents.addAll(Arrays.asList(analyticsFeatures));
if (preferenceManager.isNotifications())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ public boolean isMaxRuntimeEnabled(){
}

public boolean isSendCrash() {
return sp.getBoolean(r.getString(R.string.send_crash), true);
return sp.getBoolean(r.getString(R.string.send_crash), false);
}

public boolean isSendAnalytics() {
return sp.getBoolean(r.getString(R.string.send_analytics), true);
return sp.getBoolean(r.getString(R.string.send_analytics), false);
}

public void setSendAnalytics(boolean analytics) {
Expand All @@ -85,6 +85,12 @@ public void setShowOnboarding(boolean showIntro) {
.apply();
}

public void acceptDefaultSettings() {
sp.edit().putBoolean(r.getString(R.string.send_analytics), true)
.putBoolean(r.getString(R.string.send_crash), true)
.apply();
}

/*
* This method is used to ask user to share app usage to old users.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.openobservatory.ooniprobe.R;
import org.openobservatory.ooniprobe.activity.MainActivity;
import org.openobservatory.ooniprobe.common.Application;
import org.openobservatory.ooniprobe.common.CountlyManager;

import butterknife.BindView;
import butterknife.ButterKnife;
Expand All @@ -37,6 +38,8 @@ public class Onboarding3Fragment extends Fragment {

@OnClick(R.id.master) void masterClick() {
((Application) getActivity().getApplication()).getPreferenceManager().setShowOnboarding(false);
((Application) getActivity().getApplication()).getPreferenceManager().acceptDefaultSettings();
CountlyManager.reloadConsent(getActivity(), ((Application) getActivity().getApplication()).getPreferenceManager());
startActivity(MainActivity.newIntent(getActivity(), R.id.dashboard));
getActivity().finish();
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/xml/preferences_global.xml
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@
android:key="@string/upload_results"
android:title="@string/Settings_Sharing_UploadResults" />
<androidx.preference.SwitchPreferenceCompat
android:defaultValue="true"
android:defaultValue="false"
android:key="@string/send_analytics"
android:title="@string/Settings_Privacy_CollectAnalytics" />
<androidx.preference.SwitchPreferenceCompat
android:defaultValue="true"
android:defaultValue="false"
android:key="@string/send_crash"
android:title="@string/Settings_Privacy_SendCrashReports" />
</androidx.preference.PreferenceScreen>
Expand Down

0 comments on commit f536646

Please sign in to comment.