am 5c1a4965: Merge "SysUI/NoMan: Log clicks on notification buttons" into lmp-mr1-dev
* commit '5c1a49651b4e0a15a938560394bffeaeb5718f72': SysUI/NoMan: Log clicks on notification buttons
This commit is contained in:
@@ -43,6 +43,7 @@ interface IStatusBarService
|
|||||||
void onPanelRevealed();
|
void onPanelRevealed();
|
||||||
void onPanelHidden();
|
void onPanelHidden();
|
||||||
void onNotificationClick(String key);
|
void onNotificationClick(String key);
|
||||||
|
void onNotificationActionClick(String key, int actionIndex);
|
||||||
void onNotificationError(String pkg, String tag, int id,
|
void onNotificationError(String pkg, String tag, int id,
|
||||||
int uid, int initialPid, String message, int userId);
|
int uid, int initialPid, String message, int userId);
|
||||||
void onClearAllNotifications(int userId);
|
void onClearAllNotifications(int userId);
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ import android.view.View;
|
|||||||
import android.view.ViewAnimationUtils;
|
import android.view.ViewAnimationUtils;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewGroup.LayoutParams;
|
import android.view.ViewGroup.LayoutParams;
|
||||||
|
import android.view.ViewParent;
|
||||||
import android.view.ViewStub;
|
import android.view.ViewStub;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.WindowManagerGlobal;
|
import android.view.WindowManagerGlobal;
|
||||||
@@ -266,6 +267,7 @@ public abstract class BaseStatusBar extends SystemUI implements
|
|||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.v(TAG, "Notification click handler invoked for intent: " + pendingIntent);
|
Log.v(TAG, "Notification click handler invoked for intent: " + pendingIntent);
|
||||||
}
|
}
|
||||||
|
logActionClick(view);
|
||||||
// The intent we are sending is for the application, which
|
// The intent we are sending is for the application, which
|
||||||
// won't have permission to immediately start an activity after
|
// won't have permission to immediately start an activity after
|
||||||
// the user switches to home. We know it is safe to do at this
|
// the user switches to home. We know it is safe to do at this
|
||||||
@@ -308,6 +310,37 @@ public abstract class BaseStatusBar extends SystemUI implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void logActionClick(View view) {
|
||||||
|
ViewParent parent = view.getParent();
|
||||||
|
String key = getNotificationKeyForParent(parent);
|
||||||
|
if (key == null) {
|
||||||
|
Log.w(TAG, "Couldn't determine notification for click.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int index = -1;
|
||||||
|
// If this is a default template, determine the index of the button.
|
||||||
|
if (view.getId() == com.android.internal.R.id.action0 &&
|
||||||
|
parent != null && parent instanceof ViewGroup) {
|
||||||
|
ViewGroup actionGroup = (ViewGroup) parent;
|
||||||
|
index = actionGroup.indexOfChild(view);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
mBarService.onNotificationActionClick(key, index);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getNotificationKeyForParent(ViewParent parent) {
|
||||||
|
while (parent != null) {
|
||||||
|
if (parent instanceof ExpandableNotificationRow) {
|
||||||
|
return ((ExpandableNotificationRow) parent).getStatusBarNotification().getKey();
|
||||||
|
}
|
||||||
|
parent = parent.getParent();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean superOnClickHandler(View view, PendingIntent pendingIntent,
|
private boolean superOnClickHandler(View view, PendingIntent pendingIntent,
|
||||||
Intent fillInIntent) {
|
Intent fillInIntent) {
|
||||||
return super.onClickHandler(view, pendingIntent, fillInIntent);
|
return super.onClickHandler(view, pendingIntent, fillInIntent);
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ option java_package com.android.server
|
|||||||
27511 notification_expansion (key|3),(user_action|1),(expanded|1)
|
27511 notification_expansion (key|3),(user_action|1),(expanded|1)
|
||||||
# when a notification has been clicked
|
# when a notification has been clicked
|
||||||
27520 notification_clicked (key|3)
|
27520 notification_clicked (key|3)
|
||||||
|
# when a notification action button has been clicked
|
||||||
|
27521 notification_action_clicked (key|3),(action_index|1)
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# Watchdog.java
|
# Watchdog.java
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public interface NotificationDelegate {
|
|||||||
void onSetDisabled(int status);
|
void onSetDisabled(int status);
|
||||||
void onClearAll(int callingUid, int callingPid, int userId);
|
void onClearAll(int callingUid, int callingPid, int userId);
|
||||||
void onNotificationClick(int callingUid, int callingPid, String key);
|
void onNotificationClick(int callingUid, int callingPid, String key);
|
||||||
|
void onNotificationActionClick(int callingUid, int callingPid, String key, int actionIndex);
|
||||||
void onNotificationClear(int callingUid, int callingPid,
|
void onNotificationClear(int callingUid, int callingPid,
|
||||||
String pkg, String tag, int id, int userId);
|
String pkg, String tag, int id, int userId);
|
||||||
void onNotificationError(int callingUid, int callingPid,
|
void onNotificationError(int callingUid, int callingPid,
|
||||||
|
|||||||
@@ -540,6 +540,20 @@ public class NotificationManagerService extends SystemService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNotificationActionClick(int callingUid, int callingPid, String key,
|
||||||
|
int actionIndex) {
|
||||||
|
synchronized (mNotificationList) {
|
||||||
|
EventLogTags.writeNotificationActionClicked(key, actionIndex);
|
||||||
|
NotificationRecord r = mNotificationsByKey.get(key);
|
||||||
|
if (r == null) {
|
||||||
|
Log.w(TAG, "No notification with key: " + key);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// TODO: Log action click via UsageStats.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNotificationClear(int callingUid, int callingPid,
|
public void onNotificationClear(int callingUid, int callingPid,
|
||||||
String pkg, String tag, int id, int userId) {
|
String pkg, String tag, int id, int userId) {
|
||||||
|
|||||||
@@ -524,6 +524,20 @@ public class StatusBarManagerService extends IStatusBarService.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNotificationActionClick(String key, int actionIndex) {
|
||||||
|
enforceStatusBarService();
|
||||||
|
final int callingUid = Binder.getCallingUid();
|
||||||
|
final int callingPid = Binder.getCallingPid();
|
||||||
|
long identity = Binder.clearCallingIdentity();
|
||||||
|
try {
|
||||||
|
mNotificationDelegate.onNotificationActionClick(callingUid, callingPid, key,
|
||||||
|
actionIndex);
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(identity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNotificationError(String pkg, String tag, int id,
|
public void onNotificationError(String pkg, String tag, int id,
|
||||||
int uid, int initialPid, String message, int userId) {
|
int uid, int initialPid, String message, int userId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user