Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 966973f4 authored by Jiashen Wang's avatar Jiashen Wang Committed by Automerger Merge Worker
Browse files

Merge "Change Settings to be able to receive timeout values from LPA" into sc-dev am: 8cfa4c8c

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/13431258

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Id66f32bc60a016ec2d31a632e68076b5248ea68f
parents 58e65632 8cfa4c8c
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -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 */);
@@ -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 {
+9 −3
Original line number Diff line number Diff line
@@ -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);