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

Commit 63469da6 authored by tomhsu's avatar tomhsu
Browse files

Remove Satellite SOS entry from AOSP

Flag: com.android.settings.flags.satellite_oem_settings_ux_migration
Bug: b/378408877
Test: make pass
Test: Manual test
Change-Id: If47081be0ed0734be841b2fe9129d22a76ed8e1b
parent 3859a8ad
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -12371,13 +12371,6 @@
    <string name="description_satellite_setting_messaging">satellite messaging</string>
    <!-- Title for notifying user's account be able to use data transmission of Satellite" [CHAR_LIMIT=NONE] -->
    <string name="title_have_satellite_data_plan">Use of data is included with your account</string>
    <!-- Title for the entry of Satellite SOS [CHAR_LIMIT=NONE] -->
    <string name="title_for_satellite_sos">Satellite SOS</string>
    <!-- Summary for the entry of Satellite SOS [CHAR_LIMIT=NONE] -->
    <string name="summary_for_satellite_sos_entry">Message with emergency services when you can\u2019t connect to a mobile or Wi\u2011Fi network</string>
    <!-- Keywords for the entry of Satellite SOS [CHAR_LIMIT=NONE] -->
    <string name="keywords_satellite_sos">satellite sos, sos</string>
    <!-- Title for Apn settings in mobile network settings [CHAR LIMIT=60] -->
    <string name="mobile_network_apn_title">Access Point Names</string>
+0 −9
Original line number Diff line number Diff line
@@ -217,15 +217,6 @@
                settings:controller=
                    "com.android.settings.network.telephony.SatelliteSettingPreferenceController"/>

            <com.android.settingslib.RestrictedPreference
                android:key="telephony_satellite_setting_sos_key"
                android:persistent="false"
                android:title="@string/title_for_satellite_sos"
                android:summary="@string/summary_for_satellite_sos_entry"
                settings:keywords="@string/keywords_satellite_setting"
                settings:controller=
                    "com.android.settings.network.telephony.SatelliteSettingSosPreferenceController"/>

        </PreferenceCategory>

        <PreferenceCategory
+1 −5
Original line number Diff line number Diff line
@@ -288,11 +288,7 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings impleme
        if (satelliteSettingPreferenceController != null) {
            satelliteSettingPreferenceController.init(mSubId);
        }
        final SatelliteSettingSosPreferenceController satelliteSettingSosPreferenceController = use(
                SatelliteSettingSosPreferenceController.class);
        if (satelliteSettingSosPreferenceController != null) {
            satelliteSettingSosPreferenceController.init(mSubId);
        }

        use(ApnPreferenceController.class).init(mSubId);
        use(CarrierPreferenceController.class).init(mSubId);
        use(DataUsagePreferenceController.class).init(mSubId);
+0 −54
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.network.telephony;

import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ESOS_SUPPORTED_BOOL;

import android.content.Context;
import android.os.PersistableBundle;

import com.android.settings.flags.Flags;
import com.android.settings.network.CarrierConfigCache;

/** A controller for Satellite SOS entry preference. */
public class SatelliteSettingSosPreferenceController extends TelephonyBasePreferenceController {
    private static final String TAG = "SatelliteSettingSosPrefController";

    public SatelliteSettingSosPreferenceController(Context context,
            String preferenceKey) {
        super(context, preferenceKey);
    }

    /** Setup the subscription Id for the UI with specific UI group. */
    public void init(int subId) {
        mSubId = subId;
    }

    @Override
    public int getAvailabilityStatus(int subId) {
        if (Flags.satelliteOemSettingsUxMigration()) {
            CarrierConfigCache carrierConfigCache = CarrierConfigCache.getInstance(mContext);
            PersistableBundle bundle = carrierConfigCache.getConfigForSubId(subId);
            if (bundle == null) {
                return CONDITIONALLY_UNAVAILABLE;
            }
            boolean isCarrierSupport = bundle.getBoolean(KEY_SATELLITE_ESOS_SUPPORTED_BOOL);
            return isCarrierSupport ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
        }
        return CONDITIONALLY_UNAVAILABLE;
    }
}
+0 −110
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.network.telephony;

import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;

import static com.google.common.truth.Truth.assertThat;

import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;

import android.content.Context;
import android.os.Looper;
import android.os.PersistableBundle;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.telephony.CarrierConfigManager;

import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import com.android.internal.telephony.flags.Flags;
import com.android.settings.network.CarrierConfigCache;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;

@RunWith(AndroidJUnit4.class)
public class SatelliteSettingsSosPreferenceControllerTest {
    private static final String KEY = "key";
    private static final int TEST_SUB_ID = 0;

    @Rule
    public final MockitoRule mMockitoRule = MockitoJUnit.rule();

    @Mock
    private CarrierConfigCache mCarrierConfigCache;

    private Context mContext = null;
    private SatelliteSettingSosPreferenceController mController = null;
    private PersistableBundle mCarrierConfig = new PersistableBundle();

    @Before
    public void setUp() {
        if (Looper.myLooper() == null) {
            Looper.prepare();
        }
        mContext = spy(ApplicationProvider.getApplicationContext());
        mController = new SatelliteSettingSosPreferenceController(mContext, KEY);
        CarrierConfigCache.setTestInstance(mContext, mCarrierConfigCache);
    }

    @Test
    @EnableFlags(Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG)
    public void getAvailabilityStatus_carrierNotSupport_returnUnAvailable() {
        mCarrierConfig.putBoolean(
                        CarrierConfigManager.KEY_SATELLITE_ESOS_SUPPORTED_BOOL,
                        false);
        when(mCarrierConfigCache.getConfigForSubId(TEST_SUB_ID)).thenReturn(mCarrierConfig);
        mController.init(TEST_SUB_ID);

        int result = mController.getAvailabilityStatus(TEST_SUB_ID);

        assertThat(result).isEqualTo(CONDITIONALLY_UNAVAILABLE);
    }

    @Ignore("Avoid post submit test failed.")
    @Test
    @EnableFlags(Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG)
    public void getAvailabilityStatus_carrierSupported_returnAvailable() {
        mCarrierConfig.putBoolean(
                CarrierConfigManager.KEY_SATELLITE_ESOS_SUPPORTED_BOOL,
                true);
        when(mCarrierConfigCache.getConfigForSubId(TEST_SUB_ID)).thenReturn(mCarrierConfig);
        mController.init(TEST_SUB_ID);

        int result = mController.getAvailabilityStatus(TEST_SUB_ID);

        assertThat(result).isEqualTo(AVAILABLE);
    }

    @Test
    @DisableFlags(Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG)
    public void getAvailabilityStatus_featureDisabled_returnAvailable() {
        int result = mController.getAvailabilityStatus(TEST_SUB_ID);

        assertThat(result).isEqualTo(CONDITIONALLY_UNAVAILABLE);
    }
}