[Satellite] Refactor about content of Satellite setting

Flag: EXEMPT refactor
Bug: b/403149290
Test: Manual test pass
Test: atest pass
Change-Id: I55868869a9442648995343c857758c23fe358bc2
This commit is contained in:
tom hsu
2025-03-13 19:03:58 +00:00
parent 93f714446a
commit c19341db32
5 changed files with 142 additions and 25 deletions

View File

@@ -61,8 +61,6 @@ import java.util.Set;
/** Handle Satellite Setting Preference Layout. */
public class SatelliteSetting extends RestrictedDashboardFragment {
private static final String TAG = "SatelliteSetting";
private static final String PREF_KEY_ABOUT_SATELLITE_MESSAGING =
"key_about_satellite_messaging";
private static final String PREF_KEY_CATEGORY_YOUR_SATELLITE_PLAN =
"key_category_your_satellite_plan";
private static final String PREF_KEY_YOUR_SATELLITE_PLAN = "key_your_satellite_plan";
@@ -98,14 +96,17 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
@Override
public void onAttach(Context context) {
super.onAttach(context);
mActivity = getActivity();
mSubId = mActivity.getIntent().getIntExtra(SUB_ID,
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
use(SatelliteAppListCategoryController.class).init();
use(SatelliteSettingAboutContentController.class).init(mSubId);
}
@Override
public void onCreate(@NonNull Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mActivity = getActivity();
mSatelliteManager = mActivity.getSystemService(SatelliteManager.class);
if (mSatelliteManager == null) {
Log.d(TAG, "SatelliteManager is null, do nothing.");
@@ -113,8 +114,6 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
return;
}
mSubId = mActivity.getIntent().getIntExtra(SUB_ID,
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
mConfigBundle = fetchCarrierConfigData(mSubId);
if (!isSatelliteAttachSupported(mSubId)) {
@@ -135,7 +134,6 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
super.onViewCreated(view, savedInstanceState);
boolean isSatelliteEligible = isSatelliteEligible();
updateTitle();
updateAboutSatelliteContent();
updateMobilePlan(isSatelliteEligible);
updateHowItWorksContent(isSatelliteEligible);
updateFooterContent();
@@ -155,18 +153,6 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
findPreference("satellite_setting").setTitle(getSubjectString());
}
// About satellite content
private void updateAboutSatelliteContent() {
Preference categoryTitle = findPreference(PREF_KEY_CATEGORY_ABOUT_SATELLITE);
categoryTitle.setTitle(
getString(R.string.category_name_about_satellite_messaging,
getDescriptionString()));
Preference preference = findPreference(PREF_KEY_ABOUT_SATELLITE_MESSAGING);
preference.setTitle(
getResources().getString(R.string.title_about_satellite_setting, mSimOperatorName));
}
private void updateMobilePlan(boolean isSatelliteEligible) {
PreferenceCategory prefCategory = findPreference(PREF_KEY_CATEGORY_YOUR_SATELLITE_PLAN);
if (prefCategory == null || !mConfigBundle.getBoolean(

View File

@@ -0,0 +1,52 @@
/*
* Copyright (C) 2025 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.satellite
import android.content.Context
import android.telephony.TelephonyManager
import androidx.preference.PreferenceScreen
import com.android.settings.network.telephony.TelephonyBasePreferenceController
import com.android.settingslib.widget.TopIntroPreference
import com.android.settings.R;
/** A controller to show the introduction of satellite connectivity. */
class SatelliteSettingAboutContentController(context: Context, key: String) :
TelephonyBasePreferenceController(context, key) {
private lateinit var simOperatorName: String
fun init(subId: Int) {
mSubId = subId
simOperatorName =
mContext.getSystemService(TelephonyManager::class.java)?.getSimOperatorName(mSubId) ?: ""
}
override fun displayPreference(screen: PreferenceScreen?) {
super.displayPreference(screen)
val preference: TopIntroPreference? =
screen?.findPreference(PREF_KEY_ABOUT_SATELLITE_CONNECTIVITY)
preference?.title =
mContext.getString(R.string.description_about_satellite_setting, simOperatorName)
}
override fun getAvailabilityStatus(subId: Int): Int {
return AVAILABLE
}
companion object {
const val PREF_KEY_ABOUT_SATELLITE_CONNECTIVITY = "key_about_satellite_connectivity";
}
}