Add timing logging for startRinging
am: b11675a9ce
Change-Id: I8a4957690f62284c4528e2d51eadb8e6cb1a1a25
diff --git a/src/com/android/server/telecom/LogUtils.java b/src/com/android/server/telecom/LogUtils.java
index 760d24e..1e82fc0 100644
--- a/src/com/android/server/telecom/LogUtils.java
+++ b/src/com/android/server/telecom/LogUtils.java
@@ -17,9 +17,13 @@
package com.android.server.telecom;
import android.content.Context;
+import android.os.SystemClock;
import android.telecom.Logging.EventManager;
import android.telecom.Logging.EventManager.TimedEventPair;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* Temporary location of new Logging class
*/
@@ -31,6 +35,30 @@
public static final boolean SYSTRACE_DEBUG = false; /* STOP SHIP if true */
+ public static class EventTimer {
+ private long mLastElapsedMillis;
+ private Map<String, Long> mTimings = new HashMap<>();
+
+ public EventTimer() {
+ mLastElapsedMillis = SystemClock.elapsedRealtime();
+ }
+
+ public void record(String label) {
+ long newElapsedMillis = SystemClock.elapsedRealtime();
+ mTimings.put(label, newElapsedMillis - mLastElapsedMillis);
+ mLastElapsedMillis = newElapsedMillis;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ for (Map.Entry<String, Long> entry : mTimings.entrySet()) {
+ sb.append(entry.getKey()).append(": ").append(entry.getValue()).append(", ");
+ }
+ return sb.toString();
+ }
+ }
+
public static final class Sessions {
public static final String ICA_ANSWER_CALL = "ICA.aC";
public static final String ICA_DEFLECT_CALL = "ICA.defC";
diff --git a/src/com/android/server/telecom/Ringer.java b/src/com/android/server/telecom/Ringer.java
index 2909b72..93f6908 100644
--- a/src/com/android/server/telecom/Ringer.java
+++ b/src/com/android/server/telecom/Ringer.java
@@ -32,6 +32,7 @@
import android.os.Vibrator;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.server.telecom.LogUtils.EventTimer;
import java.util.ArrayList;
import java.util.Arrays;
@@ -220,14 +221,32 @@
AudioManager audioManager =
(AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
+ LogUtils.EventTimer timer = new EventTimer();
boolean isVolumeOverZero = audioManager.getStreamVolume(AudioManager.STREAM_RING) > 0;
+ timer.record("isVolumeOverZero");
boolean shouldRingForContact = shouldRingForContact(foregroundCall.getContactUri());
+ timer.record("shouldRingForContact");
boolean isRingtonePresent = !(mRingtoneFactory.getRingtone(foregroundCall) == null);
+ timer.record("getRingtone");
boolean isSelfManaged = foregroundCall.isSelfManaged();
+ timer.record("isSelfManaged");
boolean isSilentRingingRequested = foregroundCall.isSilentRingingRequested();
+ timer.record("isSilentRingRequested");
boolean isRingerAudible = isVolumeOverZero && shouldRingForContact && isRingtonePresent;
+ timer.record("isRingerAudible");
boolean hasExternalRinger = hasExternalRinger(foregroundCall);
+ timer.record("hasExternalRinger");
+ // Don't do call waiting operations or vibration unless these are false.
+ boolean isTheaterModeOn = mSystemSettingsUtil.isTheaterModeOn(mContext);
+ timer.record("isTheaterModeOn");
+ boolean letDialerHandleRinging = mInCallController.doesConnectedDialerSupportRinging();
+ timer.record("letDialerHandleRinging");
+
+ Log.i(this, "startRinging timings: " + timer);
+ boolean endEarly = isTheaterModeOn || letDialerHandleRinging || isSelfManaged ||
+ hasExternalRinger || isSilentRingingRequested;
+
// Acquire audio focus under any of the following conditions:
// 1. Should ring for contact and there's an HFP device attached
// 2. Volume is over zero, we should ring for the contact, and there's a audible ringtone
@@ -236,12 +255,6 @@
boolean shouldAcquireAudioFocus =
isRingerAudible || (isHfpDeviceAttached && shouldRingForContact) || isSelfManaged;
- // Don't do call waiting operations or vibration unless these are false.
- boolean isTheaterModeOn = mSystemSettingsUtil.isTheaterModeOn(mContext);
- boolean letDialerHandleRinging = mInCallController.doesConnectedDialerSupportRinging();
- boolean endEarly = isTheaterModeOn || letDialerHandleRinging || isSelfManaged ||
- hasExternalRinger || isSilentRingingRequested;
-
if (endEarly) {
if (letDialerHandleRinging) {
Log.addEvent(foregroundCall, LogUtils.Events.SKIP_RINGING, "Dialer handles");