diff options
author | Evan Charlton <evanc@google.com> | 2014-05-14 12:53:07 -0700 |
---|---|---|
committer | Evan Charlton <evanc@google.com> | 2014-05-14 12:53:07 -0700 |
commit | c87c30b2d64619d51bfe43d49b08c4a146c38c13 (patch) | |
tree | baa90952bd2957b6806599b8b8ba1d36dd01b796 /InCallUI | |
parent | b7aa8a1975cd085453998fe5bea620d458249fcb (diff) | |
parent | c6f4e50a4130fb8f7247f5eab6849829701ad484 (diff) |
resolved conflicts for merge of a4819143 to master
Change-Id: Ia724e55004733996de1fab90fb373334046fefec
Diffstat (limited to 'InCallUI')
5 files changed, 107 insertions, 136 deletions
diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java index 20075f75c..6a36657ad 100644 --- a/InCallUI/src/com/android/incallui/Call.java +++ b/InCallUI/src/com/android/incallui/Call.java @@ -16,29 +16,23 @@ package com.android.incallui; +import android.net.Uri; import android.telecomm.CallCapabilities; import android.telecomm.CallNumberPresentation; +import android.telecomm.CallServiceDescriptor; import android.telecomm.GatewayInfo; import android.telephony.DisconnectCause; -import com.android.internal.telephony.PhoneConstants; -import com.google.android.collect.Sets; -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedSet; import com.google.common.primitives.Ints; import java.util.Locale; -import java.util.Map; -import java.util.SortedSet; -import java.util.TreeSet; /** * Class object used across CallHandlerService APIs. * Describes a single call and its state. */ public final class Call { - /* Defines different states of this call */ public static class State { public static final int INVALID = 0; @@ -102,35 +96,18 @@ public final class Call { } } - // Unique identifier for the call private String mCallId; - - // The current state of the call private int mState = State.INVALID; - - // TODO: Probably need to change to wifi call state. Re-use mState? - // State.WIFI_CONNECTING - // State.WIFI_CONNECTED - // Using this simple boolean for now so we can see the UI mock. - private boolean mIsWifiCall = false; - - // Reason for disconnect. Valid when the call state is DISCONNECTED. - // Valid values are defined in {@link DisconnectCause}. private int mDisconnectCause = DisconnectCause.NOT_VALID; - - // Bit mask of capabilities unique to this call. private int mCapabilities; - - // Time that this call transitioned into ACTIVE state from INCOMING, WAITING, or OUTGOING. - private long mConnectTime = 0; - - private String mNumber; - + private long mConnectTimeMillis = 0; + private Uri mHandle; private GatewayInfo mGatewayInfo; + private CallServiceDescriptor mCurrentCallServiceDescriptor; + private CallServiceDescriptor mHandoffCallServiceDescriptor; - public Call(String callId, String number) { + public Call(String callId) { mCallId = callId; - mNumber = number; } public String getCallId() { @@ -138,7 +115,18 @@ public final class Call { } public String getNumber() { - return mNumber; + if (mGatewayInfo != null) { + return mGatewayInfo.getOriginalHandle().getSchemeSpecificPart(); + } + return getHandle().getSchemeSpecificPart(); + } + + public Uri getHandle() { + return mHandle; + } + + public void setHandle(Uri handle) { + mHandle = handle; } public int getState() { @@ -149,10 +137,6 @@ public final class Call { mState = state; } - public boolean isWifiCall() { - return mIsWifiCall; - } - public CallNumberPresentation getNumberPresentation() { return CallNumberPresentation.ALLOWED; } @@ -179,28 +163,24 @@ public final class Call { mDisconnectCause = cause; } + /** Sets a bit mask of capabilities unique to this call. */ public void setCapabilities(int capabilities) { mCapabilities = (CallCapabilities.ALL & capabilities); } + /** Checks if the call supports the given set of capabilities supplied as a bit mask. */ public boolean can(int capabilities) { return (capabilities == (capabilities & mCapabilities)); } - public void addCapabilities(int capabilities) { - setCapabilities(capabilities | mCapabilities); - } - - public void removeCapabilities(int capabilities) { - setCapabilities(~capabilities & mCapabilities); + /** Sets the time when the call first became active. */ + public void setConnectTimeMillis(long connectTimeMillis) { + mConnectTimeMillis = connectTimeMillis; } - public void setConnectTime(long connectTime) { - mConnectTime = connectTime; - } - - public long getConnectTime() { - return mConnectTime; + /** Gets the time when the call first became active. */ + public long getConnectTimeMillis() { + return mConnectTimeMillis; } public ImmutableSortedSet<Integer> getChildCallIds() { @@ -219,6 +199,27 @@ public final class Call { mGatewayInfo = gatewayInfo; } + /** The descriptor for the call service currently routing this call. */ + public CallServiceDescriptor getCurrentCallServiceDescriptor() { + return mCurrentCallServiceDescriptor; + } + + public void setCurrentCallServiceDescriptor(CallServiceDescriptor descriptor) { + mCurrentCallServiceDescriptor = descriptor; + } + + /** + * The descriptor for the call service that this call is being switched to, null if handoff is + * not in progress. + */ + public CallServiceDescriptor getHandoffCallServiceDescriptor() { + return mHandoffCallServiceDescriptor; + } + + public void setHandoffCallServiceDescriptor(CallServiceDescriptor descriptor) { + mHandoffCallServiceDescriptor = descriptor; + } + @Override public String toString() { return String.format(Locale.US, "[%s, %s]", mCallId, State.toString(mState)); diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index ab62af5be..2e15ce3fe 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -24,6 +24,7 @@ import android.graphics.Bitmap; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.telecomm.CallCapabilities; +import android.telecomm.CallServiceDescriptor; import android.telephony.DisconnectCause; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; @@ -208,6 +209,15 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> } private String getWifiConnection() { + CallServiceDescriptor descriptor = mPrimary.getCurrentCallServiceDescriptor(); + if (descriptor != null && descriptor.getNetworkType() == CallServiceDescriptor.FLAG_WIFI) { + final WifiManager wifiManager = (WifiManager) mContext.getSystemService( + Context.WIFI_SERVICE); + final WifiInfo info = wifiManager.getConnectionInfo(); + if (info != null) { + return info.getSSID(); + } + } return null; } @@ -228,7 +238,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> } mCallTimer.cancel(); } else { - final long callStart = mPrimary.getConnectTime(); + final long callStart = mPrimary.getConnectTimeMillis(); final long duration = System.currentTimeMillis() - callStart; ui.setPrimaryCallElapsedTime(true, DateUtils.formatElapsedTime(duration / 1000)); } diff --git a/InCallUI/src/com/android/incallui/DialpadPresenter.java b/InCallUI/src/com/android/incallui/DialpadPresenter.java index 427564068..b3818646f 100644 --- a/InCallUI/src/com/android/incallui/DialpadPresenter.java +++ b/InCallUI/src/com/android/incallui/DialpadPresenter.java @@ -39,7 +39,6 @@ public class DialpadPresenter extends Presenter<DialpadPresenter.DialpadUi> InCallPresenter.getInstance().removeListener(this); } - @Override public void onStateChange(InCallPresenter.InCallState state, CallList callList) { mCall = callList.getActiveCall(); diff --git a/InCallUI/src/com/android/incallui/InCallServiceImpl.java b/InCallUI/src/com/android/incallui/InCallServiceImpl.java index 68b3c2c21..a6044cccc 100644 --- a/InCallUI/src/com/android/incallui/InCallServiceImpl.java +++ b/InCallUI/src/com/android/incallui/InCallServiceImpl.java @@ -18,9 +18,10 @@ package com.android.incallui; import android.telecomm.CallAudioState; import android.telecomm.CallCapabilities; -import android.telecomm.CallInfo; +import android.telecomm.CallState; import android.telecomm.GatewayInfo; import android.telecomm.InCallAdapter; +import android.telecomm.InCallCall; import android.telecomm.InCallService; import android.telephony.DisconnectCause; @@ -33,7 +34,6 @@ import com.google.common.collect.ImmutableList; * the service triggering InCallActivity (via CallList) to finish soon after. */ public class InCallServiceImpl extends InCallService { - private static final ImmutableList<String> EMPTY_RESPONSE_TEXTS = ImmutableList.of(); /** {@inheritDoc} */ @@ -53,41 +53,17 @@ public class InCallServiceImpl extends InCallService { InCallPresenter.getInstance().tearDown(); } - /** - * TODO(santoscordon): Rename this to setTelecommAdapter. - * {@inheritDoc} - */ + /** {@inheritDoc} */ @Override protected void onAdapterAttached(InCallAdapter inCallAdapter) { Log.v(this, "onAdapterAttached"); TelecommAdapter.getInstance().setAdapter(inCallAdapter); } /** {@inheritDoc} */ - @Override protected void addCall(CallInfo callInfo) { - Log.v(this, "addCall, state: " + callInfo.getState()); - Call call = new Call(callInfo.getId(), - callInfo.getOriginalHandle().getSchemeSpecificPart()); - switch(callInfo.getState()) { - case RINGING: - call.setState(Call.State.INCOMING); - break; - case DIALING: - call.setState(Call.State.DIALING); - break; - case ACTIVE: - call.setState(Call.State.ACTIVE); - break; - case DISCONNECTED: - call.setState(Call.State.DISCONNECTED); - break; - default: - call.setState(Call.State.INVALID); - break; - } - - call.setGatewayInfo(callInfo.getGatewayInfo()); - call.addCapabilities(CallCapabilities.HOLD | CallCapabilities.MUTE); - + @Override protected void addCall(InCallCall telecommCall) { + Log.v(this, "addCall, state: " + telecommCall.getState()); + Call call = new Call(telecommCall.getId()); + updateCall(call, telecommCall); if (call.getState() == Call.State.INCOMING) { CallList.getInstance().onIncoming(call, EMPTY_RESPONSE_TEXTS); } else { @@ -96,35 +72,25 @@ public class InCallServiceImpl extends InCallService { } /** {@inheritDoc} */ - @Override protected void setActive(String callId) { - Call call = CallList.getInstance().getCall(callId); - Log.v(this, "setActive: " + call); - if (null != call) { - call.setState(Call.State.ACTIVE); - if (call.getConnectTime() == 0) { - call.setConnectTime(System.currentTimeMillis()); - } - CallList.getInstance().onUpdate(call); + @Override protected void updateCall(InCallCall telecommCall) { + Call call = CallList.getInstance().getCall(telecommCall.getId()); + if (call == null) { + Log.v(this, "updateCall for unknown call: " + telecommCall.getId()); + return; } - } - /** {@inheritDoc} */ - @Override protected void setDialing(String callId) { - Call call = CallList.getInstance().getCall(callId); - Log.v(this, "setDialing: " + call); - if (null != call) { - call.setState(Call.State.DIALING); + Log.v(this, "updateCall: " + call); + int oldState = call.getState(); + updateCall(call, telecommCall); + + if (oldState != call.getState() && call.getState() == Call.State.DISCONNECTED) { + CallList.getInstance().onDisconnect(call); + } else { CallList.getInstance().onUpdate(call); } } /** {@inheritDoc} */ - @Override protected void setRinging(String callId) { - // TODO(ihab): Implement this. - Log.v(this, "setRinging"); - } - - /** {@inheritDoc} */ @Override protected void setPostDial(String callId, String remaining) { // TODO(ihab): Add post-dial state to user interface } @@ -135,43 +101,38 @@ public class InCallServiceImpl extends InCallService { } /** {@inheritDoc} */ - @Override protected void setHandoffEnabled(String callId, boolean isHandoffEnabled) { - Call call = CallList.getInstance().getCall(callId); - Log.v(this, "setHandoffEnabled: " + call + " isEnabled: " + isHandoffEnabled); - if (null != call) { - if (isHandoffEnabled) { - // TODO(sail): Enable handoff once http://b/13800303 and http://b/13800552 are - // fixed. - } else { - call.removeCapabilities(CallCapabilities.CONNECTION_HANDOFF); - } - CallList.getInstance().onUpdate(call); - } + @Override protected void onAudioStateChanged(CallAudioState audioState) { + AudioModeProvider.getInstance().onAudioModeChange(audioState.route, audioState.isMuted); + AudioModeProvider.getInstance().onSupportedAudioModeChange(audioState.supportedRouteMask); } - /** {@inheritDoc} */ - @Override protected void setDisconnected(String callId, int disconnectCause) { - Log.v(this, "setDisconnected"); - Call call = CallList.getInstance().getCall(callId); - if (null != call) { - call.setDisconnectCause(DisconnectCause.NORMAL); - call.setState(Call.State.DISCONNECTED); - CallList.getInstance().onDisconnect(call); - } + private void updateCall(Call call, InCallCall telecommCall) { + call.setHandle(telecommCall.getHandle()); + call.setDisconnectCause(telecommCall.getDisconnectCause()); + call.setCapabilities(telecommCall.getCapabilities()); + call.setConnectTimeMillis(telecommCall.getConnectTimeMillis()); + call.setGatewayInfo(telecommCall.getGatewayInfo()); + call.setCurrentCallServiceDescriptor(telecommCall.getCurrentCallServiceDescriptor()); + call.setHandoffCallServiceDescriptor(telecommCall.getHandoffCallServiceDescriptor()); + call.setState(translateState(telecommCall.getState())); } - /** {@inheritDoc} */ - @Override protected void setOnHold(String callId) { - Call call = CallList.getInstance().getCall(callId); - if (null != call) { - call.setState(Call.State.ONHOLD); - CallList.getInstance().onUpdate(call); + private static int translateState(CallState state) { + switch (state) { + case DIALING: + return Call.State.DIALING; + case RINGING: + return Call.State.INCOMING; + case POST_DIAL: + case POST_DIAL_WAIT: + case ACTIVE: + return Call.State.ACTIVE; + case ON_HOLD: + return Call.State.ONHOLD; + case DISCONNECTED: + return Call.State.DISCONNECTED; + default: + return Call.State.INVALID; } } - - /** {@inheritDoc} */ - @Override protected void onAudioStateChanged(CallAudioState audioState) { - AudioModeProvider.getInstance().onAudioModeChange(audioState.route, audioState.isMuted); - AudioModeProvider.getInstance().onSupportedAudioModeChange(audioState.supportedRouteMask); - } } diff --git a/InCallUI/src/com/android/incallui/StatusBarNotifier.java b/InCallUI/src/com/android/incallui/StatusBarNotifier.java index b9acd5783..c28b98de2 100644 --- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java +++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java @@ -289,7 +289,7 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { if (state == Call.State.ACTIVE) { builder.setUsesChronometer(true); - builder.setWhen(call.getConnectTime()); + builder.setWhen(call.getConnectTimeMillis()); } else { builder.setUsesChronometer(false); } |