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

Commit 23e097d0 authored by Bruno Martins's avatar Bruno Martins Committed by Rashed Abdel-Tawab
Browse files

telephony: Squashed support for simactivation feature

 * This is a squash of the "OldRilFeatures" implementation plus
   the following changes, forward-ported to the new code.

   Author: Danny Baumann <dannybaumann@web.de>
   Date:   Mon Dec 7 16:37:45 2015 +0100

       Also activate default UICC apps once after SIM presence.

       Some devices apparently need this, and it shouldn't hurt on other
       devices either.

       Change-Id: I7feb27cceeffc30081e682a6f6b0e2bdb6ad5087

   Author: Danny Baumann <dannybaumann@web.de>
   Date:   Thu Nov 5 11:06:09 2015 +0100

       Activate default UICC application if not done automatically.

       Provides compatibility to the pre-M behaviour.

       Change-Id: Ie87e40cf1da3b19fd37e2c07ff50845f0842216a

Change-Id: I785a91dadd79713f57641a3c20a94a0220a723e9
parent 878d86fe
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -855,8 +855,7 @@ public abstract class BaseCommands implements CommandsInterface {
        return mRilVersion;
    }

    public void setUiccSubscription(int slotId, int appIndex, int subId, int subStatus,
            Message response) {
    public void setUiccSubscription(int appIndex, boolean activate, Message response) {
    }

    public void setDataAllowed(boolean allowed, Message response) {
+3 −8
Original line number Diff line number Diff line
@@ -1926,20 +1926,15 @@ public interface CommandsInterface {
   /**
     * Sets user selected subscription at Modem.
     *
     * @param slotId
     *          Slot.
     * @param appIndex
     *          Application index in the card.
     * @param subId
     *          Indicates subscription 0 or subscription 1.
     * @param subStatus
     *          Activation status, 1 = activate and 0 = deactivate.
     * @param activate
     *          Whether to activate or deactivate the subscription.
     * @param result
     *          Callback message contains the information of SUCCESS/FAILURE.
     */
    // FIXME Update the doc and consider modifying the request to make more generic.
    public void setUiccSubscription(int slotId, int appIndex, int subId, int subStatus,
            Message result);
    public void setUiccSubscription(int appIndex, boolean activate, Message result);

    /**
     * Tells the modem if data is allowed or not.
+13 −7
Original line number Diff line number Diff line
@@ -320,6 +320,7 @@ public final class RIL extends BaseCommands implements CommandsInterface {
    AtomicBoolean mTestingEmergencyCall = new AtomicBoolean(false);

    final Integer mPhoneId;
    private List<String> mOldRilFeatures;

    /* default work source which will blame phone process */
    private WorkSource mRILDefaultWorkSource;
@@ -611,6 +612,9 @@ public final class RIL extends BaseCommands implements CommandsInterface {
        mPhoneType = RILConstants.NO_PHONE;
        mPhoneId = instanceId;

        final String oldRilFeatures = SystemProperties.get("ro.telephony.ril.config", "");
        mOldRilFeatures = Arrays.asList(oldRilFeatures.split(","));

        ConnectivityManager cm = (ConnectivityManager)context.getSystemService(
                Context.CONNECTIVITY_SERVICE);
        mIsMobileNetworkSupported = cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE);
@@ -3351,8 +3355,7 @@ public final class RIL extends BaseCommands implements CommandsInterface {
    }

    @Override
    public void setUiccSubscription(int slotId, int appIndex, int subId,
                                    int subStatus, Message result) {
    public void setUiccSubscription(int appIndex, boolean activate, Message result) {
        IRadio radioProxy = getRadioProxy(result);
        if (radioProxy != null) {
            RILRequest rr = obtainRequest(RIL_REQUEST_SET_UICC_SUBSCRIPTION, result,
@@ -3360,15 +3363,14 @@ public final class RIL extends BaseCommands implements CommandsInterface {

            if (RILJ_LOGD) {
                riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
                        + " slot = " + slotId + " appIndex = " + appIndex
                        + " subId = " + subId + " subStatus = " + subStatus);
                        + " appIndex: " + appIndex + " activate: " + activate);
            }

            SelectUiccSub info = new SelectUiccSub();
            info.slot = slotId;
            info.slot = mPhoneId;
            info.appIndex = appIndex;
            info.subType = subId;
            info.actStatus = subStatus;
            info.subType = mPhoneId;
            info.actStatus = activate ? 1 : 0;

            try {
                radioProxy.setUiccSubscription(rr.mSerial, info);
@@ -5109,4 +5111,8 @@ public final class RIL extends BaseCommands implements CommandsInterface {
                signalStrength.tdScdma.rscp,
                false /* gsmFlag - don't care; will be changed by SST */);
    }

    public boolean needsOldRilFeature(String feature) {
        return mOldRilFeatures.contains(feature);
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -1284,8 +1284,7 @@ public class SimulatedCommandsVerifier implements CommandsInterface {
    }

    @Override
    public void setUiccSubscription(int slotId, int appIndex, int subId, int subStatus,
                                    Message result) {
    public void setUiccSubscription(int appIndex, boolean activate, Message result) {

    }

+50 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import android.view.WindowManager;
import com.android.internal.R;
import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.CommandsInterface.RadioState;
import com.android.internal.telephony.RIL;
import com.android.internal.telephony.cat.CatService;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
import com.android.internal.telephony.uicc.IccCardStatus.CardState;
@@ -83,6 +84,7 @@ public class UiccCard {
    private CatService mCatService;
    private RadioState mLastRadioState =  RadioState.RADIO_UNAVAILABLE;
    private UiccCarrierPrivilegeRules mCarrierPrivilegeRules;
    private boolean mDefaultAppsActivated;

    private RegistrantList mAbsentRegistrants = new RegistrantList();
    private RegistrantList mCarrierPrivilegeRegistrants = new RegistrantList();
@@ -182,10 +184,30 @@ public class UiccCard {
                    mHandler.sendMessage(mHandler.obtainMessage(EVENT_CARD_ADDED, null));
                }
            }
            if (needsSimActivation()) {
                if (mCardState == CardState.CARDSTATE_PRESENT) {
                    if (!mDefaultAppsActivated) {
                        activateDefaultApps();
                        mDefaultAppsActivated = true;
                    }
                } else {
                    // SIM removed, reset activation flag to make sure
                    // to re-run the activation at the next insertion
                    mDefaultAppsActivated = false;
                }
            }

            mLastRadioState = radioState;
        }
    }

    private boolean needsSimActivation() {
        if (mCi instanceof RIL) {
            return ((RIL) mCi).needsOldRilFeature("simactivation");
        }
        return false;
    }

    private void createAndUpdateCatServiceLocked() {
        if (mUiccApplications.length > 0 && mUiccApplications[0] != null) {
            // Initialize or Reinitialize CatService
@@ -245,6 +267,34 @@ public class UiccCard {
        return index;
    }

    private void activateDefaultApps() {
        int gsmIndex = mGsmUmtsSubscriptionAppIndex;
        int cdmaIndex = mCdmaSubscriptionAppIndex;

        if (gsmIndex < 0 || cdmaIndex < 0) {
            for (int i = 0; i < mUiccApplications.length; i++) {
                if (mUiccApplications[i] == null) {
                    continue;
                }

                AppType appType = mUiccApplications[i].getType();
                if (gsmIndex < 0 &&
                        (appType == AppType.APPTYPE_USIM || appType == AppType.APPTYPE_SIM)) {
                    gsmIndex = i;
                } else if (cdmaIndex < 0 &&
                        (appType == AppType.APPTYPE_CSIM || appType == AppType.APPTYPE_RUIM)) {
                    cdmaIndex = i;
                }
            }
        }
        if (gsmIndex >= 0) {
            mCi.setUiccSubscription(gsmIndex, true, null);
        }
        if (cdmaIndex >= 0) {
            mCi.setUiccSubscription(cdmaIndex, true, null);
        }
    }

    /**
     * Notifies handler of any transition into State.ABSENT
     */