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

Commit 17175f67 authored by Hakjun Choi's avatar Hakjun Choi
Browse files

Add SubscriptionManager APIs for satellite enabld/disable by user.

The following changes are made:
- Added new CARRIER_HANDOVER_TO_SATELLITE_ENABLED_BY_USER column in SubscriptionInfoInteral.

Bug: 291302444
Test: atest android.telephony.cts.SubscriptionManagerTest,
      atest FrameworkTelephonyTestCases

Change-Id: I1f74ec059e6c7b9699540c0253ba068618da54e4
parent 047f30de
Loading
Loading
Loading
Loading
+33 −4
Original line number Diff line number Diff line
@@ -274,7 +274,11 @@ public class SubscriptionDatabaseManager extends Handler {
                    SubscriptionInfoInternal::getUserId),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_SATELLITE_ENABLED,
                    SubscriptionInfoInternal::getSatelliteEnabled)
                    SubscriptionInfoInternal::getSatelliteEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
                    SubscriptionInfoInternal::getSatelliteAttachEnabledForCarrier)

    );

    /**
@@ -399,7 +403,10 @@ public class SubscriptionDatabaseManager extends Handler {
                    SubscriptionDatabaseManager::setUserId),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_SATELLITE_ENABLED,
                    SubscriptionDatabaseManager::setSatelliteEnabled)
                    SubscriptionDatabaseManager::setSatelliteEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
                    SubscriptionDatabaseManager::setSatelliteAttachEnabledForCarrier)
    );

    /**
@@ -508,7 +515,9 @@ public class SubscriptionDatabaseManager extends Handler {
            SimInfo.COLUMN_VOIMS_OPT_IN_STATUS,
            SimInfo.COLUMN_D2D_STATUS_SHARING_SELECTED_CONTACTS,
            SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED,
            SimInfo.COLUMN_USER_HANDLE
            SimInfo.COLUMN_USER_HANDLE,
            SimInfo.COLUMN_SATELLITE_ENABLED,
            SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER
    );

    /**
@@ -1987,6 +1996,23 @@ public class SubscriptionDatabaseManager extends Handler {
                SubscriptionInfoInternal.Builder::setSatelliteEnabled);
    }

    /**
     * Set whether satellite attach for carrier is enabled or disabled by user.
     *
     * @param subId Subscription id.
     * @param isSatelliteAttachEnabledForCarrier Whether satellite attach for carrier is enabled or
     * disabled.
     *
     * @throws IllegalArgumentException if the subscription does not exist.
     */
    public void setSatelliteAttachEnabledForCarrier(int subId,
            int isSatelliteAttachEnabledForCarrier) {
        writeDatabaseAndCacheHelper(subId,
                SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
                isSatelliteAttachEnabledForCarrier,
                SubscriptionInfoInternal.Builder::setSatelliteAttachEnabledForCarrier);
    }

    /**
     * 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)
@@ -2243,7 +2269,10 @@ public class SubscriptionDatabaseManager extends Handler {
                .setUserId(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_USER_HANDLE)))
                .setSatelliteEnabled(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_SATELLITE_ENABLED)));
                        SimInfo.COLUMN_SATELLITE_ENABLED)))
                .setSatelliteAttachEnabledForCarrier(cursor.getInt(
                        cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER)));
        return builder.build();
    }

+39 −2
Original line number Diff line number Diff line
@@ -442,6 +442,12 @@ public class SubscriptionInfoInternal {
     */
    private final int mIsSatelliteEnabled;

    /**
     * Whether satellite attach for carrier is enabled or disabled by user.
     * By default, its disabled. It is intended to use integer to fit the database format.
     */
    private final int mIsSatelliteAttachEnabledForCarrier;

    // 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}.
@@ -524,6 +530,8 @@ public class SubscriptionInfoInternal {
        this.mLastUsedTPMessageReference = builder.mLastUsedTPMessageReference;
        this.mUserId = builder.mUserId;
        this.mIsSatelliteEnabled = builder.mIsSatelliteEnabled;
        this.mIsSatelliteAttachEnabledForCarrier =
                builder.mIsSatelliteAttachEnabledForCarrier;

        // Below are the fields that do not exist in the SimInfo table.
        this.mCardId = builder.mCardId;
@@ -1128,6 +1136,13 @@ public class SubscriptionInfoInternal {
        return mIsSatelliteEnabled;
    }

    /**
     * @return {@code 1} if satellite attach for carrier is enabled by user.
     */
    public int getSatelliteAttachEnabledForCarrier() {
        return mIsSatelliteAttachEnabledForCarrier;
    }

    // Below are the fields that do not exist in SimInfo table.
    /**
     * @return The card ID of the SIM card which contains the subscription.
@@ -1253,6 +1268,7 @@ public class SubscriptionInfoInternal {
                + " numberFromIms=" + Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, mNumberFromIms)
                + " userId=" + mUserId
                + " isSatelliteEnabled=" + mIsSatelliteEnabled
                + " satellite_attach_enabled_for_carrier=" + mIsSatelliteAttachEnabledForCarrier
                + " isGroupDisabled=" + mIsGroupDisabled
                + "]";
    }
@@ -1308,7 +1324,8 @@ public class SubscriptionInfoInternal {
                mRcsConfig, that.mRcsConfig) && mAllowedNetworkTypesForReasons.equals(
                that.mAllowedNetworkTypesForReasons) && mDeviceToDeviceStatusSharingContacts.equals(
                that.mDeviceToDeviceStatusSharingContacts) && mNumberFromCarrier.equals(
                that.mNumberFromCarrier) && mNumberFromIms.equals(that.mNumberFromIms);
                that.mNumberFromCarrier) && mNumberFromIms.equals(that.mNumberFromIms)
                && mIsSatelliteAttachEnabledForCarrier == that.mIsSatelliteAttachEnabledForCarrier;
    }

    @Override
@@ -1329,7 +1346,8 @@ public class SubscriptionInfoInternal {
                mDeviceToDeviceStatusSharingContacts, mIsNrAdvancedCallingEnabled,
                mNumberFromCarrier,
                mNumberFromIms, mPortIndex, mUsageSetting, mLastUsedTPMessageReference, mUserId,
                mIsSatelliteEnabled, mCardId, mIsGroupDisabled);
                mIsSatelliteEnabled, mCardId, mIsGroupDisabled,
                mIsSatelliteAttachEnabledForCarrier);
        result = 31 * result + Arrays.hashCode(mNativeAccessRules);
        result = 31 * result + Arrays.hashCode(mCarrierConfigAccessRules);
        result = 31 * result + Arrays.hashCode(mRcsConfig);
@@ -1692,6 +1710,11 @@ public class SubscriptionInfoInternal {
         */
        private int mIsSatelliteEnabled = -1;

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

        // The following fields do not exist in the SimInfo table.
        /**
         * The card ID of the SIM card which contains the subscription.
@@ -1779,6 +1802,7 @@ public class SubscriptionInfoInternal {
            mLastUsedTPMessageReference = info.getLastUsedTPMessageReference();
            mUserId = info.mUserId;
            mIsSatelliteEnabled = info.mIsSatelliteEnabled;
            mIsSatelliteAttachEnabledForCarrier = info.mIsSatelliteAttachEnabledForCarrier;
            // Below are the fields that do not exist in the SimInfo table.
            mCardId = info.mCardId;
            mIsGroupDisabled = info.mIsGroupDisabled;
@@ -2649,6 +2673,19 @@ public class SubscriptionInfoInternal {
            return this;
        }

        /**
         * Set whether satellite attach for carrier is enabled or disabled by user.
         * @param isSatelliteAttachEnabledForCarrier {@code 1} if satellite attach for carrier is
         * enabled.
         * @return The builder.
         */
        @NonNull
        public Builder setSatelliteAttachEnabledForCarrier(
                @NonNull int isSatelliteAttachEnabledForCarrier) {
            mIsSatelliteAttachEnabledForCarrier = isSatelliteAttachEnabledForCarrier;
            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.
+2 −1
Original line number Diff line number Diff line
@@ -173,7 +173,8 @@ public class SubscriptionManagerService extends ISub.Stub {
            SimInfo.COLUMN_VOIMS_OPT_IN_STATUS,
            SimInfo.COLUMN_D2D_STATUS_SHARING_SELECTED_CONTACTS,
            SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED,
            SimInfo.COLUMN_SATELLITE_ENABLED
            SimInfo.COLUMN_SATELLITE_ENABLED,
            SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER
    );

    /**
+4 −1
Original line number Diff line number Diff line
@@ -127,7 +127,10 @@ public class FakeTelephonyProvider extends MockContentProvider {
                    + "," + Telephony.SimInfo.COLUMN_TP_MESSAGE_REF
                    + "  INTEGER DEFAULT -1,"
                    + Telephony.SimInfo.COLUMN_USER_HANDLE + " INTEGER DEFAULT "
                    + UserHandle.USER_NULL
                    + UserHandle.USER_NULL + ","
                    + Telephony.SimInfo.COLUMN_SATELLITE_ENABLED + " INTEGER DEFAULT -1,"
                    + Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER
                    + " INTEGER DEFAULT -1"
                    + ");";
        }

+41 −0
Original line number Diff line number Diff line
@@ -117,6 +117,8 @@ public class SubscriptionDatabaseManagerTest extends TelephonyTest {
    static final int FAKE_TP_MESSAGE_REFERENCE2 = 456;
    static final int FAKE_USER_ID1 = 10;
    static final int FAKE_USER_ID2 = 11;
    static final int FAKE_SATELLITE_ATTACH_FOR_CARRIER_ENABLED = 1;
    static final int FAKE_SATELLITE_ATTACH_FOR_CARRIER_DISABLED = 0;

    static final String FAKE_MAC_ADDRESS1 = "DC:E5:5B:38:7D:40";
    static final String FAKE_MAC_ADDRESS2 = "DC:B5:4F:47:F3:4C";
@@ -186,6 +188,8 @@ public class SubscriptionDatabaseManagerTest extends TelephonyTest {
                    .setLastUsedTPMessageReference(FAKE_TP_MESSAGE_REFERENCE1)
                    .setUserId(FAKE_USER_ID1)
                    .setSatelliteEnabled(0)
                    .setSatelliteAttachEnabledForCarrier(
                            FAKE_SATELLITE_ATTACH_FOR_CARRIER_DISABLED)
                    .setGroupDisabled(false)
                    .build();

@@ -254,6 +258,8 @@ public class SubscriptionDatabaseManagerTest extends TelephonyTest {
                    .setLastUsedTPMessageReference(FAKE_TP_MESSAGE_REFERENCE2)
                    .setUserId(FAKE_USER_ID2)
                    .setSatelliteEnabled(1)
                    .setSatelliteAttachEnabledForCarrier(
                            FAKE_SATELLITE_ATTACH_FOR_CARRIER_ENABLED)
                    .setGroupDisabled(false)
                    .build();

@@ -1929,6 +1935,41 @@ public class SubscriptionDatabaseManagerTest extends TelephonyTest {
                .isEqualTo(0);
    }

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

        SubscriptionInfoInternal subInfo = insertSubscriptionAndVerify(FAKE_SUBSCRIPTION_INFO1);
        mDatabaseManagerUT.setSatelliteAttachEnabledForCarrier(
                FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(),
                FAKE_SATELLITE_ATTACH_FOR_CARRIER_ENABLED);
        processAllMessages();

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

        assertThat(mDatabaseManagerUT.getSubscriptionProperty(
                FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(),
                SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER))
                .isEqualTo(FAKE_SATELLITE_ATTACH_FOR_CARRIER_ENABLED);

        mDatabaseManagerUT.setSubscriptionProperty(FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(),
                SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
                FAKE_SATELLITE_ATTACH_FOR_CARRIER_DISABLED);
        assertThat(mDatabaseManagerUT.getSubscriptionInfoInternal(
                FAKE_SUBSCRIPTION_INFO1.getSubscriptionId())
                .getSatelliteAttachEnabledForCarrier())
                .isEqualTo(FAKE_SATELLITE_ATTACH_FOR_CARRIER_DISABLED);
    }

    @Test
    public void testUpdateSubscriptionsInGroup() throws Exception {
        insertSubscriptionAndVerify(FAKE_SUBSCRIPTION_INFO1);
Loading