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

Commit 3631da71 authored by Jack Yu's avatar Jack Yu Committed by Android (Google) Code Review
Browse files

Merge "Added SIM events handling and fix crashes"

parents 2074480d 787f7c56
Loading
Loading
Loading
Loading
+7 −2
Original line number Original line Diff line number Diff line
@@ -214,9 +214,14 @@ public class PhoneFactory {
                    TelephonyComponentFactory.getInstance().inject(SubscriptionController.class
                    TelephonyComponentFactory.getInstance().inject(SubscriptionController.class
                            .getName()).initSubscriptionController(context);
                            .getName()).initSubscriptionController(context);
                }
                }

                SubscriptionController sc = null;
                if (!isSubscriptionManagerServiceEnabled()) {
                    sc = SubscriptionController.getInstance();
                }

                TelephonyComponentFactory.getInstance().inject(MultiSimSettingController.class.
                TelephonyComponentFactory.getInstance().inject(MultiSimSettingController.class.
                        getName()).initMultiSimSettingController(context,
                        getName()).initMultiSimSettingController(context, sc);
                        SubscriptionController.getInstance());


                if (context.getPackageManager().hasSystemFeature(
                if (context.getPackageManager().hasSystemFeature(
                        PackageManager.FEATURE_TELEPHONY_EUICC)) {
                        PackageManager.FEATURE_TELEPHONY_EUICC)) {
+2 −2
Original line number Original line Diff line number Diff line
@@ -2751,8 +2751,8 @@ public class ServiceStateTracker extends Handler {


            if (mPhone.isSubscriptionManagerServiceEnabled()) {
            if (mPhone.isSubscriptionManagerServiceEnabled()) {
                mSubscriptionManagerService.setCarrierName(mPhone.getSubId(),
                mSubscriptionManagerService.setCarrierName(mPhone.getSubId(),
                        getCarrierName(data.shouldShowPlmn(), data.getPlmn(),
                        TextUtils.emptyIfNull(getCarrierName(data.shouldShowPlmn(), data.getPlmn(),
                                data.shouldShowSpn(), data.getSpn()));
                                data.shouldShowSpn(), data.getSpn())));
            } else {
            } else {
                if (!mSubscriptionController.setPlmnSpn(mPhone.getPhoneId(),
                if (!mSubscriptionController.setPlmnSpn(mPhone.getPhoneId(),
                        data.shouldShowPlmn(), data.getPlmn(), data.shouldShowSpn(),
                        data.shouldShowPlmn(), data.getPlmn(), data.shouldShowSpn(),
+4 −1
Original line number Original line Diff line number Diff line
@@ -331,6 +331,9 @@ public class SubscriptionController extends ISub.Stub {


    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    public static SubscriptionController getInstance() {
    public static SubscriptionController getInstance() {
        if (PhoneFactory.isSubscriptionManagerServiceEnabled()) {
            throw new RuntimeException("getInstance should not be called.");
        }
        if (sInstance == null) {
        if (sInstance == null) {
            Log.wtf(LOG_TAG, "getInstance null");
            Log.wtf(LOG_TAG, "getInstance null");
        }
        }
+8 −2
Original line number Original line Diff line number Diff line
@@ -531,8 +531,14 @@ public class PhoneSwitcher extends Handler {
        mMaxDataAttachModemCount = maxActivePhones;
        mMaxDataAttachModemCount = maxActivePhones;
        mLocalLog = new LocalLog(MAX_LOCAL_LOG_LINES);
        mLocalLog = new LocalLog(MAX_LOCAL_LOG_LINES);


        mSubscriptionController = SubscriptionController.getInstance();
        if (PhoneFactory.isSubscriptionManagerServiceEnabled()) {
            mSubscriptionManagerService = SubscriptionManagerService.getInstance();
            mSubscriptionManagerService = SubscriptionManagerService.getInstance();
            mSubscriptionController = null;
        } else {
            mSubscriptionController = SubscriptionController.getInstance();
            mSubscriptionManagerService = null;
        }

        mRadioConfig = RadioConfig.getInstance();
        mRadioConfig = RadioConfig.getInstance();
        mValidator = CellularNetworkValidator.getInstance();
        mValidator = CellularNetworkValidator.getInstance();


+49 −12
Original line number Original line Diff line number Diff line
@@ -39,6 +39,7 @@ import android.telephony.SubscriptionManager.SimDisplayNameSource;
import android.telephony.SubscriptionManager.SubscriptionType;
import android.telephony.SubscriptionManager.SubscriptionType;
import android.telephony.SubscriptionManager.UsageSetting;
import android.telephony.SubscriptionManager.UsageSetting;
import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager;
import android.telephony.UiccAccessRule;
import android.telephony.ims.ImsMmTelManager;
import android.telephony.ims.ImsMmTelManager;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Base64;
@@ -562,6 +563,7 @@ public class SubscriptionDatabaseManager extends Handler {
    public SubscriptionDatabaseManager(@NonNull Context context, @NonNull Looper looper,
    public SubscriptionDatabaseManager(@NonNull Context context, @NonNull Looper looper,
            @NonNull SubscriptionDatabaseManagerCallback callback) {
            @NonNull SubscriptionDatabaseManagerCallback callback) {
        super(looper);
        super(looper);
        log("Created SubscriptionDatabaseManager.");
        mContext = context;
        mContext = context;
        mCallback = callback;
        mCallback = callback;
        mUiccController = UiccController.getInstance();
        mUiccController = UiccController.getInstance();
@@ -684,6 +686,8 @@ public class SubscriptionDatabaseManager extends Handler {


        for (String columnName : Telephony.SimInfo.getAllColumns()) {
        for (String columnName : Telephony.SimInfo.getAllColumns()) {
            if (DEPRECATED_DATABASE_COLUMNS.contains(columnName)) continue;
            if (DEPRECATED_DATABASE_COLUMNS.contains(columnName)) continue;
            // subId is generated by the database. Cannot be updated.
            if (columnName.equals(SimInfo.COLUMN_UNIQUE_KEY_SUBSCRIPTION_ID)) continue;
            Object newValue = getSubscriptionInfoFieldByColumnName(newSubInfo, columnName);
            Object newValue = getSubscriptionInfoFieldByColumnName(newSubInfo, columnName);
            if (newValue != null) {
            if (newValue != null) {
                Object oldValue = null;
                Object oldValue = null;
@@ -712,13 +716,16 @@ public class SubscriptionDatabaseManager extends Handler {
        Objects.requireNonNull(contentValues);
        Objects.requireNonNull(contentValues);
        Uri uri = mContext.getContentResolver().insert(SimInfo.CONTENT_URI, contentValues);
        Uri uri = mContext.getContentResolver().insert(SimInfo.CONTENT_URI, contentValues);
        if (uri != null && uri.getLastPathSegment() != null) {
        if (uri != null && uri.getLastPathSegment() != null) {
            int subId = Integer.parseInt(uri.getLastPathSegment());
            if (SubscriptionManager.isValidSubscriptionId(subId)) {
                logl("insertNewRecordIntoDatabaseSync: Successfully added subscription. subId="
                logl("insertNewRecordIntoDatabaseSync: Successfully added subscription. subId="
                        + uri.getLastPathSegment());
                        + uri.getLastPathSegment());
            return Integer.parseInt(uri.getLastPathSegment());
                return subId;
        } else {
            }
        }

        logel("insertNewRecordIntoDatabaseSync: Failed to insert subscription into database. "
        logel("insertNewRecordIntoDatabaseSync: Failed to insert subscription into database. "
                + "contentValues=" + contentValues);
                + "contentValues=" + contentValues);
        }
        return INVALID_ROW_INDEX;
        return INVALID_ROW_INDEX;
    }
    }


@@ -875,6 +882,8 @@ public class SubscriptionDatabaseManager extends Handler {
                    // Check if the new value is different from the old value in the cache.
                    // Check if the new value is different from the old value in the cache.
                    if (!Objects.equals(getSubscriptionInfoFieldByColumnName(subInfo, columnName),
                    if (!Objects.equals(getSubscriptionInfoFieldByColumnName(subInfo, columnName),
                            newValue)) {
                            newValue)) {
                        logv("writeDatabaseAndCacheHelper: subId=" + subId + ",columnName="
                                + columnName + ", newValue=" + newValue);
                        // If the value is different, then we need to update the cache. Since all
                        // If the value is different, then we need to update the cache. Since all
                        // fields in SubscriptionInfo are final, we need to create a new
                        // fields in SubscriptionInfo are final, we need to create a new
                        // SubscriptionInfo.
                        // SubscriptionInfo.
@@ -1210,6 +1219,24 @@ public class SubscriptionDatabaseManager extends Handler {
                SubscriptionInfoInternal.Builder::setCarrierConfigAccessRules);
                SubscriptionInfoInternal.Builder::setCarrierConfigAccessRules);
    }
    }


    /**
     * Set the carrier certificates for this subscription that are saved in carrier configs.
     * This does not include access rules from the Uicc, whether embedded or non-embedded.
     *
     * @param subId Subscription id.
     * @param carrierConfigAccessRules The carrier certificates for this subscription.
     *
     * @throws IllegalArgumentException if the subscription does not exist.
     */
    public void setCarrierConfigAccessRules(int subId,
            @NonNull UiccAccessRule[] carrierConfigAccessRules) {
        Objects.requireNonNull(carrierConfigAccessRules);
        byte[] carrierConfigAccessRulesBytes = UiccAccessRule.encodeRules(carrierConfigAccessRules);
        writeDatabaseAndCacheHelper(subId, SimInfo.COLUMN_ACCESS_RULES_FROM_CARRIER_CONFIGS,
                carrierConfigAccessRulesBytes,
                SubscriptionInfoInternal.Builder::setCarrierConfigAccessRules);
    }

    /**
    /**
     * Set whether an embedded subscription is on a removable card. Such subscriptions are
     * Set whether an embedded subscription is on a removable card. Such subscriptions are
     * marked inaccessible as soon as the current card is removed. Otherwise, they will remain
     * marked inaccessible as soon as the current card is removed. Otherwise, they will remain
@@ -1761,11 +1788,23 @@ public class SubscriptionDatabaseManager extends Handler {
        // publicCardId is the publicly exposed int card ID
        // publicCardId is the publicly exposed int card ID
        int publicCardId = mUiccController.convertToPublicCardId(cardString);
        int publicCardId = mUiccController.convertToPublicCardId(cardString);


        byte[] rules = cursor.getBlob(cursor.getColumnIndexOrThrow(SimInfo.COLUMN_ACCESS_RULES));
        if (rules != null) {
            builder.setNativeAccessRules(rules);
        }

        rules = cursor.getBlob(cursor.getColumnIndexOrThrow(
                SimInfo.COLUMN_ACCESS_RULES_FROM_CARRIER_CONFIGS));
        if (rules != null) {
            builder.setCarrierConfigAccessRules(rules);
        }

        byte[] config = cursor.getBlob(cursor.getColumnIndexOrThrow(SimInfo.COLUMN_RCS_CONFIG));
        if (config != null) {
            builder.setRcsConfig(config);
        }

        builder.setCardId(publicCardId)
        builder.setCardId(publicCardId)
                .setNativeAccessRules(cursor.getBlob(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_ACCESS_RULES)))
                .setCarrierConfigAccessRules(cursor.getBlob(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_ACCESS_RULES_FROM_CARRIER_CONFIGS)))
                .setRemovableEmbedded(cursor.getInt(cursor.getColumnIndexOrThrow(
                .setRemovableEmbedded(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_IS_REMOVABLE)))
                        SimInfo.COLUMN_IS_REMOVABLE)))
                .setEnhanced4GModeEnabled(cursor.getInt(cursor.getColumnIndexOrThrow(
                .setEnhanced4GModeEnabled(cursor.getInt(cursor.getColumnIndexOrThrow(
@@ -1805,8 +1844,6 @@ public class SubscriptionDatabaseManager extends Handler {
                        SimInfo.COLUMN_IMS_RCS_UCE_ENABLED)))
                        SimInfo.COLUMN_IMS_RCS_UCE_ENABLED)))
                .setCrossSimCallingEnabled(cursor.getInt(cursor.getColumnIndexOrThrow(
                .setCrossSimCallingEnabled(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_CROSS_SIM_CALLING_ENABLED)))
                        SimInfo.COLUMN_CROSS_SIM_CALLING_ENABLED)))
                .setRcsConfig(cursor.getBlob(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_RCS_CONFIG)))
                .setAllowedNetworkTypesForReasons(TextUtils.emptyIfNull(
                .setAllowedNetworkTypesForReasons(TextUtils.emptyIfNull(
                        cursor.getString(cursor.getColumnIndexOrThrow(
                        cursor.getString(cursor.getColumnIndexOrThrow(
                                SimInfo.COLUMN_ALLOWED_NETWORK_TYPES_FOR_REASONS))))
                                SimInfo.COLUMN_ALLOWED_NETWORK_TYPES_FOR_REASONS))))
Loading