Change Settings to be able to receive timeout values from LPA
Bug: 171846124 Test: Tested manually Change-Id: I547315eabd7cc873b0dda7a3bb2d09c84225ddd3
This commit is contained in:
@@ -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<Void, Boolean> {
|
||||
// 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<Void, Boolean> {
|
||||
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<Void, Boolean> {
|
||||
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 {
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user