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

Commit 566e003a authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 10851067 from 88a5163b to 24Q1-release

Change-Id: Ibf1eac4c2cf75e914d7c41f0aad2a2dff48064c3
parents faed0c91 88a5163b
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.Handler;
import android.os.HandlerExecutor;
@@ -153,7 +154,11 @@ public class CarrierServiceStateTracker extends Handler {
                    }
                });

        if (!mPhone.getContext().getPackageManager().hasSystemFeature(
                PackageManager.FEATURE_WATCH)) {
            registerNotificationTypes();
        }

        mAllowedNetworkType = RadioAccessFamily.getNetworkTypeFromRaf(
                (int) mPhone.getAllowedNetworkTypes(
                        TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER));
+38 −4
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import android.util.LocalLog;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.flags.FeatureFlags;
import com.android.internal.telephony.uicc.UiccController;
import com.android.internal.util.function.TriConsumer;
import com.android.telephony.Rlog;
@@ -277,8 +278,10 @@ public class SubscriptionDatabaseManager extends Handler {
                    SubscriptionInfoInternal::getSatelliteEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
                    SubscriptionInfoInternal::getSatelliteAttachEnabledForCarrier)

                    SubscriptionInfoInternal::getSatelliteAttachEnabledForCarrier),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_IS_NTN,
                    SubscriptionInfoInternal::getNtn)
    );

    /**
@@ -406,7 +409,10 @@ public class SubscriptionDatabaseManager extends Handler {
                    SubscriptionDatabaseManager::setSatelliteEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
                    SubscriptionDatabaseManager::setSatelliteAttachEnabledForCarrier)
                    SubscriptionDatabaseManager::setSatelliteAttachEnabledForCarrier),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_IS_NTN,
                    SubscriptionDatabaseManager::setNtn)
    );

    /**
@@ -538,6 +544,10 @@ public class SubscriptionDatabaseManager extends Handler {
    @NonNull
    private final Context mContext;

    /** The feature flags */
    @NonNull
    private final FeatureFlags mFeatureFlags;

    /** The callback used for passing events back to {@link SubscriptionManagerService}. */
    @NonNull
    private final SubscriptionDatabaseManagerCallback mCallback;
@@ -628,9 +638,11 @@ public class SubscriptionDatabaseManager extends Handler {
     *
     * @param context The context.
     * @param looper Looper for the handler.
     * @param featureFlags The feature flags.
     * @param callback Subscription database callback.
     */
    public SubscriptionDatabaseManager(@NonNull Context context, @NonNull Looper looper,
            @NonNull FeatureFlags featureFlags,
            @NonNull SubscriptionDatabaseManagerCallback callback) {
        super(looper);
        log("Created SubscriptionDatabaseManager.");
@@ -639,6 +651,7 @@ public class SubscriptionDatabaseManager extends Handler {
        mUiccController = UiccController.getInstance();
        mAsyncMode = mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_subscription_database_async_update);
        mFeatureFlags = featureFlags;
        initializeDatabase();
    }

@@ -2013,6 +2026,23 @@ public class SubscriptionDatabaseManager extends Handler {
                SubscriptionInfoInternal.Builder::setSatelliteAttachEnabledForCarrier);
    }

    /**
     * Set whether the subscription is exclusively used for non-terrestrial networks or not.
     *
     * @param subId Subscription ID.
     * @param isNtn {@code 1} if it is a non-terrestrial network subscription.
     * {@code 0} otherwise.
     *
     * @throws IllegalArgumentException if the subscription does not exist.
     */
    public void setNtn(int subId, int isNtn) {
        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
            return;
        }
        writeDatabaseAndCacheHelper(subId, SimInfo.COLUMN_IS_NTN, isNtn,
                SubscriptionInfoInternal.Builder::setNtn);
    }

    /**
     * Set whether group of the subscription is disabled. This is only useful if it's a grouped
     * opportunistic subscription. In this case, if all primary (non-opportunistic)
@@ -2273,6 +2303,10 @@ public class SubscriptionDatabaseManager extends Handler {
                .setSatelliteAttachEnabledForCarrier(cursor.getInt(
                        cursor.getColumnIndexOrThrow(
                                SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER)));
        if (mFeatureFlags.oemEnabledSatelliteFlag()) {
            builder.setNtn(cursor.getInt(cursor.getColumnIndexOrThrow(
                    SimInfo.COLUMN_IS_NTN)));
        }
        return builder.build();
    }

+41 −4
Original line number Diff line number Diff line
@@ -448,6 +448,12 @@ public class SubscriptionInfoInternal {
     */
    private final int mIsSatelliteAttachEnabledForCarrier;

    /**
     * Whether this subscription is used for communicating with non-terrestrial networks.
     * By default, its disabled. It is intended to use integer to fit the database format.
     */
    private final int mIsNtn;

    // Below are the fields that do not exist in the SimInfo table.
    /**
     * The card ID of the SIM card. This maps uniquely to {@link #mCardString}.
@@ -532,6 +538,7 @@ public class SubscriptionInfoInternal {
        this.mIsSatelliteEnabled = builder.mIsSatelliteEnabled;
        this.mIsSatelliteAttachEnabledForCarrier =
                builder.mIsSatelliteAttachEnabledForCarrier;
        this.mIsNtn = builder.mIsNtn;

        // Below are the fields that do not exist in the SimInfo table.
        this.mCardId = builder.mCardId;
@@ -1143,6 +1150,15 @@ public class SubscriptionInfoInternal {
        return mIsSatelliteAttachEnabledForCarrier;
    }

    /**
     * An NTN subscription connects to non-terrestrial networks.
     *
     * @return {@code 1} if the subscription is for non-terrestrial networks. {@code 0} otherwise.
     */
    public int getNtn() {
        return mIsNtn;
    }

    // Below are the fields that do not exist in SimInfo table.
    /**
     * @return The card ID of the SIM card which contains the subscription.
@@ -1212,6 +1228,7 @@ public class SubscriptionInfoInternal {
                .setUiccApplicationsEnabled(mAreUiccApplicationsEnabled != 0)
                .setPortIndex(mPortIndex)
                .setUsageSetting(mUsageSetting)
                .setNtn(mIsNtn == 1)
                .build();
    }

@@ -1269,6 +1286,7 @@ public class SubscriptionInfoInternal {
                + " userId=" + mUserId
                + " isSatelliteEnabled=" + mIsSatelliteEnabled
                + " satellite_attach_enabled_for_carrier=" + mIsSatelliteAttachEnabledForCarrier
                + " getNtn=" + mIsNtn
                + " isGroupDisabled=" + mIsGroupDisabled
                + "]";
    }
@@ -1325,7 +1343,8 @@ public class SubscriptionInfoInternal {
                that.mAllowedNetworkTypesForReasons) && mDeviceToDeviceStatusSharingContacts.equals(
                that.mDeviceToDeviceStatusSharingContacts) && mNumberFromCarrier.equals(
                that.mNumberFromCarrier) && mNumberFromIms.equals(that.mNumberFromIms)
                && mIsSatelliteAttachEnabledForCarrier == that.mIsSatelliteAttachEnabledForCarrier;
                && mIsSatelliteAttachEnabledForCarrier == that.mIsSatelliteAttachEnabledForCarrier
                && mIsNtn == that.mIsNtn;
    }

    @Override
@@ -1347,7 +1366,7 @@ public class SubscriptionInfoInternal {
                mNumberFromCarrier,
                mNumberFromIms, mPortIndex, mUsageSetting, mLastUsedTPMessageReference, mUserId,
                mIsSatelliteEnabled, mCardId, mIsGroupDisabled,
                mIsSatelliteAttachEnabledForCarrier);
                mIsSatelliteAttachEnabledForCarrier, mIsNtn);
        result = 31 * result + Arrays.hashCode(mNativeAccessRules);
        result = 31 * result + Arrays.hashCode(mCarrierConfigAccessRules);
        result = 31 * result + Arrays.hashCode(mRcsConfig);
@@ -1708,12 +1727,17 @@ public class SubscriptionInfoInternal {
        /**
         * Whether satellite is enabled or not.
         */
        private int mIsSatelliteEnabled = -1;
        private int mIsSatelliteEnabled = 0;

        /**
         * Whether satellite attach for carrier is enabled by user.
         */
        private int mIsSatelliteAttachEnabledForCarrier = -1;
        private int mIsSatelliteAttachEnabledForCarrier = 0;

        /**
         * Whether this subscription is used for communicating with non-terrestrial network or not.
         */
        private int mIsNtn = 0;

        // The following fields do not exist in the SimInfo table.
        /**
@@ -1803,6 +1827,7 @@ public class SubscriptionInfoInternal {
            mUserId = info.mUserId;
            mIsSatelliteEnabled = info.mIsSatelliteEnabled;
            mIsSatelliteAttachEnabledForCarrier = info.mIsSatelliteAttachEnabledForCarrier;
            mIsNtn = info.mIsNtn;
            // Below are the fields that do not exist in the SimInfo table.
            mCardId = info.mCardId;
            mIsGroupDisabled = info.mIsGroupDisabled;
@@ -2686,6 +2711,18 @@ public class SubscriptionInfoInternal {
            return this;
        }

        /**
         * Set whether the subscription is for NTN or not.
         *
         * @param isNtn {@code 1} if the subscription is for NTN, {@code 0} otherwise.
         * @return The builder.
         */
        @NonNull
        public Builder setNtn(int isNtn) {
            mIsNtn = isNtn;
            return this;
        }

        // Below are the fields that do not exist in the SimInfo table.
        /**
         * Set the card ID of the SIM card which contains the subscription.
+52 −2
Original line number Diff line number Diff line
@@ -175,7 +175,8 @@ public class SubscriptionManagerService extends ISub.Stub {
            SimInfo.COLUMN_D2D_STATUS_SHARING_SELECTED_CONTACTS,
            SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED,
            SimInfo.COLUMN_SATELLITE_ENABLED,
            SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER
            SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
            SimInfo.COLUMN_IS_NTN
    );

    /**
@@ -488,7 +489,8 @@ public class SubscriptionManagerService extends ISub.Stub {
        HandlerThread handlerThread = new HandlerThread(LOG_TAG);
        handlerThread.start();
        mSubscriptionDatabaseManager = new SubscriptionDatabaseManager(context,
                handlerThread.getLooper(), new SubscriptionDatabaseManagerCallback(mHandler::post) {
                handlerThread.getLooper(), mFeatureFlags,
                new SubscriptionDatabaseManagerCallback(mHandler::post) {
                    /**
                     * Called when database has been loaded into the cache.
                     */
@@ -825,6 +827,26 @@ public class SubscriptionManagerService extends ISub.Stub {
        }
    }

    /**
     * Set whether the subscription ID supports oem satellite or not.
     *
     * @param subId The subscription ID.
     * @param isNtn {@code true} Requested subscription ID supports oem satellite service,
     * {@code false} otherwise.
     */
    public void setNtn(int subId, boolean isNtn) {
        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
            return;
        }

        // This can throw IllegalArgumentException if the subscription does not exist.
        try {
            mSubscriptionDatabaseManager.setNtn(subId, (isNtn ? 1 : 0));
        } catch (IllegalArgumentException e) {
            loge("setNtn: invalid subId=" + subId);
        }
    }

    /**
     * Set ISO country code by subscription id.
     *
@@ -1120,6 +1142,9 @@ public class SubscriptionManagerService extends ISub.Stub {
                        String mnc = cid.getMnc();
                        builder.setMcc(mcc);
                        builder.setMnc(mnc);
                        if (mFeatureFlags.oemEnabledSatelliteFlag()) {
                            builder.setNtn(isSatellitePlmn(mcc + mnc) ? 1 : 0);
                        }
                    }
                    // If cardId = unsupported or un-initialized, we have no reason to update DB.
                    // Additionally, if the device does not support cardId for default eUICC, the
@@ -1391,6 +1416,7 @@ public class SubscriptionManagerService extends ISub.Stub {
                            MccTable.updateMccMncConfiguration(mContext, mccMnc);
                        }
                        setMccMnc(subId, mccMnc);
                        setNtn(subId, isSatellitePlmn(mccMnc));
                    } else {
                        loge("updateSubscription: mcc/mnc is empty");
                    }
@@ -3958,6 +3984,30 @@ public class SubscriptionManagerService extends ISub.Stub {
                .collect(Collectors.joining(", ")) + "]";
    }

    /**
     * @param mccMnc MccMnc value to check whether it supports non-terrestrial network or not.
     * @return {@code true} if MCC/MNC is matched with in the device overlay key
     * "config_satellite_esim_identifier", {@code false} otherwise.
     */
    private boolean isSatellitePlmn(@NonNull String mccMnc) {
        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
            return false;
        }

        final int id = R.string.config_satellite_esim_identifier;
        String overlayMccMnc = null;
        try {
            overlayMccMnc = mContext.getResources().getString(id);
        } catch (Resources.NotFoundException ex) {
            loge("isSatellitePlmn: id= " + id + ", ex=" + ex);
        }
        if (overlayMccMnc == null) {
            return false;
        } else {
            return mccMnc.equals(overlayMccMnc);
        }
    }

    /**
     * Log debug messages.
     *
+14 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Message;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
@@ -82,6 +83,7 @@ public class CarrierServiceStateTrackerTest extends TelephonyTest {
        mBundle = mContextFixture.getCarrierConfigBundle();
        when(mPhone.getSubId()).thenReturn(SUB_ID);
        when(mCarrierConfigManager.getConfigForSubId(anyInt(), any())).thenReturn(mBundle);
        doReturn(false).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_WATCH);

        // Capture listener to emulate the carrier config change notification used later
        ArgumentCaptor<CarrierConfigManager.CarrierConfigChangeListener> listenerArgumentCaptor =
@@ -303,6 +305,18 @@ public class CarrierServiceStateTrackerTest extends TelephonyTest {
                eq(SUB_ID), isA(Notification.class));
    }


    /** Verifies notification map is empty when device is watch. */
    @Test
    @SmallTest
    public void testNotificationMapWhenDeviceIsWatch() {
        doReturn(true).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_WATCH);

        CarrierServiceStateTracker tracker = new CarrierServiceStateTracker(mPhone, mSST);

        assertTrue(tracker.getNotificationTypeMap().isEmpty());
    }

    private void sendMessageOnHandler(int messageWhat) {
        Message notificationMsg = mSpyCarrierSST.obtainMessage(messageWhat, null);
        doReturn(true).when(mSpyCarrierSST).evaluateSendingMessage(any());
Loading