Merge "Log BAL and full screen intent to statsd." into tm-qpr-dev
This is only for the full screen intent part of the change. BAL will be merged in a separate patch. Test: atest StatusBarNotificationActivityStarterTest Bug: 266010511 Change-Id: I150c37d02bef3b0838c62cbd41d62d703de7480b Merged-In: I4fdfbe80ea0c368a4809e5613e5f9c3a8369e2a3
This commit is contained in:
@@ -27,6 +27,7 @@ import android.app.PendingIntent;
|
||||
import android.app.TaskStackBuilder;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -45,6 +46,7 @@ import androidx.annotation.VisibleForTesting;
|
||||
import com.android.internal.jank.InteractionJankMonitor;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.statusbar.NotificationVisibility;
|
||||
import com.android.internal.util.FrameworkStatsLog;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.systemui.ActivityIntentHelper;
|
||||
import com.android.systemui.EventLogTags;
|
||||
@@ -74,6 +76,7 @@ import com.android.systemui.statusbar.policy.HeadsUpUtil;
|
||||
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
||||
import com.android.systemui.wmshell.BubblesManager;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@@ -81,6 +84,7 @@ import javax.inject.Inject;
|
||||
|
||||
import dagger.Lazy;
|
||||
|
||||
|
||||
/**
|
||||
* Status bar implementation of {@link NotificationActivityStarter}.
|
||||
*/
|
||||
@@ -572,16 +576,29 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte
|
||||
});
|
||||
|
||||
// not immersive & a fullscreen alert should be shown
|
||||
final PendingIntent fullscreenIntent =
|
||||
final PendingIntent fullScreenIntent =
|
||||
entry.getSbn().getNotification().fullScreenIntent;
|
||||
mLogger.logSendingFullScreenIntent(entry, fullscreenIntent);
|
||||
mLogger.logSendingFullScreenIntent(entry, fullScreenIntent);
|
||||
try {
|
||||
EventLog.writeEvent(EventLogTags.SYSUI_FULLSCREEN_NOTIFICATION,
|
||||
entry.getKey());
|
||||
mCentralSurfaces.wakeUpForFullScreenIntent();
|
||||
fullscreenIntent.send();
|
||||
fullScreenIntent.send();
|
||||
entry.notifyFullScreenIntentLaunched();
|
||||
mMetricsLogger.count("note_fullscreen", 1);
|
||||
|
||||
String activityName;
|
||||
List<ResolveInfo> resolveInfos = fullScreenIntent.queryIntentComponents(0);
|
||||
if (resolveInfos.size() > 0 && resolveInfos.get(0) != null
|
||||
&& resolveInfos.get(0).activityInfo != null
|
||||
&& resolveInfos.get(0).activityInfo.name != null) {
|
||||
activityName = resolveInfos.get(0).activityInfo.name;
|
||||
} else {
|
||||
activityName = "";
|
||||
}
|
||||
FrameworkStatsLog.write(FrameworkStatsLog.FULL_SCREEN_INTENT_LAUNCHED,
|
||||
fullScreenIntent.getCreatorUid(),
|
||||
activityName);
|
||||
} catch (PendingIntent.CanceledException e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ package com.android.systemui.statusbar.phone;
|
||||
|
||||
import static android.service.notification.NotificationListenerService.REASON_CLICK;
|
||||
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession;
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
|
||||
|
||||
import static org.mockito.AdditionalAnswers.answerVoid;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
@@ -28,7 +31,6 @@ import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -38,6 +40,8 @@ import android.app.KeyguardManager;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Handler;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserHandle;
|
||||
@@ -51,6 +55,7 @@ import androidx.test.filters.SmallTest;
|
||||
import com.android.internal.jank.InteractionJankMonitor;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.statusbar.NotificationVisibility;
|
||||
import com.android.internal.util.FrameworkStatsLog;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.systemui.ActivityIntentHelper;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
@@ -90,9 +95,12 @@ import org.mockito.InOrder;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.MockitoSession;
|
||||
import org.mockito.quality.Strictness;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -398,4 +406,40 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase {
|
||||
// THEN display should try wake up for the full screen intent
|
||||
verify(mCentralSurfaces).wakeUpForFullScreenIntent();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnFullScreenIntentWhenDozing_logToStatsd() {
|
||||
final int kTestUid = 12345;
|
||||
final String kTestActivityName = "TestActivity";
|
||||
// GIVEN entry that can has a full screen intent that can show
|
||||
PendingIntent mockFullScreenIntent = mock(PendingIntent.class);
|
||||
when(mockFullScreenIntent.getCreatorUid()).thenReturn(kTestUid);
|
||||
ResolveInfo resolveInfo = new ResolveInfo();
|
||||
resolveInfo.activityInfo = new ActivityInfo();
|
||||
resolveInfo.activityInfo.name = kTestActivityName;
|
||||
when(mockFullScreenIntent.queryIntentComponents(anyInt()))
|
||||
.thenReturn(Arrays.asList(resolveInfo));
|
||||
Notification.Builder nb = new Notification.Builder(mContext, "a")
|
||||
.setContentTitle("foo")
|
||||
.setSmallIcon(android.R.drawable.sym_def_app_icon)
|
||||
.setFullScreenIntent(mockFullScreenIntent, true);
|
||||
StatusBarNotification sbn = new StatusBarNotification("pkg", "pkg", 0,
|
||||
"tag" + System.currentTimeMillis(), 0, 0,
|
||||
nb.build(), new UserHandle(0), null, 0);
|
||||
NotificationEntry entry = mock(NotificationEntry.class);
|
||||
when(entry.getImportance()).thenReturn(NotificationManager.IMPORTANCE_HIGH);
|
||||
when(entry.getSbn()).thenReturn(sbn);
|
||||
MockitoSession mockingSession = mockitoSession()
|
||||
.mockStatic(FrameworkStatsLog.class)
|
||||
.strictness(Strictness.LENIENT)
|
||||
.startMocking();
|
||||
|
||||
// WHEN
|
||||
mNotificationActivityStarter.launchFullScreenIntent(entry);
|
||||
|
||||
// THEN the full screen intent should be logged to statsd.
|
||||
verify(() -> FrameworkStatsLog.write(FrameworkStatsLog.FULL_SCREEN_INTENT_LAUNCHED,
|
||||
kTestUid, kTestActivityName));
|
||||
mockingSession.finishMocking();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user