diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2017-08-31 07:30:38 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-08-31 07:30:38 +0000 |
commit | 595893125ea83ccdf5d1cbe03897017b6ab9ff18 (patch) | |
tree | acec9211f6fa64580e8533b1682d4026a80ad89e | |
parent | 0e6c61e7b983ee5fa16fd1e28d6cfb34e0253211 (diff) | |
parent | 118e5a88b580c98242094021063166cb0f9369ef (diff) | |
download | ims-595893125ea83ccdf5d1cbe03897017b6ab9ff18.tar.gz |
release-request-fd631211-effa-4885-9314-559fcbd0a094-for-git_oc-mr1-release-4308825 snap-temp-L52700000098265170
Change-Id: Ic5e7c6849c62d6d2e833390818de196b41b44f0f
-rw-r--r-- | src/java/com/android/ims/ImsManager.java | 65 |
1 files changed, 60 insertions, 5 deletions
diff --git a/src/java/com/android/ims/ImsManager.java b/src/java/com/android/ims/ImsManager.java index ccb602bb..5319ea42 100644 --- a/src/java/com/android/ims/ImsManager.java +++ b/src/java/com/android/ims/ImsManager.java @@ -21,7 +21,9 @@ import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.AsyncTask; +import android.os.Handler; import android.os.IBinder; +import android.os.Looper; import android.os.Message; import android.os.Parcel; import android.os.PersistableBundle; @@ -50,6 +52,7 @@ import com.android.ims.internal.IImsUt; import com.android.ims.internal.ImsCallSession; import com.android.ims.internal.IImsConfig; import com.android.internal.annotations.VisibleForTesting; +import com.android.internal.telephony.ExponentialBackoff; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -227,6 +230,17 @@ public class ImsManager { private ConcurrentLinkedDeque<ImsReasonInfo> mRecentDisconnectReasons = new ConcurrentLinkedDeque<>(); + // Exponential backoff for provisioning cache update. May be null for instances of ImsManager + // that are not on a thread supporting a looper. + private ExponentialBackoff mProvisionBackoff; + // Initial Provisioning check delay in ms + private static final long BACKOFF_INITIAL_DELAY_MS = 500; + // Max Provisioning check delay in ms (5 Minutes) + private static final long BACKOFF_MAX_DELAY_MS = 300000; + // Multiplier for exponential delay + private static final int BACKOFF_MULTIPLIER = 2; + + /** * Gets a manager instance. * @@ -1183,9 +1197,9 @@ public class ImsManager { } } - private class AsyncUpdateProvisionedValues extends AsyncTask<Void, Void, Void> { + private class AsyncUpdateProvisionedValues extends AsyncTask<Void, Void, Boolean> { @Override - protected Void doInBackground(Void... params) { + protected Boolean doInBackground(Void... params) { // disable on any error setVolteProvisionedProperty(false); setWfcProvisionedProperty(false); @@ -1209,18 +1223,40 @@ public class ImsManager { } } catch (ImsException ie) { Rlog.e(TAG, "AsyncUpdateProvisionedValues error: ", ie); + return false; } - return null; + return true; + } + + @Override + protected void onPostExecute(Boolean completed) { + if (mProvisionBackoff == null) { + return; + } + if (!completed) { + mProvisionBackoff.notifyFailed(); + } else { + mProvisionBackoff.stop(); + } } + /** + * Will return with config value or throw an ImsException if we receive an error from + * ImsConfig for that value. + */ private boolean getProvisionedBool(ImsConfig config, int item) throws ImsException { + int value = config.getProvisionedValue(item); + if (value == ImsConfig.FeatureValueConstants.ERROR) { + throw new ImsException("getProvisionedBool failed with error for item: " + item, + ImsReasonInfo.CODE_LOCAL_INTERNAL_ERROR); + } return config.getProvisionedValue(item) == ImsConfig.FeatureValueConstants.ON; } } - /** Asynchronously get VoLTE, WFC, VT provisioning statuses */ - private void updateProvisionedValues() { + // used internally only, use #updateProvisionedValues instead. + private void handleUpdateProvisionedValues() { if (getBooleanCarrierConfigForSlot( CarrierConfigManager.KEY_CARRIER_VOLTE_PROVISIONING_REQUIRED_BOOL)) { @@ -1229,6 +1265,20 @@ public class ImsManager { } /** + * Asynchronously get VoLTE, WFC, VT provisioning statuses. If ImsConfig is not available, we + * will retry with exponential backoff. + */ + private void updateProvisionedValues() { + // Start trying to receive provisioning status after BACKOFF_INITIAL_DELAY_MS. + if (mProvisionBackoff != null) { + mProvisionBackoff.start(); + } else { + // bypass and launch async thread once without backoff. + handleUpdateProvisionedValues(); + } + } + + /** * Sync carrier config and user settings with ImsConfig. * * @param context for the manager object @@ -1436,6 +1486,11 @@ public class ImsManager { com.android.internal.R.bool.config_dynamic_bind_ims); mConfigManager = (CarrierConfigManager) context.getSystemService( Context.CARRIER_CONFIG_SERVICE); + if (Looper.getMainLooper() != null) { + mProvisionBackoff = new ExponentialBackoff(BACKOFF_INITIAL_DELAY_MS, + BACKOFF_MAX_DELAY_MS, BACKOFF_MULTIPLIER, + new Handler(Looper.getMainLooper()), this::handleUpdateProvisionedValues); + } createImsService(); } |