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

Commit 1f936285 authored by Jack Yu's avatar Jack Yu
Browse files

Support legacy cell broadcast fields

Supported legacy cell broadcast settings in subscription
manager.

Fix: 273343840
Test: atest SubscriptionManagerServiceTest SubscriptionDatabaseManagerTest
      SubscriptionDatabaseManagerTest
Change-Id: I76c0667651214df432b71a2d43acdcff4b2fac85
parent 19745e77
Loading
Loading
Loading
Loading
+270 −12
Original line number Diff line number Diff line
@@ -147,6 +147,42 @@ public class SubscriptionDatabaseManager extends Handler {
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_IS_REMOVABLE,
                    SubscriptionInfoInternal::getRemovableEmbedded),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_EXTREME_THREAT_ALERT,
                    SubscriptionInfoInternal::getCellBroadcastExtremeThreatAlertEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_SEVERE_THREAT_ALERT,
                    SubscriptionInfoInternal::getCellBroadcastSevereThreatAlertEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_AMBER_ALERT,
                    SubscriptionInfoInternal::getCellBroadcastAmberAlertEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_EMERGENCY_ALERT,
                    SubscriptionInfoInternal::getCellBroadcastEmergencyAlertEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_ALERT_SOUND_DURATION,
                    SubscriptionInfoInternal::getCellBroadcastAlertSoundDuration),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_ALERT_REMINDER_INTERVAL,
                    SubscriptionInfoInternal::getCellBroadcastAlertReminderInterval),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_ALERT_VIBRATE,
                    SubscriptionInfoInternal::getCellBroadcastAlertVibrationEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_ALERT_SPEECH,
                    SubscriptionInfoInternal::getCellBroadcastAlertSpeechEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_ETWS_TEST_ALERT,
                    SubscriptionInfoInternal::getCellBroadcastEtwsTestAlertEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_CHANNEL_50_ALERT,
                    SubscriptionInfoInternal::getCellBroadcastAreaInfoMessageEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_CMAS_TEST_ALERT,
                    SubscriptionInfoInternal::getCellBroadcastTestAlertEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_OPT_OUT_DIALOG,
                    SubscriptionInfoInternal::getCellBroadcastOptOutDialogEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_ENHANCED_4G_MODE_ENABLED,
                    SubscriptionInfoInternal::getEnhanced4GModeEnabled),
@@ -266,6 +302,42 @@ public class SubscriptionDatabaseManager extends Handler {
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_IS_REMOVABLE,
                    SubscriptionDatabaseManager::setRemovableEmbedded),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_EXTREME_THREAT_ALERT,
                    SubscriptionDatabaseManager::setCellBroadcastExtremeThreatAlertEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_SEVERE_THREAT_ALERT,
                    SubscriptionDatabaseManager::setCellBroadcastSevereThreatAlertEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_AMBER_ALERT,
                    SubscriptionDatabaseManager::setCellBroadcastAmberAlertEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_EMERGENCY_ALERT,
                    SubscriptionDatabaseManager::setCellBroadcastEmergencyAlertEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_ALERT_SOUND_DURATION,
                    SubscriptionDatabaseManager::setCellBroadcastAlertSoundDuration),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_ALERT_REMINDER_INTERVAL,
                    SubscriptionDatabaseManager::setCellBroadcastAlertReminderInterval),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_ALERT_VIBRATE,
                    SubscriptionDatabaseManager::setCellBroadcastAlertVibrationEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_ALERT_SPEECH,
                    SubscriptionDatabaseManager::setCellBroadcastAlertSpeechEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_ETWS_TEST_ALERT,
                    SubscriptionDatabaseManager::setCellBroadcastEtwsTestAlertEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_CHANNEL_50_ALERT,
                    SubscriptionDatabaseManager::setCellBroadcastAreaInfoMessageEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_CMAS_TEST_ALERT,
                    SubscriptionDatabaseManager::setCellBroadcastTestAlertEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_CB_OPT_OUT_DIALOG,
                    SubscriptionDatabaseManager::setCellBroadcastOptOutDialogEnabled),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_ENHANCED_4G_MODE_ENABLED,
                    SubscriptionDatabaseManager::setEnhanced4GModeEnabled),
@@ -449,18 +521,6 @@ public class SubscriptionDatabaseManager extends Handler {
            SimInfo.COLUMN_MCC,
            SimInfo.COLUMN_MNC,
            SimInfo.COLUMN_SIM_PROVISIONING_STATUS,
            SimInfo.COLUMN_CB_EXTREME_THREAT_ALERT,
            SimInfo.COLUMN_CB_SEVERE_THREAT_ALERT,
            SimInfo.COLUMN_CB_AMBER_ALERT,
            SimInfo.COLUMN_CB_EMERGENCY_ALERT,
            SimInfo.COLUMN_CB_ALERT_SOUND_DURATION,
            SimInfo.COLUMN_CB_ALERT_REMINDER_INTERVAL,
            SimInfo.COLUMN_CB_ALERT_VIBRATE,
            SimInfo.COLUMN_CB_ALERT_SPEECH,
            SimInfo.COLUMN_CB_ETWS_TEST_ALERT,
            SimInfo.COLUMN_CB_CHANNEL_50_ALERT,
            SimInfo.COLUMN_CB_CMAS_TEST_ALERT,
            SimInfo.COLUMN_CB_OPT_OUT_DIALOG,
            SimInfo.COLUMN_IS_METERED,
            SimInfo.COLUMN_DATA_ENABLED_OVERRIDE_RULES,
            SimInfo.COLUMN_ALLOWED_NETWORK_TYPES
@@ -1287,6 +1347,180 @@ public class SubscriptionDatabaseManager extends Handler {
                SubscriptionInfoInternal.Builder::setRemovableEmbedded);
    }

    /**
     * Set whether cell broadcast extreme threat alert is enabled by the user or not.
     *
     * @param subId Subscription id.
     * @param isExtremeThreatAlertEnabled whether cell broadcast extreme threat alert is enabled by
     * the user or not.
     *
     * @throws IllegalArgumentException if the subscription does not exist.
     */
    public void setCellBroadcastExtremeThreatAlertEnabled(int subId,
            int isExtremeThreatAlertEnabled) {
        writeDatabaseAndCacheHelper(subId, SimInfo.COLUMN_CB_EXTREME_THREAT_ALERT,
                isExtremeThreatAlertEnabled,
                SubscriptionInfoInternal.Builder::setCellBroadcastExtremeThreatAlertEnabled);
    }

    /**
     * Set whether cell broadcast severe threat alert is enabled by the user or not.
     *
     * @param subId Subscription id.
     * @param isSevereThreatAlertEnabled whether cell broadcast severe threat alert is enabled by
     * the user or not.
     *
     * @throws IllegalArgumentException if the subscription does not exist.
     */
    public void setCellBroadcastSevereThreatAlertEnabled(int subId,
            int isSevereThreatAlertEnabled) {
        writeDatabaseAndCacheHelper(subId, SimInfo.COLUMN_CB_SEVERE_THREAT_ALERT,
                isSevereThreatAlertEnabled,
                SubscriptionInfoInternal.Builder::setCellBroadcastSevereThreatAlertEnabled);
    }

    /**
     * Set whether cell broadcast amber alert is enabled by the user or not.
     *
     * @param subId Subscription id.
     * @param isAmberAlertEnabled whether cell broadcast amber alert is enabled by
     * the user or not.
     *
     * @throws IllegalArgumentException if the subscription does not exist.
     */
    public void setCellBroadcastAmberAlertEnabled(int subId, int isAmberAlertEnabled) {
        writeDatabaseAndCacheHelper(subId, SimInfo.COLUMN_CB_AMBER_ALERT, isAmberAlertEnabled,
                SubscriptionInfoInternal.Builder::setCellBroadcastAmberAlertEnabled);
    }

    /**
     * Set whether cell broadcast emergency alert is enabled by the user or not.
     *
     * @param subId Subscription id.
     * @param isEmergencyAlertEnabled whether cell broadcast emergency alert is enabled by
     * the user or not.
     *
     * @throws IllegalArgumentException if the subscription does not exist.
     */
    public void setCellBroadcastEmergencyAlertEnabled(int subId,
            int isEmergencyAlertEnabled) {
        writeDatabaseAndCacheHelper(subId, SimInfo.COLUMN_CB_EMERGENCY_ALERT,
                isEmergencyAlertEnabled,
                SubscriptionInfoInternal.Builder::setCellBroadcastEmergencyAlertEnabled);
    }

    /**
     * Set cell broadcast alert sound duration.
     *
     * @param subId Subscription id.
     * @param alertSoundDuration Alert sound duration in seconds.
     *
     * @throws IllegalArgumentException if the subscription does not exist.
     */
    public void setCellBroadcastAlertSoundDuration(int subId, int alertSoundDuration) {
        writeDatabaseAndCacheHelper(subId, SimInfo.COLUMN_CB_ALERT_SOUND_DURATION,
                alertSoundDuration,
                SubscriptionInfoInternal.Builder::setCellBroadcastAlertSoundDuration);
    }

    /**
     * Set cell broadcast alert reminder interval.
     *
     * @param subId Subscription id.
     * @param reminderInterval Alert reminder interval in milliseconds.
     *
     * @throws IllegalArgumentException if the subscription does not exist.
     */
    public void setCellBroadcastAlertReminderInterval(int subId, int reminderInterval) {
        writeDatabaseAndCacheHelper(subId, SimInfo.COLUMN_CB_ALERT_REMINDER_INTERVAL,
                reminderInterval,
                SubscriptionInfoInternal.Builder::setCellBroadcastAlertReminderInterval);
    }

    /**
     * Set whether cell broadcast alert vibration is enabled by the user or not.
     *
     * @param subId Subscription id.
     * @param isAlertVibrationEnabled whether cell broadcast alert vibration is enabled by the user
     * or not.
     *
     * @throws IllegalArgumentException if the subscription does not exist.
     */
    public void setCellBroadcastAlertVibrationEnabled(int subId, int isAlertVibrationEnabled) {
        writeDatabaseAndCacheHelper(subId, SimInfo.COLUMN_CB_ALERT_VIBRATE, isAlertVibrationEnabled,
                SubscriptionInfoInternal.Builder::setCellBroadcastAlertVibrationEnabled);
    }

    /**
     * Set whether cell broadcast alert speech is enabled by the user or not.
     *
     * @param subId Subscription id.
     * @param isAlertSpeechEnabled whether cell broadcast alert speech is enabled by the user or
     * not.
     *
     * @throws IllegalArgumentException if the subscription does not exist.
     */
    public void setCellBroadcastAlertSpeechEnabled(int subId, int isAlertSpeechEnabled) {
        writeDatabaseAndCacheHelper(subId, SimInfo.COLUMN_CB_ALERT_SPEECH, isAlertSpeechEnabled,
                SubscriptionInfoInternal.Builder::setCellBroadcastAlertSpeechEnabled);
    }

    /**
     * Set whether ETWS test alert is enabled by the user or not.
     *
     * @param subId Subscription id.
     * @param isEtwsTestAlertEnabled whether cell broadcast ETWS test alert is enabled by the user
     * or not.
     *
     * @throws IllegalArgumentException if the subscription does not exist.
     */
    public void setCellBroadcastEtwsTestAlertEnabled(int subId, int isEtwsTestAlertEnabled) {
        writeDatabaseAndCacheHelper(subId, SimInfo.COLUMN_CB_ETWS_TEST_ALERT,
                isEtwsTestAlertEnabled,
                SubscriptionInfoInternal.Builder::setCellBroadcastEtwsTestAlertEnabled);
    }

    /**
     * Set whether area info message is enabled by the user or not.
     *
     * @param subId Subscription id.
     * @param isAreaInfoMessageEnabled whether cell broadcast area info message is enabled by the
     * user or not.
     *
     * @throws IllegalArgumentException if the subscription does not exist.
     */
    public void setCellBroadcastAreaInfoMessageEnabled(int subId, int isAreaInfoMessageEnabled) {
        writeDatabaseAndCacheHelper(subId, SimInfo.COLUMN_CB_CHANNEL_50_ALERT,
                isAreaInfoMessageEnabled,
                SubscriptionInfoInternal.Builder::setCellBroadcastAreaInfoMessageEnabled);
    }

    /**
     * Set whether cell broadcast test alert is enabled by the user or not.
     *
     * @param subId Subscription id.
     * @param isTestAlertEnabled whether cell broadcast test alert is enabled by the user or not.
     *
     * @throws IllegalArgumentException if the subscription does not exist.
     */
    public void setCellBroadcastTestAlertEnabled(int subId, int isTestAlertEnabled) {
        writeDatabaseAndCacheHelper(subId, SimInfo.COLUMN_CB_CMAS_TEST_ALERT, isTestAlertEnabled,
                SubscriptionInfoInternal.Builder::setCellBroadcastTestAlertEnabled);
    }

    /**
     * Set whether cell broadcast opt-out dialog should be shown or not.
     *
     * @param subId Subscription id.
     * @param isOptOutDialogEnabled whether cell broadcast opt-out dialog should be shown or not.
     *
     * @throws IllegalArgumentException if the subscription does not exist.
     */
    public void setCellBroadcastOptOutDialogEnabled(int subId, int isOptOutDialogEnabled) {
        writeDatabaseAndCacheHelper(subId, SimInfo.COLUMN_CB_OPT_OUT_DIALOG, isOptOutDialogEnabled,
                SubscriptionInfoInternal.Builder::setCellBroadcastOptOutDialogEnabled);
    }

    /**
     * Set whether enhanced 4G mode is enabled by the user or not.
     *
@@ -1921,6 +2155,30 @@ public class SubscriptionDatabaseManager extends Handler {
        builder.setCardId(publicCardId)
                .setRemovableEmbedded(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_IS_REMOVABLE)))
                .setCellBroadcastExtremeThreatAlertEnabled(cursor.getInt(cursor
                        .getColumnIndexOrThrow(SimInfo.COLUMN_CB_EXTREME_THREAT_ALERT)))
                .setCellBroadcastSevereThreatAlertEnabled(cursor.getInt(cursor
                        .getColumnIndexOrThrow(SimInfo.COLUMN_CB_SEVERE_THREAT_ALERT)))
                .setCellBroadcastAmberAlertEnabled(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_CB_AMBER_ALERT)))
                .setCellBroadcastEmergencyAlertEnabled(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_CB_EMERGENCY_ALERT)))
                .setCellBroadcastAlertSoundDuration(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_CB_ALERT_SOUND_DURATION)))
                .setCellBroadcastAlertReminderInterval(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_CB_ALERT_REMINDER_INTERVAL)))
                .setCellBroadcastAlertVibrationEnabled(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_CB_ALERT_VIBRATE)))
                .setCellBroadcastAlertSpeechEnabled(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_CB_ALERT_SPEECH)))
                .setCellBroadcastEtwsTestAlertEnabled(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_CB_ETWS_TEST_ALERT)))
                .setCellBroadcastAreaInfoMessageEnabled(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_CB_CHANNEL_50_ALERT)))
                .setCellBroadcastTestAlertEnabled(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_CB_CMAS_TEST_ALERT)))
                .setCellBroadcastOptOutDialogEnabled(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_CB_OPT_OUT_DIALOG)))
                .setEnhanced4GModeEnabled(cursor.getInt(cursor.getColumnIndexOrThrow(
                        SimInfo.COLUMN_ENHANCED_4G_MODE_ENABLED)))
                .setVideoTelephonyEnabled(cursor.getInt(cursor.getColumnIndexOrThrow(
+425 −40

File changed.

Preview size limit exceeded, changes collapsed.

+12 −0
Original line number Diff line number Diff line
@@ -146,6 +146,18 @@ public class SubscriptionManagerService extends ISub.Stub {
     * that requires higher permission to access.
     */
    private static final Set<String> DIRECT_ACCESS_SUBSCRIPTION_COLUMNS = Set.of(
            SimInfo.COLUMN_CB_EXTREME_THREAT_ALERT,
            SimInfo.COLUMN_CB_SEVERE_THREAT_ALERT,
            SimInfo.COLUMN_CB_AMBER_ALERT,
            SimInfo.COLUMN_CB_EMERGENCY_ALERT,
            SimInfo.COLUMN_CB_ALERT_SOUND_DURATION,
            SimInfo.COLUMN_CB_ALERT_REMINDER_INTERVAL,
            SimInfo.COLUMN_CB_ALERT_VIBRATE,
            SimInfo.COLUMN_CB_ALERT_SPEECH,
            SimInfo.COLUMN_CB_ETWS_TEST_ALERT,
            SimInfo.COLUMN_CB_CHANNEL_50_ALERT,
            SimInfo.COLUMN_CB_CMAS_TEST_ALERT,
            SimInfo.COLUMN_CB_OPT_OUT_DIALOG,
            SimInfo.COLUMN_ENHANCED_4G_MODE_ENABLED,
            SimInfo.COLUMN_VT_IMS_ENABLED,
            SimInfo.COLUMN_WFC_IMS_ENABLED,
+312 −0

File changed.

Preview size limit exceeded, changes collapsed.

+24 −0
Original line number Diff line number Diff line
@@ -53,6 +53,18 @@ public class SubscriptionInfoInternalTest {
                    .setCarrierConfigAccessRules(SubscriptionDatabaseManagerTest
                            .FAKE_CARRIER_CONFIG_ACCESS_RULES1)
                    .setRemovableEmbedded(0)
                    .setCellBroadcastExtremeThreatAlertEnabled(1)
                    .setCellBroadcastSevereThreatAlertEnabled(1)
                    .setCellBroadcastAmberAlertEnabled(1)
                    .setCellBroadcastEmergencyAlertEnabled(1)
                    .setCellBroadcastAlertSoundDuration(4)
                    .setCellBroadcastAlertReminderInterval(1)
                    .setCellBroadcastAlertVibrationEnabled(1)
                    .setCellBroadcastAlertSpeechEnabled(1)
                    .setCellBroadcastEtwsTestAlertEnabled(1)
                    .setCellBroadcastAreaInfoMessageEnabled(1)
                    .setCellBroadcastTestAlertEnabled(1)
                    .setCellBroadcastOptOutDialogEnabled(1)
                    .setEnhanced4GModeEnabled(1)
                    .setVideoTelephonyEnabled(1)
                    .setWifiCallingEnabled(1)
@@ -145,6 +157,18 @@ public class SubscriptionInfoInternalTest {
        assertThat(mSubInfo.getCarrierConfigAccessRules()).isEqualTo(SubscriptionDatabaseManagerTest
                .FAKE_CARRIER_CONFIG_ACCESS_RULES1);
        assertThat(mSubInfo.getRemovableEmbedded()).isEqualTo(0);
        assertThat(mSubInfo.getCellBroadcastExtremeThreatAlertEnabled()).isEqualTo(1);
        assertThat(mSubInfo.getCellBroadcastSevereThreatAlertEnabled()).isEqualTo(1);
        assertThat(mSubInfo.getCellBroadcastAmberAlertEnabled()).isEqualTo(1);
        assertThat(mSubInfo.getCellBroadcastEmergencyAlertEnabled()).isEqualTo(1);
        assertThat(mSubInfo.getCellBroadcastAlertSoundDuration()).isEqualTo(4);
        assertThat(mSubInfo.getCellBroadcastAlertReminderInterval()).isEqualTo(1);
        assertThat(mSubInfo.getCellBroadcastAlertVibrationEnabled()).isEqualTo(1);
        assertThat(mSubInfo.getCellBroadcastAlertSpeechEnabled()).isEqualTo(1);
        assertThat(mSubInfo.getCellBroadcastEtwsTestAlertEnabled()).isEqualTo(1);
        assertThat(mSubInfo.getCellBroadcastAreaInfoMessageEnabled()).isEqualTo(1);
        assertThat(mSubInfo.getCellBroadcastTestAlertEnabled()).isEqualTo(1);
        assertThat(mSubInfo.getCellBroadcastOptOutDialogEnabled()).isEqualTo(1);
        assertThat(mSubInfo.getEnhanced4GModeEnabled()).isEqualTo(1);
        assertThat(mSubInfo.getVideoTelephonyEnabled()).isEqualTo(1);
        assertThat(mSubInfo.getWifiCallingEnabled()).isEqualTo(1);