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

Commit c20af516 authored by Bruno Martins's avatar Bruno Martins
Browse files

telephony: Squashed support for simactivation feature

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

   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 24372cc4
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -939,8 +939,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
@@ -2107,21 +2107,16 @@ 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.
    @UnsupportedAppUsage
    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.
+14 −7
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.WorkSource;
import android.provider.Settings;
import android.service.carrier.CarrierIdentifier;
@@ -236,6 +237,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
    AtomicBoolean mTestingEmergencyCall = new AtomicBoolean(false);

    final Integer mPhoneId;
    private List<String> mOldRilFeatures;

    /**
     * A set that records if radio service is disabled in hal for
@@ -655,6 +657,9 @@ public class RIL extends BaseCommands implements CommandsInterface {
            mRadioBugDetector = new RadioBugDetector(context, mPhoneId);
        }

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

        TelephonyManager tm = (TelephonyManager) context.getSystemService(
                Context.TELEPHONY_SERVICE);
        mIsCellularSupported = tm.isVoiceCapable() || tm.isSmsCapable() || tm.isDataCapable();
@@ -4328,8 +4333,7 @@ public 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,
@@ -4337,15 +4341,14 @@ public 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);
@@ -6946,4 +6949,8 @@ public class RIL extends BaseCommands implements CommandsInterface {
    public HalVersion getHalVersion() {
        return mRadioVersion;
    }

    public boolean needsOldRilFeature(String feature) {
        return mOldRilFeatures.contains(feature);
    }
}
+51 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import com.android.internal.telephony.MccTable;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.RIL;
import com.android.internal.telephony.SubscriptionController;
import com.android.internal.telephony.cat.CatService;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
@@ -106,6 +107,7 @@ public class UiccProfile extends IccCard {
    private final UiccCard mUiccCard; //parent
    private CatService mCatService;
    private UiccCarrierPrivilegeRules mCarrierPrivilegeRules;
    private boolean mDefaultAppsActivated;
    private boolean mDisposed = false;

    private RegistrantList mCarrierPrivilegeRegistrants = new RegistrantList();
@@ -1041,10 +1043,59 @@ public class UiccProfile extends IccCard {
            }

            sanitizeApplicationIndexesLocked();

            if (needsSimActivation()) {
                if (ics.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;
                }
            }

            updateIccAvailability(true);
        }
    }

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

    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);
        }
    }

    private void createAndUpdateCatServiceLocked() {
        if (mUiccApplications.length > 0 && mUiccApplications[0] != null) {
            // Initialize or Reinitialize CatService
+1 −2
Original line number Diff line number Diff line
@@ -1314,8 +1314,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) {

    }