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

Commit 7b7ba40e authored by Aishwarya Mallampati's avatar Aishwarya Mallampati Committed by Jack Yu
Browse files

Add SubscriptionManager APIs for satellite communication.

The following changes are made:
- Added new SATELLITE_ENABLED column in SubscriptionInfoInteral.
- Added SubscriptionManagerService#setSatelliteEnabled.

Bug: 263502414
Test: atest android.telephony.cts.SubscriptionManagerTest,
      atest FrameworkTelephonyTestCases
Merged-In: I5e43b8bd94694b5f5a9af523a81be8cc94c8a719
Change-Id: I5e43b8bd94694b5f5a9af523a81be8cc94c8a719
parent 80f016c2
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -3213,6 +3213,7 @@ public class SubscriptionController extends ISub.Stub {
            case SubscriptionManager.NR_ADVANCED_CALLING_ENABLED:
            case SubscriptionManager.USAGE_SETTING:
            case SubscriptionManager.USER_HANDLE:
            case SubscriptionManager.SATELLITE_ENABLED:
                value.put(propKey, Integer.parseInt(propValue));
                break;
            case SubscriptionManager.ALLOWED_NETWORK_TYPES:
@@ -3310,6 +3311,7 @@ public class SubscriptionController extends ISub.Stub {
                        case SimInfo.COLUMN_PHONE_NUMBER_SOURCE_IMS:
                        case SubscriptionManager.USAGE_SETTING:
                        case SubscriptionManager.USER_HANDLE:
                        case SubscriptionManager.SATELLITE_ENABLED:
                            resultValue = cursor.getString(0);
                            break;
                        default:
+25 −4
Original line number Diff line number Diff line
@@ -232,7 +232,10 @@ public class SubscriptionDatabaseManager extends Handler {
                    SubscriptionInfoInternal::getLastUsedTPMessageReference),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_USER_HANDLE,
                    SubscriptionInfoInternal::getUserId)
                    SubscriptionInfoInternal::getUserId),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_SATELLITE_ENABLED,
                    SubscriptionInfoInternal::getSatelliteEnabled)
    );

    /**
@@ -318,7 +321,10 @@ public class SubscriptionDatabaseManager extends Handler {
                    SubscriptionDatabaseManager::setLastUsedTPMessageReference),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_USER_HANDLE,
                    SubscriptionDatabaseManager::setUserId)
                    SubscriptionDatabaseManager::setUserId),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_SATELLITE_ENABLED,
                    SubscriptionDatabaseManager::setSatelliteEnabled)
    );

    /**
@@ -1678,6 +1684,20 @@ public class SubscriptionDatabaseManager extends Handler {
                SubscriptionInfoInternal.Builder::setUserId);
    }

    /**
     * Set whether satellite is enabled or not.
     *
     * @param subId Subscription id.
     * @param isSatelliteEnabled if satellite is enabled or not.
     *
     * @throws IllegalArgumentException if the subscription does not exist.
     */
    public void setSatelliteEnabled(int subId, int isSatelliteEnabled) {
        writeDatabaseAndCacheHelper(subId, SimInfo.COLUMN_SATELLITE_ENABLED,
                isSatelliteEnabled,
                SubscriptionInfoInternal.Builder::setSatelliteEnabled);
    }

    /**
     * Load the entire database into the cache.
     */
@@ -1833,8 +1853,9 @@ public class SubscriptionDatabaseManager extends Handler {
                .setLastUsedTPMessageReference(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_TP_MESSAGE_REF)))
                .setUserId(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_USER_HANDLE)));

                        SimInfo.COLUMN_USER_HANDLE)))
                .setSatelliteEnabled(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_SATELLITE_ENABLED)));
        return builder.build();
    }

+35 −2
Original line number Diff line number Diff line
@@ -376,6 +376,12 @@ public class SubscriptionInfoInternal {
     */
    private final int mUserId;

    /**
     * Whether satellite is enabled or disabled.
     * By default, its disabled. It is intended to use integer to fit the database format.
     */
    private final int mIsSatelliteEnabled;

    // 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}.
@@ -445,6 +451,7 @@ public class SubscriptionInfoInternal {
        this.mUsageSetting = builder.mUsageSetting;
        this.mLastUsedTPMessageReference = builder.mLastUsedTPMessageReference;
        this.mUserId = builder.mUserId;
        this.mIsSatelliteEnabled = builder.mIsSatelliteEnabled;

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

    /**
     * @return {@code 1} if satellite is enabled.
     */
    public int getSatelliteEnabled() {
        return mIsSatelliteEnabled;
    }

    // Below are the fields that do not exist in SimInfo table.
    /**
     * @return The card ID of the SIM card which contains the subscription.
@@ -1102,6 +1116,7 @@ public class SubscriptionInfoInternal {
                + " numberFromCarrier=" + mNumberFromCarrier
                + " numberFromIms=" + mNumberFromIms
                + " userId=" + mUserId
                + " isSatelliteEnabled=" + mIsSatelliteEnabled
                + " isGroupDisabled=" + mIsGroupDisabled
                + "]";
    }
@@ -1148,7 +1163,8 @@ public class SubscriptionInfoInternal {
                && mAllowedNetworkTypesForReasons.equals(that.mAllowedNetworkTypesForReasons)
                && mDeviceToDeviceStatusSharingContacts.equals(
                that.mDeviceToDeviceStatusSharingContacts) && mNumberFromCarrier.equals(
                that.mNumberFromCarrier) && mNumberFromIms.equals(that.mNumberFromIms);
                that.mNumberFromCarrier) && mNumberFromIms.equals(that.mNumberFromIms)
                && mIsSatelliteEnabled == that.mIsSatelliteEnabled;
    }

    @Override
@@ -1165,7 +1181,7 @@ public class SubscriptionInfoInternal {
                mDeviceToDeviceStatusSharingContacts, mIsNrAdvancedCallingEnabled,
                mNumberFromCarrier,
                mNumberFromIms, mPortIndex, mUsageSetting, mLastUsedTPMessageReference, mUserId,
                mCardId, mIsGroupDisabled);
                mIsSatelliteEnabled, mCardId, mIsGroupDisabled);
        result = 31 * result + Arrays.hashCode(mNativeAccessRules);
        result = 31 * result + Arrays.hashCode(mCarrierConfigAccessRules);
        result = 31 * result + Arrays.hashCode(mRcsConfig);
@@ -1463,6 +1479,11 @@ public class SubscriptionInfoInternal {
         */
        private int mUserId = UserHandle.USER_NULL;

        /**
         * Whether satellite is enabled or not.
         */
        private int mIsSatelliteEnabled = -1;

        // The following fields do not exist in the SimInfo table.
        /**
         * The card ID of the SIM card which contains the subscription.
@@ -1537,6 +1558,7 @@ public class SubscriptionInfoInternal {
            mUsageSetting = info.mUsageSetting;
            mLastUsedTPMessageReference = info.getLastUsedTPMessageReference();
            mUserId = info.mUserId;
            mIsSatelliteEnabled = info.mIsSatelliteEnabled;
            // Below are the fields that do not exist in the SimInfo table.
            mCardId = info.mCardId;
            mIsGroupDisabled = info.mIsGroupDisabled;
@@ -2231,6 +2253,17 @@ public class SubscriptionInfoInternal {
            return this;
        }

        /**
         * Set whether satellite is enabled or not.
         * @param isSatelliteEnabled {@code 1} if satellite is enabled.
         * @return The builder.
         */
        @NonNull
        public Builder setSatelliteEnabled(int isSatelliteEnabled) {
            mIsSatelliteEnabled = isSatelliteEnabled;
            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
@@ -140,7 +140,8 @@ public class SubscriptionManagerService extends ISub.Stub {
            SimInfo.COLUMN_D2D_STATUS_SHARING,
            SimInfo.COLUMN_VOIMS_OPT_IN_STATUS,
            SimInfo.COLUMN_D2D_STATUS_SHARING_SELECTED_CONTACTS,
            SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED
            SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED,
            SimInfo.COLUMN_SATELLITE_ENABLED
    );

    /**
+29 −0
Original line number Diff line number Diff line
@@ -165,6 +165,7 @@ public class SubscriptionDatabaseManagerTest extends TelephonyTest {
                    .setUsageSetting(SubscriptionManager.USAGE_SETTING_DEFAULT)
                    .setLastUsedTPMessageReference(FAKE_TP_MESSAGE_REFERENCE1)
                    .setUserId(FAKE_USER_ID1)
                    .setSatelliteEnabled(0)
                    .setGroupDisabled(false)
                    .build();

@@ -220,6 +221,7 @@ public class SubscriptionDatabaseManagerTest extends TelephonyTest {
                    .setUsageSetting(SubscriptionManager.USAGE_SETTING_DATA_CENTRIC)
                    .setLastUsedTPMessageReference(FAKE_TP_MESSAGE_REFERENCE2)
                    .setUserId(FAKE_USER_ID2)
                    .setSatelliteEnabled(1)
                    .setGroupDisabled(false)
                    .build();

@@ -1553,6 +1555,33 @@ public class SubscriptionDatabaseManagerTest extends TelephonyTest {
                .getUserId()).isEqualTo(FAKE_USER_ID1);
    }

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

        SubscriptionInfoInternal subInfo = insertSubscriptionAndVerify(FAKE_SUBSCRIPTION_INFO1);
        mDatabaseManagerUT.setSatelliteEnabled(FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(),
                1);
        processAllMessages();

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

        assertThat(mDatabaseManagerUT.getSubscriptionProperty(
                FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(), SimInfo.COLUMN_SATELLITE_ENABLED))
                .isEqualTo(1);

        mDatabaseManagerUT.setSubscriptionProperty(FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(),
                SimInfo.COLUMN_SATELLITE_ENABLED, 0);
        assertThat(mDatabaseManagerUT.getSubscriptionInfoInternal(
                FAKE_SUBSCRIPTION_INFO1.getSubscriptionId()).getSatelliteEnabled())
                .isEqualTo(0);
    }

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