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

Commit 62447c97 authored by Jack Yu's avatar Jack Yu Committed by Gerrit Code Review
Browse files

Merge changes from topics "subscriptionInfo_builder", "subscription_manager_service"

* changes:
  Added builder for SubscriptionInfo
  Added empty subscription manager service
  Add optional phoneId for SST TelephonyTester override
parents 084afdff 8ae5c275
Loading
Loading
Loading
Loading
+22 −4
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.internal.telephony.imsphone.ImsPhoneCall;
import com.android.internal.telephony.metrics.SmsStats;
import com.android.internal.telephony.metrics.VoiceCallSessionStats;
import com.android.internal.telephony.subscription.SubscriptionManagerService;
import com.android.internal.telephony.test.SimulatedRadioControl;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
import com.android.internal.telephony.uicc.IccFileHandler;
@@ -354,6 +355,12 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    private int mUsageSettingFromModem = SubscriptionManager.USAGE_SETTING_UNKNOWN;
    private boolean mIsUsageSettingSupported = true;

    /**
     * {@code true} if the new SubscriptionManagerService is enabled, otherwise the old
     * SubscriptionController is used.
     */
    private boolean mIsSubscriptionManagerServiceEnabled = false;

    //IMS
    /**
     * {@link CallStateException} message text used to indicate that an IMS call has failed because
@@ -557,10 +564,6 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
                .makeAppSmsManager(context);
        mLocalLog = new LocalLog(64);

        if (TelephonyUtils.IS_DEBUGGABLE) {
            mTelephonyTester = new TelephonyTester(this);
        }

        setUnitTestMode(unitTestMode);

        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
@@ -600,6 +603,13 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
            return;
        }

        if (TelephonyUtils.IS_DEBUGGABLE) {
            mTelephonyTester = new TelephonyTester(this);
        }

        mIsSubscriptionManagerServiceEnabled = mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_using_subscription_manager_service);

        // Initialize device storage and outgoing SMS usage monitors for SMSDispatchers.
        mTelephonyComponentFactory = telephonyComponentFactory;
        mSmsStorageMonitor = mTelephonyComponentFactory.inject(SmsStorageMonitor.class.getName())
@@ -4844,6 +4854,14 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        return mIsAllowedNetworkTypesLoadedFromDb;
    }

    /**
     * @return {@code true} if the new {@link SubscriptionManagerService} is enabled, otherwise the
     * old {@link SubscriptionController} is used.
     */
    public boolean isSubscriptionManagerServiceEnabled() {
        return mIsSubscriptionManagerServiceEnabled;
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("Phone: subId=" + getSubId());
        pw.println(" mPhoneId=" + mPhoneId);
+11 −3
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.internal.telephony.imsphone.ImsPhoneFactory;
import com.android.internal.telephony.metrics.MetricsCollector;
import com.android.internal.telephony.metrics.TelephonyMetrics;
import com.android.internal.telephony.subscription.SubscriptionManagerService;
import com.android.internal.telephony.uicc.UiccController;
import com.android.internal.telephony.util.NotificationChannelController;
import com.android.internal.util.IndentingPrintWriter;
@@ -83,6 +84,7 @@ public class PhoneFactory {
    private static IntentBroadcaster sIntentBroadcaster;
    private static @Nullable EuiccController sEuiccController;
    private static @Nullable EuiccCardController sEuiccCardController;
    private static SubscriptionManagerService sSubscriptionManagerService;

    static private SubscriptionInfoUpdater sSubInfoRecordUpdater = null;

@@ -194,9 +196,15 @@ public class PhoneFactory {
                // call getInstance()
                sUiccController = UiccController.make(context);

                if (sContext.getResources().getBoolean(
                        com.android.internal.R.bool.config_using_subscription_manager_service)) {
                    Rlog.i(LOG_TAG, "Creating SubscriptionManagerService");
                    sSubscriptionManagerService = new SubscriptionManagerService(context);
                } else {
                    Rlog.i(LOG_TAG, "Creating SubscriptionController");
                TelephonyComponentFactory.getInstance().inject(SubscriptionController.class.
                        getName()).initSubscriptionController(context);
                    TelephonyComponentFactory.getInstance().inject(SubscriptionController.class
                            .getName()).initSubscriptionController(context);
                }
                TelephonyComponentFactory.getInstance().inject(MultiSimSettingController.class.
                        getName()).initMultiSimSettingController(context,
                        SubscriptionController.getInstance());
+87 −94
Original line number Diff line number Diff line
@@ -536,33 +536,34 @@ public class SubscriptionController extends ISub.Stub {

    /**
     * New SubInfoRecord instance and fill in detail info
     * @param cursor
     * @param cursor The database cursor
     * @return the query result of desired SubInfoRecord
     */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    private SubscriptionInfo getSubInfoRecord(Cursor cursor) {
        SubscriptionInfo.Builder builder = new SubscriptionInfo.Builder();
        int id = cursor.getInt(cursor.getColumnIndexOrThrow(
                SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID));
        String iccId = cursor.getString(cursor.getColumnIndexOrThrow(
                SubscriptionManager.ICC_ID));
        int simSlotIndex = cursor.getInt(cursor.getColumnIndexOrThrow(
                SubscriptionManager.SIM_SLOT_INDEX));
        String displayName = cursor.getString(cursor.getColumnIndexOrThrow(
                SubscriptionManager.DISPLAY_NAME));
        String carrierName = cursor.getString(cursor.getColumnIndexOrThrow(
                SubscriptionManager.CARRIER_NAME));
        int nameSource = cursor.getInt(cursor.getColumnIndexOrThrow(
                SubscriptionManager.NAME_SOURCE));
        int iconTint = cursor.getInt(cursor.getColumnIndexOrThrow(
                SubscriptionManager.HUE));
        String number = cursor.getString(cursor.getColumnIndexOrThrow(
                SubscriptionManager.NUMBER));
        int dataRoaming = cursor.getInt(cursor.getColumnIndexOrThrow(
                SubscriptionManager.DATA_ROAMING));
        String mcc = cursor.getString(cursor.getColumnIndexOrThrow(
                SubscriptionManager.MCC_STRING));
        String mnc = cursor.getString(cursor.getColumnIndexOrThrow(
                SubscriptionManager.MNC_STRING));
        builder.setId(id)
                .setIccId(cursor.getString(cursor.getColumnIndexOrThrow(
                        SubscriptionManager.ICC_ID)))
                .setSimSlotIndex(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SubscriptionManager.SIM_SLOT_INDEX)))
                .setDisplayName(cursor.getString(cursor.getColumnIndexOrThrow(
                        SubscriptionManager.DISPLAY_NAME)))
                .setCarrierName(cursor.getString(cursor.getColumnIndexOrThrow(
                        SubscriptionManager.CARRIER_NAME)))
                .setNameSource(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SubscriptionManager.NAME_SOURCE)))
                .setIconTint(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SubscriptionManager.HUE)))
                .setDataRoaming(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SubscriptionManager.DATA_ROAMING)))
                .setMcc(cursor.getString(cursor.getColumnIndexOrThrow(
                        SubscriptionManager.MCC_STRING)))
                .setMnc(cursor.getString(cursor.getColumnIndexOrThrow(
                        SubscriptionManager.MNC_STRING)));

        String ehplmnsRaw = cursor.getString(cursor.getColumnIndexOrThrow(
                SubscriptionManager.EHPLMNS));
        String hplmnsRaw = cursor.getString(cursor.getColumnIndexOrThrow(
@@ -570,77 +571,63 @@ public class SubscriptionController extends ISub.Stub {
        String[] ehplmns = ehplmnsRaw == null ? null : ehplmnsRaw.split(",");
        String[] hplmns = hplmnsRaw == null ? null : hplmnsRaw.split(",");

        // cardId is the private ICCID/EID string, also known as the card string
        String cardId = cursor.getString(cursor.getColumnIndexOrThrow(
        builder.setEhplmns(ehplmns).setHplmns(hplmns);


        // CARD_ID is the private ICCID/EID string, also known as the card string
        String cardString = cursor.getString(cursor.getColumnIndexOrThrow(
                SubscriptionManager.CARD_ID));
        String countryIso = cursor.getString(cursor.getColumnIndexOrThrow(
                SubscriptionManager.ISO_COUNTRY_CODE));
        builder.setCardString(cardString);
        // publicCardId is the publicly exposed int card ID
        int publicCardId = mUiccController.convertToPublicCardId(cardId);
        int publicCardId = mUiccController.convertToPublicCardId(cardString);
        builder.setCardId(publicCardId);

        builder.setCountryIso(cursor.getString(cursor.getColumnIndexOrThrow(
                SubscriptionManager.ISO_COUNTRY_CODE)))
                .setCarrierId(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SubscriptionManager.CARRIER_ID)));

        boolean isEmbedded = cursor.getInt(cursor.getColumnIndexOrThrow(
                SubscriptionManager.IS_EMBEDDED)) == 1;
        int carrierId = cursor.getInt(cursor.getColumnIndexOrThrow(
                SubscriptionManager.CARRIER_ID));
        UiccAccessRule[] accessRules;
        builder.setEmbedded(isEmbedded);
        if (isEmbedded) {
            accessRules = UiccAccessRule.decodeRules(cursor.getBlob(
                    cursor.getColumnIndexOrThrow(SubscriptionManager.ACCESS_RULES)));
        } else {
            accessRules = null;
        }
        UiccAccessRule[] carrierConfigAccessRules = UiccAccessRule.decodeRules(cursor.getBlob(
            cursor.getColumnIndexOrThrow(SubscriptionManager.ACCESS_RULES_FROM_CARRIER_CONFIGS)));
        boolean isOpportunistic = cursor.getInt(cursor.getColumnIndexOrThrow(
                SubscriptionManager.IS_OPPORTUNISTIC)) == 1;
        String groupUUID = cursor.getString(cursor.getColumnIndexOrThrow(
                SubscriptionManager.GROUP_UUID));
        int profileClass = cursor.getInt(cursor.getColumnIndexOrThrow(
                SubscriptionManager.PROFILE_CLASS));
        int portIndex = cursor.getInt(cursor.getColumnIndexOrThrow(
                SubscriptionManager.PORT_INDEX));
        int subType = cursor.getInt(cursor.getColumnIndexOrThrow(
                SubscriptionManager.SUBSCRIPTION_TYPE));
        String groupOwner = getOptionalStringFromCursor(cursor, SubscriptionManager.GROUP_OWNER,
                /*defaultVal*/ null);
        boolean areUiccApplicationsEnabled = cursor.getInt(cursor.getColumnIndexOrThrow(
                SubscriptionManager.UICC_APPLICATIONS_ENABLED)) == 1;

        int usageSetting = cursor.getInt(cursor.getColumnIndexOrThrow(
                SubscriptionManager.USAGE_SETTING));

        if (VDBG) {
            String iccIdToPrint = SubscriptionInfo.givePrintableIccid(iccId);
            String cardIdToPrint = SubscriptionInfo.givePrintableIccid(cardId);
            logd("[getSubInfoRecord] id:" + id + " iccid:" + iccIdToPrint + " simSlotIndex:"
                    + simSlotIndex + " carrierid:" + carrierId + " displayName:" + displayName
                    + " nameSource:" + nameSource + " iconTint:" + iconTint
                    + " dataRoaming:" + dataRoaming + " mcc:" + mcc + " mnc:" + mnc
                    + " countIso:" + countryIso + " isEmbedded:"
                    + isEmbedded + " accessRules:" + Arrays.toString(accessRules)
                    + " carrierConfigAccessRules: " + Arrays.toString(carrierConfigAccessRules)
                    + " cardId:" + cardIdToPrint + " portIndex:" + portIndex
                    + " publicCardId:" + publicCardId
                    + " isOpportunistic:" + isOpportunistic + " groupUUID:" + groupUUID
                    + " profileClass:" + profileClass + " subscriptionType: " + subType
                    + " areUiccApplicationsEnabled: " + areUiccApplicationsEnabled
                    + " usageSetting: " + usageSetting);
        }
            builder.setNativeAccessRules(UiccAccessRule.decodeRules(cursor.getBlob(
                            cursor.getColumnIndexOrThrow(SubscriptionManager.ACCESS_RULES))));
        }

        builder.setCarrierConfigAccessRules(UiccAccessRule.decodeRules(cursor.getBlob(
                cursor.getColumnIndexOrThrow(
                        SubscriptionManager.ACCESS_RULES_FROM_CARRIER_CONFIGS))))
                .setOpportunistic(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SubscriptionManager.IS_OPPORTUNISTIC)) == 1)
                .setGroupUuid(cursor.getString(cursor.getColumnIndexOrThrow(
                        SubscriptionManager.GROUP_UUID)))
                .setProfileClass(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SubscriptionManager.PROFILE_CLASS)))
                .setPortIndex(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SubscriptionManager.PORT_INDEX)))
                .setType(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SubscriptionManager.SUBSCRIPTION_TYPE)))
                .setGroupOwner(getOptionalStringFromCursor(cursor, SubscriptionManager.GROUP_OWNER,
                        /*defaultVal*/ null))
                .setUiccApplicationsEnabled(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SubscriptionManager.UICC_APPLICATIONS_ENABLED)) == 1)
                .setUsageSetting(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SubscriptionManager.USAGE_SETTING)));

        // If line1number has been set to a different number, use it instead.
        String number = cursor.getString(cursor.getColumnIndexOrThrow(
                SubscriptionManager.NUMBER));
        String line1Number = mTelephonyManager.getLine1Number(id);
        if (!TextUtils.isEmpty(line1Number) && !line1Number.equals(number)) {
            number = line1Number;
        }
        builder.setNumber(number);

        // FIXME(b/210771052): constructing a complete SubscriptionInfo requires a port index,
        // but the port index isn't available here. Should it actually be part of SubscriptionInfo?
        SubscriptionInfo info = new SubscriptionInfo(id, iccId, simSlotIndex, displayName,
                carrierName, nameSource, iconTint, number, dataRoaming, /* icon= */ null,
                mcc, mnc, countryIso, isEmbedded, accessRules, cardId, publicCardId,
                isOpportunistic, groupUUID, /* isGroupDisabled= */ false , carrierId, profileClass,
                subType, groupOwner, carrierConfigAccessRules, areUiccApplicationsEnabled,
                portIndex, usageSetting);
        info.setAssociatedPlmns(ehplmns, hplmns);
        return info;

        return builder.build();
    }

    private String getOptionalStringFromCursor(Cursor cursor, String column, String defaultVal) {
@@ -3196,8 +3183,8 @@ public class SubscriptionController extends ISub.Stub {

    /**
     * Get the SIM state for the slot index.
     * For Remote-SIMs, this method returns {@link #IccCardConstants.State.UNKNOWN}
     * @return SIM state as the ordinal of {@See IccCardConstants.State}
     * For Remote-SIMs, this method returns {@link IccCardConstants.State#UNKNOWN}
     * @return SIM state as the ordinal of {@link IccCardConstants.State}
     */
    @Override
    public int getSimStateForSlotIndex(int slotIndex) {
@@ -4191,7 +4178,10 @@ public class SubscriptionController extends ISub.Stub {
        }

        // Can't find the existing SIM.
        if (slotInfo == null) return false;
        if (slotInfo == null) {
            loge("Can't find the existing SIM.");
            return false;
        }

        // this for physical slot which has only one port
        if (enable && !slotInfo.getPorts().stream().findFirst().get().isActive()) {
@@ -4441,16 +4431,16 @@ public class SubscriptionController extends ISub.Stub {
        if (hasIdentifierAccess && hasPhoneNumberAccess) {
            return subInfo;
        }
        SubscriptionInfo result = new SubscriptionInfo(subInfo);
        SubscriptionInfo.Builder result = new SubscriptionInfo.Builder(subInfo);
        if (!hasIdentifierAccess) {
            result.clearIccId();
            result.clearCardString();
            result.clearGroupUuid();
            result.setIccId(null);
            result.setCardString(null);
            result.setGroupUuid(null);
        }
        if (!hasPhoneNumberAccess) {
            result.clearNumber();
            result.setNumber(null);
        }
        return result;
        return result.build();
    }

    private synchronized boolean addToSubIdList(int slotIndex, int subId, int subscriptionType) {
@@ -4525,20 +4515,23 @@ public class SubscriptionController extends ISub.Stub {

            mCacheOpportunisticSubInfoList = subList;

            for (SubscriptionInfo info : mCacheOpportunisticSubInfoList) {
            for (int i = 0; i < mCacheOpportunisticSubInfoList.size(); i++) {
                SubscriptionInfo info = mCacheOpportunisticSubInfoList.get(i);
                if (shouldDisableSubGroup(info.getGroupUuid())) {
                    info.setGroupDisabled(true);
                    SubscriptionInfo.Builder builder = new SubscriptionInfo.Builder(info);
                    builder.setGroupDisabled(true);
                    mCacheOpportunisticSubInfoList.set(i, builder.build());
                }
            }

            if (DBG_CACHE) {
                if (!mCacheOpportunisticSubInfoList.isEmpty()) {
                    for (SubscriptionInfo si : mCacheOpportunisticSubInfoList) {
                        logd("[refreshCachedOpptSubscriptionInfoList] Setting Cached info="
                                + si);
                        logd("[refreshCachedOpportunisticSubscriptionInfoList] Setting Cached "
                                + "info=" + si);
                    }
                } else {
                    logdl("[refreshCachedOpptSubscriptionInfoList]- no info return");
                    logdl("[refreshCachedOpportunisticSubscriptionInfoList]- no info return");
                }
            }

@@ -4720,7 +4713,7 @@ public class SubscriptionController extends ISub.Stub {
     * Sets the phone number for the given {@code subId}.
     *
     * <p>The only accepted {@code source} is {@link
     * SubscriptionManager.PHONE_NUMBER_SOURCE_CARRIER}.
     * SubscriptionManager#PHONE_NUMBER_SOURCE_CARRIER}.
     */
    @Override
    public void setPhoneNumber(int subId, int source, String number,
+11 −4
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@ import java.util.List;
 *
 */
public class TelephonyTester {
    private static final String LOG_TAG = "TelephonyTester";
    private static final boolean DBG = true;

    /**
@@ -144,6 +143,7 @@ public class TelephonyTester {
            "com.android.internal.telephony.TestServiceState";

    private static final String EXTRA_ACTION = "action";
    private static final String EXTRA_PHONE_ID = "phone_id";
    private static final String EXTRA_VOICE_RAT = "voice_rat";
    private static final String EXTRA_DATA_RAT = "data_rat";
    private static final String EXTRA_VOICE_REG_STATE = "voice_reg_state";
@@ -157,6 +157,8 @@ public class TelephonyTester {

    private static final String ACTION_RESET = "reset";

    private String mLogTag;

    private static List<ImsExternalCallState> mImsExternalCallStates = null;

    private Intent mServiceStateTestIntent;
@@ -216,7 +218,7 @@ public class TelephonyTester {
                    if (DBG) log("onReceive: unknown action=" + action);
                }
            } catch (BadParcelableException e) {
                Rlog.w(LOG_TAG, e);
                Rlog.w(mLogTag, e);
            }
        }
    };
@@ -225,6 +227,7 @@ public class TelephonyTester {
        mPhone = phone;

        if (TelephonyUtils.IS_DEBUGGABLE) {
            mLogTag = "TelephonyTester-" + mPhone.getPhoneId();
            IntentFilter filter = new IntentFilter();

            filter.addAction(mPhone.getActionDetached());
@@ -261,8 +264,8 @@ public class TelephonyTester {
        }
    }

    private static void log(String s) {
        Rlog.d(LOG_TAG, s);
    private void log(String s) {
        Rlog.d(mLogTag, s);
    }

    private void handleSuppServiceFailedIntent(Intent intent) {
@@ -387,6 +390,10 @@ public class TelephonyTester {

    void overrideServiceState(ServiceState ss) {
        if (mServiceStateTestIntent == null || ss == null) return;
        if (mPhone.getPhoneId() != mServiceStateTestIntent.getIntExtra(
                EXTRA_PHONE_ID, mPhone.getPhoneId())) {
            return;
        }
        if (mServiceStateTestIntent.hasExtra(EXTRA_ACTION)
                && ACTION_RESET.equals(mServiceStateTestIntent.getStringExtra(EXTRA_ACTION))) {
            log("Service state override reset");
+606 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading