diff options
Diffstat (limited to 'InCallUI/src/com/android/incallui/Call.java')
-rw-r--r-- | InCallUI/src/com/android/incallui/Call.java | 72 |
1 files changed, 65 insertions, 7 deletions
diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java index 447c34c88..d552ecfe5 100644 --- a/InCallUI/src/com/android/incallui/Call.java +++ b/InCallUI/src/com/android/incallui/Call.java @@ -33,6 +33,8 @@ import android.telecom.VideoProfile; import android.text.TextUtils; import com.android.contacts.common.CallUtil; +import com.android.contacts.common.compat.CallSdkCompat; +import com.android.contacts.common.compat.CompatUtils; import com.android.contacts.common.compat.SdkVersionOverride; import com.android.contacts.common.compat.telecom.TelecomManagerCompat; import com.android.contacts.common.testing.NeededForTesting; @@ -400,13 +402,30 @@ public class Call { setState(state); } + /** + * Creates a new instance of a {@link Call}. Registers a callback for + * {@link android.telecom.Call} events. + */ public Call(android.telecom.Call telecomCall) { + this(telecomCall, true /* registerCallback */); + } + + /** + * Creates a new instance of a {@link Call}. Optionally registers a callback for + * {@link android.telecom.Call} events. + * + * Intended for use when creating a {@link Call} instance for use with the + * {@link ContactInfoCache}, where we do not want to register callbacks for the new call. + */ + public Call(android.telecom.Call telecomCall, boolean registerCallback) { mTelecomCall = telecomCall; mId = ID_PREFIX + Integer.toString(sIdCounter++); - updateFromTelecomCall(); + updateFromTelecomCall(registerCallback); - mTelecomCall.registerCallback(mTelecomCallCallback); + if (registerCallback) { + mTelecomCall.registerCallback(mTelecomCallCallback); + } mTimeAddedMs = System.currentTimeMillis(); } @@ -426,7 +445,8 @@ public class Call { private void update() { Trace.beginSection("Update"); int oldState = getState(); - updateFromTelecomCall(); + // We want to potentially register a video call callback here. + updateFromTelecomCall(true /* registerCallback */); if (oldState != getState() && getState() == Call.State.DISCONNECTED) { CallList.getInstance().onDisconnect(this); } else { @@ -435,7 +455,7 @@ public class Call { Trace.endSection(); } - private void updateFromTelecomCall() { + private void updateFromTelecomCall(boolean registerCallback) { Log.d(this, "updateFromTelecomCall: " + mTelecomCall.toString()); final int translatedState = translateState(mTelecomCall.getState()); if (mState != State.BLOCKED) { @@ -444,7 +464,7 @@ public class Call { maybeCancelVideoUpgrade(mTelecomCall.getDetails().getVideoState()); } - if (mTelecomCall.getVideoCall() != null) { + if (registerCallback && mTelecomCall.getVideoCall() != null) { if (mVideoCallCallback == null) { mVideoCallCallback = new InCallVideoCallCallback(this); } @@ -883,9 +903,46 @@ public class Call { } /** + * Determines if the call is an external call. + * + * An external call is one which does not exist locally for the + * {@link android.telecom.ConnectionService} it is associated with. + * + * External calls are only supported in N and higher. + * + * @return {@code true} if the call is an external call, {@code false} otherwise. + */ + public boolean isExternalCall() { + return CompatUtils.isNCompatible() && + hasProperty(CallSdkCompat.Details.PROPERTY_IS_EXTERNAL_CALL); + } + + /** + * Determines if the external call is pullable. + * + * An external call is one which does not exist locally for the + * {@link android.telecom.ConnectionService} it is associated with. An external call may be + * "pullable", which means that the user can request it be transferred to the current device. + * + * External calls are only supported in N and higher. + * + * @return {@code true} if the call is an external call, {@code false} otherwise. + */ + public boolean isPullableExternalCall() { + return CompatUtils.isNCompatible() && + (mTelecomCall.getDetails().getCallCapabilities() + & CallSdkCompat.Details.CAPABILITY_CAN_PULL_CALL) + == CallSdkCompat.Details.CAPABILITY_CAN_PULL_CALL; + } + + /** * Logging utility methods */ public void logCallInitiationType() { + if (isExternalCall()) { + return; + } + if (getState() == State.INCOMING) { getLogState().callInitiationMethod = LogState.INITIATION_INCOMING; } else if (getIntentExtras() != null) { @@ -903,11 +960,12 @@ public class Call { return String.valueOf(mId); } - return String.format(Locale.US, "[%s, %s, %s, children:%s, parent:%s, conferenceable:%s, " + - "videoState:%s, mSessionModificationState:%d, VideoSettings:%s]", + return String.format(Locale.US, "[%s, %s, %s, %s, children:%s, parent:%s, " + + "conferenceable:%s, videoState:%s, mSessionModificationState:%d, VideoSettings:%s]", mId, State.toString(getState()), Details.capabilitiesToString(mTelecomCall.getDetails().getCallCapabilities()), + Details.propertiesToString(mTelecomCall.getDetails().getCallProperties()), mChildCallIds, getParentId(), this.mTelecomCall.getConferenceableCalls(), |