From c76ca765c3ee306ed2ccdc0a71e79e1dcc028715 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Thu, 14 Apr 2016 20:38:40 -0700 Subject: Add LatencyReport for every call [This is a manual cherry pick from ub-contactsdialer-b-dev.] This CL tracks latency for all incoming and outgoing calls. We now measure the following latency values: - time for a connection service to add a call to telecom. - time for telecom to process a call - time for the dialer app to launch and have a call added to it by telecom. - time for dialer to check if a call should be blocked. - time to show a notification about the call (incoming only) - time it took to show the InCallUI (only if HUN wasn't displayed) Change-Id: I08685d312cbaefc564feb4119350da71df9b9e6c --- .../com/android/incallui/StatusBarNotifier.java | 28 +++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'InCallUI/src/com/android/incallui/StatusBarNotifier.java') diff --git a/InCallUI/src/com/android/incallui/StatusBarNotifier.java b/InCallUI/src/com/android/incallui/StatusBarNotifier.java index 1ed3ae7dc..da553f4a3 100644 --- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java +++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java @@ -79,6 +79,9 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, // Notification for incoming calls. This is interruptive and will show up as a HUN. private static final int NOTIFICATION_INCOMING_CALL = 2; + private static final int PENDING_INTENT_REQUEST_CODE_NON_FULL_SCREEN = 0; + private static final int PENDING_INTENT_REQUEST_CODE_FULL_SCREEN = 1; + private static final long[] VIBRATE_PATTERN = new long[] {0, 1000, 1000}; private final Context mContext; @@ -290,13 +293,13 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, builder.setPublicVersion(publicBuilder.build()); // Set up the main intent to send the user to the in-call screen - final PendingIntent inCallPendingIntent = createLaunchPendingIntent(); - builder.setContentIntent(inCallPendingIntent); + builder.setContentIntent(createLaunchPendingIntent(false /* isFullScreen */)); // Set the intent as a full screen intent as well if a call is incoming if (notificationType == NOTIFICATION_INCOMING_CALL && !InCallPresenter.getInstance().isShowingInCallUi()) { - configureFullScreenIntent(builder, inCallPendingIntent, call); + configureFullScreenIntent( + builder, createLaunchPendingIntent(true /* isFullScreen */), call); // Set the notification category for incoming calls builder.setCategory(Notification.CATEGORY_CALL); } @@ -345,8 +348,10 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, + mCurrentNotification); mNotificationManager.cancel(mCurrentNotification); } + Log.i(this, "Displaying notification for " + notificationType); mNotificationManager.notify(notificationType, notification); + call.getLatencyReport().onNotificationShown(); mCurrentNotification = notificationType; } @@ -721,19 +726,24 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, return builder; } - private PendingIntent createLaunchPendingIntent() { - - final Intent intent = InCallPresenter.getInstance().getInCallIntent( + private PendingIntent createLaunchPendingIntent(boolean isFullScreen) { + Intent intent = InCallPresenter.getInstance().getInCallIntent( false /* showDialpad */, false /* newOutgoingCall */); + int requestCode = PENDING_INTENT_REQUEST_CODE_NON_FULL_SCREEN; + if (isFullScreen) { + intent.putExtra(InCallActivity.FOR_FULL_SCREEN_INTENT, true); + // Use a unique request code so that the pending intent isn't clobbered by the + // non-full screen pending intent. + requestCode = PENDING_INTENT_REQUEST_CODE_FULL_SCREEN; + } + // PendingIntent that can be used to launch the InCallActivity. The // system fires off this intent if the user pulls down the windowshade // and clicks the notification's expanded view. It's also used to // launch the InCallActivity immediately when when there's an incoming // call (see the "fullScreenIntent" field below). - PendingIntent inCallPendingIntent = PendingIntent.getActivity(mContext, 0, intent, 0); - - return inCallPendingIntent; + return PendingIntent.getActivity(mContext, requestCode, intent, 0); } /** -- cgit v1.2.3