[Satellite] Add category UI for Satellite functions

Flag: com.android.settings.flags.satellite_oem_settings_ux_migration
Fix: b/378408939
Test: atest pass
Test: make pass
Change-Id: Id0f2ba047f4ee71a9ae398aa828978097717ce1a
This commit is contained in:
tomhsu
2024-11-19 03:30:03 +00:00
committed by Tom Hsu
parent 4d19f45505
commit c9017355d9
5 changed files with 220 additions and 8 deletions

View File

@@ -277,6 +277,12 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings impleme
if (roamingPreferenceController != null) {
roamingPreferenceController.init(getParentFragmentManager(), mSubId);
}
final SatelliteSettingsPreferenceCategoryController
satelliteSettingsPreferenceCategoryController =
use(SatelliteSettingsPreferenceCategoryController.class);
if (satelliteSettingsPreferenceCategoryController != null) {
satelliteSettingsPreferenceCategoryController.init(mSubId);
}
final SatelliteSettingPreferenceController satelliteSettingPreferenceController = use(
SatelliteSettingPreferenceController.class);
if (satelliteSettingPreferenceController != null) {

View File

@@ -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;
}
}