Loading services/core/java/com/android/server/EventLogTags.logtags +4 −4 Original line number Original line Diff line number Diff line Loading @@ -66,13 +66,13 @@ option java_package com.android.server # when notifications are newly displayed on screen, or disappear from screen # when notifications are newly displayed on screen, or disappear from screen 27510 notification_visibility_changed (newlyVisibleKeys|3),(noLongerVisibleKeys|3) 27510 notification_visibility_changed (newlyVisibleKeys|3),(noLongerVisibleKeys|3) # when notifications are expanded, or contracted # when notifications are expanded, or contracted 27511 notification_expansion (key|3),(user_action|1),(expanded|1) 27511 notification_expansion (key|3),(user_action|1),(expanded|1),(lifespan|1),(freshness|1),(exposure|1) # when a notification has been clicked # when a notification has been clicked 27520 notification_clicked (key|3) 27520 notification_clicked (key|3),(lifespan|1),(freshness|1),(exposure|1) # when a notification action button has been clicked # when a notification action button has been clicked 27521 notification_action_clicked (key|3),(action_index|1) 27521 notification_action_clicked (key|3),(action_index|1),(lifespan|1),(freshness|1),(exposure|1) # when a notification has been canceled # when a notification has been canceled 27530 notification_canceled (key|3),(reason|1),(lifespan|1),(exposure|1) 27530 notification_canceled (key|3),(reason|1),(lifespan|1),(freshness|1),(exposure|1) # replaces 27510 with a row per notification # replaces 27510 with a row per notification 27531 notification_visibility (key|3),(visibile|1),(lifespan|1),(freshness|1) 27531 notification_visibility (key|3),(visibile|1),(lifespan|1),(freshness|1) Loading services/core/java/com/android/server/notification/NotificationManagerService.java +13 −7 Original line number Original line Diff line number Diff line Loading @@ -555,12 +555,15 @@ public class NotificationManagerService extends SystemService { @Override @Override public void onNotificationClick(int callingUid, int callingPid, String key) { public void onNotificationClick(int callingUid, int callingPid, String key) { synchronized (mNotificationList) { synchronized (mNotificationList) { EventLogTags.writeNotificationClicked(key); NotificationRecord r = mNotificationsByKey.get(key); NotificationRecord r = mNotificationsByKey.get(key); if (r == null) { if (r == null) { Log.w(TAG, "No notification with key: " + key); Log.w(TAG, "No notification with key: " + key); return; return; } } final long now = System.currentTimeMillis(); EventLogTags.writeNotificationClicked(key, r.getLifespanMs(now), r.getFreshnessMs(now), r.getExposureMs(now)); StatusBarNotification sbn = r.sbn; StatusBarNotification sbn = r.sbn; cancelNotification(callingUid, callingPid, sbn.getPackageName(), sbn.getTag(), cancelNotification(callingUid, callingPid, sbn.getPackageName(), sbn.getTag(), sbn.getId(), Notification.FLAG_AUTO_CANCEL, sbn.getId(), Notification.FLAG_AUTO_CANCEL, Loading @@ -573,12 +576,14 @@ public class NotificationManagerService extends SystemService { public void onNotificationActionClick(int callingUid, int callingPid, String key, public void onNotificationActionClick(int callingUid, int callingPid, String key, int actionIndex) { int actionIndex) { synchronized (mNotificationList) { synchronized (mNotificationList) { EventLogTags.writeNotificationActionClicked(key, actionIndex); NotificationRecord r = mNotificationsByKey.get(key); NotificationRecord r = mNotificationsByKey.get(key); if (r == null) { if (r == null) { Log.w(TAG, "No notification with key: " + key); Log.w(TAG, "No notification with key: " + key); return; return; } } final long now = System.currentTimeMillis(); EventLogTags.writeNotificationActionClicked(key, actionIndex, r.getLifespanMs(now), r.getFreshnessMs(now), r.getExposureMs(now)); // TODO: Log action click via UsageStats. // TODO: Log action click via UsageStats. } } } } Loading Loading @@ -685,11 +690,14 @@ public class NotificationManagerService extends SystemService { @Override @Override public void onNotificationExpansionChanged(String key, public void onNotificationExpansionChanged(String key, boolean userAction, boolean expanded) { boolean userAction, boolean expanded) { EventLogTags.writeNotificationExpansion(key, userAction ? 1 : 0, expanded ? 1 : 0); synchronized (mNotificationList) { synchronized (mNotificationList) { NotificationRecord r = mNotificationsByKey.get(key); NotificationRecord r = mNotificationsByKey.get(key); if (r != null) { if (r != null) { r.stats.onExpansionChanged(userAction, expanded); r.stats.onExpansionChanged(userAction, expanded); final long now = System.currentTimeMillis(); EventLogTags.writeNotificationExpansion(key, userAction ? 1 : 0, expanded ? 1 : 0, r.getLifespanMs(now), r.getFreshnessMs(now), r.getExposureMs(now)); } } } } } } Loading Loading @@ -2787,10 +2795,8 @@ public class NotificationManagerService extends SystemService { mArchive.record(r.sbn); mArchive.record(r.sbn); final long now = System.currentTimeMillis(); final long now = System.currentTimeMillis(); final int lifespan = (int) (now - r.getCreationTimeMs()); EventLogTags.writeNotificationCanceled(canceledKey, reason, final long visibleSinceMs = r.getVisibleSinceMs(); r.getLifespanMs(now), r.getFreshnessMs(now), r.getExposureMs(now)); final int exposure = visibleSinceMs == 0L ? 0 : (int) (now - visibleSinceMs); EventLogTags.writeNotificationCanceled(canceledKey, reason, lifespan, exposure); } } /** /** Loading services/core/java/com/android/server/notification/NotificationRecord.java +13 −10 Original line number Original line Diff line number Diff line Loading @@ -288,24 +288,27 @@ public final class NotificationRecord { } } /** /** * Returns the timestamp of the most recent updates, or the post time if none. * @param now this current time in milliseconds. * @returns the number of milliseconds since the most recent update, or the post time if none. */ */ public long getUpdateTimeMs() { public int getFreshnessMs(long now) { return mUpdateTimeMs; return (int) (now - mUpdateTimeMs); } } /** /** * Returns the timestamp of the first post, ignoring updates. * @param now this current time in milliseconds. * @returns the number of milliseconds since the the first post, ignoring updates. */ */ public long getCreationTimeMs() { public int getLifespanMs(long now) { return mCreationTimeMs; return (int) (now - mCreationTimeMs); } } /** /** * Returns the timestamp of the most recent visibility event, or 0L if hidden. * @param now this current time in milliseconds. * @returns the number of milliseconds since the most recent visibility event, or 0 if never. */ */ public long getVisibleSinceMs() { public int getExposureMs(long now) { return mVisibleSinceMs; return mVisibleSinceMs == 0 ? 0 : (int) (now - mVisibleSinceMs); } } /** /** Loading @@ -313,7 +316,7 @@ public final class NotificationRecord { */ */ public void setVisibility(boolean visible) { public void setVisibility(boolean visible) { final long now = System.currentTimeMillis(); final long now = System.currentTimeMillis(); mVisibleSinceMs = visible ? now : 0L; mVisibleSinceMs = visible ? now : mVisibleSinceMs; stats.onVisibilityChanged(visible); stats.onVisibilityChanged(visible); EventLogTags.writeNotificationVisibility(getKey(), visible ? 1 : 0, EventLogTags.writeNotificationVisibility(getKey(), visible ? 1 : 0, (int) (now - mCreationTimeMs), (int) (now - mCreationTimeMs), Loading Loading
services/core/java/com/android/server/EventLogTags.logtags +4 −4 Original line number Original line Diff line number Diff line Loading @@ -66,13 +66,13 @@ option java_package com.android.server # when notifications are newly displayed on screen, or disappear from screen # when notifications are newly displayed on screen, or disappear from screen 27510 notification_visibility_changed (newlyVisibleKeys|3),(noLongerVisibleKeys|3) 27510 notification_visibility_changed (newlyVisibleKeys|3),(noLongerVisibleKeys|3) # when notifications are expanded, or contracted # when notifications are expanded, or contracted 27511 notification_expansion (key|3),(user_action|1),(expanded|1) 27511 notification_expansion (key|3),(user_action|1),(expanded|1),(lifespan|1),(freshness|1),(exposure|1) # when a notification has been clicked # when a notification has been clicked 27520 notification_clicked (key|3) 27520 notification_clicked (key|3),(lifespan|1),(freshness|1),(exposure|1) # when a notification action button has been clicked # when a notification action button has been clicked 27521 notification_action_clicked (key|3),(action_index|1) 27521 notification_action_clicked (key|3),(action_index|1),(lifespan|1),(freshness|1),(exposure|1) # when a notification has been canceled # when a notification has been canceled 27530 notification_canceled (key|3),(reason|1),(lifespan|1),(exposure|1) 27530 notification_canceled (key|3),(reason|1),(lifespan|1),(freshness|1),(exposure|1) # replaces 27510 with a row per notification # replaces 27510 with a row per notification 27531 notification_visibility (key|3),(visibile|1),(lifespan|1),(freshness|1) 27531 notification_visibility (key|3),(visibile|1),(lifespan|1),(freshness|1) Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +13 −7 Original line number Original line Diff line number Diff line Loading @@ -555,12 +555,15 @@ public class NotificationManagerService extends SystemService { @Override @Override public void onNotificationClick(int callingUid, int callingPid, String key) { public void onNotificationClick(int callingUid, int callingPid, String key) { synchronized (mNotificationList) { synchronized (mNotificationList) { EventLogTags.writeNotificationClicked(key); NotificationRecord r = mNotificationsByKey.get(key); NotificationRecord r = mNotificationsByKey.get(key); if (r == null) { if (r == null) { Log.w(TAG, "No notification with key: " + key); Log.w(TAG, "No notification with key: " + key); return; return; } } final long now = System.currentTimeMillis(); EventLogTags.writeNotificationClicked(key, r.getLifespanMs(now), r.getFreshnessMs(now), r.getExposureMs(now)); StatusBarNotification sbn = r.sbn; StatusBarNotification sbn = r.sbn; cancelNotification(callingUid, callingPid, sbn.getPackageName(), sbn.getTag(), cancelNotification(callingUid, callingPid, sbn.getPackageName(), sbn.getTag(), sbn.getId(), Notification.FLAG_AUTO_CANCEL, sbn.getId(), Notification.FLAG_AUTO_CANCEL, Loading @@ -573,12 +576,14 @@ public class NotificationManagerService extends SystemService { public void onNotificationActionClick(int callingUid, int callingPid, String key, public void onNotificationActionClick(int callingUid, int callingPid, String key, int actionIndex) { int actionIndex) { synchronized (mNotificationList) { synchronized (mNotificationList) { EventLogTags.writeNotificationActionClicked(key, actionIndex); NotificationRecord r = mNotificationsByKey.get(key); NotificationRecord r = mNotificationsByKey.get(key); if (r == null) { if (r == null) { Log.w(TAG, "No notification with key: " + key); Log.w(TAG, "No notification with key: " + key); return; return; } } final long now = System.currentTimeMillis(); EventLogTags.writeNotificationActionClicked(key, actionIndex, r.getLifespanMs(now), r.getFreshnessMs(now), r.getExposureMs(now)); // TODO: Log action click via UsageStats. // TODO: Log action click via UsageStats. } } } } Loading Loading @@ -685,11 +690,14 @@ public class NotificationManagerService extends SystemService { @Override @Override public void onNotificationExpansionChanged(String key, public void onNotificationExpansionChanged(String key, boolean userAction, boolean expanded) { boolean userAction, boolean expanded) { EventLogTags.writeNotificationExpansion(key, userAction ? 1 : 0, expanded ? 1 : 0); synchronized (mNotificationList) { synchronized (mNotificationList) { NotificationRecord r = mNotificationsByKey.get(key); NotificationRecord r = mNotificationsByKey.get(key); if (r != null) { if (r != null) { r.stats.onExpansionChanged(userAction, expanded); r.stats.onExpansionChanged(userAction, expanded); final long now = System.currentTimeMillis(); EventLogTags.writeNotificationExpansion(key, userAction ? 1 : 0, expanded ? 1 : 0, r.getLifespanMs(now), r.getFreshnessMs(now), r.getExposureMs(now)); } } } } } } Loading Loading @@ -2787,10 +2795,8 @@ public class NotificationManagerService extends SystemService { mArchive.record(r.sbn); mArchive.record(r.sbn); final long now = System.currentTimeMillis(); final long now = System.currentTimeMillis(); final int lifespan = (int) (now - r.getCreationTimeMs()); EventLogTags.writeNotificationCanceled(canceledKey, reason, final long visibleSinceMs = r.getVisibleSinceMs(); r.getLifespanMs(now), r.getFreshnessMs(now), r.getExposureMs(now)); final int exposure = visibleSinceMs == 0L ? 0 : (int) (now - visibleSinceMs); EventLogTags.writeNotificationCanceled(canceledKey, reason, lifespan, exposure); } } /** /** Loading
services/core/java/com/android/server/notification/NotificationRecord.java +13 −10 Original line number Original line Diff line number Diff line Loading @@ -288,24 +288,27 @@ public final class NotificationRecord { } } /** /** * Returns the timestamp of the most recent updates, or the post time if none. * @param now this current time in milliseconds. * @returns the number of milliseconds since the most recent update, or the post time if none. */ */ public long getUpdateTimeMs() { public int getFreshnessMs(long now) { return mUpdateTimeMs; return (int) (now - mUpdateTimeMs); } } /** /** * Returns the timestamp of the first post, ignoring updates. * @param now this current time in milliseconds. * @returns the number of milliseconds since the the first post, ignoring updates. */ */ public long getCreationTimeMs() { public int getLifespanMs(long now) { return mCreationTimeMs; return (int) (now - mCreationTimeMs); } } /** /** * Returns the timestamp of the most recent visibility event, or 0L if hidden. * @param now this current time in milliseconds. * @returns the number of milliseconds since the most recent visibility event, or 0 if never. */ */ public long getVisibleSinceMs() { public int getExposureMs(long now) { return mVisibleSinceMs; return mVisibleSinceMs == 0 ? 0 : (int) (now - mVisibleSinceMs); } } /** /** Loading @@ -313,7 +316,7 @@ public final class NotificationRecord { */ */ public void setVisibility(boolean visible) { public void setVisibility(boolean visible) { final long now = System.currentTimeMillis(); final long now = System.currentTimeMillis(); mVisibleSinceMs = visible ? now : 0L; mVisibleSinceMs = visible ? now : mVisibleSinceMs; stats.onVisibilityChanged(visible); stats.onVisibilityChanged(visible); EventLogTags.writeNotificationVisibility(getKey(), visible ? 1 : 0, EventLogTags.writeNotificationVisibility(getKey(), visible ? 1 : 0, (int) (now - mCreationTimeMs), (int) (now - mCreationTimeMs), Loading