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

Commit 93727554 authored by Hyosun Kim's avatar Hyosun Kim Committed by Android (Google) Code Review
Browse files

Merge "Add new api for satellite entitlement status and satellite entitlement plmns" into main

parents dd639f88 2dda955d
Loading
Loading
Loading
Loading
+67 −4
Original line number Diff line number Diff line
@@ -287,7 +287,13 @@ public class SubscriptionDatabaseManager extends Handler {
                    SubscriptionInfoInternal::getServiceCapabilities),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_TRANSFER_STATUS,
                    SubscriptionInfoInternal::getTransferStatus)
                    SubscriptionInfoInternal::getTransferStatus),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_SATELLITE_ENTITLEMENT_STATUS,
                    SubscriptionInfoInternal::getSatelliteEntitlementStatus),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_SATELLITE_ENTITLEMENT_PLMNS,
                    SubscriptionInfoInternal::getSatelliteEntitlementPlmns)
    );

    /**
@@ -424,7 +430,10 @@ public class SubscriptionDatabaseManager extends Handler {
                    SubscriptionDatabaseManager::setServiceCapabilities),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_TRANSFER_STATUS,
                    SubscriptionDatabaseManager::setTransferStatus)
                    SubscriptionDatabaseManager::setTransferStatus),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_SATELLITE_ENTITLEMENT_STATUS,
                    SubscriptionDatabaseManager::setSatelliteEntitlementStatus)
    );

    /**
@@ -486,7 +495,10 @@ public class SubscriptionDatabaseManager extends Handler {
                    SubscriptionDatabaseManager::setNumberFromCarrier),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_PHONE_NUMBER_SOURCE_IMS,
                    SubscriptionDatabaseManager::setNumberFromIms)
                    SubscriptionDatabaseManager::setNumberFromIms),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_SATELLITE_ENTITLEMENT_PLMNS,
                    SubscriptionDatabaseManager::setSatelliteEntitlementPlmns)
    );

    /**
@@ -2104,6 +2116,51 @@ public class SubscriptionDatabaseManager extends Handler {
                capabilities, SubscriptionInfoInternal.Builder::setServiceCapabilities);
    }

    /**
     * Set whether satellite entitlement status is enabled by entitlement query result.
     *
     * @param subId Subscription id.
     * @param isSatelliteEntitlementStatus Whether satellite entitlement status is enabled or
     * disabled.
     * @throws IllegalArgumentException if the subscription does not exist.
     */
    public void setSatelliteEntitlementStatus(int subId,
            int isSatelliteEntitlementStatus) {
        writeDatabaseAndCacheHelper(subId,
                SimInfo.COLUMN_SATELLITE_ENTITLEMENT_STATUS,
                isSatelliteEntitlementStatus,
                SubscriptionInfoInternal.Builder::setSatelliteEntitlementStatus);
    }

    /**
     * Set satellite entitlement plmns by entitlement query result.
     *
     * @param subId Subscription id.
     * @param satelliteEntitlementPlmns Satellite entitlement plmns
     * @throws IllegalArgumentException if the subscription does not exist.
     */
    public void setSatelliteEntitlementPlmns(int subId,
            @NonNull String satelliteEntitlementPlmns) {
        writeDatabaseAndCacheHelper(subId,
                SimInfo.COLUMN_SATELLITE_ENTITLEMENT_PLMNS,
                satelliteEntitlementPlmns,
                SubscriptionInfoInternal.Builder::setSatelliteEntitlementPlmns);
    }

    /**
     * Set satellite entitlement plmn list by entitlement query result.
     *
     * @param subId Subscription id.
     * @param satelliteEntitlementPlmnList Satellite entitlement plmn list
     * @throws IllegalArgumentException if the subscription does not exist.
     */
    public void setSatelliteEntitlementPlmnList(int subId,
            @NonNull List<String> satelliteEntitlementPlmnList) {
        String satelliteEntitlementPlmns = satelliteEntitlementPlmnList.stream().collect(
                Collectors.joining(","));
        setSatelliteEntitlementPlmns(subId, satelliteEntitlementPlmns);
    }

    /**
     * Reload the database from content provider to the cache. This must be a synchronous operation
     * to prevent cache/database out-of-sync. Callers should be cautious to call this method because
@@ -2336,7 +2393,13 @@ public class SubscriptionDatabaseManager extends Handler {
                                SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER)))
                .setServiceCapabilities(cursor.getInt(
                        cursor.getColumnIndexOrThrow(
                                SimInfo.COLUMN_SERVICE_CAPABILITIES)));
                                SimInfo.COLUMN_SERVICE_CAPABILITIES)))
                .setSatelliteEntitlementStatus(cursor.getInt(
                        cursor.getColumnIndexOrThrow(
                                SimInfo.COLUMN_SATELLITE_ENTITLEMENT_STATUS)))
                .setSatelliteEntitlementPlmns(cursor.getString(
                        cursor.getColumnIndexOrThrow(
                                SimInfo.COLUMN_SATELLITE_ENTITLEMENT_PLMNS)));
        if (mFeatureFlags.oemEnabledSatelliteFlag()) {
            builder.setOnlyNonTerrestrialNetwork(cursor.getInt(cursor.getColumnIndexOrThrow(
                    SimInfo.COLUMN_IS_NTN)));
+77 −2
Original line number Diff line number Diff line
@@ -478,6 +478,18 @@ public class SubscriptionInfoInternal {
     */
    private final int mTransferStatus;

    /**
     * Whether satellite entitlement status is enabled or disabled by the entitlement query result.
     * By default, its disabled. It is intended to use integer to fit the database format.
     */
    private final int mIsSatelliteEntitlementStatus;

    /**
     * The satellite entitlement plmns based on the entitlement query results
     * By default, its empty. It is intended to use string to fit the database format.
     */
    @NonNull private final String mSatelliteEntitlementPlmns;

    /**
     * Constructor from builder.
     *
@@ -555,6 +567,8 @@ public class SubscriptionInfoInternal {
        this.mIsGroupDisabled = builder.mIsGroupDisabled;
        this.mServiceCapabilities = builder.mServiceCapabilities;
        this.mTransferStatus = builder.mTransferStatus;
        this.mIsSatelliteEntitlementStatus = builder.mIsSatelliteEntitlementStatus;
        this.mSatelliteEntitlementPlmns = builder.mSatelliteEntitlementPlmns;
    }

    /**
@@ -1218,6 +1232,23 @@ public class SubscriptionInfoInternal {
        return mTransferStatus;
    }

    /**
     * @return {@code 1} if satellite entitlement status is enabled by entitlement query result.
     */
    public int getSatelliteEntitlementStatus() {
        return mIsSatelliteEntitlementStatus;
    }

    /**
     * @return Satellite entitlement plmns is empty or not by entitlement query result.
     *
     * For example, "123123, 12310" or ""
     */
    @NonNull
    public String getSatelliteEntitlementPlmns() {
        return mSatelliteEntitlementPlmns;
    }

    /** @return converted {@link SubscriptionInfo}. */
    @NonNull
    public SubscriptionInfo toSubscriptionInfo() {
@@ -1318,6 +1349,8 @@ public class SubscriptionInfoInternal {
                + " isGroupDisabled=" + mIsGroupDisabled
                + " serviceCapabilities=" + mServiceCapabilities
                + " transferStatus=" + mTransferStatus
                + " satelliteEntitlementStatus=" + mIsSatelliteEntitlementStatus
                + " satelliteEntitlementPlmns=" + mSatelliteEntitlementPlmns
                + "]";
    }

@@ -1376,7 +1409,9 @@ public class SubscriptionInfoInternal {
                && mIsSatelliteAttachEnabledForCarrier == that.mIsSatelliteAttachEnabledForCarrier
                && mIsOnlyNonTerrestrialNetwork == that.mIsOnlyNonTerrestrialNetwork
                && mServiceCapabilities == that.mServiceCapabilities
                && mTransferStatus == that.mTransferStatus;
                && mTransferStatus == that.mTransferStatus
                && mIsSatelliteEntitlementStatus == that.mIsSatelliteEntitlementStatus
                && mSatelliteEntitlementPlmns == that.mSatelliteEntitlementPlmns;
    }

    @Override
@@ -1399,7 +1434,8 @@ public class SubscriptionInfoInternal {
                mNumberFromIms, mPortIndex, mUsageSetting, mLastUsedTPMessageReference, mUserId,
                mIsSatelliteEnabled, mCardId, mIsGroupDisabled,
                mIsSatelliteAttachEnabledForCarrier, mIsOnlyNonTerrestrialNetwork,
                mServiceCapabilities, mTransferStatus);
                mServiceCapabilities, mTransferStatus, mIsSatelliteEntitlementStatus,
                mSatelliteEntitlementPlmns);
        result = 31 * result + Arrays.hashCode(mNativeAccessRules);
        result = 31 * result + Arrays.hashCode(mCarrierConfigAccessRules);
        result = 31 * result + Arrays.hashCode(mRcsConfig);
@@ -1796,6 +1832,17 @@ public class SubscriptionInfoInternal {
         */
        private int mTransferStatus;

        /**
         * Whether satellite entitlement status is enabled by entitlement query result.
         */
        private int mIsSatelliteEntitlementStatus = 0;

        /**
         * Whether satellite entitlement plmns is empty or not by entitlement query result.
         */
        @NonNull
        private String mSatelliteEntitlementPlmns = "";

        /**
         * Default constructor.
         */
@@ -1876,6 +1923,8 @@ public class SubscriptionInfoInternal {
            mIsGroupDisabled = info.mIsGroupDisabled;
            mServiceCapabilities = info.mServiceCapabilities;
            mTransferStatus = info.mTransferStatus;
            mIsSatelliteEntitlementStatus = info.mIsSatelliteEntitlementStatus;
            mSatelliteEntitlementPlmns = info.mSatelliteEntitlementPlmns;
        }

        /**
@@ -2819,6 +2868,32 @@ public class SubscriptionInfoInternal {
            return this;
        }

        /**
         * Set whether satellite entitlement status is enabled by entitlement query result.
         *
         * @param isSatelliteEntitlementStatus {@code 1} if satellite entitlement status is
         * enabled by entitlement query result.
         * @return The builder
         */
        @NonNull
        public Builder setSatelliteEntitlementStatus(int isSatelliteEntitlementStatus) {
            mIsSatelliteEntitlementStatus = isSatelliteEntitlementStatus;
            return this;
        }

        /**
         * Set whether satellite entitlement plmns is empty or not by entitlement query result.
         *
         * @param satelliteEntitlementPlmns satellite entitlement plmns is empty or not by
         * entitlement query result.
         * @return The builder
         */
        @NonNull
        public Builder setSatelliteEntitlementPlmns(@NonNull String satelliteEntitlementPlmns) {
            mSatelliteEntitlementPlmns = satelliteEntitlementPlmns;
            return this;
        }

        /**
         * Build the {@link SubscriptionInfoInternal}.
         *
+37 −1
Original line number Diff line number Diff line
@@ -187,7 +187,9 @@ public class SubscriptionManagerService extends ISub.Stub {
            SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED,
            SimInfo.COLUMN_SATELLITE_ENABLED,
            SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
            SimInfo.COLUMN_IS_NTN
            SimInfo.COLUMN_IS_NTN,
            SimInfo.COLUMN_SATELLITE_ENTITLEMENT_STATUS,
            SimInfo.COLUMN_SATELLITE_ENTITLEMENT_PLMNS
    );

    /**
@@ -4339,6 +4341,40 @@ public class SubscriptionManagerService extends ISub.Stub {
        }
    }

    /**
     * Set the satellite entitlement plmn list value in the subscription database.
     *
     * @param subId subscription id.
     * @param satelliteEntitlementPlmnList satellite entitlement plmn list
     */
    public void setSatelliteEntitlementPlmnList(int subId,
            @NonNull List<String> satelliteEntitlementPlmnList) {
        try {
            mSubscriptionDatabaseManager.setSatelliteEntitlementPlmnList(
                    subId, satelliteEntitlementPlmnList);
        } catch (IllegalArgumentException e) {
            loge("setSatelliteEntitlementPlmnList: invalid subId=" + subId);
        }
    }

    /**
     * Get the satellite entitlement plmn list value from the subscription database.
     *
     * @param subId subscription id.
     * @return satellite entitlement plmn list
     */
    @NonNull
    public List<String> getSatelliteEntitlementPlmnList(int subId) {
        SubscriptionInfoInternal subInfo = mSubscriptionDatabaseManager.getSubscriptionInfoInternal(
                subId);
        if (subInfo == null) {
            loge("getSatelliteEntitlementPlmnList: invalid subId=" + subId);
            return new ArrayList<>();
        }

        return Arrays.stream(subInfo.getSatelliteEntitlementPlmns().split(",")).collect(
                Collectors.toList());
    }

    /**
     * Get the current calling package name.
+3 −1
Original line number Diff line number Diff line
@@ -133,7 +133,9 @@ public class FakeTelephonyProvider extends MockContentProvider {
                    + " INTEGER DEFAULT 1, "
                    + Telephony.SimInfo.COLUMN_IS_NTN + " INTEGER DEFAULT 0,"
                    + Telephony.SimInfo.COLUMN_SERVICE_CAPABILITIES + " INTEGER DEFAULT 7,"
                    + Telephony.SimInfo.COLUMN_TRANSFER_STATUS + " INTEGER DEFAULT 0"
                    + Telephony.SimInfo.COLUMN_TRANSFER_STATUS + " INTEGER DEFAULT 0,"
                    + Telephony.SimInfo.COLUMN_SATELLITE_ENTITLEMENT_STATUS + " INTEGER DEFAULT 0,"
                    + Telephony.SimInfo.COLUMN_SATELLITE_ENTITLEMENT_PLMNS + " TEXT"
                    + ");";
        }

+76 −0
Original line number Diff line number Diff line
@@ -128,6 +128,10 @@ public class SubscriptionDatabaseManagerTest extends TelephonyTest {
            SubscriptionManager.SERVICE_CAPABILITY_DATA_BITMASK;
    static final int FAKE_SERVICE_CAPABILITIES_2 =
            SubscriptionManager.SERVICE_CAPABILITY_SMS_BITMASK;
    static final int FAKE_SATELLITE_ENTITLEMENT_STATUS_ENABLED = 1;
    static final int FAKE_SATELLITE_ENTITLEMENT_STATUS_DISABLED = 0;
    static final String FAKE_SATELLITE_ENTITLEMENT_PLMNS1 = "123123,12310";
    static final String FAKE_SATELLITE_ENTITLEMENT_PLMNS2 = "";

    static final String FAKE_MAC_ADDRESS1 = "DC:E5:5B:38:7D:40";
    static final String FAKE_MAC_ADDRESS2 = "DC:B5:4F:47:F3:4C";
@@ -208,6 +212,8 @@ public class SubscriptionDatabaseManagerTest extends TelephonyTest {
                    .setGroupDisabled(false)
                    .setServiceCapabilities(FAKE_SERVICE_CAPABILITIES_1)
                    .setTransferStatus(FAKE_TRANSFER_STATUS_TRANSFERRED_OUT)
                    .setSatelliteEntitlementStatus(FAKE_SATELLITE_ENTITLEMENT_STATUS_DISABLED)
                    .setSatelliteEntitlementPlmns(FAKE_SATELLITE_ENTITLEMENT_PLMNS2)
                    .build();

    static final SubscriptionInfoInternal FAKE_SUBSCRIPTION_INFO2 =
@@ -281,6 +287,8 @@ public class SubscriptionDatabaseManagerTest extends TelephonyTest {
                    .setGroupDisabled(false)
                    .setServiceCapabilities(FAKE_SERVICE_CAPABILITIES_2)
                    .setTransferStatus(FAKE_TRANSFER_STATUS_CONVERTED)
                    .setSatelliteEntitlementStatus(FAKE_SATELLITE_ENTITLEMENT_STATUS_ENABLED)
                    .setSatelliteEntitlementPlmns(FAKE_SATELLITE_ENTITLEMENT_PLMNS1)
                    .build();

    private SubscriptionDatabaseManager mDatabaseManagerUT;
@@ -2278,4 +2286,72 @@ public class SubscriptionDatabaseManagerTest extends TelephonyTest {
                FAKE_SUBSCRIPTION_INFO1.getSubscriptionId()).getTransferStatus())
                .isNotEqualTo(FAKE_TRANSFER_STATUS_TRANSFERRED_OUT);
    }

    @Test
    public void testUpdateSatelliteEntitlementStatus() throws Exception {
        // exception is expected if there is nothing in the database.
        assertThrows(IllegalArgumentException.class,
                () -> mDatabaseManagerUT.setSatelliteEntitlementStatus(
                        FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(),
                        FAKE_SATELLITE_ENTITLEMENT_STATUS_ENABLED));

        SubscriptionInfoInternal subInfo = insertSubscriptionAndVerify(FAKE_SUBSCRIPTION_INFO1);
        mDatabaseManagerUT.setSatelliteEntitlementStatus(
                FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(),
                FAKE_SATELLITE_ENTITLEMENT_STATUS_ENABLED);
        processAllMessages();

        subInfo = new SubscriptionInfoInternal.Builder(subInfo)
                .setSatelliteEntitlementStatus(FAKE_SATELLITE_ENTITLEMENT_STATUS_ENABLED)
                .build();
        verifySubscription(subInfo);
        verify(mSubscriptionDatabaseManagerCallback, times(2)).onSubscriptionChanged(eq(1));

        assertThat(mDatabaseManagerUT.getSubscriptionProperty(
                FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(),
                SimInfo.COLUMN_SATELLITE_ENTITLEMENT_STATUS))
                .isEqualTo(FAKE_SATELLITE_ENTITLEMENT_STATUS_ENABLED);

        mDatabaseManagerUT.setSubscriptionProperty(FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(),
                SimInfo.COLUMN_SATELLITE_ENTITLEMENT_STATUS,
                FAKE_SATELLITE_ENTITLEMENT_STATUS_DISABLED);
        assertThat(mDatabaseManagerUT.getSubscriptionInfoInternal(
                        FAKE_SUBSCRIPTION_INFO1.getSubscriptionId())
                .getSatelliteEntitlementStatus())
                .isEqualTo(FAKE_SATELLITE_ENTITLEMENT_STATUS_DISABLED);
    }

    @Test
    public void testUpdateSatelliteEntitlementPlmns() throws Exception {
        // exception is expected if there is nothing in the database.
        assertThrows(IllegalArgumentException.class,
                () -> mDatabaseManagerUT.setSatelliteEntitlementPlmns(
                        FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(),
                        FAKE_SATELLITE_ENTITLEMENT_PLMNS1));

        SubscriptionInfoInternal subInfo = insertSubscriptionAndVerify(FAKE_SUBSCRIPTION_INFO1);
        mDatabaseManagerUT.setSatelliteEntitlementPlmns(
                FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(),
                FAKE_SATELLITE_ENTITLEMENT_PLMNS1);
        processAllMessages();

        subInfo = new SubscriptionInfoInternal.Builder(subInfo)
                .setSatelliteEntitlementPlmns(FAKE_SATELLITE_ENTITLEMENT_PLMNS1)
                .build();
        verifySubscription(subInfo);
        verify(mSubscriptionDatabaseManagerCallback, times(2)).onSubscriptionChanged(eq(1));

        assertThat(mDatabaseManagerUT.getSubscriptionProperty(
                FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(),
                SimInfo.COLUMN_SATELLITE_ENTITLEMENT_PLMNS))
                .isEqualTo(FAKE_SATELLITE_ENTITLEMENT_PLMNS1);

        mDatabaseManagerUT.setSubscriptionProperty(FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(),
                SimInfo.COLUMN_SATELLITE_ENTITLEMENT_PLMNS,
                FAKE_SATELLITE_ENTITLEMENT_PLMNS2);
        assertThat(mDatabaseManagerUT.getSubscriptionInfoInternal(
                        FAKE_SUBSCRIPTION_INFO1.getSubscriptionId())
                .getSatelliteEntitlementPlmns())
                .isEqualTo(FAKE_SATELLITE_ENTITLEMENT_PLMNS2);
    }
}
Loading