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

Commit f333b9b4 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 ffcbdc81 ad5058dc
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -214,9 +214,14 @@ public class PhoneFactory {
                    TelephonyComponentFactory.getInstance().inject(SubscriptionController.class
                            .getName()).initSubscriptionController(context);
                }

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

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

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

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

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

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

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

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

        for (String columnName : Telephony.SimInfo.getAllColumns()) {
            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);
            if (newValue != null) {
                Object oldValue = null;
@@ -712,13 +716,16 @@ public class SubscriptionDatabaseManager extends Handler {
        Objects.requireNonNull(contentValues);
        Uri uri = mContext.getContentResolver().insert(SimInfo.CONTENT_URI, contentValues);
        if (uri != null && uri.getLastPathSegment() != null) {
            int subId = Integer.parseInt(uri.getLastPathSegment());
            if (SubscriptionManager.isValidSubscriptionId(subId)) {
                logl("insertNewRecordIntoDatabaseSync: Successfully added subscription. subId="
                        + uri.getLastPathSegment());
            return Integer.parseInt(uri.getLastPathSegment());
        } else {
                return subId;
            }
        }

        logel("insertNewRecordIntoDatabaseSync: Failed to insert subscription into database. "
                + "contentValues=" + contentValues);
        }
        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.
                    if (!Objects.equals(getSubscriptionInfoFieldByColumnName(subInfo, columnName),
                            newValue)) {
                        logv("writeDatabaseAndCacheHelper: subId=" + subId + ",columnName="
                                + columnName + ", newValue=" + newValue);
                        // 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
                        // SubscriptionInfo.
@@ -1210,6 +1219,24 @@ public class SubscriptionDatabaseManager extends Handler {
                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
     * 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
        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)
                .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(
                        SimInfo.COLUMN_IS_REMOVABLE)))
                .setEnhanced4GModeEnabled(cursor.getInt(cursor.getColumnIndexOrThrow(
@@ -1805,8 +1844,6 @@ public class SubscriptionDatabaseManager extends Handler {
                        SimInfo.COLUMN_IMS_RCS_UCE_ENABLED)))
                .setCrossSimCallingEnabled(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_CROSS_SIM_CALLING_ENABLED)))
                .setRcsConfig(cursor.getBlob(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_RCS_CONFIG)))
                .setAllowedNetworkTypesForReasons(TextUtils.emptyIfNull(
                        cursor.getString(cursor.getColumnIndexOrThrow(
                                SimInfo.COLUMN_ALLOWED_NETWORK_TYPES_FOR_REASONS))))
Loading