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

Commit 7e4c169a authored by Malcolm Chen's avatar Malcolm Chen Committed by Xiangyu/Malcolm Chen
Browse files

Remove IccCardProxy.

IccCardProxy is deprecated after UICC refactor. Remove the file
and all references and tests related.

Bug: 72463137
Test: unit-test
Change-Id: Id5e293233147c36e201e3ab946cb32873b90828a
Merged-In: Id5e293233147c36e201e3ab946cb32873b90828a
(cherry picked from commit 29d8d98e)
parent 95364759
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -34,8 +34,8 @@ import com.android.internal.telephony.uicc.IccRecords;
 * Apps (those that have access to Phone object) can retrieve this object
 * by calling phone.getIccCard()
 *
 * This interface is implemented by IccCardProxy and the object PhoneApp
 * gets when it calls getIccCard is IccCardProxy.
 * This interface is implemented by UiccProfile and the object PhoneApp
 * gets when it calls getIccCard is UiccProfile.
 */
public interface IccCard {
    /**
+0 −5
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import com.android.internal.telephony.dataconnection.DcTracker;
import com.android.internal.telephony.imsphone.ImsExternalCallTracker;
import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
import com.android.internal.telephony.uicc.IccCardProxy;
import com.android.internal.telephony.uicc.IccCardStatus;
import com.android.internal.telephony.uicc.UiccCard;
import com.android.internal.telephony.uicc.UiccProfile;
@@ -100,10 +99,6 @@ public class TelephonyComponentFactory {
        return new IccSmsInterfaceManager(phone);
    }

    public IccCardProxy makeIccCardProxy(Context context, CommandsInterface ci, int phoneId) {
        return new IccCardProxy(context, ci, phoneId);
    }

    /**
     * Create a new UiccProfile object.
     */
+0 −778

File deleted.

Preview size limit exceeded, changes collapsed.

+1 −7
Original line number Diff line number Diff line
@@ -64,7 +64,6 @@ import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
import com.android.internal.telephony.test.SimulatedCommands;
import com.android.internal.telephony.test.SimulatedCommandsVerifier;
import com.android.internal.telephony.uicc.IccCardProxy;
import com.android.internal.telephony.uicc.IccCardStatus;
import com.android.internal.telephony.uicc.IccRecords;
import com.android.internal.telephony.uicc.IsimUiccRecords;
@@ -109,8 +108,6 @@ public abstract class TelephonyTest {
    @Mock
    protected UiccController mUiccController;
    @Mock
    protected IccCardProxy mIccCardProxy;
    @Mock
    protected UiccProfile mUiccProfile;
    @Mock
    protected CallManager mCallManager;
@@ -328,9 +325,6 @@ public abstract class TelephonyTest {
        doReturn(mSST).when(mTelephonyComponentFactory)
                .makeServiceStateTracker(nullable(GsmCdmaPhone.class),
                        nullable(CommandsInterface.class));
        doReturn(mIccCardProxy).when(mTelephonyComponentFactory)
                .makeIccCardProxy(nullable(Context.class), nullable(CommandsInterface.class),
                        anyInt());
        doReturn(mUiccProfile).when(mTelephonyComponentFactory)
                .makeUiccProfile(nullable(Context.class), nullable(CommandsInterface.class),
                        nullable(IccCardStatus.class), anyInt(), nullable(UiccCard.class));
@@ -419,7 +413,7 @@ public abstract class TelephonyTest {
        doReturn(mRuimRecords).when(mUiccCardApplication3gpp2).getIccRecords();
        doReturn(mIsimUiccRecords).when(mUiccCardApplicationIms).getIccRecords();

        //mIccCardProxy
        //mUiccProfile
        doReturn(mSimRecords).when(mUiccProfile).getIccRecords();
        doAnswer(new Answer<IccRecords>() {
            public IccRecords answer(InvocationOnMock invocation) {
+0 −150
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.internal.telephony.uicc;

import static com.android.internal.telephony.TelephonyTestUtils.waitForMs;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.doReturn;

import android.os.HandlerThread;
import android.support.test.filters.FlakyTest;
import android.test.suitebuilder.annotation.SmallTest;

import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.IccCardConstants.State;
import com.android.internal.telephony.TelephonyTest;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
import com.android.internal.telephony.uicc.IccCardStatus.CardState;

import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mock;

public class IccCardProxyTest extends TelephonyTest {
    private IccCardProxy mIccCardProxyUT;
    // private UiccCard mUiccCard;
    private IccCardProxyHandlerThread mIccCardProxyHandlerThread;
    private static final int PHONE_ID = 0;
    private static final int PHONE_COUNT = 1;

    private static final int SCARY_SLEEP_MS = 200;
    // Must match IccCardProxy.EVENT_ICC_CHANGED
    private static final int EVENT_ICC_CHANGED = 3;

    @Mock private IccCardStatus mIccCardStatus;
    @Mock private UiccCard mUiccCard;
    @Mock private UiccCardApplication mUiccCardApplication;

    private class IccCardProxyHandlerThread extends HandlerThread {

        private IccCardProxyHandlerThread(String name) {
            super(name);
        }

        @Override
        public void onLooperPrepared() {
            /* create a new UICC Controller associated with the simulated Commands */
            mIccCardProxyUT = new IccCardProxy(mContext, mSimulatedCommands, PHONE_ID);
            setReady(true);
        }
    }

    @Before
    public void setUp() throws Exception {
        super.setUp(this.getClass().getSimpleName());
        doReturn(PHONE_COUNT).when(mTelephonyManager).getPhoneCount();
        doReturn(PHONE_COUNT).when(mTelephonyManager).getSimCount();
        mSimulatedCommands.setIccCardStatus(mIccCardStatus);
        mIccCardProxyHandlerThread = new IccCardProxyHandlerThread(TAG);
        mIccCardProxyHandlerThread.start();
        waitUntilReady();
    }

    @After
    public void tearDown() throws Exception {
        mIccCardProxyHandlerThread.quitSafely();
        super.tearDown();
    }

    @Test
    @SmallTest
    public void testInitialCardState() {
        assertEquals(mIccCardProxyUT.getState(), State.UNKNOWN);
    }

    @Test
    @Ignore
    @FlakyTest
    @SmallTest
    public void testPowerOn() {
        mSimulatedCommands.setRadioPower(true, null);
        mSimulatedCommands.notifyRadioOn();
        doReturn(mUiccCard).when(mUiccController).getUiccCard(anyInt());
        mIccCardProxyUT.sendMessage(mIccCardProxyUT.obtainMessage(EVENT_ICC_CHANGED));

        waitForMs(SCARY_SLEEP_MS);
        assertEquals(CommandsInterface.RadioState.RADIO_ON, mSimulatedCommands.getRadioState());
        assertEquals(mIccCardProxyUT.getState(), State.NOT_READY);
        logd("IccCardProxy state = " + mIccCardProxyUT.getState());
    }

    @Test
    @Ignore
    @FlakyTest
    @SmallTest
    public void testCardLoaded() {
        testPowerOn();
        doReturn(CardState.CARDSTATE_PRESENT).when(mUiccCard).getCardState();
        mIccCardProxyUT.sendMessage(mIccCardProxyUT.obtainMessage(EVENT_ICC_CHANGED));

        waitForMs(SCARY_SLEEP_MS);
        assertEquals(mIccCardProxyUT.getState(), State.NOT_READY);
    }

    @Test
    @Ignore
    @FlakyTest
    @SmallTest
    public void testAppNotLoaded() {
        testPowerOn();
        doReturn(CardState.CARDSTATE_PRESENT).when(mUiccCard).getCardState();
        mIccCardProxyUT.sendMessage(mIccCardProxyUT.obtainMessage(EVENT_ICC_CHANGED));
        doReturn(AppState.APPSTATE_UNKNOWN).when(mUiccCardApplication).getState();
        doReturn(mUiccCardApplication).when(mUiccCard).getApplication(anyInt());

        waitForMs(SCARY_SLEEP_MS);
        assertEquals(mIccCardProxyUT.getState(), State.NOT_READY);
    }

    @Test
    @Ignore
    @FlakyTest
    @SmallTest
    public void testAppReady() {
        testPowerOn();
        doReturn(CardState.CARDSTATE_PRESENT).when(mUiccCard).getCardState();
        mIccCardProxyUT.sendMessage(mIccCardProxyUT.obtainMessage(EVENT_ICC_CHANGED));
        doReturn(AppState.APPSTATE_READY).when(mUiccCardApplication).getState();
        doReturn(mUiccCardApplication).when(mUiccCard).getApplication(anyInt());

        waitForMs(SCARY_SLEEP_MS);
        assertEquals(mIccCardProxyUT.getState(), State.READY);
    }
}