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

Commit 78403d79 authored by Chris Wren's avatar Chris Wren
Browse files

Add a log and statistics for notification expansion.

Bug: 16618854
Change-Id: I501f396fa495e1e55a27d7d0b65aac66495418c1
parent 29762c3d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ interface IStatusBarService
    void onNotificationClear(String pkg, String tag, int id, int userId);
    void onNotificationVisibilityChanged(
            in String[] newlyVisibleKeys, in String[] noLongerVisibleKeys);
    void onNotificationExpansionChanged(in String key, in boolean userAction, in boolean expanded);
    void setSystemUiVisibility(int vis, int mask);
    void setHardKeyboardEnabled(boolean enabled);
    void setWindowState(int window, int state);
+11 −1
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ import static com.android.keyguard.KeyguardHostView.OnDismissAction;

public abstract class BaseStatusBar extends SystemUI implements
        CommandQueue.Callbacks, ActivatableNotificationView.OnActivatedListener,
        RecentsComponent.Callbacks {
        RecentsComponent.Callbacks, ExpandableNotificationRow.ExpansionLogger {
    public static final String TAG = "StatusBar";
    public static final boolean DEBUG = false;
    public static final boolean MULTIUSER_DEBUG = false;
@@ -1035,6 +1035,7 @@ public abstract class BaseStatusBar extends SystemUI implements
                    Context.LAYOUT_INFLATER_SERVICE);
            row = (ExpandableNotificationRow) inflater.inflate(R.layout.status_bar_notification_row,
                    parent, false);
            row.setExpansionLogger(this, entry.notification.getKey());
        }

        // the notification inspector (see SwipeHelper.setLongPressListener)
@@ -1784,4 +1785,13 @@ public abstract class BaseStatusBar extends SystemUI implements
        }
        return contextForUser.getPackageManager();
    }

    @Override
    public void logNotificationExpansion(String key, boolean userAction, boolean expanded) {
        try {
            mBarService.onNotificationExpansionChanged(key, userAction, expanded);
        } catch (RemoteException e) {
            // Ignore.
        }
    }
}
+27 −0
Original line number Diff line number Diff line
@@ -54,6 +54,12 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
    private int mMaxExpandHeight;
    private View mVetoButton;
    private boolean mClearable;
    private ExpansionLogger mLogger;
    private String mLoggingKey;

    public interface ExpansionLogger {
        public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
    }

    public ExpandableNotificationRow(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -66,6 +72,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
    public void reset() {
        super.reset();
        mRowMinHeight = 0;
        final boolean wasExpanded = isExpanded();
        mRowMaxHeight = 0;
        mExpandable = false;
        mHasUserChangedExpansion = false;
@@ -76,6 +83,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        mPublicLayout.reset();
        mPrivateLayout.reset();
        mMaxExpandHeight = 0;
        logExpansionEvent(false, wasExpanded);
    }

    @Override
@@ -131,8 +139,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
     */
    public void setUserExpanded(boolean userExpanded) {
        if (userExpanded && !mExpandable) return;
        final boolean wasExpanded = isExpanded();
        mHasUserChangedExpansion = true;
        mUserExpanded = userExpanded;
        logExpansionEvent(true, wasExpanded);
    }

    public boolean isUserLocked() {
@@ -156,15 +166,19 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
     * @param expand whether the system wants this notification to be expanded.
     */
    public void setSystemExpanded(boolean expand) {
        final boolean wasExpanded = isExpanded();
        mIsSystemExpanded = expand;
        notifyHeightChanged();
        logExpansionEvent(false, wasExpanded);
    }

    /**
     * @param expansionDisabled whether to prevent notification expansion
     */
    public void setExpansionDisabled(boolean expansionDisabled) {
        final boolean wasExpanded = isExpanded();
        mExpansionDisabled = expansionDisabled;
        logExpansionEvent(false, wasExpanded);
        notifyHeightChanged();
    }

@@ -302,4 +316,17 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
    private NotificationContentView getShowingLayout() {
        return mShowingPublic ? mPublicLayout : mPrivateLayout;
    }

    public void setExpansionLogger(ExpansionLogger logger, String key) {
        mLogger = logger;
        mLoggingKey = key;
    }


    private void logExpansionEvent(boolean userAction, boolean wasExpanded) {
        final boolean nowExpanded = isExpanded();
        if (wasExpanded != nowExpanded && mLogger != null) {
            mLogger.logNotificationExpansion(mLoggingKey, userAction, nowExpanded) ;
        }
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -65,6 +65,8 @@ option java_package com.android.server
27501 notification_panel_hidden
# when notifications are newly displayed on screen, or disappear from screen
27510 notification_visibility_changed (newlyVisibleKeys|3),(noLongerVisibleKeys|3)
# when notifications are expanded, or contracted
27511 notification_expansion (key|3),(user_action|1),(expanded|1)
# when a notification has been clicked
27520 notification_clicked (key|3)

+1 −0
Original line number Diff line number Diff line
@@ -32,4 +32,5 @@ public interface NotificationDelegate {
    boolean allowDisable(int what, IBinder token, String pkg);
    void onNotificationVisibilityChanged(
            String[] newlyVisibleKeys, String[] noLongerVisibleKeys);
    void onNotificationExpansionChanged(String key, boolean userAction, boolean expanded);
}
Loading