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

Commit f0b582a4 authored by Jack Yu's avatar Jack Yu Committed by Gerrit Code Review
Browse files

Merge "Add SubscriptionManager APIs for satellite communication."

parents 80f016c2 7b7ba40e
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -3213,6 +3213,7 @@ public class SubscriptionController extends ISub.Stub {
            case SubscriptionManager.NR_ADVANCED_CALLING_ENABLED:
            case SubscriptionManager.NR_ADVANCED_CALLING_ENABLED:
            case SubscriptionManager.USAGE_SETTING:
            case SubscriptionManager.USAGE_SETTING:
            case SubscriptionManager.USER_HANDLE:
            case SubscriptionManager.USER_HANDLE:
            case SubscriptionManager.SATELLITE_ENABLED:
                value.put(propKey, Integer.parseInt(propValue));
                value.put(propKey, Integer.parseInt(propValue));
                break;
                break;
            case SubscriptionManager.ALLOWED_NETWORK_TYPES:
            case SubscriptionManager.ALLOWED_NETWORK_TYPES:
@@ -3310,6 +3311,7 @@ public class SubscriptionController extends ISub.Stub {
                        case SimInfo.COLUMN_PHONE_NUMBER_SOURCE_IMS:
                        case SimInfo.COLUMN_PHONE_NUMBER_SOURCE_IMS:
                        case SubscriptionManager.USAGE_SETTING:
                        case SubscriptionManager.USAGE_SETTING:
                        case SubscriptionManager.USER_HANDLE:
                        case SubscriptionManager.USER_HANDLE:
                        case SubscriptionManager.SATELLITE_ENABLED:
                            resultValue = cursor.getString(0);
                            resultValue = cursor.getString(0);
                            break;
                            break;
                        default:
                        default:
+25 −4
Original line number Original line Diff line number Diff line
@@ -232,7 +232,10 @@ public class SubscriptionDatabaseManager extends Handler {
                    SubscriptionInfoInternal::getLastUsedTPMessageReference),
                    SubscriptionInfoInternal::getLastUsedTPMessageReference),
            new AbstractMap.SimpleImmutableEntry<>(
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_USER_HANDLE,
                    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),
                    SubscriptionDatabaseManager::setLastUsedTPMessageReference),
            new AbstractMap.SimpleImmutableEntry<>(
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_USER_HANDLE,
                    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);
                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.
     * Load the entire database into the cache.
     */
     */
@@ -1833,8 +1853,9 @@ public class SubscriptionDatabaseManager extends Handler {
                .setLastUsedTPMessageReference(cursor.getInt(cursor.getColumnIndexOrThrow(
                .setLastUsedTPMessageReference(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_TP_MESSAGE_REF)))
                        SimInfo.COLUMN_TP_MESSAGE_REF)))
                .setUserId(cursor.getInt(cursor.getColumnIndexOrThrow(
                .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();
        return builder.build();
    }
    }


+35 −2
Original line number Original line Diff line number Diff line
@@ -376,6 +376,12 @@ public class SubscriptionInfoInternal {
     */
     */
    private final int mUserId;
    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.
    // 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}.
     * 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.mUsageSetting = builder.mUsageSetting;
        this.mLastUsedTPMessageReference = builder.mLastUsedTPMessageReference;
        this.mLastUsedTPMessageReference = builder.mLastUsedTPMessageReference;
        this.mUserId = builder.mUserId;
        this.mUserId = builder.mUserId;
        this.mIsSatelliteEnabled = builder.mIsSatelliteEnabled;


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


    @Override
    @Override
@@ -1165,7 +1181,7 @@ public class SubscriptionInfoInternal {
                mDeviceToDeviceStatusSharingContacts, mIsNrAdvancedCallingEnabled,
                mDeviceToDeviceStatusSharingContacts, mIsNrAdvancedCallingEnabled,
                mNumberFromCarrier,
                mNumberFromCarrier,
                mNumberFromIms, mPortIndex, mUsageSetting, mLastUsedTPMessageReference, mUserId,
                mNumberFromIms, mPortIndex, mUsageSetting, mLastUsedTPMessageReference, mUserId,
                mCardId, mIsGroupDisabled);
                mIsSatelliteEnabled, mCardId, mIsGroupDisabled);
        result = 31 * result + Arrays.hashCode(mNativeAccessRules);
        result = 31 * result + Arrays.hashCode(mNativeAccessRules);
        result = 31 * result + Arrays.hashCode(mCarrierConfigAccessRules);
        result = 31 * result + Arrays.hashCode(mCarrierConfigAccessRules);
        result = 31 * result + Arrays.hashCode(mRcsConfig);
        result = 31 * result + Arrays.hashCode(mRcsConfig);
@@ -1463,6 +1479,11 @@ public class SubscriptionInfoInternal {
         */
         */
        private int mUserId = UserHandle.USER_NULL;
        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 following fields do not exist in the SimInfo table.
        /**
        /**
         * The card ID of the SIM card which contains the subscription.
         * The card ID of the SIM card which contains the subscription.
@@ -1537,6 +1558,7 @@ public class SubscriptionInfoInternal {
            mUsageSetting = info.mUsageSetting;
            mUsageSetting = info.mUsageSetting;
            mLastUsedTPMessageReference = info.getLastUsedTPMessageReference();
            mLastUsedTPMessageReference = info.getLastUsedTPMessageReference();
            mUserId = info.mUserId;
            mUserId = info.mUserId;
            mIsSatelliteEnabled = info.mIsSatelliteEnabled;
            // Below are the fields that do not exist in the SimInfo table.
            // Below are the fields that do not exist in the SimInfo table.
            mCardId = info.mCardId;
            mCardId = info.mCardId;
            mIsGroupDisabled = info.mIsGroupDisabled;
            mIsGroupDisabled = info.mIsGroupDisabled;
@@ -2231,6 +2253,17 @@ public class SubscriptionInfoInternal {
            return this;
            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.
        // Below are the fields that do not exist in the SimInfo table.
        /**
        /**
         * Set the card ID of the SIM card which contains the subscription.
         * Set the card ID of the SIM card which contains the subscription.
+2 −1
Original line number Original line Diff line number Diff line
@@ -140,7 +140,8 @@ public class SubscriptionManagerService extends ISub.Stub {
            SimInfo.COLUMN_D2D_STATUS_SHARING,
            SimInfo.COLUMN_D2D_STATUS_SHARING,
            SimInfo.COLUMN_VOIMS_OPT_IN_STATUS,
            SimInfo.COLUMN_VOIMS_OPT_IN_STATUS,
            SimInfo.COLUMN_D2D_STATUS_SHARING_SELECTED_CONTACTS,
            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 Original line Diff line number Diff line
@@ -165,6 +165,7 @@ public class SubscriptionDatabaseManagerTest extends TelephonyTest {
                    .setUsageSetting(SubscriptionManager.USAGE_SETTING_DEFAULT)
                    .setUsageSetting(SubscriptionManager.USAGE_SETTING_DEFAULT)
                    .setLastUsedTPMessageReference(FAKE_TP_MESSAGE_REFERENCE1)
                    .setLastUsedTPMessageReference(FAKE_TP_MESSAGE_REFERENCE1)
                    .setUserId(FAKE_USER_ID1)
                    .setUserId(FAKE_USER_ID1)
                    .setSatelliteEnabled(0)
                    .setGroupDisabled(false)
                    .setGroupDisabled(false)
                    .build();
                    .build();


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


@@ -1553,6 +1555,33 @@ public class SubscriptionDatabaseManagerTest extends TelephonyTest {
                .getUserId()).isEqualTo(FAKE_USER_ID1);
                .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
    @Test
    public void testUpdateSubscriptionsInGroup() throws Exception {
    public void testUpdateSubscriptionsInGroup() throws Exception {
        insertSubscriptionAndVerify(FAKE_SUBSCRIPTION_INFO1);
        insertSubscriptionAndVerify(FAKE_SUBSCRIPTION_INFO1);
Loading