Merge "[Satellite] Add category UI for Satellite functions" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
770df52e47
@@ -12286,6 +12286,8 @@
|
|||||||
<string name="satellite_warning_dialog_title">Can’t turn on <xliff:g id="function" example="bluetooth">%1$s</xliff:g></string>
|
<string name="satellite_warning_dialog_title">Can’t turn on <xliff:g id="function" example="bluetooth">%1$s</xliff:g></string>
|
||||||
<!-- Content for satellite warning dialog to avoid user using wifi/bluetooth/airplane mode [CHAR_LIMIT=NONE] -->
|
<!-- Content for satellite warning dialog to avoid user using wifi/bluetooth/airplane mode [CHAR_LIMIT=NONE] -->
|
||||||
<string name="satellite_warning_dialog_content">To turn on <xliff:g id="function" example="bluetooth">%1$s</xliff:g>, first end the satellite connection</string>
|
<string name="satellite_warning_dialog_content">To turn on <xliff:g id="function" example="bluetooth">%1$s</xliff:g>, first end the satellite connection</string>
|
||||||
|
<!-- Category title for satellite functions in mobile network settings [CHAR LIMIT=60] -->
|
||||||
|
<string name="category_title_satellite_connectivity">Satellite connectivity</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- Title for Apn settings in mobile network settings [CHAR LIMIT=60] -->
|
<!-- Title for Apn settings in mobile network settings [CHAR LIMIT=60] -->
|
||||||
|
@@ -204,6 +204,21 @@
|
|||||||
settings:enableCopying="true"
|
settings:enableCopying="true"
|
||||||
settings:controller="com.android.settings.network.telephony.MobileNetworkEidPreferenceController"/>
|
settings:controller="com.android.settings.network.telephony.MobileNetworkEidPreferenceController"/>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="telephony_satellite_settings_category_key"
|
||||||
|
android:title="@string/category_title_satellite_connectivity"
|
||||||
|
settings:controller="com.android.settings.network.telephony.SatelliteSettingsPreferenceCategoryController">
|
||||||
|
|
||||||
|
<com.android.settingslib.RestrictedPreference
|
||||||
|
android:key="telephony_satellite_setting_key"
|
||||||
|
android:persistent="false"
|
||||||
|
android:title="@string/satellite_setting_title"
|
||||||
|
settings:keywords="@string/keywords_satellite_setting"
|
||||||
|
settings:controller=
|
||||||
|
"com.android.settings.network.telephony.SatelliteSettingPreferenceController"/>
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="calling_category"
|
android:key="calling_category"
|
||||||
android:title="@string/call_category"
|
android:title="@string/call_category"
|
||||||
@@ -267,14 +282,6 @@
|
|||||||
settings:controller="com.android.settings.network.telephony.gsm.OpenNetworkSelectPagePreferenceController"/>
|
settings:controller="com.android.settings.network.telephony.gsm.OpenNetworkSelectPagePreferenceController"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<com.android.settingslib.RestrictedPreference
|
|
||||||
android:key="telephony_satellite_setting_key"
|
|
||||||
android:persistent="false"
|
|
||||||
android:title="@string/satellite_setting_title"
|
|
||||||
settings:keywords="@string/keywords_satellite_setting"
|
|
||||||
settings:controller=
|
|
||||||
"com.android.settings.network.telephony.SatelliteSettingPreferenceController"/>
|
|
||||||
|
|
||||||
<!--We want separate APN setting from reset of settings because we want user to change it with caution-->
|
<!--We want separate APN setting from reset of settings because we want user to change it with caution-->
|
||||||
<com.android.settingslib.RestrictedPreference
|
<com.android.settingslib.RestrictedPreference
|
||||||
android:key="telephony_apn_key"
|
android:key="telephony_apn_key"
|
||||||
|
@@ -277,6 +277,12 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings impleme
|
|||||||
if (roamingPreferenceController != null) {
|
if (roamingPreferenceController != null) {
|
||||||
roamingPreferenceController.init(getParentFragmentManager(), mSubId);
|
roamingPreferenceController.init(getParentFragmentManager(), mSubId);
|
||||||
}
|
}
|
||||||
|
final SatelliteSettingsPreferenceCategoryController
|
||||||
|
satelliteSettingsPreferenceCategoryController =
|
||||||
|
use(SatelliteSettingsPreferenceCategoryController.class);
|
||||||
|
if (satelliteSettingsPreferenceCategoryController != null) {
|
||||||
|
satelliteSettingsPreferenceCategoryController.init(mSubId);
|
||||||
|
}
|
||||||
final SatelliteSettingPreferenceController satelliteSettingPreferenceController = use(
|
final SatelliteSettingPreferenceController satelliteSettingPreferenceController = use(
|
||||||
SatelliteSettingPreferenceController.class);
|
SatelliteSettingPreferenceController.class);
|
||||||
if (satelliteSettingPreferenceController != null) {
|
if (satelliteSettingPreferenceController != null) {
|
||||||
|
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* 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 android.content.Context;
|
||||||
|
import android.os.PersistableBundle;
|
||||||
|
import android.telephony.CarrierConfigManager;
|
||||||
|
import android.telephony.satellite.SatelliteManager;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.android.internal.telephony.flags.Flags;
|
||||||
|
import com.android.settings.network.CarrierConfigCache;
|
||||||
|
|
||||||
|
/** Preference controller for Satellite functions in mobile network settings.*/
|
||||||
|
public class SatelliteSettingsPreferenceCategoryController
|
||||||
|
extends TelephonyBasePreferenceController {
|
||||||
|
private static final String TAG = "SatelliteSettingsPrefCategoryCon";
|
||||||
|
|
||||||
|
private CarrierConfigCache mCarrierConfigCache;
|
||||||
|
private SatelliteManager mSatelliteManager;
|
||||||
|
|
||||||
|
public SatelliteSettingsPreferenceCategoryController(Context context, String key) {
|
||||||
|
super(context, key);
|
||||||
|
mCarrierConfigCache = CarrierConfigCache.getInstance(context);
|
||||||
|
mSatelliteManager = context.getSystemService(SatelliteManager.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set subId for Satellite Settings category .
|
||||||
|
* @param subId subscription ID.
|
||||||
|
*/
|
||||||
|
public void init(int subId) {
|
||||||
|
Log.d(TAG, "init(), subId=" + subId);
|
||||||
|
mSubId = subId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailabilityStatus(int subId) {
|
||||||
|
if (!Flags.carrierEnabledSatelliteFlag()) {
|
||||||
|
Log.d(TAG, "getAvailabilityStatus(" + subId + ") : carrierEnabledSatelliteFlag "
|
||||||
|
+ "is disabled");
|
||||||
|
return UNSUPPORTED_ON_DEVICE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mSatelliteManager == null) {
|
||||||
|
Log.d(TAG, "getAvailabilityStatus(" + subId + ") : SatelliteManager is null");
|
||||||
|
return UNSUPPORTED_ON_DEVICE;
|
||||||
|
}
|
||||||
|
|
||||||
|
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId);
|
||||||
|
final boolean isSatelliteAttachSupported = carrierConfig.getBoolean(
|
||||||
|
CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL);
|
||||||
|
|
||||||
|
return isSatelliteAttachSupported ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,127 @@
|
|||||||
|
/*
|
||||||
|
* 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.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||||
|
|
||||||
|
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.platform.test.flag.junit.SetFlagsRule;
|
||||||
|
import android.telephony.CarrierConfigManager;
|
||||||
|
import android.telephony.satellite.SatelliteManager;
|
||||||
|
|
||||||
|
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.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 SatelliteSettingsPreferenceCategoryControllerTest {
|
||||||
|
private static final String KEY = "key";
|
||||||
|
private static final int TEST_SUB_ID = 0;
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||||
|
@Rule
|
||||||
|
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private CarrierConfigCache mCarrierConfigCache;
|
||||||
|
|
||||||
|
private Context mContext = null;
|
||||||
|
private SatelliteManager mSatelliteManager = null;
|
||||||
|
private SatelliteSettingsPreferenceCategoryController mController = null;
|
||||||
|
private PersistableBundle mCarrierConfig = new PersistableBundle();
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
if (Looper.myLooper() == null) {
|
||||||
|
Looper.prepare();
|
||||||
|
}
|
||||||
|
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
|
mSatelliteManager = new SatelliteManager(mContext);
|
||||||
|
CarrierConfigCache.setTestInstance(mContext, mCarrierConfigCache);
|
||||||
|
when(mContext.getSystemService(SatelliteManager.class)).thenReturn(mSatelliteManager);
|
||||||
|
mController = new SatelliteSettingsPreferenceCategoryController(mContext, KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisableFlags(Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG)
|
||||||
|
public void getAvailabilityStatus_featureDisabled_returnUnsupport() {
|
||||||
|
int result = mController.getAvailabilityStatus(TEST_SUB_ID);
|
||||||
|
|
||||||
|
assertThat(result).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG)
|
||||||
|
public void getAvailabilityStatus_noSatellite_returnUnsupport() {
|
||||||
|
when(mContext.getSystemService(SatelliteManager.class)).thenReturn(null);
|
||||||
|
mController = new SatelliteSettingsPreferenceCategoryController(mContext, KEY);
|
||||||
|
|
||||||
|
int result = mController.getAvailabilityStatus(TEST_SUB_ID);
|
||||||
|
|
||||||
|
assertThat(result).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG)
|
||||||
|
public void getAvailabilityStatus_carrierIsNotSupport_returnUnavailable() {
|
||||||
|
when(mContext.getSystemService(SatelliteManager.class)).thenReturn(null);
|
||||||
|
mCarrierConfig.putBoolean(
|
||||||
|
CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL,
|
||||||
|
false);
|
||||||
|
when(mCarrierConfigCache.getConfigForSubId(TEST_SUB_ID)).thenReturn(mCarrierConfig);
|
||||||
|
|
||||||
|
int result = mController.getAvailabilityStatus(TEST_SUB_ID);
|
||||||
|
|
||||||
|
assertThat(result).isEqualTo(CONDITIONALLY_UNAVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG)
|
||||||
|
public void getAvailabilityStatus_carrierIsSupport_returnAvailable() {
|
||||||
|
when(mContext.getSystemService(SatelliteManager.class)).thenReturn(null);
|
||||||
|
mCarrierConfig.putBoolean(
|
||||||
|
CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL,
|
||||||
|
true);
|
||||||
|
when(mCarrierConfigCache.getConfigForSubId(TEST_SUB_ID)).thenReturn(mCarrierConfig);
|
||||||
|
|
||||||
|
int result = mController.getAvailabilityStatus(TEST_SUB_ID);
|
||||||
|
|
||||||
|
assertThat(result).isEqualTo(AVAILABLE);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user