diff options
author | Sailesh Nepal <sail@google.com> | 2015-09-19 00:25:17 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-09-19 00:25:17 +0000 |
commit | a8020a65843a8f0df37c9456ed7759372bb8387f (patch) | |
tree | 714ae1b608a6c1967e7f1323d74a5b17614483dd /src | |
parent | ef51640d6f3d0bf7ffc9408b3a0addee15a528b7 (diff) | |
parent | 8ed7eeb62df48943eae3caac3005beaefa53330c (diff) | |
download | android_packages_services_Telecomm-a8020a65843a8f0df37c9456ed7759372bb8387f.tar.gz android_packages_services_Telecomm-a8020a65843a8f0df37c9456ed7759372bb8387f.tar.bz2 android_packages_services_Telecomm-a8020a65843a8f0df37c9456ed7759372bb8387f.zip |
am 8ed7eeb6: Change requirements for emergency call timeout
* commit '8ed7eeb62df48943eae3caac3005beaefa53330c':
Change requirements for emergency call timeout
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/server/telecom/CreateConnectionTimeout.java | 68 | ||||
-rw-r--r-- | src/com/android/server/telecom/PhoneAccountRegistrar.java | 25 |
2 files changed, 34 insertions, 59 deletions
diff --git a/src/com/android/server/telecom/CreateConnectionTimeout.java b/src/com/android/server/telecom/CreateConnectionTimeout.java index 8acc2b46..06dc9ed3 100644 --- a/src/com/android/server/telecom/CreateConnectionTimeout.java +++ b/src/com/android/server/telecom/CreateConnectionTimeout.java @@ -17,14 +17,10 @@ package com.android.server.telecom; import android.content.Context; -import android.net.ConnectivityManager; -import android.net.NetworkInfo; import android.os.Handler; import android.os.Looper; import android.telecom.PhoneAccountHandle; import android.telephony.TelephonyManager; -import android.telephony.PhoneStateListener; -import android.telephony.ServiceState; import java.util.Collection; import java.util.Objects; @@ -32,7 +28,7 @@ import java.util.Objects; /** * Registers a timeout for a call and disconnects the call when the timeout expires. */ -final class CreateConnectionTimeout extends PhoneStateListener implements Runnable { +final class CreateConnectionTimeout implements Runnable { private final Context mContext; private final PhoneAccountRegistrar mPhoneAccountRegistrar; private final ConnectionServiceWrapper mConnectionService; @@ -43,7 +39,6 @@ final class CreateConnectionTimeout extends PhoneStateListener implements Runnab CreateConnectionTimeout(Context context, PhoneAccountRegistrar phoneAccountRegistrar, ConnectionServiceWrapper service, Call call) { - super(Looper.getMainLooper()); mContext = context; mPhoneAccountRegistrar = phoneAccountRegistrar; mConnectionService = service; @@ -69,27 +64,27 @@ final class CreateConnectionTimeout extends PhoneStateListener implements Runnab return false; } - // To reduce the number of scenarios where a timeout is needed, only use a timeout if - // we're connected to Wi-Fi. This ensures that the fallback connection manager has an - // alternate route to place the call. TODO: remove this condition or allow connection - // managers to specify transports. See http://b/19199181. - if (!isConnectedToWifi()) { + // Timeout is only supported for SIM call managers that are set by the carrier. + if (!Objects.equals(connectionManager.getComponentName(), + mPhoneAccountRegistrar.getSystemSimCallManagerComponent())) { + Log.d(this, "isTimeoutNeededForCall, not a system sim call manager"); return false; } - Log.d(this, "isTimeoutNeededForCall, returning true"); + Log.i(this, "isTimeoutNeededForCall, returning true"); return true; } void registerTimeout() { Log.d(this, "registerTimeout"); mIsRegistered = true; - // First find out the cellular service state. Based on the state we decide whether a timeout - // will actually be enforced and if so how long it should be. - TelephonyManager telephonyManager = - (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); - telephonyManager.listen(this, PhoneStateListener.LISTEN_SERVICE_STATE); - telephonyManager.listen(this, 0); + + long timeoutLengthMillis = getTimeoutLengthMillis(); + if (timeoutLengthMillis <= 0) { + Log.d(this, "registerTimeout, timeout set to %d, skipping", timeoutLengthMillis); + } else { + mHandler.postDelayed(this, timeoutLengthMillis); + } } void unregisterTimeout() { @@ -103,24 +98,9 @@ final class CreateConnectionTimeout extends PhoneStateListener implements Runnab } @Override - public void onServiceStateChanged(ServiceState serviceState) { - long timeoutLengthMillis = getTimeoutLengthMillis(serviceState); - if (!mIsRegistered) { - Log.d(this, "onServiceStateChanged, timeout no longer registered, skipping"); - } else if (timeoutLengthMillis <= 0) { - Log.d(this, "onServiceStateChanged, timeout set to %d, skipping", timeoutLengthMillis); - } else if (serviceState.getState() == ServiceState.STATE_IN_SERVICE) { - // If cellular service is available then don't bother with a timeout. - Log.d(this, "onServiceStateChanged, cellular service available, skipping"); - } else { - mHandler.postDelayed(this, timeoutLengthMillis); - } - } - - @Override public void run() { if (mIsRegistered && isCallBeingPlaced(mCall)) { - Log.d(this, "run, call timed out, calling disconnect"); + Log.i(this, "run, call timed out, calling disconnect"); mIsCallTimedOut = true; mConnectionService.disconnect(mCall); } @@ -133,24 +113,16 @@ final class CreateConnectionTimeout extends PhoneStateListener implements Runnab || state == CallState.DIALING; } - private long getTimeoutLengthMillis(ServiceState serviceState) { + private long getTimeoutLengthMillis() { // If the radio is off then use a longer timeout. This gives us more time to power on the // radio. - if (serviceState.getState() == ServiceState.STATE_POWER_OFF) { + TelephonyManager telephonyManager = + (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); + if (telephonyManager.isRadioOn()) { + return Timeouts.getEmergencyCallTimeoutMillis(mContext.getContentResolver()); + } else { return Timeouts.getEmergencyCallTimeoutRadioOffMillis( mContext.getContentResolver()); - } else { - return Timeouts.getEmergencyCallTimeoutMillis(mContext.getContentResolver()); - } - } - - private boolean isConnectedToWifi() { - ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService( - Context.CONNECTIVITY_SERVICE); - if (cm != null) { - NetworkInfo ni = cm.getActiveNetworkInfo(); - return ni != null && ni.isConnected() && ni.getType() == ConnectivityManager.TYPE_WIFI; } - return false; } } diff --git a/src/com/android/server/telecom/PhoneAccountRegistrar.java b/src/com/android/server/telecom/PhoneAccountRegistrar.java index 65847b8e..a795d6f0 100644 --- a/src/com/android/server/telecom/PhoneAccountRegistrar.java +++ b/src/com/android/server/telecom/PhoneAccountRegistrar.java @@ -286,6 +286,19 @@ public final class PhoneAccountRegistrar { return getSimCallManager(user); } + public ComponentName getSystemSimCallManagerComponent() { + String defaultSimCallManager = null; + CarrierConfigManager configManager = (CarrierConfigManager) mContext.getSystemService( + Context.CARRIER_CONFIG_SERVICE); + PersistableBundle configBundle = configManager.getConfig(); + if (configBundle != null) { + defaultSimCallManager = configBundle.getString( + CarrierConfigManager.KEY_DEFAULT_SIM_CALL_MANAGER_STRING); + } + return TextUtils.isEmpty(defaultSimCallManager) + ? null : ComponentName.unflattenFromString(defaultSimCallManager); + } + /** * Returns the {@link PhoneAccountHandle} corresponding to the currently active SIM Call * Manager. SIM Call Manager returned corresponds to the following priority order: @@ -300,17 +313,7 @@ public final class PhoneAccountRegistrar { String dialerPackage = DefaultDialerManager.getDefaultDialerApplication(mContext, user); // Check carrier config. - String defaultSimCallManager = null; - CarrierConfigManager configManager = (CarrierConfigManager) mContext.getSystemService( - Context.CARRIER_CONFIG_SERVICE); - PersistableBundle configBundle = configManager.getConfig(); - if (configBundle != null) { - defaultSimCallManager = configBundle.getString( - CarrierConfigManager.KEY_DEFAULT_SIM_CALL_MANAGER_STRING); - } - - ComponentName systemSimCallManagerComponent = TextUtils.isEmpty(defaultSimCallManager) ? - null : ComponentName.unflattenFromString(defaultSimCallManager); + ComponentName systemSimCallManagerComponent = getSystemSimCallManagerComponent(); PhoneAccountHandle dialerSimCallManager = null; PhoneAccountHandle systemSimCallManager = null; |