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

Commit 74f24c17 authored by Angela Wu's avatar Angela Wu
Browse files

Change to use supplyNetworkDepersonalization to unlock network in lower RIL versions



supplySimDepersonalization only support on IRadio 1.5 or greater version
, but some chipset not support IRadio 1.5.
If need to use supplySimDepersonalization on the different chipset ,
need to change to use supplyNetworkDepersonalization to unlock network
in lower RIL versions.

Test: atest RILTest#testSupplySimDepersonalization
atest RILTest#testSupplySimDepersonalizationWithNetworkLock

Signed-off-by: default avatarAngela Wu <hswu@microsoft.com>
Change-Id: I2f2da58824f23e15e19821ab7cd4a70835d1f132
parent 559bf020
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1267,6 +1267,10 @@ public class RIL extends BaseCommands implements CommandsInterface {
                handleRadioProxyExceptionForRR(SIM_SERVICE, "supplySimDepersonalization", e);
            }
        } else {
            if (PersoSubState.PERSOSUBSTATE_SIM_NETWORK == persoType) {
                supplyNetworkDepersonalization(controlKey, result);
                return;
            }
            if (RILJ_LOGD) {
                Rlog.d(RILJ_LOG_TAG, "supplySimDepersonalization: REQUEST_NOT_SUPPORTED");
            }
+75 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static com.android.internal.telephony.RILConstants.RIL_REQUEST_DEVICE_IDE
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_DTMF;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ENABLE_UICC_APPLICATIONS;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ENTER_SIM_DEPERSONALIZATION;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ENTER_SIM_PIN;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ENTER_SIM_PIN2;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ENTER_SIM_PUK;
@@ -168,6 +169,8 @@ import android.util.SparseArray;

import androidx.test.filters.FlakyTest;

import com.android.internal.telephony.uicc.IccCardApplicationStatus.PersoSubState;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -471,6 +474,78 @@ public class RILTest extends TelephonyTest {
                RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION);
    }

    @FlakyTest
    @Test
    public void testSupplySimDepersonalization() throws Exception {

        String controlKey = "1234";
        PersoSubState persoType = PersoSubState.PERSOSUBSTATE_SIM_NETWORK_PUK;

        // Not supported on Radio 1.0.
        mRILUnderTest.supplySimDepersonalization(persoType, controlKey, obtainMessage());
        verify(mRadioProxy, never()).supplySimDepersonalization(anyInt(), anyInt(), eq(controlKey));
        verify(mRadioProxy, never()).supplyNetworkDepersonalization(
                anyInt(), eq(controlKey));

        // Make radio version 1.5 to support the operation.
        try {
            replaceInstance(RIL.class, "mRadioVersion", mRILUnderTest, mRadioVersionV15);
        } catch (Exception e) {
        }

        mRILUnderTest.supplySimDepersonalization(persoType, controlKey, obtainMessage());
        verify(mRadioProxy).supplySimDepersonalization(
                mSerialNumberCaptor.capture(),
                eq((int) invokeMethod(
                        mRILInstance,
                        "convertPersoTypeToHalPersoType",
                        new Class<?>[] {PersoSubState.class},
                        new Object[] {persoType})),
                eq(controlKey));
        verifyRILResponse(
                mRILUnderTest,
                mSerialNumberCaptor.getValue(),
                RIL_REQUEST_ENTER_SIM_DEPERSONALIZATION);
    }

    @FlakyTest
    @Test
    public void testSupplySimDepersonalizationWithNetworkLock() throws Exception {

        String controlKey = "1234";
        PersoSubState persoType = PersoSubState.PERSOSUBSTATE_SIM_NETWORK;

        // use supplyNetworkDepersonalization on Radio 1.0.
        mRILUnderTest.supplySimDepersonalization(persoType, controlKey, obtainMessage());
        verify(mRadioProxy, never()).supplySimDepersonalization(anyInt(), anyInt(), eq(controlKey));
        verify(mRadioProxy).supplyNetworkDepersonalization(
                mSerialNumberCaptor.capture(), eq(controlKey));
        verifyRILResponse(
                mRILUnderTest,
                mSerialNumberCaptor.getValue(),
                RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION);

        // Make radio version 1.5 to support the operation.
        try {
            replaceInstance(RIL.class, "mRadioVersion", mRILUnderTest, mRadioVersionV15);
        } catch (Exception e) {
        }

        mRILUnderTest.supplySimDepersonalization(persoType, controlKey, obtainMessage());
        verify(mRadioProxy).supplySimDepersonalization(
                mSerialNumberCaptor.capture(),
                eq((int) invokeMethod(
                        mRILInstance,
                        "convertPersoTypeToHalPersoType",
                        new Class<?>[] {PersoSubState.class},
                        new Object[] {persoType})),
                eq(controlKey));
        verifyRILResponse(
                mRILUnderTest,
                mSerialNumberCaptor.getValue(),
                RIL_REQUEST_ENTER_SIM_DEPERSONALIZATION);
    }

    @FlakyTest
    @Test
    public void testGetCurrentCalls() throws Exception {