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

Commit 65056969 authored by Xiangyu/Malcolm Chen's avatar Xiangyu/Malcolm Chen Committed by Gerrit Code Review
Browse files

Merge "Add support for API enableUiccApplications"

parents beac3f42 a0bfe048
Loading
Loading
Loading
Loading
+26 −3
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ public abstract class BaseCommands implements CommandsInterface {
    protected RegistrantList mPhysicalChannelConfigurationRegistrants = new RegistrantList();
    protected RegistrantList mLceInfoRegistrants = new RegistrantList();
    protected RegistrantList mEmergencyNumberListRegistrants = new RegistrantList();
    protected RegistrantList mUiccApplicationsEnablementRegistrants = new RegistrantList();

    @UnsupportedAppUsage
    protected Registrant mGsmSmsRegistrant;
@@ -952,7 +953,7 @@ public abstract class BaseCommands implements CommandsInterface {

    @Override
    public void registerForModemReset(Handler h, int what, Object obj) {
        mModemResetRegistrants.add(new Registrant(h, what, obj));
        mModemResetRegistrants.addUnique(h, what, obj);
    }

    @Override
@@ -962,7 +963,7 @@ public abstract class BaseCommands implements CommandsInterface {

    @Override
    public void registerForPcoData(Handler h, int what, Object obj) {
        mPcoDataRegistrants.add(new Registrant(h, what, obj));
        mPcoDataRegistrants.addUnique(h, what, obj);
    }

    @Override
@@ -972,7 +973,7 @@ public abstract class BaseCommands implements CommandsInterface {

    @Override
    public void registerForCarrierInfoForImsiEncryption(Handler h, int what, Object obj) {
        mCarrierInfoForImsiEncryptionRegistrants.add(new Registrant(h, what, obj));
        mCarrierInfoForImsiEncryptionRegistrants.addUnique(h, what, obj);
    }

    @Override
@@ -993,4 +994,26 @@ public abstract class BaseCommands implements CommandsInterface {
            mNattKeepaliveStatusRegistrants.remove(h);
        }
    }

    /**
     * Registers the handler for RIL_UNSOL_UICC_APPLICATIONS_ENABLEMENT_CHANGED events.
     *
     * @param h Handler for notification message.
     * @param what User-defined message code.
     * @param obj User object.
     */
    @Override
    public void registerUiccApplicationEnablementChanged(Handler h, int what, Object obj) {
        mUiccApplicationsEnablementRegistrants.addUnique(h, what, obj);
    }

    /**
     * Unregisters the handler for RIL_UNSOL_UICC_APPLICATIONS_ENABLEMENT_CHANGED events.
     *
     * @param h Handler for notification message.
     */
    @Override
    public void unregisterUiccApplicationEnablementChanged(Handler h) {
        mUiccApplicationsEnablementRegistrants.remove(h);
    }
}
+38 −0
Original line number Diff line number Diff line
@@ -655,6 +655,22 @@ public interface CommandsInterface {
     @UnsupportedAppUsage
     void unregisterForRilConnected(Handler h);

    /**
     * Registers the handler for RIL_UNSOL_SIM_DETACH_FROM_NETWORK_CONFIG_CHANGED events.
     *
     * @param h Handler for notification message.
     * @param what User-defined message code.
     * @param obj User object.
     */
    default void registerUiccApplicationEnablementChanged(Handler h, int what, Object obj) {};

    /**
     * Unregisters the handler for RIL_UNSOL_SIM_DETACH_FROM_NETWORK_CONFIG_CHANGED events.
     *
     * @param h Handler for notification message.
     */
    default void unregisterUiccApplicationEnablementChanged(Handler h) {};

    /**
     * Supply the ICC PIN to the ICC card
     *
@@ -2393,6 +2409,28 @@ public interface CommandsInterface {
     */
    default void getModemStatus(Message result) {};

    /**
     * Enable or disable uicc applications on the SIM.
     *
     * @param enable enable or disable UiccApplications on the SIM.
     * @param onCompleteMessage a Message to return to the requester
     */
    default void enableUiccApplications(boolean enable, Message onCompleteMessage) {}

    /**
     * Whether uicc applications are enabled or not.
     *
     * @param onCompleteMessage a Message to return to the requester
     */
    default void areUiccApplicationsEnabled(Message onCompleteMessage) {}

    /**
     * Whether {@link #enableUiccApplications} is supported, based on IRadio version.
     */
    default boolean canToggleUiccApplicationsEnablement() {
        return false;
    }

    default List<ClientRequestStats> getClientRequestStats() {
        return null;
    }
+44 −0
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@ import com.android.internal.telephony.gsm.GsmMmiCode;
import com.android.internal.telephony.gsm.SuppServiceNotification;
import com.android.internal.telephony.test.SimulatedRadioControl;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
import com.android.internal.telephony.uicc.IccCardStatus;
import com.android.internal.telephony.uicc.IccException;
import com.android.internal.telephony.uicc.IccRecords;
import com.android.internal.telephony.uicc.IccVmNotSupportedException;
@@ -152,6 +153,7 @@ public class GsmCdmaPhone extends Phone {
    private String mMeid;
    // string to define how the carrier specifies its own ota sp number
    private String mCarrierOtaSpNumSchema;
    private boolean mUiccApplicationsEnabled = true;

    // A runnable which is used to automatically exit from Ecm after a period of time.
    private Runnable mExitEcmRunnable = new Runnable() {
@@ -324,6 +326,8 @@ public class GsmCdmaPhone extends Phone {
        mCi.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
        mCi.registerForOn(this, EVENT_RADIO_ON, null);
        mCi.registerForRadioStateChanged(this, EVENT_RADIO_STATE_CHANGED, null);
        mCi.registerUiccApplicationEnablementChanged(this, EVENT_UICC_APPS_ENABLEMENT_CHANGED,
                null);
        mCi.setOnSuppServiceNotification(this, EVENT_SSN, null);

        //GSM
@@ -2404,6 +2408,8 @@ public class GsmCdmaPhone extends Phone {

        mCi.getDeviceIdentity(obtainMessage(EVENT_GET_DEVICE_IDENTITY_DONE));
        mCi.getRadioCapability(obtainMessage(EVENT_GET_RADIO_CAPABILITY));
        mCi.areUiccApplicationsEnabled(obtainMessage(EVENT_GET_UICC_APPS_ENABLEMENT_DONE));

        startLceAfterRadioIsAvailable();
    }

@@ -2843,6 +2849,18 @@ public class GsmCdmaPhone extends Phone {
                    onComplete.sendToTarget();
                }
                break;
            case EVENT_GET_UICC_APPS_ENABLEMENT_DONE:
            case EVENT_UICC_APPS_ENABLEMENT_CHANGED: {
                ar = (AsyncResult) msg.obj;
                if (ar == null) return;
                if (ar.exception != null) {
                    logd("Received exception on event" + msg.what + " : " + ar.exception);
                    return;
                }

                mUiccApplicationsEnabled = (boolean) ar.result;
                break;
            }
            default:
                super.handleMessage(msg);
        }
@@ -4036,4 +4054,30 @@ public class GsmCdmaPhone extends Phone {
                Settings.Secure.PREFERRED_TTY_MODE, TelecomManager.TTY_MODE_OFF);
        updateUiTtyMode(ttyMode);
    }

    // Enable or disable uicc applications.
    @Override
    public void enableUiccApplications(boolean enable, Message onCompleteMessage) {
        // First check if card is present. Otherwise mUiccApplicationsDisabled doesn't make
        // any sense.
        UiccSlot slot = mUiccController.getUiccSlotForPhone(mPhoneId);
        if (slot == null || slot.getCardState() != IccCardStatus.CardState.CARDSTATE_PRESENT) {
            if (onCompleteMessage != null) {
                AsyncResult.forMessage(onCompleteMessage, null,
                        new IllegalStateException("No SIM card is present"));
                onCompleteMessage.sendToTarget();
            }
            return;
        }

        mCi.enableUiccApplications(enable, onCompleteMessage);
    }

    /**
     * Whether disabling a physical subscription is supported or not.
     */
    @Override
    public boolean canDisablePhysicalSubscription() {
        return mCi.canToggleUiccApplicationsEnablement();
    }
}
+17 −1
Original line number Diff line number Diff line
@@ -196,6 +196,8 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    protected static final int EVENT_GET_AVAILABLE_NETWORKS_DONE    = 51;

    private static final int EVENT_ALL_DATA_DISCONNECTED            = 52;
    protected static final int EVENT_UICC_APPS_ENABLEMENT_CHANGED   = 53;
    protected static final int EVENT_GET_UICC_APPS_ENABLEMENT_DONE  = 54;

    protected static final int EVENT_LAST = EVENT_ALL_DATA_DISCONNECTED;

@@ -4075,6 +4077,20 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        return false;
    }

    /**
     * Enable or disable uicc applications.
     * @param enable whether to enable or disable uicc applications.
     * @param onCompleteMessage callback for async operation. Ignored if blockingCall is true.
     */
    public void enableUiccApplications(boolean enable, Message onCompleteMessage) {}

    /**
     * Whether disabling a physical subscription is supported or not.
     */
    public boolean canDisablePhysicalSubscription() {
        return false;
    }

    /**
     * Get the HAL version.
     *
+98 −0
Original line number Diff line number Diff line
@@ -4842,6 +4842,98 @@ public class RIL extends BaseCommands implements CommandsInterface {
        throw new RuntimeException("getLastDataCallFailCause not expected to be called");
    }

    /**
     * Enable or disable uicc applications on the SIM.
     *
     * @param enable whether to enable or disable uicc applications.
     * @param onCompleteMessage a Message to return to the requester
     */
    @Override
    public void enableUiccApplications(boolean enable, Message onCompleteMessage) {
        IRadio radioProxy = getRadioProxy(onCompleteMessage);
        if (radioProxy == null) {
            Rlog.e(RIL.RILJ_LOG_TAG, "Radio Proxy object is null!");
            if (onCompleteMessage != null) {
                AsyncResult.forMessage(onCompleteMessage, null,
                        CommandException.fromRilErrno(RADIO_NOT_AVAILABLE));
                onCompleteMessage.sendToTarget();
            }
        }

        if (mRadioVersion.less(RADIO_HAL_VERSION_1_5)) {
            if (onCompleteMessage != null) {
                AsyncResult.forMessage(onCompleteMessage, null,
                        CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED));
                onCompleteMessage.sendToTarget();
            }
            return;
        }

        android.hardware.radio.V1_5.IRadio radioProxy15 =
                (android.hardware.radio.V1_5.IRadio) radioProxy;

        RILRequest rr = obtainRequest(RIL_REQUEST_ENABLE_UICC_APPLICATIONS,
                onCompleteMessage, mRILDefaultWorkSource);

        if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));

        try {
            radioProxy15.enableUiccApplications(rr.mSerial, enable);
        } catch (RemoteException | RuntimeException e) {
            handleRadioProxyExceptionForRR(rr, "enableUiccApplications", e);
        }
    }

    /**
     * Whether uicc applications are enabled or not.
     *
     * @param onCompleteMessage a Message to return to the requester
     */
    @Override
    public void areUiccApplicationsEnabled(Message onCompleteMessage) {
        IRadio radioProxy = getRadioProxy(onCompleteMessage);
        if (radioProxy == null) {
            Rlog.e(RIL.RILJ_LOG_TAG, "Radio Proxy object is null!");
            if (onCompleteMessage != null) {
                AsyncResult.forMessage(onCompleteMessage, null,
                        CommandException.fromRilErrno(RADIO_NOT_AVAILABLE));
                onCompleteMessage.sendToTarget();
            }
        }

        if (mRadioVersion.less(RADIO_HAL_VERSION_1_5)) {
            if (onCompleteMessage != null) {
                AsyncResult.forMessage(onCompleteMessage, null,
                        CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED));
                onCompleteMessage.sendToTarget();
            }
            return;
        }

        android.hardware.radio.V1_5.IRadio radioProxy15 =
                (android.hardware.radio.V1_5.IRadio) radioProxy;

        RILRequest rr = obtainRequest(RIL_REQUEST_GET_UICC_APPLICATIONS_ENABLEMENT,
                onCompleteMessage, mRILDefaultWorkSource);

        if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));

        try {
            radioProxy15.areUiccApplicationsEnabled(rr.mSerial);
        } catch (RemoteException | RuntimeException e) {
            handleRadioProxyExceptionForRR(rr, "areUiccApplicationsEnabled", e);
        }
    }

    /**
     * Whether {@link #enableUiccApplications} is supported, which is supported in 1.5 version.
     */
    @Override
    public boolean canToggleUiccApplicationsEnablement() {
        return getRadioProxy(null) != null && mRadioVersion
                .greaterOrEqual(RADIO_HAL_VERSION_1_5);
    }

    /**
     *  Translates EF_SMS status bits to a status value compatible with
     *  SMS AT commands.  See TS 27.005 3.1.
@@ -5764,6 +5856,10 @@ public class RIL extends BaseCommands implements CommandsInterface {
                return "RIL_REQUEST_ENABLE_MODEM";
            case RIL_REQUEST_GET_MODEM_STATUS:
                return "RIL_REQUEST_GET_MODEM_STATUS";
            case RIL_REQUEST_ENABLE_UICC_APPLICATIONS:
                return "RIL_REQUEST_ENABLE_UICC_APPLICATIONS";
            case RIL_REQUEST_GET_UICC_APPLICATIONS_ENABLEMENT:
                return "RIL_REQUEST_GET_UICC_APPLICATIONS_ENABLEMENT";
            default: return "<unknown request>";
        }
    }
@@ -5877,6 +5973,8 @@ public class RIL extends BaseCommands implements CommandsInterface {
                return "RIL_UNSOL_PHYSICAL_CHANNEL_CONFIG";
            case RIL_UNSOL_EMERGENCY_NUMBER_LIST:
                return "RIL_UNSOL_EMERGENCY_NUMBER_LIST";
            case RIL_UNSOL_UICC_APPLICATIONS_ENABLEMENT_CHANGED:
                return "RIL_UNSOL_UICC_APPLICATIONS_ENABLEMENT_CHANGED";
            default:
                return "<unknown response>";
        }
Loading