diff options
Diffstat (limited to 'InCallUI/src/com/android/incallui/Call.java')
-rw-r--r-- | InCallUI/src/com/android/incallui/Call.java | 51 |
1 files changed, 41 insertions, 10 deletions
diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java index 3d6f2032e..4ed7a49cf 100644 --- a/InCallUI/src/com/android/incallui/Call.java +++ b/InCallUI/src/com/android/incallui/Call.java @@ -17,11 +17,14 @@ package com.android.incallui; import com.android.contacts.common.CallUtil; +import com.android.contacts.common.testing.NeededForTesting; import com.android.incallui.CallList.Listener; import android.content.Context; import android.hardware.camera2.CameraCharacteristics; import android.net.Uri; +import android.os.Bundle; +import android.os.Trace; import android.telecom.CallProperties; import android.telecom.DisconnectCause; import android.telecom.GatewayInfo; @@ -36,7 +39,8 @@ import java.util.Locale; /** * Describes a single call and its state. */ -public final class Call { +@NeededForTesting +public class Call { /* Defines different states of this call */ public static class State { public static final int INVALID = 0; @@ -236,7 +240,7 @@ public final class Call { } }; - private final android.telecom.Call mTelecommCall; + private android.telecom.Call mTelecommCall; private final String mId; private int mState = State.INVALID; private DisconnectCause mDisconnectCause; @@ -250,6 +254,16 @@ public final class Call { private InCallVideoCallListener mVideoCallListener; + /** + * Used only to create mock calls for testing + */ + @NeededForTesting + Call(int state) { + mTelecommCall = null; + mId = ID_PREFIX + Integer.toString(sIdCounter++); + setState(state); + } + public Call(android.telecom.Call telecommCall) { mTelecommCall = telecommCall; mId = ID_PREFIX + Integer.toString(sIdCounter++); @@ -270,6 +284,7 @@ public final class Call { } private void update() { + Trace.beginSection("Update"); int oldState = getState(); updateFromTelecommCall(); if (oldState != getState() && getState() == Call.State.DISCONNECTED) { @@ -277,6 +292,7 @@ public final class Call { } else { CallList.getInstance().onUpdate(this); } + Trace.endSection(); } private void updateFromTelecommCall() { @@ -329,6 +345,9 @@ public final class Call { } public String getNumber() { + if (mTelecommCall == null) { + return null; + } if (mTelecommCall.getDetails().getGatewayInfo() != null) { return mTelecommCall.getDetails().getGatewayInfo() .getOriginalAddress().getSchemeSpecificPart(); @@ -337,11 +356,11 @@ public final class Call { } public Uri getHandle() { - return mTelecommCall.getDetails().getHandle(); + return mTelecommCall == null ? null : mTelecommCall.getDetails().getHandle(); } public int getState() { - if (mTelecommCall.getParent() != null) { + if (mTelecommCall != null && mTelecommCall.getParent() != null) { return State.CONFERENCED; } else { return mState; @@ -353,15 +372,21 @@ public final class Call { } public int getNumberPresentation() { - return getTelecommCall().getDetails().getHandlePresentation(); + return mTelecommCall == null ? null : mTelecommCall.getDetails().getHandlePresentation(); } public int getCnapNamePresentation() { - return getTelecommCall().getDetails().getCallerDisplayNamePresentation(); + return mTelecommCall == null ? null + : mTelecommCall.getDetails().getCallerDisplayNamePresentation(); } public String getCnapName() { - return getTelecommCall().getDetails().getCallerDisplayName(); + return mTelecommCall == null ? null + : getTelecommCall().getDetails().getCallerDisplayName(); + } + + public Bundle getExtras() { + return mTelecommCall == null ? null : mTelecommCall.getDetails().getExtras(); } /** Returns call disconnect cause, defined by {@link DisconnectCause}. */ @@ -414,15 +439,15 @@ public final class Call { } public GatewayInfo getGatewayInfo() { - return mTelecommCall.getDetails().getGatewayInfo(); + return mTelecommCall == null ? null : mTelecommCall.getDetails().getGatewayInfo(); } public PhoneAccountHandle getAccountHandle() { - return mTelecommCall.getDetails().getAccountHandle(); + return mTelecommCall == null ? null : mTelecommCall.getDetails().getAccountHandle(); } public VideoCall getVideoCall() { - return mTelecommCall.getVideoCall(); + return mTelecommCall == null ? null : mTelecommCall.getVideoCall(); } public List<String> getChildCallIds() { @@ -521,6 +546,12 @@ public final class Call { @Override public String toString() { + if (mTelecommCall == null) { + // This should happen only in testing since otherwise we would never have a null + // Telecom call. + return String.valueOf(mId); + } + return String.format(Locale.US, "[%s, %s, %s, children:%s, parent:%s, conferenceable:%s, " + "videoState:%d, callSubState:%d, mSessionModificationState:%d, VideoSettings:%s]", mId, |