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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUmaTracker.java

Issue 2833583004: [Android] Log notification shown/blocked for all other notifications (Closed)
Patch Set: Verify media notifications not logged in other test cases Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.notifications; 5 package org.chromium.chrome.browser.notifications;
6 6
7 import android.annotation.TargetApi; 7 import android.annotation.TargetApi;
8 import android.app.NotificationManager; 8 import android.app.NotificationManager;
9 import android.content.SharedPreferences; 9 import android.content.SharedPreferences;
10 import android.support.annotation.IntDef; 10 import android.support.annotation.IntDef;
11 import android.support.v4.app.NotificationManagerCompat; 11 import android.support.v4.app.NotificationManagerCompat;
12 12
13 import org.chromium.base.BuildInfo; 13 import org.chromium.base.BuildInfo;
14 import org.chromium.base.ContextUtils; 14 import org.chromium.base.ContextUtils;
15 import org.chromium.base.Log; 15 import org.chromium.base.Log;
16 import org.chromium.base.library_loader.LibraryLoader; 16 import org.chromium.base.library_loader.LibraryLoader;
17 import org.chromium.base.metrics.RecordHistogram; 17 import org.chromium.base.metrics.RecordHistogram;
18 18
19 import java.lang.annotation.Retention; 19 import java.lang.annotation.Retention;
20 import java.lang.annotation.RetentionPolicy; 20 import java.lang.annotation.RetentionPolicy;
21 import java.lang.reflect.InvocationTargetException; 21 import java.lang.reflect.InvocationTargetException;
22 import java.lang.reflect.Method; 22 import java.lang.reflect.Method;
23 23
24 /** 24 /**
25 * Helper class to make tracking notification UMA stats easier for various featu res. Having a 25 * Helper class to make tracking notification UMA stats easier for various featu res. Having a
26 * single entry point here to make more complex tracking easier to add in the fu ture. 26 * single entry point here to make more complex tracking easier to add in the fu ture.
27 */ 27 */
28 public class NotificationUmaTracker { 28 public class NotificationUmaTracker {
29 private static final String TAG = "NotifsUMATracker"; 29 private static final String TAG = "NotifsUMATracker";
30
31 @Retention(RetentionPolicy.SOURCE) 30 @Retention(RetentionPolicy.SOURCE)
32 @IntDef({DOWNLOAD_FILES, DOWNLOAD_PAGES, CLOSE_INCOGNITO, CONTENT_SUGGESTION , 31 @IntDef({DOWNLOAD_FILES, DOWNLOAD_PAGES, CLOSE_INCOGNITO, CONTENT_SUGGESTION , MEDIA_CAPTURE,
33 SYSTEM_NOTIFICATION_TYPE_BOUNDARY}) 32 PHYSICAL_WEB, MEDIA, SITES, SYNC, SYSTEM_NOTIFICATION_TYPE_BOUNDARY} )
34 public @interface SystemNotificationType {} 33 public @interface SystemNotificationType {}
35 34
36 /* 35 /*
37 * A list of notification types. To add a type to this list please update 36 * A list of notification types. To add a type to this list please update
38 * SystemNotificationType in histograms.xml and make sure to keep this list in sync. Additions 37 * SystemNotificationType in histograms.xml and make sure to keep this list in sync. Additions
39 * should be treated as APPEND ONLY to keep the UMA metric semantics the sam e over time. 38 * should be treated as APPEND ONLY to keep the UMA metric semantics the sam e over time.
40 * 39 *
41 * A SystemNotificationType value can also be saved in shared preferences. 40 * A SystemNotificationType value can also be saved in shared preferences.
42 */ 41 */
43 public static final int DOWNLOAD_FILES = 0; 42 public static final int DOWNLOAD_FILES = 0;
43
44 public static final int DOWNLOAD_PAGES = 1; 44 public static final int DOWNLOAD_PAGES = 1;
45
45 public static final int CLOSE_INCOGNITO = 2; 46 public static final int CLOSE_INCOGNITO = 2;
47
46 public static final int CONTENT_SUGGESTION = 3; 48 public static final int CONTENT_SUGGESTION = 3;
49 public static final int MEDIA_CAPTURE = 4;
50 public static final int PHYSICAL_WEB = 5;
51 public static final int MEDIA = 6;
52 public static final int SITES = 7;
53 public static final int SYNC = 8;
47 54
48 private static final int SYSTEM_NOTIFICATION_TYPE_BOUNDARY = 4; 55 private static final int SYSTEM_NOTIFICATION_TYPE_BOUNDARY = 9;
49 56
50 private static final String LAST_SHOWN_NOTIFICATION_TYPE_KEY = 57 private static final String LAST_SHOWN_NOTIFICATION_TYPE_KEY =
51 "NotificationUmaTracker.LastShownNotificationType"; 58 "NotificationUmaTracker.LastShownNotificationType";
52 59
53 private static class LazyHolder { 60 private static class LazyHolder {
54 private static final NotificationUmaTracker INSTANCE = new NotificationU maTracker(); 61 private static final NotificationUmaTracker INSTANCE = new NotificationU maTracker();
55 } 62 }
56 63
57 /** Cached objects. */ 64 /** Cached objects. */
58 private final SharedPreferences mSharedPreferences; 65 private final SharedPreferences mSharedPreferences;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 mSharedPreferences.edit().remove(LAST_SHOWN_NOTIFICATION_TYPE_KEY).apply (); 133 mSharedPreferences.edit().remove(LAST_SHOWN_NOTIFICATION_TYPE_KEY).apply ();
127 134
128 recordHistogram("Mobile.SystemNotification.BlockedAfterShown", lastType) ; 135 recordHistogram("Mobile.SystemNotification.BlockedAfterShown", lastType) ;
129 } 136 }
130 137
131 private static void recordHistogram(String name, @SystemNotificationType int type) { 138 private static void recordHistogram(String name, @SystemNotificationType int type) {
132 if (!LibraryLoader.isInitialized()) return; 139 if (!LibraryLoader.isInitialized()) return;
133 RecordHistogram.recordEnumeratedHistogram(name, type, SYSTEM_NOTIFICATIO N_TYPE_BOUNDARY); 140 RecordHistogram.recordEnumeratedHistogram(name, type, SYSTEM_NOTIFICATIO N_TYPE_BOUNDARY);
134 } 141 }
135 } 142 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698