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

Commit be3dc4b0 authored by Wink Saville's avatar Wink Saville
Browse files

Fix 7255789

Two problems were identified, first in IccCardProxy needs to assume a
the current app type is 3GPP because some rils are not managing the
sim status properly and return the csim as PINSTATE_UNKNOWN if the device
is gets PUK locked because the PIN was entered incorrectly 3 times. This
is fixed with the changes IccCardProxy.java and Phone.java.

The second problem is that some rils are not sending a
RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED when the PIN or PUK are changed.
This causes some devices to NOT automatically go to the lock screen
when a PUK is required. This is fixed by the change to RIL.java.

Bug: 7255789
Change-Id: I969585edf416e6b11f52470ee69d19f781bf29ca
parent d070d1c9
Loading
Loading
Loading
Loading
+22 −18
Original line number Diff line number Diff line
@@ -38,8 +38,8 @@ import com.android.internal.telephony.IccCardStatus.CardState;
import com.android.internal.telephony.IccCardStatus.PinState;
import com.android.internal.telephony.cdma.CdmaSubscriptionSourceManager;
import com.android.internal.telephony.uicc.UiccController;
import com.android.internal.telephony.Phone;

import static com.android.internal.telephony.Phone.CDMA_SUBSCRIPTION_NV;
import static com.android.internal.telephony.TelephonyProperties.PROPERTY_SIM_STATE;

/**
@@ -90,9 +90,6 @@ public class IccCardProxy extends Handler implements IccCard {
    private IccRecords mIccRecords = null;
    private CdmaSubscriptionSourceManager mCdmaSSM = null;
    private boolean mRadioOn = false;
    private boolean mCdmaSubscriptionFromNv = false;
    private boolean mIsMultimodeCdmaPhone =
            SystemProperties.getBoolean("ro.config.multimode_cdma", false);
    private boolean mQuietMode = false; // when set to true IccCardProxy will not broadcast
                                        // ACTION_SIM_STATE_CHANGED intents
    private boolean mInitialized = false;
@@ -143,27 +140,29 @@ public class IccCardProxy extends Handler implements IccCard {

    /**
     * In case of 3gpp2 we need to find out if subscription used is coming from
     * NV in which case we shouldn't broadcast any sim states changes if at the
     * same time ro.config.multimode_cdma property set to false.
     * NV in which case we shouldn't broadcast any sim states changes.
     */
    private void updateQuietMode() {
        synchronized (mLock) {
            if (DBG) log("Updating quiet mode");
            boolean oldQuietMode = mQuietMode;
            boolean newQuietMode;
            int cdmaSource = Phone.CDMA_SUBSCRIPTION_UNKNOWN;
            boolean isLteOnCdmaMode = TelephonyManager.getLteOnCdmaModeStatic()
                    == PhoneConstants.LTE_ON_CDMA_TRUE;
            if (mCurrentAppType == UiccController.APP_FAM_3GPP) {
                newQuietMode = false;
                if (DBG) log("3GPP subscription -> QuietMode: " + newQuietMode);
                if (DBG) log("updateQuietMode: 3GPP subscription -> newQuietMode=" + newQuietMode);
            } else {
                int newSubscriptionSource = mCdmaSSM.getCdmaSubscriptionSource();
                mCdmaSubscriptionFromNv = newSubscriptionSource == CDMA_SUBSCRIPTION_NV;
                if (mCdmaSubscriptionFromNv && mIsMultimodeCdmaPhone) {
                    log("Cdma multimode phone detected. Forcing IccCardProxy into 3gpp mode");
                if (isLteOnCdmaMode) {
                    log("updateQuietMode: is cdma/lte device, force IccCardProxy into 3gpp mode");
                    mCurrentAppType = UiccController.APP_FAM_3GPP;
                }
                newQuietMode = mCdmaSubscriptionFromNv
                cdmaSource = mCdmaSSM != null ?
                        mCdmaSSM.getCdmaSubscriptionSource() : Phone.CDMA_SUBSCRIPTION_UNKNOWN;

                newQuietMode = (cdmaSource == Phone.CDMA_SUBSCRIPTION_NV)
                        && (mCurrentAppType == UiccController.APP_FAM_3GPP2)
                        && !mIsMultimodeCdmaPhone;
                        && !isLteOnCdmaMode;
            }

            if (mQuietMode == false && newQuietMode == true) {
@@ -173,13 +172,18 @@ public class IccCardProxy extends Handler implements IccCard {
                setExternalState(State.READY);
                mQuietMode = newQuietMode;
            } else if (mQuietMode == true && newQuietMode == false) {
                if (DBG) log("Switching out from QuietMode. Force broadcast of current state:"
                        + mExternalState);
                if (DBG) {
                    log("updateQuietMode: Switching out from QuietMode."
                            + " Force broadcast of current state=" + mExternalState);
                }
                mQuietMode = newQuietMode;
                setExternalState(mExternalState, true);
            }
            if (DBG) log("QuietMode is " + mQuietMode + " (app_type: " + mCurrentAppType + " nv: "
                    + mCdmaSubscriptionFromNv + " multimode: " + mIsMultimodeCdmaPhone + ")");
            if (DBG) {
                log("updateQuietMode: QuietMode is " + mQuietMode + " (app_type="
                    + mCurrentAppType + " isLteOnCdmaMode=" + isLteOnCdmaMode
                    + " cdmaSource=" + cdmaSource + ")");
            }
            mInitialized = true;
            sendMessage(obtainMessage(EVENT_ICC_CHANGED));
        }
+1 −0
Original line number Diff line number Diff line
@@ -136,6 +136,7 @@ public interface Phone {
    static final int CDMA_RM_ANY         = 2;  // Roaming on Any Network, as defined in PRL

    // Used for CDMA subscription mode
    static final int CDMA_SUBSCRIPTION_UNKNOWN  =-1; // Unknown
    static final int CDMA_SUBSCRIPTION_RUIM_SIM = 0; // RUIM/SIM (default)
    static final int CDMA_SUBSCRIPTION_NV       = 1; // NV -> non-volatile memory

+19 −0
Original line number Diff line number Diff line
@@ -2347,6 +2347,25 @@ public final class RIL extends BaseCommands implements CommandsInterface {
            }
        }

        // Some devices do not send RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED so fake it.
        // See b/7255789
        switch (rr.mRequest) {
            case RIL_REQUEST_ENTER_SIM_PIN:
            case RIL_REQUEST_ENTER_SIM_PUK:
            case RIL_REQUEST_ENTER_SIM_PIN2:
            case RIL_REQUEST_ENTER_SIM_PUK2:
            case RIL_REQUEST_CHANGE_SIM_PIN:
            case RIL_REQUEST_CHANGE_SIM_PIN2:
                if (RILJ_LOGD) {
                    riljLog("fakeSimStatusChanged: reg count="
                            + mIccStatusChangedRegistrants.size());
                }
                if (mIccStatusChangedRegistrants != null) {
                    mIccStatusChangedRegistrants.notifyRegistrants();
                }
                break;
        }

        if (error != 0) {
            rr.onError(error, ret);
            rr.release();