Optimization for incoming call latency.
There are many binder call triggered by IPC on main thread. This change will try to reduce them by caching thing that's bound to a call. It reduce total binder transaction from 1002 to 664 and saves ~11% latency of incoming call on locked screen.
1. Cache isVoiceMailNumber in DialerCall
2. Cache call capable accounts in DialerCall
3. Cache current country iso in DialerCall
4. Don't set orientation change if it's not changed.
This change also add lots of trace info. It won't affect release build though since they are stripped out by proguard.
Bug: 64542087
Test: manual
PiperOrigin-RevId: 171901266
Change-Id: Iec48f030529aa59974212147276f6d0ae121872a
diff --git a/java/com/android/incallui/CallerInfoUtils.java b/java/com/android/incallui/CallerInfoUtils.java
index bf586f5..38043ed 100644
--- a/java/com/android/incallui/CallerInfoUtils.java
+++ b/java/com/android/incallui/CallerInfoUtils.java
@@ -16,15 +16,10 @@
package com.android.incallui;
-import android.Manifest.permission;
import android.content.Context;
import android.content.Loader;
import android.content.Loader.OnLoadCompleteListener;
-import android.content.pm.PackageManager;
import android.net.Uri;
-import android.support.annotation.NonNull;
-import android.support.v4.content.ContextCompat;
-import android.telecom.PhoneAccount;
import android.telecom.TelecomManager;
import android.text.TextUtils;
import com.android.contacts.common.model.Contact;
@@ -34,7 +29,6 @@
import com.android.dialer.phonenumbercache.CachedNumberLookupService.CachedContactInfo;
import com.android.dialer.phonenumbercache.ContactInfo;
import com.android.dialer.phonenumberutil.PhoneNumberHelper;
-import com.android.dialer.telecom.TelecomUtil;
import com.android.dialer.util.PermissionsUtil;
import com.android.incallui.call.DialerCall;
import java.util.Arrays;
@@ -112,7 +106,7 @@
// Because the InCallUI is immediately launched before the call is connected, occasionally
// a voicemail call will be passed to InCallUI as a "voicemail:" URI without a number.
// This call should still be handled as a voicemail call.
- if (isVoiceMailNumber(context, call)) {
+ if (call.isVoiceMailNumber()) {
info.markAsVoiceMail(context);
}
@@ -146,20 +140,6 @@
return cacheInfo;
}
- public static boolean isVoiceMailNumber(Context context, @NonNull DialerCall call) {
- if (call.getHandle() != null
- && PhoneAccount.SCHEME_VOICEMAIL.equals(call.getHandle().getScheme())) {
- return true;
- }
-
- if (ContextCompat.checkSelfPermission(context, permission.READ_PHONE_STATE)
- != PackageManager.PERMISSION_GRANTED) {
- return false;
- }
-
- return TelecomUtil.isVoicemailNumber(context, call.getAccountHandle(), call.getNumber());
- }
-
/**
* Handles certain "corner cases" for CNAP. When we receive weird phone numbers from the network
* to indicate different number presentations, convert them to expected number and presentation