Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c10f39d5 authored by Christoph Studer's avatar Christoph Studer Committed by Android Git Automerger
Browse files

am 5c1a4965: Merge "SysUI/NoMan: Log clicks on notification buttons" into lmp-mr1-dev

* commit '5c1a4965':
  SysUI/NoMan: Log clicks on notification buttons
parents e5c5b948 5c1a4965
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ interface IStatusBarService
    void onPanelRevealed();
    void onPanelHidden();
    void onNotificationClick(String key);
    void onNotificationActionClick(String key, int actionIndex);
    void onNotificationError(String pkg, String tag, int id,
            int uid, int initialPid, String message, int userId);
    void onClearAllNotifications(int userId);
+33 −0
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewParent;
import android.view.ViewStub;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
@@ -266,6 +267,7 @@ public abstract class BaseStatusBar extends SystemUI implements
            if (DEBUG) {
                Log.v(TAG, "Notification click handler invoked for intent: " + pendingIntent);
            }
            logActionClick(view);
            // The intent we are sending is for the application, which
            // won't have permission to immediately start an activity after
            // 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,
                Intent fillInIntent) {
            return super.onClickHandler(view, pendingIntent, fillInIntent);
+2 −0
Original line number Diff line number Diff line
@@ -69,6 +69,8 @@ option java_package com.android.server
27511 notification_expansion (key|3),(user_action|1),(expanded|1)
# when a notification has been clicked
27520 notification_clicked (key|3)
# when a notification action button has been clicked
27521 notification_action_clicked (key|3),(action_index|1)

# ---------------------------
# Watchdog.java
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ public interface NotificationDelegate {
    void onSetDisabled(int status);
    void onClearAll(int callingUid, int callingPid, int userId);
    void onNotificationClick(int callingUid, int callingPid, String key);
    void onNotificationActionClick(int callingUid, int callingPid, String key, int actionIndex);
    void onNotificationClear(int callingUid, int callingPid,
            String pkg, String tag, int id, int userId);
    void onNotificationError(int callingUid, int callingPid,
+14 −0
Original line number Diff line number Diff line
@@ -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
        public void onNotificationClear(int callingUid, int callingPid,
                String pkg, String tag, int id, int userId) {
Loading