From 2ca4318cc1ee57dda907ba2069bd61d162b1baef Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Thu, 31 Aug 2017 06:57:16 -0700 Subject: Update Dialer source to latest internal Google revision. Previously, Android's Dialer app was developed in an internal Google source control system and only exported to public during AOSP drops. The Dialer team is now switching to a public development model similar to the telephony team. This CL represents all internal Google changes that were committed to Dialer between the public O release and today's tip of tree on internal master. This CL squashes those changes into a single commit. In subsequent changes, changes will be exported on a per-commit basis. Test: make, flash install, run Merged-In: I45270eaa8ce732d71a1bd84b08c7fa0e99af3160 Change-Id: I529aaeb88535b9533c0ae4ef4e6c1222d4e0f1c8 PiperOrigin-RevId: 167068436 --- java/com/android/incallui/CallCardPresenter.java | 138 +++++++++++------------ 1 file changed, 66 insertions(+), 72 deletions(-) (limited to 'java/com/android/incallui/CallCardPresenter.java') diff --git a/java/com/android/incallui/CallCardPresenter.java b/java/com/android/incallui/CallCardPresenter.java index c2b99c1d1..653b51aa5 100644 --- a/java/com/android/incallui/CallCardPresenter.java +++ b/java/com/android/incallui/CallCardPresenter.java @@ -28,6 +28,7 @@ import android.graphics.drawable.Drawable; import android.hardware.display.DisplayManager; import android.os.BatteryManager; import android.os.Handler; +import android.os.Trace; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; @@ -44,16 +45,14 @@ import com.android.contacts.common.ContactsUtils; import com.android.contacts.common.preference.ContactsPreferences; import com.android.contacts.common.util.ContactDisplayUtils; import com.android.dialer.common.Assert; -import com.android.dialer.common.ConfigProviderBindings; import com.android.dialer.common.LogUtil; import com.android.dialer.compat.ActivityCompat; -import com.android.dialer.enrichedcall.EnrichedCallComponent; -import com.android.dialer.enrichedcall.EnrichedCallManager; -import com.android.dialer.enrichedcall.Session; +import com.android.dialer.configprovider.ConfigProviderBindings; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.multimedia.MultimediaData; import com.android.dialer.oem.MotorolaUtils; +import com.android.dialer.postcall.PostCall; import com.android.incallui.ContactInfoCache.ContactCacheEntry; import com.android.incallui.ContactInfoCache.ContactInfoCacheCallback; import com.android.incallui.InCallPresenter.InCallDetailsListener; @@ -63,6 +62,7 @@ import com.android.incallui.InCallPresenter.InCallStateListener; import com.android.incallui.InCallPresenter.IncomingCallListener; import com.android.incallui.call.CallList; import com.android.incallui.call.DialerCall; +import com.android.incallui.call.DialerCall.State; import com.android.incallui.call.DialerCallListener; import com.android.incallui.calllocation.CallLocation; import com.android.incallui.calllocation.CallLocationComponent; @@ -70,6 +70,7 @@ import com.android.incallui.incall.protocol.ContactPhotoType; import com.android.incallui.incall.protocol.InCallScreen; import com.android.incallui.incall.protocol.InCallScreenDelegate; import com.android.incallui.incall.protocol.PrimaryCallState; +import com.android.incallui.incall.protocol.PrimaryCallState.ButtonState; import com.android.incallui.incall.protocol.PrimaryInfo; import com.android.incallui.incall.protocol.SecondaryInfo; import com.android.incallui.videotech.utils.SessionModificationState; @@ -85,8 +86,7 @@ public class CallCardPresenter InCallDetailsListener, InCallEventListener, InCallScreenDelegate, - DialerCallListener, - EnrichedCallManager.StateChangedListener { + DialerCallListener { /** * Amount of time to wait before sending an announcement via the accessibility manager. When the @@ -249,8 +249,10 @@ public class CallCardPresenter @Override public void onStateChange(InCallState oldState, InCallState newState, CallList callList) { - LogUtil.v("CallCardPresenter.onStateChange", "" + newState); + Trace.beginSection("CallCardPresenter.onStateChange"); + LogUtil.v("CallCardPresenter.onStateChange", "oldState: %s, newState: %s", oldState, newState); if (mInCallScreen == null) { + Trace.endSection(); return; } @@ -347,6 +349,7 @@ public class CallCardPresenter callState != DialerCall.State.INCOMING /* animate */); maybeSendAccessibilityEvent(oldState, newState, primaryChanged); + Trace.endSection(); } @Override @@ -376,6 +379,12 @@ public class CallCardPresenter @Override public void onInternationalCallOnWifi() {} + @Override + public void onEnrichedCallSessionUpdate() { + LogUtil.enterBlock("CallCardPresenter.onEnrichedCallSessionUpdate"); + updatePrimaryDisplayInfo(); + } + /** Handles a change to the child number by refreshing the primary call info. */ @Override public void onDialerCallChildNumberChange() { @@ -418,12 +427,6 @@ public class CallCardPresenter updatePrimaryCallState(); } - @Override - public void onEnrichedCallStateChanged() { - LogUtil.enterBlock("CallCardPresenter.onEnrichedCallStateChanged"); - updatePrimaryDisplayInfo(); - } - private boolean shouldRefreshPrimaryInfo(boolean primaryChanged) { if (mPrimary == null) { return false; @@ -475,7 +478,11 @@ public class CallCardPresenter mPrimary.getConnectTimeMillis(), CallerInfoUtils.isVoiceMailNumber(mContext, mPrimary), mPrimary.isRemotelyHeld(), - isBusiness)); + isBusiness, + supports2ndCallOnHold(), + getSwapToSecondaryButtonState(), + mPrimary.isAssistedDialed(), + null)); InCallActivity activity = (InCallActivity) (mInCallScreen.getInCallScreenFragment().getActivity()); @@ -485,6 +492,16 @@ public class CallCardPresenter } } + private @ButtonState int getSwapToSecondaryButtonState() { + if (mSecondary == null) { + return ButtonState.NOT_SUPPORT; + } + if (mPrimary.getState() == State.ACTIVE) { + return ButtonState.ENABLED; + } + return ButtonState.DISABLED; + } + /** Only show the conference call button if we can manage the conference. */ private void maybeShowManageConferenceCallButton() { getUi().showManageConferenceCallButton(shouldShowManageConference()); @@ -505,6 +522,15 @@ public class CallCardPresenter && !mIsFullscreen; } + private boolean supports2ndCallOnHold() { + DialerCall firstCall = CallList.getInstance().getActiveOrBackgroundCall(); + DialerCall incomingCall = CallList.getInstance().getIncomingCall(); + if (firstCall != null && incomingCall != null && firstCall != incomingCall) { + return incomingCall.can(Details.CAPABILITY_HOLD); + } + return true; + } + @Override public void onCallStateButtonClicked() { Intent broadcastIntent = Bindings.get(mContext).getCallStateButtonBroadcastIntent(mContext); @@ -528,11 +554,6 @@ public class CallCardPresenter InCallPresenter.getInstance().onShrinkAnimationComplete(); } - @Override - public Drawable getDefaultContactPhotoDrawable() { - return ContactInfoCache.getInstance(mContext).getDefaultContactPhotoDrawable(); - } - private void maybeStartSearch(DialerCall call, boolean isPrimary) { // no need to start search for conference calls which show generic info. if (call != null && !call.isConferenceCall()) { @@ -564,8 +585,8 @@ public class CallCardPresenter if (call != null) { call.getLogState().contactLookupResult = entry.contactLookupResult; } - if (entry.contactUri != null) { - CallerInfoUtils.sendViewNotification(mContext, entry.contactUri); + if (entry.lookupUri != null) { + CallerInfoUtils.sendViewNotification(mContext, entry.lookupUri); } } @@ -666,26 +687,8 @@ public class CallCardPresenter boolean hasWorkCallProperty = mPrimary.hasProperty(PROPERTY_ENTERPRISE_CALL); MultimediaData multimediaData = null; - if (mPrimary.getNumber() != null) { - EnrichedCallManager manager = EnrichedCallComponent.get(mContext).getEnrichedCallManager(); - - EnrichedCallManager.Filter filter; - if (mPrimary.isIncoming()) { - filter = manager.createIncomingCallComposerFilter(); - } else { - filter = manager.createOutgoingCallComposerFilter(); - } - - Session enrichedCallSession = - manager.getSession(mPrimary.getUniqueCallId(), mPrimary.getNumber(), filter); - - mPrimary.setEnrichedCallSession(enrichedCallSession); - mPrimary.setEnrichedCallCapabilities(manager.getCapabilities(mPrimary.getNumber())); - - if (enrichedCallSession != null) { - enrichedCallSession.setUniqueDialerCallId(mPrimary.getUniqueCallId()); - multimediaData = enrichedCallSession.getMultimediaData(); - } + if (mPrimary.getEnrichedCallSession() != null) { + multimediaData = mPrimary.getEnrichedCallSession().getMultimediaData(); } if (mPrimary.isConferenceCall()) { @@ -696,7 +699,8 @@ public class CallCardPresenter mInCallScreen.setPrimary( new PrimaryInfo( null /* number */, - getConferenceString(mPrimary), + CallerInfoUtils.getConferenceString( + mContext, mPrimary.hasProperty(Details.PROPERTY_GENERIC_CONFERENCE)), false /* nameIsNumber */, null /* location */, null /* label */, @@ -710,6 +714,7 @@ public class CallCardPresenter shouldShowLocation(), null /* contactInfoLookupKey */, null /* enrichedCallMultimediaData */, + true /* showInCallButtonGrid */, mPrimary.getNumberPresentation())); } else if (mPrimaryContactInfo != null) { LogUtil.v( @@ -757,6 +762,7 @@ public class CallCardPresenter shouldShowLocation(), mPrimaryContactInfo.lookupKey, multimediaData, + true /* showInCallButtonGrid */, mPrimary.getNumberPresentation())); } else { // Clear the primary display info. @@ -876,11 +882,20 @@ public class CallCardPresenter return; } + if (mSecondary.isMergeInProcess()) { + LogUtil.i( + "CallCardPresenter.updateSecondaryDisplayInfo", + "secondary call is merge in process, clearing info"); + mInCallScreen.setSecondary(SecondaryInfo.createEmptySecondaryInfo(mIsFullscreen)); + return; + } + if (mSecondary.isConferenceCall()) { mInCallScreen.setSecondary( new SecondaryInfo( true /* show */, - getConferenceString(mSecondary), + CallerInfoUtils.getConferenceString( + mContext, mSecondary.hasProperty(Details.PROPERTY_GENERIC_CONFERENCE)), false /* nameIsNumber */, null /* label */, mSecondary.getCallProviderLabel(), @@ -972,7 +987,7 @@ public class CallCardPresenter } /** Gets the name to display for the call. */ - String getNameForCall(ContactCacheEntry contactInfo) { + private String getNameForCall(ContactCacheEntry contactInfo) { String preferredName = ContactDisplayUtils.getPreferredDisplayName( contactInfo.namePrimary, contactInfo.nameAlternative, mContactsPreferences); @@ -982,19 +997,6 @@ public class CallCardPresenter return preferredName; } - /** Gets the number to display for a call. */ - String getNumberForCall(ContactCacheEntry contactInfo) { - // If the name is empty, we use the number for the name...so don't show a second - // number in the number field - String preferredName = - ContactDisplayUtils.getPreferredDisplayName( - contactInfo.namePrimary, contactInfo.nameAlternative, mContactsPreferences); - if (TextUtils.isEmpty(preferredName)) { - return contactInfo.location; - } - return contactInfo.number; - } - @Override public void onSecondaryInfoClicked() { if (mSecondary == null) { @@ -1004,6 +1006,11 @@ public class CallCardPresenter return; } + Logger.get(mContext) + .logCallImpression( + DialerImpression.Type.IN_CALL_SWAP_SECONDARY_BUTTON_PRESSED, + mPrimary.getUniqueCallId(), + mPrimary.getTimeAddedMs()); LogUtil.i( "CallCardPresenter.onSecondaryInfoClicked", "swapping call to foreground: " + mSecondary); mSecondary.unhold(); @@ -1015,6 +1022,7 @@ public class CallCardPresenter if (mPrimary != null) { mPrimary.disconnect(); } + PostCall.onDisconnectPressed(mContext); } /** @@ -1035,15 +1043,6 @@ public class CallCardPresenter return mPrimary != null && mPrimary.getState() == DialerCall.State.ACTIVE; } - private String getConferenceString(DialerCall call) { - boolean isGenericConference = call.hasProperty(Details.PROPERTY_GENERIC_CONFERENCE); - LogUtil.v("CallCardPresenter.getConferenceString", "" + isGenericConference); - - final int resId = - isGenericConference ? R.string.generic_conference_call_name : R.string.conference_call_name; - return mContext.getResources().getString(resId); - } - private boolean shouldShowEndCallButton(DialerCall primary, int callState) { if (primary == null) { return false; @@ -1063,7 +1062,6 @@ public class CallCardPresenter @Override public void onInCallScreenResumed() { - EnrichedCallComponent.get(mContext).getEnrichedCallManager().registerStateChangedListener(this); updatePrimaryDisplayInfo(); if (shouldSendAccessibilityEvent) { @@ -1072,11 +1070,7 @@ public class CallCardPresenter } @Override - public void onInCallScreenPaused() { - EnrichedCallComponent.get(mContext) - .getEnrichedCallManager() - .unregisterStateChangedListener(this); - } + public void onInCallScreenPaused() {} static boolean sendAccessibilityEvent(Context context, InCallScreen inCallScreen) { AccessibilityManager am = -- cgit v1.2.3