diff --git a/src/com/android/settings/network/EnableMultiSimSidecar.java b/src/com/android/settings/network/EnableMultiSimSidecar.java index c47e61a1929..4a3243323c2 100644 --- a/src/com/android/settings/network/EnableMultiSimSidecar.java +++ b/src/com/android/settings/network/EnableMultiSimSidecar.java @@ -21,6 +21,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.provider.Settings; import android.telephony.CarrierConfigManager; import android.telephony.TelephonyManager; import android.telephony.UiccSlotInfo; @@ -46,8 +47,7 @@ public class EnableMultiSimSidecar extends AsyncTaskSidecar { // Tags private static final String TAG = "EnableMultiSimSidecar"; - // TODO(b/171846124): Pass timeout value from LPA to Settings - private static final long ENABLE_MULTI_SIM_TIMEOUT_MILLS = 40 * 1000L; + private static final long DEFAULT_ENABLE_MULTI_SIM_TIMEOUT_MILLS = 40 * 1000L; public static EnableMultiSimSidecar get(FragmentManager fm) { return SidecarFragment.get(fm, TAG, EnableMultiSimSidecar.class, null /* args */); @@ -77,7 +77,7 @@ public class EnableMultiSimSidecar extends AsyncTaskSidecar { TAG, String.format( "%d slots are active and %d SIMs are ready. Keep waiting until" - + " timeout.", + + " timeout.", activeSlotsCount, readySimsCount)); } }; @@ -123,8 +123,12 @@ public class EnableMultiSimSidecar extends AsyncTaskSidecar { mCarrierConfigChangeReceiver, new IntentFilter(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)); mTelephonyManager.switchMultiSimConfig(mNumOfActiveSim); - if (mSimCardStateChangedLatch.await( - ENABLE_MULTI_SIM_TIMEOUT_MILLS, TimeUnit.MILLISECONDS)) { + long waitingTimeMillis = + Settings.Global.getLong( + getContext().getContentResolver(), + Settings.Global.ENABLE_MULTI_SLOT_TIMEOUT_MILLIS, + DEFAULT_ENABLE_MULTI_SIM_TIMEOUT_MILLS); + if (mSimCardStateChangedLatch.await(waitingTimeMillis, TimeUnit.MILLISECONDS)) { Log.i(TAG, "Multi SIM were successfully enabled."); return true; } else { diff --git a/src/com/android/settings/network/UiccSlotUtil.java b/src/com/android/settings/network/UiccSlotUtil.java index 792f02a3c9c..6113f5a6aef 100644 --- a/src/com/android/settings/network/UiccSlotUtil.java +++ b/src/com/android/settings/network/UiccSlotUtil.java @@ -18,6 +18,7 @@ package com.android.settings.network; import android.annotation.IntDef; import android.content.Context; +import android.provider.Settings; import android.telephony.TelephonyManager; import android.telephony.UiccSlotInfo; import android.util.Log; @@ -35,8 +36,8 @@ public class UiccSlotUtil { private static final String TAG = "UiccSlotUtil"; - // TODO(b/171846124): Pass timeout value from LPA to Settings - private static final long WAIT_AFTER_SWITCH_TIMEOUT_MILLIS = 25000; + private static final long DEFAULT_WAIT_AFTER_SWITCH_TIMEOUT_MILLIS = 25 * 1000L; + ; public static final int INVALID_PHYSICAL_SLOT_ID = -1; @@ -115,12 +116,17 @@ public class UiccSlotUtil { private static void performSwitchToRemovableSlot(int slotId, Context context) throws UiccSlotsException { CarrierConfigChangedReceiver receiver = null; + long waitingTimeMillis = + Settings.Global.getLong( + context.getContentResolver(), + Settings.Global.EUICC_SWITCH_SLOT_TIMEOUT_MILLIS, + DEFAULT_WAIT_AFTER_SWITCH_TIMEOUT_MILLIS); try { CountDownLatch latch = new CountDownLatch(1); receiver = new CarrierConfigChangedReceiver(latch); receiver.registerOn(context); switchSlots(context, slotId); - latch.await(WAIT_AFTER_SWITCH_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); + latch.await(waitingTimeMillis, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); Log.e(TAG, "Failed switching to physical slot.", e);