Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/metrics/UmaSessionStats.java

Issue 2248243002: Enabling sampling of UMA and crash reports on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Theresa's and dfalcantara's comments with sync Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/metrics/UmaSessionStats.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/metrics/UmaSessionStats.java b/chrome/android/java/src/org/chromium/chrome/browser/metrics/UmaSessionStats.java
index 7aaaff8b232e5d2bde0f2e777384bacd122d1203..93efec358a982997a198589d42005c9ae2f3ae0a 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/metrics/UmaSessionStats.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/metrics/UmaSessionStats.java
@@ -155,15 +155,37 @@ public class UmaSessionStats implements NetworkChangeNotifier.ConnectionTypeObse
}
/**
- * Updates the state of the MetricsService to account for the user's preferences.
+ * Updates the metrics services based on a change of consent. This can happen during first-run
+ * flow, and when the user changes their preferences.
*/
- public void updateMetricsServiceState() {
- boolean mayRecordStats = !PrivacyPreferencesManager.getInstance()
- .isNeverUploadCrashDump();
- boolean mayUploadStats = mReportingPermissionManager.isUmaUploadPermitted();
+ public static void changeMetricsReportingConsent(boolean consent) {
+ PrivacyPreferencesManager privacyManager = PrivacyPreferencesManager.getInstance();
+ // Update the new two-choice Android preference.
+ privacyManager.setUsageAndCrashReporting(consent);
+ // Update the old three-choice Android preference, and synchronize with Chrome local state
+ // preferences. Note, this forces the three-choice preferences to be either never upload,
+ // or only upload on WiFi.
+ privacyManager.initCrashUploadPreference(consent);
+
+ // Perform native changes needed to reflect the new consent value.
+ nativeChangeMetricsReportingConsent(consent);
- // Re-start the MetricsService with the given parameters.
- nativeUpdateMetricsServiceState(mayRecordStats, mayUploadStats);
+ updateMetricsServiceState();
+ }
+
+ /**
+ * Updates the state of MetricsService to account for the user's preferences.
+ */
+ public static void updateMetricsServiceState() {
+ PrivacyPreferencesManager privacyManager = PrivacyPreferencesManager.getInstance();
+
+ // Ensure Android and Chrome local state prefs are in sync.
+ privacyManager.syncUsageAndCrashReportingPrefs();
+
+ boolean mayUploadStats = privacyManager.isUmaUploadPermitted();
+
+ // Re-start the MetricsService with the given parameter, and current consent.
+ nativeUpdateMetricsServiceState(mayUploadStats);
}
/**
@@ -194,6 +216,10 @@ public class UmaSessionStats implements NetworkChangeNotifier.ConnectionTypeObse
prefManager.setUsageAndCrashReporting(prefBridge.isMetricsReportingEnabled());
}
+ // Update the metrics sampling state so it's available before the native feature list is
+ // available.
+ prefManager.setClientInMetricsSample(UmaUtils.isClientInMetricsReportingSample());
+
// Make sure preferences are in sync.
prefManager.syncUsageAndCrashReportingPrefs();
}
@@ -212,7 +238,8 @@ public class UmaSessionStats implements NetworkChangeNotifier.ConnectionTypeObse
}
private static native long nativeInit();
- private native void nativeUpdateMetricsServiceState(boolean mayRecord, boolean mayUpload);
+ private static native void nativeChangeMetricsReportingConsent(boolean consent);
+ private static native void nativeUpdateMetricsServiceState(boolean mayUpload);
private native void nativeUmaResumeSession(long nativeUmaSessionStats);
private native void nativeUmaEndSession(long nativeUmaSessionStats);
private static native void nativeLogRendererCrash();

Powered by Google App Engine
This is Rietveld 408576698