Merge "Revert "Notification statsd logs: Notification panel."" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f5324f74f5
@@ -48,17 +48,6 @@ public final class InstanceId implements Parcelable {
|
||||
return mId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a fake instance ID for testing purposes. Not for production use. See also
|
||||
* InstanceIdSequenceFake, which is a testing replacement for InstanceIdSequence.
|
||||
* @param id The ID you want to assign.
|
||||
* @return new InstanceId.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public static InstanceId fakeInstanceId(int id) {
|
||||
return new InstanceId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return mId;
|
||||
|
||||
@@ -43,8 +43,6 @@ import com.android.systemui.statusbar.notification.init.NotificationsController;
|
||||
import com.android.systemui.statusbar.notification.init.NotificationsControllerImpl;
|
||||
import com.android.systemui.statusbar.notification.init.NotificationsControllerStub;
|
||||
import com.android.systemui.statusbar.notification.logging.NotificationLogger;
|
||||
import com.android.systemui.statusbar.notification.logging.NotificationPanelLogger;
|
||||
import com.android.systemui.statusbar.notification.logging.NotificationPanelLoggerImpl;
|
||||
import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager;
|
||||
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
|
||||
import com.android.systemui.statusbar.phone.NotificationGroupManager;
|
||||
@@ -146,22 +144,13 @@ public interface NotificationsModule {
|
||||
@UiBackground Executor uiBgExecutor,
|
||||
NotificationEntryManager entryManager,
|
||||
StatusBarStateController statusBarStateController,
|
||||
NotificationLogger.ExpansionStateLogger expansionStateLogger,
|
||||
NotificationPanelLogger notificationPanelLogger) {
|
||||
NotificationLogger.ExpansionStateLogger expansionStateLogger) {
|
||||
return new NotificationLogger(
|
||||
notificationListener,
|
||||
uiBgExecutor,
|
||||
entryManager,
|
||||
statusBarStateController,
|
||||
expansionStateLogger,
|
||||
notificationPanelLogger);
|
||||
}
|
||||
|
||||
/** Provides an instance of {@link NotificationPanelLogger} */
|
||||
@Singleton
|
||||
@Provides
|
||||
static NotificationPanelLogger provideNotificationPanelLogger() {
|
||||
return new NotificationPanelLoggerImpl();
|
||||
expansionStateLogger);
|
||||
}
|
||||
|
||||
/** Provides an instance of {@link NotificationBlockingHelperManager} */
|
||||
|
||||
@@ -70,7 +70,6 @@ public class NotificationLogger implements StateListener {
|
||||
private final NotificationListenerService mNotificationListener;
|
||||
private final Executor mUiBgExecutor;
|
||||
private final NotificationEntryManager mEntryManager;
|
||||
private final NotificationPanelLogger mNotificationPanelLogger;
|
||||
private HeadsUpManager mHeadsUpManager;
|
||||
private final ExpansionStateLogger mExpansionStateLogger;
|
||||
|
||||
@@ -199,15 +198,13 @@ public class NotificationLogger implements StateListener {
|
||||
@UiBackground Executor uiBgExecutor,
|
||||
NotificationEntryManager entryManager,
|
||||
StatusBarStateController statusBarStateController,
|
||||
ExpansionStateLogger expansionStateLogger,
|
||||
NotificationPanelLogger notificationPanelLogger) {
|
||||
ExpansionStateLogger expansionStateLogger) {
|
||||
mNotificationListener = notificationListener;
|
||||
mUiBgExecutor = uiBgExecutor;
|
||||
mEntryManager = entryManager;
|
||||
mBarService = IStatusBarService.Stub.asInterface(
|
||||
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
|
||||
mExpansionStateLogger = expansionStateLogger;
|
||||
mNotificationPanelLogger = notificationPanelLogger;
|
||||
// Not expected to be destroyed, don't need to unsubscribe
|
||||
statusBarStateController.addCallback(this);
|
||||
|
||||
@@ -267,9 +264,6 @@ public class NotificationLogger implements StateListener {
|
||||
// (Note that in cases where the scroller does emit events, this
|
||||
// additional event doesn't break anything.)
|
||||
mNotificationLocationsChangedListener.onChildLocationsChanged();
|
||||
// TODO - determine if this work needs to be put on mUiBgExecutor
|
||||
mNotificationPanelLogger.logPanelShown(mListContainer.hasPulsingNotifications(),
|
||||
mEntryManager.getVisibleNotifications());
|
||||
}
|
||||
|
||||
private void setDozing(boolean dozing) {
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.statusbar.notification.logging;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
|
||||
import com.android.internal.logging.UiEvent;
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import nano.Notifications;
|
||||
|
||||
/**
|
||||
* Statsd logging for notification panel.
|
||||
*/
|
||||
public interface NotificationPanelLogger {
|
||||
|
||||
/**
|
||||
* Log a NOTIFICATION_PANEL_REPORTED statsd event.
|
||||
* @param visibleNotifications as provided by NotificationEntryManager.getVisibleNotifications()
|
||||
*/
|
||||
void logPanelShown(boolean isLockscreen,
|
||||
@Nullable List<NotificationEntry> visibleNotifications);
|
||||
|
||||
enum NotificationPanelEvent implements UiEventLogger.UiEventEnum {
|
||||
@UiEvent(doc = "Notification panel shown from status bar.")
|
||||
NOTIFICATION_PANEL_OPEN_STATUS_BAR(200),
|
||||
@UiEvent(doc = "Notification panel shown from lockscreen.")
|
||||
NOTIFICATION_PANEL_OPEN_LOCKSCREEN(201);
|
||||
|
||||
private final int mId;
|
||||
NotificationPanelEvent(int id) {
|
||||
mId = id;
|
||||
}
|
||||
@Override public int getId() {
|
||||
return mId;
|
||||
}
|
||||
|
||||
public static NotificationPanelEvent fromLockscreen(boolean isLockscreen) {
|
||||
return isLockscreen ? NOTIFICATION_PANEL_OPEN_LOCKSCREEN :
|
||||
NOTIFICATION_PANEL_OPEN_STATUS_BAR;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Composes a NotificationsList proto from the list of visible notifications.
|
||||
* @param visibleNotifications as provided by NotificationEntryManager.getVisibleNotifications()
|
||||
* @return NotificationList proto suitable for SysUiStatsLog.write(NOTIFICATION_PANEL_REPORTED)
|
||||
*/
|
||||
static Notifications.NotificationList toNotificationProto(
|
||||
@Nullable List<NotificationEntry> visibleNotifications) {
|
||||
Notifications.NotificationList notificationList = new Notifications.NotificationList();
|
||||
if (visibleNotifications == null) {
|
||||
return notificationList;
|
||||
}
|
||||
final Notifications.Notification[] nn =
|
||||
new Notifications.Notification[visibleNotifications.size()];
|
||||
int i = 0;
|
||||
for (NotificationEntry ne : visibleNotifications) {
|
||||
StatusBarNotification n = ne.getSbn();
|
||||
Notifications.Notification np = new Notifications.Notification();
|
||||
np.uid = n.getUid();
|
||||
np.packageName = n.getPackageName();
|
||||
np.instanceId = n.getInstanceId().getId();
|
||||
// TODO set np.groupInstanceId
|
||||
np.isGroupSummary = n.getNotification().isGroupSummary();
|
||||
np.section = 1 + ne.getBucket(); // We want 0 to mean not set / unknown
|
||||
nn[i] = np;
|
||||
++i;
|
||||
}
|
||||
notificationList.notifications = nn;
|
||||
return notificationList;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.statusbar.notification.logging;
|
||||
|
||||
import com.android.systemui.shared.system.SysUiStatsLog;
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
||||
|
||||
import com.google.protobuf.nano.MessageNano;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import nano.Notifications;
|
||||
|
||||
/**
|
||||
* Normal implementation of NotificationPanelLogger.
|
||||
*/
|
||||
public class NotificationPanelLoggerImpl implements NotificationPanelLogger {
|
||||
@Override
|
||||
public void logPanelShown(boolean isLockscreen,
|
||||
List<NotificationEntry> visibleNotifications) {
|
||||
final Notifications.NotificationList proto = NotificationPanelLogger.toNotificationProto(
|
||||
visibleNotifications);
|
||||
SysUiStatsLog.write(SysUiStatsLog.NOTIFICATION_PANEL_REPORTED,
|
||||
/* int event_id */ NotificationPanelEvent.fromLockscreen(isLockscreen).getId(),
|
||||
/* int num_notifications*/ proto.notifications.length,
|
||||
/* byte[] notifications*/ MessageNano.toByteArray(proto));
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* NotificationList proto from atoms.proto, duplicated here so that it's accessible in the build.
|
||||
* Must be kept in sync with the version in atoms.proto.
|
||||
*/
|
||||
|
||||
message Notification {
|
||||
// The notifying app's uid and package.
|
||||
optional int32 uid = 1;
|
||||
optional string package_name = 2;
|
||||
// A small system-assigned identifier for the notification.
|
||||
optional int32 instance_id = 3;
|
||||
|
||||
// Grouping information.
|
||||
optional int32 group_instance_id = 4;
|
||||
optional bool is_group_summary = 5;
|
||||
|
||||
// The section of the shade that the notification is in.
|
||||
// See NotificationSectionsManager.PriorityBucket.
|
||||
enum NotificationSection {
|
||||
SECTION_UNKNOWN = 0;
|
||||
SECTION_PEOPLE = 1;
|
||||
SECTION_ALERTING = 2;
|
||||
SECTION_SILENT = 3;
|
||||
}
|
||||
optional NotificationSection section = 6;
|
||||
}
|
||||
|
||||
message NotificationList {
|
||||
repeated Notification notifications = 1; // An ordered sequence of notifications.
|
||||
}
|
||||
@@ -22,8 +22,6 @@ import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
|
||||
import com.android.internal.logging.InstanceId;
|
||||
|
||||
/**
|
||||
* Convenience builder for {@link StatusBarNotification} since its constructor is terrifying.
|
||||
*
|
||||
@@ -42,7 +40,6 @@ public class SbnBuilder {
|
||||
private UserHandle mUser = UserHandle.of(0);
|
||||
private String mOverrideGroupKey;
|
||||
private long mPostTime;
|
||||
private InstanceId mInstanceId;
|
||||
|
||||
public SbnBuilder() {
|
||||
}
|
||||
@@ -58,7 +55,6 @@ public class SbnBuilder {
|
||||
mUser = source.getUser();
|
||||
mOverrideGroupKey = source.getOverrideGroupKey();
|
||||
mPostTime = source.getPostTime();
|
||||
mInstanceId = source.getInstanceId();
|
||||
}
|
||||
|
||||
public StatusBarNotification build() {
|
||||
@@ -75,7 +71,7 @@ public class SbnBuilder {
|
||||
notification.setBubbleMetadata(mBubbleMetadata);
|
||||
}
|
||||
|
||||
StatusBarNotification result = new StatusBarNotification(
|
||||
return new StatusBarNotification(
|
||||
mPkg,
|
||||
mOpPkg,
|
||||
mId,
|
||||
@@ -86,12 +82,6 @@ public class SbnBuilder {
|
||||
mUser,
|
||||
mOverrideGroupKey,
|
||||
mPostTime);
|
||||
if (mInstanceId != null) {
|
||||
result.setInstanceId(mInstanceId);
|
||||
} else {
|
||||
result.setInstanceId(InstanceId.fakeInstanceId(1));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public SbnBuilder setPkg(String pkg) {
|
||||
@@ -185,9 +175,4 @@ public class SbnBuilder {
|
||||
mBubbleMetadata = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SbnBuilder setInstanceId(InstanceId instanceId) {
|
||||
mInstanceId = instanceId;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,7 @@
|
||||
|
||||
package com.android.systemui.statusbar.notification.logging;
|
||||
|
||||
import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_ALERTING;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -65,8 +62,6 @@ import org.mockito.MockitoAnnotations;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import nano.Notifications;
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@TestableLooper.RunWithLooper
|
||||
@@ -86,10 +81,9 @@ public class NotificationLoggerTest extends SysuiTestCase {
|
||||
|
||||
private NotificationEntry mEntry;
|
||||
private TestableNotificationLogger mLogger;
|
||||
private NotificationEntryListener mNotificationEntryListener;
|
||||
private ConcurrentLinkedQueue<AssertionError> mErrorQueue = new ConcurrentLinkedQueue<>();
|
||||
private FakeExecutor mUiBgExecutor = new FakeExecutor(new FakeSystemClock());
|
||||
private NotificationPanelLoggerFake mNotificationPanelLoggerFake =
|
||||
new NotificationPanelLoggerFake();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -111,6 +105,7 @@ public class NotificationLoggerTest extends SysuiTestCase {
|
||||
mExpansionStateLogger);
|
||||
mLogger.setUpWithContainer(mListContainer);
|
||||
verify(mEntryManager).addNotificationEntryListener(mEntryListenerCaptor.capture());
|
||||
mNotificationEntryListener = mEntryListenerCaptor.getValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -169,21 +164,6 @@ public class NotificationLoggerTest extends SysuiTestCase {
|
||||
verify(mBarService, times(1)).onNotificationVisibilityChanged(any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLogPanelShownOnLoggingStart() {
|
||||
when(mEntryManager.getVisibleNotifications()).thenReturn(Lists.newArrayList(mEntry));
|
||||
mLogger.startNotificationLogging();
|
||||
assertEquals(1, mNotificationPanelLoggerFake.getCalls().size());
|
||||
assertEquals(false, mNotificationPanelLoggerFake.get(0).isDozing);
|
||||
assertEquals(1, mNotificationPanelLoggerFake.get(0).list.notifications.length);
|
||||
Notifications.Notification n = mNotificationPanelLoggerFake.get(0).list.notifications[0];
|
||||
assertEquals(TEST_PACKAGE_NAME, n.packageName);
|
||||
assertEquals(TEST_UID, n.uid);
|
||||
assertEquals(1, n.instanceId);
|
||||
assertEquals(false, n.isGroupSummary);
|
||||
assertEquals(1 + BUCKET_ALERTING, n.section);
|
||||
}
|
||||
|
||||
private class TestableNotificationLogger extends NotificationLogger {
|
||||
|
||||
TestableNotificationLogger(NotificationListener notificationListener,
|
||||
@@ -193,7 +173,7 @@ public class NotificationLoggerTest extends SysuiTestCase {
|
||||
IStatusBarService barService,
|
||||
ExpansionStateLogger expansionStateLogger) {
|
||||
super(notificationListener, uiBgExecutor, entryManager, statusBarStateController,
|
||||
expansionStateLogger, mNotificationPanelLoggerFake);
|
||||
expansionStateLogger);
|
||||
mBarService = barService;
|
||||
// Make this on the current thread so we can wait for it during tests.
|
||||
mHandler = Handler.createAsync(Looper.myLooper());
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.statusbar.notification.logging;
|
||||
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nano.Notifications;
|
||||
|
||||
public class NotificationPanelLoggerFake implements NotificationPanelLogger {
|
||||
private List<CallRecord> mCalls = new ArrayList<>();
|
||||
|
||||
List<CallRecord> getCalls() {
|
||||
return mCalls;
|
||||
}
|
||||
|
||||
CallRecord get(int index) {
|
||||
return mCalls.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logPanelShown(boolean isLockscreen,
|
||||
List<NotificationEntry> visibleNotifications) {
|
||||
mCalls.add(new CallRecord(isLockscreen,
|
||||
NotificationPanelLogger.toNotificationProto(visibleNotifications)));
|
||||
}
|
||||
|
||||
public static class CallRecord {
|
||||
public boolean isDozing;
|
||||
public Notifications.NotificationList list;
|
||||
CallRecord(boolean isDozing, Notifications.NotificationList list) {
|
||||
this.isDozing = isDozing;
|
||||
this.list = list;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,7 +122,6 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
|
||||
import com.android.systemui.statusbar.notification.init.NotificationsController;
|
||||
import com.android.systemui.statusbar.notification.logging.NotificationLogger;
|
||||
import com.android.systemui.statusbar.notification.logging.NotificationPanelLoggerFake;
|
||||
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
|
||||
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
|
||||
import com.android.systemui.statusbar.phone.dagger.StatusBarComponent;
|
||||
@@ -274,7 +273,7 @@ public class StatusBarTest extends SysuiTestCase {
|
||||
mMetricsLogger = new FakeMetricsLogger();
|
||||
NotificationLogger notificationLogger = new NotificationLogger(mNotificationListener,
|
||||
mUiBgExecutor, mock(NotificationEntryManager.class), mStatusBarStateController,
|
||||
mExpansionStateLogger, new NotificationPanelLoggerFake());
|
||||
mExpansionStateLogger);
|
||||
notificationLogger.setVisibilityReporter(mock(Runnable.class));
|
||||
|
||||
when(mCommandQueue.asBinder()).thenReturn(new Binder());
|
||||
|
||||
Reference in New Issue
Block a user