diff options
Diffstat (limited to 'java/com/android/incallui')
24 files changed, 172 insertions, 61 deletions
diff --git a/java/com/android/incallui/CallButtonPresenter.java b/java/com/android/incallui/CallButtonPresenter.java index b3fb97fad..aa17dc4eb 100644 --- a/java/com/android/incallui/CallButtonPresenter.java +++ b/java/com/android/incallui/CallButtonPresenter.java @@ -118,7 +118,7 @@ public class CallButtonPresenter // OUTGOING. We may want to do that once we start showing "Voice mail" label on // the dialpad too.) if (oldState == InCallState.OUTGOING && mCall != null) { - if (CallerInfoUtils.isVoiceMailNumber(mContext, mCall) && getActivity() != null) { + if (mCall.isVoiceMailNumber() && getActivity() != null) { getActivity().showDialpadFragment(true /* show */, true /* animate */); } } diff --git a/java/com/android/incallui/CallCardPresenter.java b/java/com/android/incallui/CallCardPresenter.java index d49d556a6..871243c7d 100644 --- a/java/com/android/incallui/CallCardPresenter.java +++ b/java/com/android/incallui/CallCardPresenter.java @@ -478,13 +478,14 @@ public class CallCardPresenter !TextUtils.isEmpty(mPrimary.getLastForwardedNumber()), shouldShowContactPhoto, mPrimary.getConnectTimeMillis(), - CallerInfoUtils.isVoiceMailNumber(mContext, mPrimary), + mPrimary.isVoiceMailNumber(), mPrimary.isRemotelyHeld(), isBusiness, supports2ndCallOnHold(), getSwapToSecondaryButtonState(), mPrimary.isAssistedDialed(), - null)); + null, + mPrimary.getAssistedDialingExtras())); InCallActivity activity = (InCallActivity) (mInCallScreen.getInCallScreenFragment().getActivity()); diff --git a/java/com/android/incallui/CallerInfoAsyncQuery.java b/java/com/android/incallui/CallerInfoAsyncQuery.java index 09752c71f..8fc9c4f14 100644 --- a/java/com/android/incallui/CallerInfoAsyncQuery.java +++ b/java/com/android/incallui/CallerInfoAsyncQuery.java @@ -29,6 +29,7 @@ import android.os.Build.VERSION_CODES; import android.os.Handler; import android.os.Looper; import android.os.Message; +import android.os.Trace; import android.provider.ContactsContract; import android.provider.ContactsContract.Directory; import android.support.annotation.MainThread; @@ -191,9 +192,11 @@ public class CallerInfoAsyncQuery { CallerInfo info, OnQueryCompleteListener listener, Object cookie) { + Trace.beginSection("CallerInfoAsyncQuery.startOtherDirectoriesQuery"); long[] directoryIds = StrictModeUtils.bypass(() -> getDirectoryIds(context)); int size = directoryIds.length; if (size == 0) { + Trace.endSection(); return false; } @@ -213,6 +216,7 @@ public class CallerInfoAsyncQuery { OnQueryCompleteListener intermediateListener = listenerFactory.newListener(directoryId); startQueryInternal(token, context, info, intermediateListener, cookie, uri); } + Trace.endSection(); return true; } diff --git a/java/com/android/incallui/CallerInfoUtils.java b/java/com/android/incallui/CallerInfoUtils.java index bf586f504..38043eda8 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; 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 @@ public class CallerInfoUtils { // 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 @@ public class CallerInfoUtils { 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 diff --git a/java/com/android/incallui/ContactInfoCache.java b/java/com/android/incallui/ContactInfoCache.java index 2a9394526..2fb18b8d7 100644 --- a/java/com/android/incallui/ContactInfoCache.java +++ b/java/com/android/incallui/ContactInfoCache.java @@ -807,10 +807,12 @@ public class ContactInfoCache implements OnImageLoadCompleteListener { @Override public void onQueryComplete(int token, Object cookie, CallerInfo callerInfo) { + Trace.beginSection("ContactInfoCache.FindInfoCallback.onQueryComplete"); Assert.isMainThread(); DialerCallCookieWrapper cw = (DialerCallCookieWrapper) cookie; String callId = cw.callId; if (!isWaitingForThisQuery(cw.callId, mQueryToken.mQueryId)) { + Trace.endSection(); return; } ContactCacheEntry cacheEntry = mInfoMap.get(callId); @@ -818,6 +820,7 @@ public class ContactInfoCache implements OnImageLoadCompleteListener { if (cacheEntry == null) { Log.w(TAG, "Contact lookup done, but cache entry is not found."); clearCallbacks(callId); + Trace.endSection(); return; } // Before issuing a request for more data from other services, we only check that the @@ -842,6 +845,7 @@ public class ContactInfoCache implements OnImageLoadCompleteListener { } clearCallbacks(callId); } + Trace.endSection(); } } diff --git a/java/com/android/incallui/InCallActivity.java b/java/com/android/incallui/InCallActivity.java index 2ba4d98a1..2e3d721df 100644 --- a/java/com/android/incallui/InCallActivity.java +++ b/java/com/android/incallui/InCallActivity.java @@ -95,6 +95,7 @@ public class InCallActivity extends TransactionSafeFragmentActivity private boolean touchDownWhenPseudoScreenOff; private boolean isInShowMainInCallFragment; private boolean needDismissPendingDialogs; + private boolean allowOrientationChange; public InCallActivity() { common = new InCallActivityCommon(this); @@ -161,7 +162,9 @@ public class InCallActivity extends TransactionSafeFragmentActivity protected void onStart() { Trace.beginSection("InCallActivity.onStart"); LogUtil.i("InCallActivity.onStart", ""); + Trace.beginSection("call super"); super.onStart(); + Trace.endSection(); isVisible = true; showMainInCallFragment(); common.onStart(); @@ -514,6 +517,10 @@ public class InCallActivity extends TransactionSafeFragmentActivity } public void setAllowOrientationChange(boolean allowOrientationChange) { + if (this.allowOrientationChange == allowOrientationChange) { + return; + } + this.allowOrientationChange = allowOrientationChange; if (!allowOrientationChange) { setRequestedOrientation(InCallOrientationEventListener.ACTIVITY_PREFERENCE_DISALLOW_ROTATION); } else { diff --git a/java/com/android/incallui/InCallActivityCommon.java b/java/com/android/incallui/InCallActivityCommon.java index 9ccda3251..0a7c2689b 100644 --- a/java/com/android/incallui/InCallActivityCommon.java +++ b/java/com/android/incallui/InCallActivityCommon.java @@ -29,6 +29,7 @@ import android.content.Intent; import android.content.res.Configuration; import android.content.res.Resources; import android.os.Bundle; +import android.os.Trace; import android.support.annotation.IntDef; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -257,6 +258,7 @@ public class InCallActivityCommon { } public void onStart() { + Trace.beginSection("InCallActivityCommon.onStart"); // setting activity should be last thing in setup process InCallPresenter.getInstance().setActivity(inCallActivity); enableInCallOrientationEventListener( @@ -267,9 +269,11 @@ public class InCallActivityCommon { if (!isRecreating) { InCallPresenter.getInstance().onUiShowing(true); } + Trace.endSection(); } public void onResume() { + Trace.beginSection("InCallActivityCommon.onResume"); if (InCallPresenter.getInstance().isReadyForTearDown()) { LogUtil.i( "InCallActivityCommon.onResume", @@ -309,6 +313,7 @@ public class InCallActivityCommon { CallList.getInstance() .onInCallUiShown( inCallActivity.getIntent().getBooleanExtra(INTENT_EXTRA_FOR_FULL_SCREEN, false)); + Trace.endSection(); } // onPause is guaranteed to be called when the InCallActivity goes diff --git a/java/com/android/incallui/InCallPresenter.java b/java/com/android/incallui/InCallPresenter.java index a0069a629..70fe88be8 100644 --- a/java/com/android/incallui/InCallPresenter.java +++ b/java/com/android/incallui/InCallPresenter.java @@ -444,6 +444,7 @@ public class InCallPresenter implements CallList.Listener { * activity is provided, it means that the activity was finished and we should attempt to cleanup. */ private void updateActivity(InCallActivity inCallActivity) { + Trace.beginSection("InCallPresenter.updateActivity"); boolean updateListeners = false; boolean doAttemptCleanup = false; @@ -475,6 +476,7 @@ public class InCallPresenter implements CallList.Listener { if (mInCallState == InCallState.NO_CALLS) { LogUtil.i("InCallPresenter.updateActivity", "UI Initialized, but no calls left. Shut down"); attemptFinishActivity(); + Trace.endSection(); return; } } else { @@ -510,6 +512,7 @@ public class InCallPresenter implements CallList.Listener { if (doAttemptCleanup) { attemptCleanup(); } + Trace.endSection(); } public void setManageConferenceActivity( @@ -842,7 +845,7 @@ public class InCallPresenter implements CallList.Listener { if (!mCallList.hasLiveCall() && !call.getLogState().isIncoming && !isSecretCode(call.getNumber()) - && !CallerInfoUtils.isVoiceMailNumber(mContext, call)) { + && !call.isVoiceMailNumber()) { PostCall.onCallDisconnected(mContext, call.getNumber(), call.getConnectTimeMillis()); } } diff --git a/java/com/android/incallui/InCallServiceImpl.java b/java/com/android/incallui/InCallServiceImpl.java index a08ee0aa5..8570c58c4 100644 --- a/java/com/android/incallui/InCallServiceImpl.java +++ b/java/com/android/incallui/InCallServiceImpl.java @@ -41,7 +41,9 @@ public class InCallServiceImpl extends InCallService { @Override public void onCallAudioStateChanged(CallAudioState audioState) { + Trace.beginSection("InCallServiceImpl.onCallAudioStateChanged"); AudioModeProvider.getInstance().onAudioStateChanged(audioState); + Trace.endSection(); } @Override diff --git a/java/com/android/incallui/ProximitySensor.java b/java/com/android/incallui/ProximitySensor.java index db538abdc..339a2e941 100644 --- a/java/com/android/incallui/ProximitySensor.java +++ b/java/com/android/incallui/ProximitySensor.java @@ -20,6 +20,7 @@ import android.content.Context; import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManager.DisplayListener; import android.os.PowerManager; +import android.os.Trace; import android.support.annotation.NonNull; import android.telecom.CallAudioState; import android.view.Display; @@ -206,6 +207,7 @@ public class ProximitySensor * request for, or is in a video call; or the phone is horizontal while in a call. */ private synchronized void updateProximitySensorMode() { + Trace.beginSection("ProximitySensor.updateProximitySensorMode"); final int audioRoute = mAudioModeProvider.getAudioState().getRoute(); boolean screenOnImmediately = @@ -249,6 +251,7 @@ public class ProximitySensor // behavior in either case. turnOffProximitySensor(screenOnImmediately); } + Trace.endSection(); } /** diff --git a/java/com/android/incallui/StatusBarNotifier.java b/java/com/android/incallui/StatusBarNotifier.java index 7146c7235..e5908f12e 100644 --- a/java/com/android/incallui/StatusBarNotifier.java +++ b/java/com/android/incallui/StatusBarNotifier.java @@ -541,6 +541,18 @@ public class StatusBarNotifier || !Objects.equals(mRingtone, ringtone) || !Objects.equals(savedCallAudioState, callAudioState); + LogUtil.d( + "StatusBarNotifier.checkForChangeAndSaveData", + "data changed: icon: %b, content: %b, state: %b, largeIcon: %b, title: %b, ringtone: %b, " + + "audioState: %b, type: %b", + (mSavedIcon != icon), + !Objects.equals(mSavedContent, content), + (mCallState != state), + largeIconChanged, + contentTitleChanged, + !Objects.equals(mRingtone, ringtone), + !Objects.equals(savedCallAudioState, callAudioState), + mCurrentNotification != notificationType); // If we aren't showing a notification right now or the notification type is changing, // definitely do an update. if (mCurrentNotification != notificationType) { @@ -614,7 +626,7 @@ public class StatusBarNotifier @ContactType int contactType = LetterTileDrawable.getContactTypeFromPrimitives( - CallerInfoUtils.isVoiceMailNumber(context, call), + call.isVoiceMailNumber(), call.isSpam(), contactInfo.isBusiness, call.getNumberPresentation(), @@ -709,7 +721,7 @@ public class StatusBarNotifier resId = getECIncomingCallText(call.getEnrichedCallSession()); } else if (call.hasProperty(Details.PROPERTY_WIFI)) { resId = R.string.notification_incoming_call_wifi_template; - } else if (call.getAccountHandle() != null && hasMultiplePhoneAccounts()) { + } else if (call.getAccountHandle() != null && hasMultiplePhoneAccounts(call)) { return getMultiSimIncomingText(call); } else if (call.isVideoCall()) { resId = R.string.notification_incoming_video_call; @@ -1043,9 +1055,11 @@ public class StatusBarNotifier mStatusBarCallListener = listener; } - @SuppressWarnings("MissingPermission") - private boolean hasMultiplePhoneAccounts() { - return mContext.getSystemService(TelecomManager.class).getCallCapablePhoneAccounts().size() > 1; + private boolean hasMultiplePhoneAccounts(DialerCall call) { + if (call.getCallCapableAccounts() == null) { + return false; + } + return call.getCallCapableAccounts().size() > 1; } @Override diff --git a/java/com/android/incallui/answer/impl/AnswerFragment.java b/java/com/android/incallui/answer/impl/AnswerFragment.java index 3476557ba..f0b0c0fde 100644 --- a/java/com/android/incallui/answer/impl/AnswerFragment.java +++ b/java/com/android/incallui/answer/impl/AnswerFragment.java @@ -744,6 +744,7 @@ public class AnswerFragment extends Fragment @Override public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) { + Trace.beginSection("AnswerFragment.onViewCreated"); super.onViewCreated(view, savedInstanceState); createInCallScreenDelegate(); updateUI(); @@ -751,18 +752,22 @@ public class AnswerFragment extends Fragment if (savedInstanceState == null || !savedInstanceState.getBoolean(STATE_HAS_ANIMATED_ENTRY)) { ViewUtil.doOnGlobalLayout(view, this::animateEntry); } + Trace.endSection(); } @Override public void onResume() { + Trace.beginSection("AnswerFragment.onResume"); super.onResume(); LogUtil.i("AnswerFragment.onResume", null); restoreSwipeHintTexts(); inCallScreenDelegate.onInCallScreenResumed(); + Trace.endSection(); } @Override public void onStart() { + Trace.beginSection("AnswerFragment.onStart"); super.onStart(); LogUtil.i("AnswerFragment.onStart", null); @@ -770,10 +775,12 @@ public class AnswerFragment extends Fragment if (answerVideoCallScreen != null) { answerVideoCallScreen.onVideoScreenStart(); } + Trace.endSection(); } @Override public void onStop() { + Trace.beginSection("AnswerFragment.onStop"); super.onStop(); LogUtil.i("AnswerFragment.onStop", null); @@ -781,13 +788,16 @@ public class AnswerFragment extends Fragment if (answerVideoCallScreen != null) { answerVideoCallScreen.onVideoScreenStop(); } + Trace.endSection(); } @Override public void onPause() { + Trace.beginSection("AnswerFragment.onPause"); super.onPause(); LogUtil.i("AnswerFragment.onPause", null); inCallScreenDelegate.onInCallScreenPaused(); + Trace.endSection(); } @Override diff --git a/java/com/android/incallui/answer/impl/answermethod/FlingUpDownMethod.java b/java/com/android/incallui/answer/impl/answermethod/FlingUpDownMethod.java index 5c1ee47e6..ea5956c8c 100644 --- a/java/com/android/incallui/answer/impl/answermethod/FlingUpDownMethod.java +++ b/java/com/android/incallui/answer/impl/answermethod/FlingUpDownMethod.java @@ -28,6 +28,7 @@ import android.content.res.ColorStateList; import android.graphics.PorterDuff.Mode; import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.os.Trace; import android.support.annotation.ColorInt; import android.support.annotation.FloatRange; import android.support.annotation.IntDef; @@ -157,6 +158,7 @@ public class FlingUpDownMethod extends AnswerMethod implements OnProgressChanged @Override public void onStart() { + Trace.beginSection("FlingUpDownMethod.onStart"); super.onStart(); falsingManager.onScreenOn(); if (getView() != null) { @@ -170,22 +172,26 @@ public class FlingUpDownMethod extends AnswerMethod implements OnProgressChanged startSwipeToAnswerEntryAnimation(); } } + Trace.endSection(); } @Override public void onStop() { + Trace.beginSection("FlingUpDownMethod.onStop"); endAnimation(); falsingManager.onScreenOff(); if (getActivity().isFinishing()) { setAnimationState(AnimationState.COMPLETED); } super.onStop(); + Trace.endSection(); } @Nullable @Override public View onCreateView( LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) { + Trace.beginSection("FlingUpDownMethod.onCreateView"); View view = layoutInflater.inflate(R.layout.swipe_up_down_method, viewGroup, false); contactPuckContainer = view.findViewById(R.id.incoming_call_puck_container); @@ -242,6 +248,7 @@ public class FlingUpDownMethod extends AnswerMethod implements OnProgressChanged (ViewGroup) view.findViewById(R.id.hint_container), contactPuckContainer, swipeToAnswerText); + Trace.endSection(); return view; } @@ -400,6 +407,7 @@ public class FlingUpDownMethod extends AnswerMethod implements OnProgressChanged } private void updateSwipeTextAndPuckForTouch() { + Trace.beginSection("FlingUpDownMethod.updateSwipeTextAndPuckForTouch"); // Clamp progress value between -1 and 1. final float clampedProgress = MathUtil.clamp(swipeProgress, -1 /* min */, 1 /* max */); final float positiveAdjustedProgress = Math.abs(clampedProgress); @@ -473,6 +481,7 @@ public class FlingUpDownMethod extends AnswerMethod implements OnProgressChanged } getParent().onAnswerProgressUpdate(clampedProgress); + Trace.endSection(); } private void startSwipeToAnswerSwipeAnimation() { diff --git a/java/com/android/incallui/answer/impl/classifier/FalsingManager.java b/java/com/android/incallui/answer/impl/classifier/FalsingManager.java index fdcc0a3f9..9cdd888d1 100644 --- a/java/com/android/incallui/answer/impl/classifier/FalsingManager.java +++ b/java/com/android/incallui/answer/impl/classifier/FalsingManager.java @@ -22,6 +22,7 @@ import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.PowerManager; +import android.os.Trace; import android.view.MotionEvent; import android.view.accessibility.AccessibilityManager; @@ -130,11 +131,17 @@ public class FalsingManager implements SensorEventListener { } private void registerSensors(int[] sensors) { + Trace.beginSection("FalsingManager.registerSensors"); for (int sensorType : sensors) { + Trace.beginSection("get sensor " + sensorType); Sensor s = mSensorManager.getDefaultSensor(sensorType); + Trace.endSection(); if (s != null) { + Trace.beginSection("register"); mSensorManager.registerListener(this, s, SensorManager.SENSOR_DELAY_GAME); + Trace.endSection(); } } + Trace.endSection(); } } diff --git a/java/com/android/incallui/answerproximitysensor/AnswerProximitySensor.java b/java/com/android/incallui/answerproximitysensor/AnswerProximitySensor.java index 16fad8b17..113144b7f 100644 --- a/java/com/android/incallui/answerproximitysensor/AnswerProximitySensor.java +++ b/java/com/android/incallui/answerproximitysensor/AnswerProximitySensor.java @@ -19,6 +19,7 @@ package com.android.incallui.answerproximitysensor; import android.content.Context; import android.hardware.display.DisplayManager; import android.os.PowerManager; +import android.os.Trace; import android.view.Display; import com.android.dialer.common.LogUtil; import com.android.dialer.configprovider.ConfigProviderBindings; @@ -43,16 +44,19 @@ public class AnswerProximitySensor private final AnswerProximityWakeLock answerProximityWakeLock; public static boolean shouldUse(Context context, DialerCall call) { + Trace.beginSection("AnswerProximitySensor.shouldUse"); // Don't use the AnswerProximitySensor for call waiting and other states. Those states are // handled by the general ProximitySensor code. if (call.getState() != State.INCOMING) { LogUtil.i("AnswerProximitySensor.shouldUse", "call state is not incoming"); + Trace.endSection(); return false; } if (!ConfigProviderBindings.get(context) .getBoolean(CONFIG_ANSWER_PROXIMITY_SENSOR_ENABLED, true)) { LogUtil.i("AnswerProximitySensor.shouldUse", "disabled by config"); + Trace.endSection(); return false; } @@ -60,19 +64,23 @@ public class AnswerProximitySensor .getSystemService(PowerManager.class) .isWakeLockLevelSupported(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK)) { LogUtil.i("AnswerProximitySensor.shouldUse", "wake lock level not supported"); + Trace.endSection(); return false; } if (isDefaultDisplayOn(context)) { LogUtil.i("AnswerProximitySensor.shouldUse", "display is already on"); + Trace.endSection(); return false; } + Trace.endSection(); return true; } public AnswerProximitySensor( Context context, DialerCall call, PseudoScreenState pseudoScreenState) { + Trace.beginSection("AnswerProximitySensor Constructor"); this.call = call; LogUtil.i("AnswerProximitySensor.constructor", "acquiring lock"); @@ -90,11 +98,14 @@ public class AnswerProximitySensor answerProximityWakeLock.acquire(); call.addListener(this); + Trace.endSection(); } private void cleanup() { + Trace.beginSection("AnswerProximitySensor.Cleanup"); call.removeListener(this); releaseProximityWakeLock(); + Trace.endSection(); } private void releaseProximityWakeLock() { diff --git a/java/com/android/incallui/call/CallList.java b/java/com/android/incallui/call/CallList.java index 8d6620628..7c35e4b92 100644 --- a/java/com/android/incallui/call/CallList.java +++ b/java/com/android/incallui/call/CallList.java @@ -34,7 +34,6 @@ import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.enrichedcall.EnrichedCallComponent; import com.android.dialer.enrichedcall.EnrichedCallManager; -import com.android.dialer.location.GeoUtil; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.shortcuts.ShortcutUsageReporter; @@ -139,7 +138,7 @@ public class CallList implements DialerCallDelegate { Spam.get(context) .checkSpamStatus( number, - null, + call.getCountryIso(), new SpamBindings.Listener() { @Override public void onComplete(boolean isSpam) { @@ -196,7 +195,7 @@ public class CallList implements DialerCallDelegate { } }, call.getNumber(), - GeoUtil.getCurrentCountryIso(context)); + call.getCountryIso()); Trace.endSection(); if (call.getState() == DialerCall.State.INCOMING @@ -257,7 +256,7 @@ public class CallList implements DialerCallDelegate { Spam.get(context) .checkUserMarkedNonSpamStatus( number, - null, + call.getCountryIso(), new SpamBindings.Listener() { @Override public void onComplete(boolean isInUserWhiteList) { @@ -268,7 +267,7 @@ public class CallList implements DialerCallDelegate { Spam.get(context) .checkGlobalSpamListStatus( number, - null, + call.getCountryIso(), new SpamBindings.Listener() { @Override public void onComplete(boolean isInGlobalSpamList) { @@ -279,7 +278,7 @@ public class CallList implements DialerCallDelegate { Spam.get(context) .checkUserMarkedSpamStatus( number, - null, + call.getCountryIso(), new SpamBindings.Listener() { @Override public void onComplete(boolean isInUserSpamList) { @@ -626,9 +625,11 @@ public class CallList implements DialerCallDelegate { * listeners to call back to determine what changed. */ private void notifyGenericListeners() { + Trace.beginSection("CallList.notifyGenericListeners"); for (Listener listener : mListeners) { listener.onCallListChange(this); } + Trace.endSection(); } private void notifyListenersOfDisconnect(DialerCall call) { diff --git a/java/com/android/incallui/call/DialerCall.java b/java/com/android/incallui/call/DialerCall.java index 2511bb8ca..47a4a70f5 100644 --- a/java/com/android/incallui/call/DialerCall.java +++ b/java/com/android/incallui/call/DialerCall.java @@ -16,6 +16,7 @@ package com.android.incallui.call; +import android.Manifest.permission; import android.content.Context; import android.hardware.camera2.CameraCharacteristics; import android.net.Uri; @@ -42,6 +43,7 @@ import android.telecom.VideoProfile; import android.text.TextUtils; import com.android.contacts.common.compat.CallCompat; import com.android.contacts.common.compat.telecom.TelecomManagerCompat; +import com.android.dialer.assisteddialing.TransformationInfo; import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.callintent.CallIntentParser; import com.android.dialer.callintent.CallSpecificAppData; @@ -57,11 +59,14 @@ import com.android.dialer.enrichedcall.EnrichedCallManager.Filter; import com.android.dialer.enrichedcall.EnrichedCallManager.StateChangedListener; import com.android.dialer.enrichedcall.Session; import com.android.dialer.lightbringer.LightbringerComponent; +import com.android.dialer.location.GeoUtil; import com.android.dialer.logging.ContactLookupResult; import com.android.dialer.logging.ContactLookupResult.Type; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; +import com.android.dialer.telecom.TelecomUtil; import com.android.dialer.theme.R; +import com.android.dialer.util.PermissionsUtil; import com.android.incallui.audiomode.AudioModeProvider; import com.android.incallui.latencyreport.LatencyReport; import com.android.incallui.util.TelecomCallUtil; @@ -157,6 +162,9 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa private com.android.dialer.logging.VideoTech.Type selectedAvailableVideoTechType = com.android.dialer.logging.VideoTech.Type.NONE; + private boolean isVoicemailNumber; + private List<PhoneAccountHandle> callCapableAccounts; + private String countryIso; public static String getNumberFromHandle(Uri handle) { return handle == null ? "" : handle.getSchemeSpecificPart(); @@ -449,6 +457,30 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa return mLogState.conferencedCalls != 0; } + public boolean isVoiceMailNumber() { + return isVoicemailNumber; + } + + public List<PhoneAccountHandle> getCallCapableAccounts() { + return callCapableAccounts; + } + + public String getCountryIso() { + return countryIso; + } + + private void updateIsVoiceMailNumber() { + if (getHandle() != null && PhoneAccount.SCHEME_VOICEMAIL.equals(getHandle().getScheme())) { + isVoicemailNumber = true; + } + + if (!PermissionsUtil.hasPermission(mContext, permission.READ_PHONE_STATE)) { + isVoicemailNumber = false; + } + + isVoicemailNumber = TelecomUtil.isVoicemailNumber(mContext, getAccountHandle(), getNumber()); + } + private void update() { Trace.beginSection("DialerCall.update"); int oldState = getState(); @@ -474,6 +506,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa Trace.endSection(); } + @SuppressWarnings("MissingPermission") private void updateFromTelecomCall() { Trace.beginSection("DialerCall.updateFromTelecomCall"); LogUtil.v("DialerCall.updateFromTelecomCall", mTelecomCall.toString()); @@ -509,6 +542,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa updateEmergencyCallState(); } + TelecomManager telecomManager = mContext.getSystemService(TelecomManager.class); // If the phone account handle of the call is set, cache capability bit indicating whether // the phone account supports call subjects. PhoneAccountHandle newPhoneAccountHandle = mTelecomCall.getDetails().getAccountHandle(); @@ -516,14 +550,18 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa mPhoneAccountHandle = newPhoneAccountHandle; if (mPhoneAccountHandle != null) { - PhoneAccount phoneAccount = - mContext.getSystemService(TelecomManager.class).getPhoneAccount(mPhoneAccountHandle); + PhoneAccount phoneAccount = telecomManager.getPhoneAccount(mPhoneAccountHandle); if (phoneAccount != null) { mIsCallSubjectSupported = phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_CALL_SUBJECT); } } } + if (PermissionsUtil.hasPermission(mContext, permission.READ_PHONE_STATE)) { + updateIsVoiceMailNumber(); + callCapableAccounts = telecomManager.getCallCapablePhoneAccounts(); + countryIso = GeoUtil.getCurrentCountryIso(mContext); + } Trace.endSection(); } @@ -856,7 +894,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa } public boolean isVideoCall() { - return getVideoTech().isTransmittingOrReceiving(); + return getVideoTech().isTransmittingOrReceiving() || VideoProfile.isVideo(getVideoState()); } public boolean hasReceivedVideoUpgradeRequest() { @@ -1036,6 +1074,14 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa return false; } + public TransformationInfo getAssistedDialingExtras() { + if (isAssistedDialed()) { + return TransformationInfo.newInstanceFromBundle( + getIntentExtras().getBundle(TelephonyManagerCompat.ASSISTED_DIALING_EXTRAS)); + } + return null; + } + public LatencyReport getLatencyReport() { return mLatencyReport; } @@ -1139,9 +1185,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa if (callProviderLabel == null) { PhoneAccount account = getPhoneAccount(); if (account != null && !TextUtils.isEmpty(account.getLabel())) { - List<PhoneAccountHandle> accounts = - mContext.getSystemService(TelecomManager.class).getCallCapablePhoneAccounts(); - if (accounts != null && accounts.size() > 1) { + if (callCapableAccounts != null && callCapableAccounts.size() > 1) { callProviderLabel = account.getLabel().toString(); } } @@ -1211,9 +1255,11 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa @Override public void onSessionModificationStateChanged() { + Trace.beginSection("DialerCall.onSessionModificationStateChanged"); for (DialerCallListener listener : mListeners) { listener.onDialerCallSessionModificationStateChange(); } + Trace.endSection(); } @Override diff --git a/java/com/android/incallui/contactgrid/BottomRow.java b/java/com/android/incallui/contactgrid/BottomRow.java index 91f08ef3e..a0d118552 100644 --- a/java/com/android/incallui/contactgrid/BottomRow.java +++ b/java/com/android/incallui/contactgrid/BottomRow.java @@ -49,7 +49,6 @@ public class BottomRow { public final boolean isForwardIconVisible; public final boolean isSpamIconVisible; public final boolean shouldPopulateAccessibilityEvent; - public final boolean isAssistedDialedVisisble; public Info( @Nullable CharSequence label, @@ -59,8 +58,7 @@ public class BottomRow { boolean isHdIconVisible, boolean isForwardIconVisible, boolean isSpamIconVisible, - boolean shouldPopulateAccessibilityEvent, - boolean isAssistedDialedVisisble) { + boolean shouldPopulateAccessibilityEvent) { this.label = label; this.isTimerVisible = isTimerVisible; this.isWorkIconVisible = isWorkIconVisible; @@ -69,7 +67,6 @@ public class BottomRow { this.isForwardIconVisible = isForwardIconVisible; this.isSpamIconVisible = isSpamIconVisible; this.shouldPopulateAccessibilityEvent = shouldPopulateAccessibilityEvent; - this.isAssistedDialedVisisble = isAssistedDialedVisisble; } } @@ -84,7 +81,6 @@ public class BottomRow { boolean isHdAttemptingIconVisible = state.isHdAttempting; boolean isSpamIconVisible = false; boolean shouldPopulateAccessibilityEvent = true; - boolean isAssistedDialedVisisble = state.isAssistedDialed; if (isIncoming(state) && primaryInfo.isSpam) { label = context.getString(R.string.contact_grid_incoming_suspected_spam); @@ -118,8 +114,7 @@ public class BottomRow { isHdIconVisible, isForwardIconVisible, isSpamIconVisible, - shouldPopulateAccessibilityEvent, - isAssistedDialedVisisble); + shouldPopulateAccessibilityEvent); } private static CharSequence getLabelForPhoneNumber(PrimaryInfo primaryInfo) { diff --git a/java/com/android/incallui/contactgrid/ContactGridManager.java b/java/com/android/incallui/contactgrid/ContactGridManager.java index c0ab9609f..8deee8263 100644 --- a/java/com/android/incallui/contactgrid/ContactGridManager.java +++ b/java/com/android/incallui/contactgrid/ContactGridManager.java @@ -61,7 +61,7 @@ public class ContactGridManager { @Nullable private ImageView avatarImageView; // Row 2: Mobile +1 (650) 253-0000 - // Row 2: [HD attempting icon]/[HD icon] [Assisted Dialing Icon] 00:15 + // Row 2: [HD attempting icon]/[HD icon] 00:15 // Row 2: Call ended // Row 2: Hanging up // Row 2: [Alert sign] Suspected spam caller @@ -69,7 +69,6 @@ public class ContactGridManager { private final ImageView workIconImageView; private final ImageView hdIconImageView; private final ImageView forwardIconImageView; - private final ImageView assistedDialingImageView; private final TextView forwardedNumberView; private final ImageView spamIconImageView; private final ViewAnimator bottomTextSwitcher; @@ -101,7 +100,6 @@ public class ContactGridManager { hdIconImageView = view.findViewById(R.id.contactgrid_hdIcon); forwardIconImageView = view.findViewById(R.id.contactgrid_forwardIcon); forwardedNumberView = view.findViewById(R.id.contactgrid_forwardNumber); - assistedDialingImageView = view.findViewById(R.id.contactgrid_assistedDialingIcon); spamIconImageView = view.findViewById(R.id.contactgrid_spamIcon); bottomTextSwitcher = view.findViewById(R.id.contactgrid_bottom_text_switcher); bottomTextView = view.findViewById(R.id.contactgrid_bottom_text); @@ -321,8 +319,6 @@ public class ContactGridManager { bottomTextView.setText(info.label); bottomTextView.setAllCaps(info.isSpamIconVisible); workIconImageView.setVisibility(info.isWorkIconVisible ? View.VISIBLE : View.GONE); - assistedDialingImageView.setVisibility( - info.isAssistedDialedVisisble ? View.VISIBLE : View.GONE); if (hdIconImageView.getVisibility() == View.GONE) { if (info.isHdAttemptingIconVisible) { hdIconImageView.setImageResource(R.drawable.asd_hd_icon); diff --git a/java/com/android/incallui/contactgrid/TopRow.java b/java/com/android/incallui/contactgrid/TopRow.java index 3593c991d..cfa7e1b86 100644 --- a/java/com/android/incallui/contactgrid/TopRow.java +++ b/java/com/android/incallui/contactgrid/TopRow.java @@ -173,6 +173,15 @@ public class TopRow { return context.getString(R.string.incall_video_call_requesting); } } + + if (state.isAssistedDialed) { + String countryCode = + String.valueOf(state.assistedDialingExtras.transformedNumberCountryCallingCode()); + return context.getString( + R.string.incall_connecting_assited_dialed, + countryCode, + state.assistedDialingExtras.userHomeCountryCode()); + } return context.getString(R.string.incall_connecting); } } diff --git a/java/com/android/incallui/contactgrid/res/layout/incall_contactgrid_bottom_row.xml b/java/com/android/incallui/contactgrid/res/layout/incall_contactgrid_bottom_row.xml index c545c25cd..ce355ea2d 100644 --- a/java/com/android/incallui/contactgrid/res/layout/incall_contactgrid_bottom_row.xml +++ b/java/com/android/incallui/contactgrid/res/layout/incall_contactgrid_bottom_row.xml @@ -31,10 +31,6 @@ style="@style/BottomRowIcon" android:visibility="gone"/> <ImageView - android:id="@+id/contactgrid_assistedDialingIcon" - style="@style/BottomRowIcon" - android:src="@drawable/quantum_ic_language_vd_theme_24"/> - <ImageView android:id="@id/contactgrid_forwardIcon" style="@style/BottomRowIcon" android:src="@drawable/quantum_ic_forward_vd_theme_24"/> diff --git a/java/com/android/incallui/contactgrid/res/values/strings.xml b/java/com/android/incallui/contactgrid/res/values/strings.xml index eba4abf30..c6bdb11ba 100644 --- a/java/com/android/incallui/contactgrid/res/values/strings.xml +++ b/java/com/android/incallui/contactgrid/res/values/strings.xml @@ -24,6 +24,9 @@ in the connecting stage. --> <string name="incall_connecting">Calling…</string> + <!-- Display information related to assisted dialing, for example Calling using +1 (US)… --> + <string name="incall_connecting_assited_dialed">Calling using +<xliff:g example="1" id="ad_country_code">%1$s</xliff:g> (<xliff:g example="1" id="ad_user_home_locale">%2$s</xliff:g>)\u2026</string> + <!-- Displayed above the contact name when an external call is being pulled to the local device. --> <string name="incall_transferring">Transferring…</string> diff --git a/java/com/android/incallui/incall/protocol/PrimaryCallState.java b/java/com/android/incallui/incall/protocol/PrimaryCallState.java index fe80276c9..4a50fbeaf 100644 --- a/java/com/android/incallui/incall/protocol/PrimaryCallState.java +++ b/java/com/android/incallui/incall/protocol/PrimaryCallState.java @@ -21,6 +21,7 @@ import android.support.annotation.IntDef; import android.support.annotation.Nullable; import android.telecom.DisconnectCause; import android.text.TextUtils; +import com.android.dialer.assisteddialing.TransformationInfo; import com.android.dialer.common.Assert; import com.android.incallui.call.DialerCall; import com.android.incallui.call.DialerCall.State; @@ -68,6 +69,7 @@ public class PrimaryCallState { public final @ButtonState int swapToSecondaryButtonState; public final boolean isAssistedDialed; @Nullable public final String customLabel; + @Nullable public final TransformationInfo assistedDialingExtras; // TODO: Convert to autovalue. b/34502119 public static PrimaryCallState createEmptyPrimaryCallState() { @@ -100,7 +102,8 @@ public class PrimaryCallState { true /* supportsCallOnHold */, ButtonState.NOT_SUPPORT /* swapToSecondaryButtonState */, false /* isAssistedDialed */, - customLabel); + customLabel, + null /* assistedDialingExtras */); } public PrimaryCallState( @@ -127,7 +130,8 @@ public class PrimaryCallState { boolean supportsCallOnHold, @ButtonState int swapToSecondaryButtonState, boolean isAssistedDialed, - @Nullable String customLabel) { + @Nullable String customLabel, + @Nullable TransformationInfo assistedDialingExtras) { this.state = state; this.isVideoCall = isVideoCall; this.sessionModificationState = sessionModificationState; @@ -155,6 +159,7 @@ public class PrimaryCallState { Assert.checkArgument(state == State.CALL_PENDING); } this.customLabel = customLabel; + this.assistedDialingExtras = assistedDialingExtras; } @Override diff --git a/java/com/android/incallui/spam/SpamCallListListener.java b/java/com/android/incallui/spam/SpamCallListListener.java index 6b2bdcef6..cf545c071 100644 --- a/java/com/android/incallui/spam/SpamCallListListener.java +++ b/java/com/android/incallui/spam/SpamCallListListener.java @@ -150,7 +150,7 @@ public class SpamCallListListener implements CallList.Listener { } NumberInCallHistoryWorker historyTask = - new NumberInCallHistoryWorker(context, number, GeoUtil.getCurrentCountryIso(context)); + new NumberInCallHistoryWorker(context, number, call.getCountryIso()); dialerExecutorFactory .createNonUiTaskBuilder(historyTask) .onSuccess((result) -> call.setCallHistoryStatus(result)) |