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

Commit a8e38aa5 authored by Gustav Sennton's avatar Gustav Sennton
Browse files

Add notification location to onNotificationExpansionChanged.

To know from what UI location a notification was expanded we here pass
the location of the notification through
onNotificationExpansionChanged().

Bug: 120767764
Test: atest SystemUITests
Test: atest NotificationManagerServiceTest
Change-Id: I20612f5a88cf987f434392ae7a004d3ee3098998
parent 7980f066
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ interface IStatusBarService
            int dismissalSurface, int dismissalSentiment, in NotificationVisibility nv);
    void onNotificationVisibilityChanged( in NotificationVisibility[] newlyVisibleKeys,
            in NotificationVisibility[] noLongerVisibleKeys);
    void onNotificationExpansionChanged(in String key, in boolean userAction, in boolean expanded);
    void onNotificationExpansionChanged(in String key, in boolean userAction, in boolean expanded, in int notificationLocation);
    void onNotificationDirectReplied(String key);
    void onNotificationSmartSuggestionsAdded(String key, int smartReplyCount, int smartActionCount,
            boolean generatedByAsssistant);
+4 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import androidx.annotation.Nullable;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.statusbar.notification.stack.ExpandableViewState;
import com.android.systemui.UiOffloadThread;
import com.android.systemui.statusbar.NotificationListener;
import com.android.systemui.statusbar.StatusBarStateController;
@@ -460,7 +461,9 @@ public class NotificationLogger implements StateListener {
            mUiOffloadThread.submit(() -> {
                try {
                    mBarService.onNotificationExpansionChanged(
                            key, stateToBeLogged.mIsUserAction, stateToBeLogged.mIsExpanded);
                            key, stateToBeLogged.mIsUserAction, stateToBeLogged.mIsExpanded,
                            // TODO (b/120767764): fill in location
                            ExpandableViewState.LOCATION_UNKNOWN /* notificationLocation */);
                } catch (RemoteException e) {
                    Log.e(TAG, "Failed to call onNotificationExpansionChanged: ", e);
                }
+9 −7
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package com.android.systemui.statusbar.notification.logging;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;

@@ -27,6 +28,7 @@ import android.testing.TestableLooper;

import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.statusbar.notification.stack.ExpandableViewState;
import com.android.systemui.Dependency;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.UiOffloadThread;
@@ -66,7 +68,7 @@ public class ExpansionStateLoggerTest extends SysuiTestCase {
        waitForUiOffloadThread();

        verify(mBarService, Mockito.never()).onNotificationExpansionChanged(
                eq(NOTIFICATION_KEY), anyBoolean(), anyBoolean());
                eq(NOTIFICATION_KEY), anyBoolean(), anyBoolean(), anyInt());
    }

    @Test
@@ -75,7 +77,7 @@ public class ExpansionStateLoggerTest extends SysuiTestCase {
        waitForUiOffloadThread();

        verify(mBarService, Mockito.never()).onNotificationExpansionChanged(
                eq(NOTIFICATION_KEY), anyBoolean(), anyBoolean());
                eq(NOTIFICATION_KEY), anyBoolean(), anyBoolean(), anyInt());
    }

    @Test
@@ -87,7 +89,7 @@ public class ExpansionStateLoggerTest extends SysuiTestCase {
        waitForUiOffloadThread();

        verify(mBarService, Mockito.never()).onNotificationExpansionChanged(
                eq(NOTIFICATION_KEY), anyBoolean(), anyBoolean());
                eq(NOTIFICATION_KEY), anyBoolean(), anyBoolean(), anyInt());
    }

    @Test
@@ -99,7 +101,7 @@ public class ExpansionStateLoggerTest extends SysuiTestCase {
        waitForUiOffloadThread();

        verify(mBarService).onNotificationExpansionChanged(
                NOTIFICATION_KEY, true, true);
                NOTIFICATION_KEY, true, true, ExpandableViewState.LOCATION_UNKNOWN);
    }

    @Test
@@ -111,7 +113,7 @@ public class ExpansionStateLoggerTest extends SysuiTestCase {
        waitForUiOffloadThread();

        verify(mBarService).onNotificationExpansionChanged(
                NOTIFICATION_KEY, false, true);
                NOTIFICATION_KEY, false, true, ExpandableViewState.LOCATION_UNKNOWN);
    }

    @Test
@@ -123,7 +125,7 @@ public class ExpansionStateLoggerTest extends SysuiTestCase {
        waitForUiOffloadThread();

        verify(mBarService).onNotificationExpansionChanged(
                NOTIFICATION_KEY, false, true);
                NOTIFICATION_KEY, false, true, ExpandableViewState.LOCATION_UNKNOWN);
    }

    @Test
@@ -136,7 +138,7 @@ public class ExpansionStateLoggerTest extends SysuiTestCase {
        waitForUiOffloadThread();

        verify(mBarService).onNotificationExpansionChanged(
                NOTIFICATION_KEY, false, true);
                NOTIFICATION_KEY, false, true, ExpandableViewState.LOCATION_UNKNOWN);
    }

    private NotificationVisibility createNotificationVisibility(String key, boolean visibility) {
+2 −1
Original line number Diff line number Diff line
@@ -42,7 +42,8 @@ public interface NotificationDelegate {
    void onNotificationVisibilityChanged(
            NotificationVisibility[] newlyVisibleKeys,
            NotificationVisibility[] noLongerVisibleKeys);
    void onNotificationExpansionChanged(String key, boolean userAction, boolean expanded);
    void onNotificationExpansionChanged(String key, boolean userAction, boolean expanded,
            int notificationLocation);
    void onNotificationDirectReplied(String key);
    void onNotificationSettingsViewed(String key);

+1 −1
Original line number Diff line number Diff line
@@ -868,7 +868,7 @@ public class NotificationManagerService extends SystemService {

        @Override
        public void onNotificationExpansionChanged(String key,
                boolean userAction, boolean expanded) {
                boolean userAction, boolean expanded, int notificationLocation) {
            synchronized (mNotificationLock) {
                NotificationRecord r = mNotificationsByKey.get(key);
                if (r != null) {
Loading