Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebUma.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebUma.java b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebUma.java |
| index 4212d7e31b8ade673532ad585933c8e5285b42c9..35c75e37f2d4d6bce684fb086ae9e3eed6ca09f8 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebUma.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebUma.java |
| @@ -4,18 +4,18 @@ |
| package org.chromium.chrome.browser.physicalweb; |
| -import android.content.Context; |
| import android.content.SharedPreferences; |
| import android.os.AsyncTask; |
|
mattreynolds
2017/01/05 20:01:12
Remove newline (go/java-imports says to put all no
cco3
2017/01/05 20:20:10
Presubmit check says otherwise for chromium.
|
| +import org.json.JSONArray; |
| +import org.json.JSONException; |
| + |
| import org.chromium.base.ContextUtils; |
| import org.chromium.base.Log; |
| import org.chromium.base.library_loader.LibraryLoader; |
| import org.chromium.base.metrics.RecordHistogram; |
| import org.chromium.base.metrics.RecordUserAction; |
| import org.chromium.components.location.LocationUtils; |
| -import org.json.JSONArray; |
| -import org.json.JSONException; |
| import java.util.concurrent.TimeUnit; |
| @@ -69,81 +69,81 @@ public class PhysicalWebUma { |
| /** |
| * Records a URL selection. |
| */ |
| - public static void onUrlSelected(Context context) { |
| - handleAction(context, URL_SELECTED_COUNT); |
| + public static void onUrlSelected() { |
| + handleAction(URL_SELECTED_COUNT); |
| } |
| /** |
| * Records a tap on the opt-in decline button. |
| */ |
| - public static void onOptInDeclineButtonPressed(Context context) { |
| - handleAction(context, OPT_IN_DECLINE_BUTTON_PRESS_COUNT); |
| + public static void onOptInDeclineButtonPressed() { |
| + handleAction(OPT_IN_DECLINE_BUTTON_PRESS_COUNT); |
| } |
| /** |
| * Records a tap on the opt-in enable button. |
| */ |
| - public static void onOptInEnableButtonPressed(Context context) { |
| - handleAction(context, OPT_IN_ENABLE_BUTTON_PRESS_COUNT); |
| + public static void onOptInEnableButtonPressed() { |
| + handleAction(OPT_IN_ENABLE_BUTTON_PRESS_COUNT); |
| } |
| /** |
| * Records a display of a high priority opt-in notification. |
| */ |
| - public static void onOptInHighPriorityNotificationShown(Context context) { |
| - handleAction(context, OPT_IN_HIGH_PRIORITY_NOTIFICATION_COUNT); |
| + public static void onOptInHighPriorityNotificationShown() { |
| + handleAction(OPT_IN_HIGH_PRIORITY_NOTIFICATION_COUNT); |
| } |
| /** |
| * Records a display of a min priority opt-in notification. |
| */ |
| - public static void onOptInMinPriorityNotificationShown(Context context) { |
| - handleAction(context, OPT_IN_MIN_PRIORITY_NOTIFICATION_COUNT); |
| + public static void onOptInMinPriorityNotificationShown() { |
| + handleAction(OPT_IN_MIN_PRIORITY_NOTIFICATION_COUNT); |
| } |
| /** |
| * Records a display of the opt-in activity. |
| */ |
| - public static void onOptInNotificationPressed(Context context) { |
| - handleAction(context, OPT_IN_NOTIFICATION_PRESS_COUNT); |
| + public static void onOptInNotificationPressed() { |
| + handleAction(OPT_IN_NOTIFICATION_PRESS_COUNT); |
| } |
| /** |
| * Records when the user disables the Physical Web fetaure. |
| */ |
| - public static void onPrefsFeatureDisabled(Context context) { |
| - handleAction(context, PREFS_FEATURE_DISABLED_COUNT); |
| + public static void onPrefsFeatureDisabled() { |
| + handleAction(PREFS_FEATURE_DISABLED_COUNT); |
| } |
| /** |
| * Records when the user enables the Physical Web fetaure. |
| */ |
| - public static void onPrefsFeatureEnabled(Context context) { |
| - handleAction(context, PREFS_FEATURE_ENABLED_COUNT); |
| + public static void onPrefsFeatureEnabled() { |
| + handleAction(PREFS_FEATURE_ENABLED_COUNT); |
| } |
| /** |
| * Records when the user denies the location permission when enabling the Physical Web from the |
| * privacy settings menu. |
| */ |
| - public static void onPrefsLocationDenied(Context context) { |
| - handleAction(context, PREFS_LOCATION_DENIED_COUNT); |
| + public static void onPrefsLocationDenied() { |
| + handleAction(PREFS_LOCATION_DENIED_COUNT); |
| } |
| /** |
| * Records when the user grants the location permission when enabling the Physical Web from the |
| * privacy settings menu. |
| */ |
| - public static void onPrefsLocationGranted(Context context) { |
| - handleAction(context, PREFS_LOCATION_GRANTED_COUNT); |
| + public static void onPrefsLocationGranted() { |
| + handleAction(PREFS_LOCATION_GRANTED_COUNT); |
| } |
| /** |
| * Records a response time from PWS for a resolution during a background scan. |
| * @param duration The length of time PWS took to respond. |
| */ |
| - public static void onBackgroundPwsResolution(Context context, long duration) { |
| - handleTime(context, PWS_BACKGROUND_RESOLVE_TIMES, duration, TimeUnit.MILLISECONDS); |
| + public static void onBackgroundPwsResolution(long duration) { |
| + handleTime(PWS_BACKGROUND_RESOLVE_TIMES, duration, TimeUnit.MILLISECONDS); |
| } |
| /** |
| @@ -151,8 +151,8 @@ public class PhysicalWebUma { |
| * explicitly user-initiated through a refresh. |
| * @param duration The length of time PWS took to respond. |
| */ |
| - public static void onForegroundPwsResolution(Context context, long duration) { |
| - handleTime(context, PWS_FOREGROUND_RESOLVE_TIMES, duration, TimeUnit.MILLISECONDS); |
| + public static void onForegroundPwsResolution(long duration) { |
| + handleTime(PWS_FOREGROUND_RESOLVE_TIMES, duration, TimeUnit.MILLISECONDS); |
| } |
| /** |
| @@ -160,19 +160,19 @@ public class PhysicalWebUma { |
| * user-initiated through a refresh. |
| * @param duration The length of time PWS took to respond. |
| */ |
| - public static void onRefreshPwsResolution(Context context, long duration) { |
| - handleTime(context, PWS_REFRESH_RESOLVE_TIMES, duration, TimeUnit.MILLISECONDS); |
| + public static void onRefreshPwsResolution(long duration) { |
| + handleTime(PWS_REFRESH_RESOLVE_TIMES, duration, TimeUnit.MILLISECONDS); |
| } |
| /** |
| * Records number of URLs displayed to a user when the URL list is first displayed. |
| * @param numUrls The number of URLs displayed to a user. |
| */ |
| - public static void onUrlsDisplayed(Context context, int numUrls) { |
| + public static void onUrlsDisplayed(int numUrls) { |
| if (LibraryLoader.isInitialized()) { |
| RecordHistogram.recordCountHistogram(TOTAL_URLS_INITIAL_COUNTS, numUrls); |
| } else { |
| - storeValue(context, TOTAL_URLS_INITIAL_COUNTS, numUrls); |
| + storeValue(TOTAL_URLS_INITIAL_COUNTS, numUrls); |
| } |
| } |
| @@ -180,11 +180,11 @@ public class PhysicalWebUma { |
| * Records number of URLs displayed to a user when the user refreshes the URL list. |
| * @param numUrls The number of URLs displayed to a user. |
| */ |
| - public static void onUrlsRefreshed(Context context, int numUrls) { |
| + public static void onUrlsRefreshed(int numUrls) { |
| if (LibraryLoader.isInitialized()) { |
| RecordHistogram.recordCountHistogram(TOTAL_URLS_REFRESH_COUNTS, numUrls); |
| } else { |
| - storeValue(context, TOTAL_URLS_REFRESH_COUNTS, numUrls); |
| + storeValue(TOTAL_URLS_REFRESH_COUNTS, numUrls); |
| } |
| } |
| @@ -193,24 +193,24 @@ public class PhysicalWebUma { |
| * @param refer The type of referral. This enum is listed as PhysicalWebActivityReferer in |
| * histograms.xml. |
| */ |
| - public static void onActivityReferral(Context context, int referer) { |
| - handleEnum(context, ACTIVITY_REFERRALS, referer, ListUrlsActivity.REFERER_BOUNDARY); |
| + public static void onActivityReferral(int referer) { |
| + handleEnum(ACTIVITY_REFERRALS, referer, ListUrlsActivity.REFERER_BOUNDARY); |
| switch (referer) { |
| case ListUrlsActivity.NOTIFICATION_REFERER: |
| - handleTime(context, STANDARD_NOTIFICATION_PRESS_DELAYS, |
| + handleTime(STANDARD_NOTIFICATION_PRESS_DELAYS, |
| UrlManager.getInstance().getTimeSinceNotificationUpdate(), |
| TimeUnit.MILLISECONDS); |
| break; |
| case ListUrlsActivity.OPTIN_REFERER: |
| - handleTime(context, OPT_IN_NOTIFICATION_PRESS_DELAYS, |
| + handleTime(OPT_IN_NOTIFICATION_PRESS_DELAYS, |
| UrlManager.getInstance().getTimeSinceNotificationUpdate(), |
| TimeUnit.MILLISECONDS); |
| break; |
| case ListUrlsActivity.PREFERENCE_REFERER: |
| - recordPhysicalWebState(context, LAUNCH_FROM_PREFERENCES); |
| + recordPhysicalWebState(LAUNCH_FROM_PREFERENCES); |
| break; |
| case ListUrlsActivity.DIAGNOSTICS_REFERER: |
| - recordPhysicalWebState(context, LAUNCH_FROM_DIAGNOSTICS); |
| + recordPhysicalWebState(LAUNCH_FROM_DIAGNOSTICS); |
| break; |
| default: |
| break; |
| @@ -226,21 +226,21 @@ public class PhysicalWebUma { |
| * - The data connection status |
| * - The Physical Web preference status |
| */ |
| - public static void recordPhysicalWebState(Context context, String actionName) { |
| + public static void recordPhysicalWebState(String actionName) { |
| LocationUtils locationUtils = LocationUtils.getInstance(); |
| - handleEnum(context, createStateString(LOCATION_SERVICES, actionName), |
| + handleEnum(createStateString(LOCATION_SERVICES, actionName), |
| locationUtils.isSystemLocationSettingEnabled() ? 1 : 0, BOOLEAN_BOUNDARY); |
| - handleEnum(context, createStateString(LOCATION_PERMISSION, actionName), |
| + handleEnum(createStateString(LOCATION_PERMISSION, actionName), |
| locationUtils.hasAndroidLocationPermission() ? 1 : 0, BOOLEAN_BOUNDARY); |
| - handleEnum(context, createStateString(BLUETOOTH, actionName), |
| + handleEnum(createStateString(BLUETOOTH, actionName), |
| Utils.getBluetoothEnabledStatus(), TRISTATE_BOUNDARY); |
| - handleEnum(context, createStateString(DATA_CONNECTION, actionName), |
| + handleEnum(createStateString(DATA_CONNECTION, actionName), |
| Utils.isDataConnectionActive() ? 1 : 0, BOOLEAN_BOUNDARY); |
| int preferenceState = 2; |
| if (!PhysicalWeb.isOnboarding()) { |
| preferenceState = PhysicalWeb.isPhysicalWebPreferenceEnabled() ? 1 : 0; |
| } |
| - handleEnum(context, createStateString(PREFERENCE, actionName), |
| + handleEnum(createStateString(PREFERENCE, actionName), |
| preferenceState, TRISTATE_BOUNDARY); |
| } |
| @@ -259,7 +259,7 @@ public class PhysicalWebUma { |
| return PHYSICAL_WEB_STATE + "." + stateName + "." + actionName; |
| } |
| - private static void storeAction(Context context, String key) { |
| + private static void storeAction(String key) { |
| SharedPreferences prefs = ContextUtils.getAppSharedPreferences(); |
| int count = prefs.getInt(key, 0); |
| prefs.edit() |
| @@ -268,7 +268,7 @@ public class PhysicalWebUma { |
| .apply(); |
| } |
| - private static void storeValue(Context context, String key, Object value) { |
| + private static void storeValue(String key, Object value) { |
| SharedPreferences prefs = ContextUtils.getAppSharedPreferences(); |
| SharedPreferences.Editor prefsEditor = prefs.edit(); |
| JSONArray values = null; |
| @@ -287,27 +287,27 @@ public class PhysicalWebUma { |
| prefsEditor.putString(key, values.toString()).apply(); |
| } |
| - private static void handleAction(Context context, String key) { |
| + private static void handleAction(String key) { |
| if (LibraryLoader.isInitialized()) { |
| RecordUserAction.record(key); |
| } else { |
| - storeAction(context, key); |
| + storeAction(key); |
| } |
| } |
| - private static void handleTime(Context context, String key, long duration, TimeUnit tu) { |
| + private static void handleTime(String key, long duration, TimeUnit tu) { |
| if (LibraryLoader.isInitialized()) { |
| RecordHistogram.recordTimesHistogram(key, duration, tu); |
| } else { |
| - storeValue(context, key, duration); |
| + storeValue(key, duration); |
| } |
| } |
| - private static void handleEnum(Context context, String key, int value, int boundary) { |
| + private static void handleEnum(String key, int value, int boundary) { |
| if (LibraryLoader.isInitialized()) { |
| RecordHistogram.recordEnumeratedHistogram(key, value, boundary); |
| } else { |
| - storeValue(context, key, value); |
| + storeValue(key, value); |
| } |
| } |