From 46848bb9b89cc5417afae19aaab38fe331a7b474 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Mon, 7 Apr 2014 22:33:09 -0700 Subject: InCallUI: Handoff UI tweaks This CL disables the handoff button when handoff is pending. It also cleans up the handoff UI code. Bug: 13565185, 13799169 Change-Id: Ie2831ba29d628fb5a0538defe918e3151eb5b824 --- .../com/android/incallui/CallCardPresenter.java | 52 ++++++++++------------ 1 file changed, 23 insertions(+), 29 deletions(-) (limited to 'InCallUI/src/com/android/incallui/CallCardPresenter.java') diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index a63c426b6..30639751c 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -21,8 +21,6 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; 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; @@ -56,6 +54,7 @@ public class CallCardPresenter extends Presenter private ContactCacheEntry mSecondaryContactInfo; private CallTimer mCallTimer; private Context mContext; + private boolean mIsWiFiCachedValue; public CallCardPresenter() { // create the call timer @@ -183,41 +182,36 @@ public class CallCardPresenter extends Presenter ui.setPrimaryCallElapsedTime(false, null); } - // Set the call state + setUiCallState(); + } + + private void setUiCallState() { if (mPrimary != null) { - final boolean bluetoothOn = + boolean bluetoothOn = (AudioModeProvider.getInstance().getAudioMode() == AudioMode.BLUETOOTH); - ui.setCallState(mPrimary.getState(), mPrimary.getDisconnectCause(), bluetoothOn, - getGatewayLabel(), getGatewayNumber(), getWifiConnection()); + boolean isHandoffCapable = mPrimary.can(CallCapabilities.CONNECTION_HANDOFF); + boolean isHandoffPending = mPrimary.getHandoffCallServiceDescriptor() != null; + + CallServiceDescriptor descriptor = mPrimary.getCurrentCallServiceDescriptor(); + boolean isWiFi = descriptor != null && + descriptor.getNetworkType() == CallServiceDescriptor.FLAG_WIFI; + // Cache the value so the UI doesn't change when the call ends. + mIsWiFiCachedValue = isWiFi; + + getUi().setCallState(mPrimary.getState(), mPrimary.getDisconnectCause(), bluetoothOn, + getGatewayLabel(), getGatewayNumber(), isWiFi, isHandoffCapable, + isHandoffPending); } else { - ui.setCallState(Call.State.IDLE, DisconnectCause.NOT_VALID, false, null, null, null); + getUi().setCallState(Call.State.IDLE, DisconnectCause.NOT_VALID, false, null, null, + mIsWiFiCachedValue, false, false); } - - ui.setShowConnectionHandoff(mPrimary != null && - mPrimary.can(CallCapabilities.CONNECTION_HANDOFF)); } @Override public void onAudioMode(int mode) { if (mPrimary != null && getUi() != null) { - final boolean bluetoothOn = (AudioMode.BLUETOOTH == mode); - - getUi().setCallState(mPrimary.getState(), mPrimary.getDisconnectCause(), bluetoothOn, - getGatewayLabel(), getGatewayNumber(), getWifiConnection()); - } - } - - 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(); - } + setUiCallState(); } - return null; } @Override @@ -489,12 +483,12 @@ public class CallCardPresenter extends Presenter Drawable photo, boolean isConference, boolean isGeneric); void setSecondaryImage(Drawable image); void setCallState(int state, int cause, boolean bluetoothOn, - String gatewayLabel, String gatewayNumber, String wifiConnection); + String gatewayLabel, String gatewayNumber, boolean isWiFi, + boolean isHandoffCapable, boolean isHandoffPending); void setPrimaryCallElapsedTime(boolean show, String duration); void setPrimaryName(String name, boolean nameIsNumber); void setPrimaryImage(Drawable image); void setPrimaryPhoneNumber(String phoneNumber); void setPrimaryLabel(String label); - void setShowConnectionHandoff(boolean showConnectionHandoff); } } -- cgit v1.2.3