[Satellite] Change footer format in satellite setting
- Use controller base design instead of current Flag: EXEMPT bug fix Bug: b/401648126 Fix: b/402037025 Test: Manual test Test: atest pass Change-Id: Icb3fd6a1c5340e554593fc57cb238bf98d3ed0e3
This commit is contained in:
@@ -27,13 +27,11 @@ import static android.telephony.CarrierConfigManager.KEY_SATELLITE_INFORMATION_R
|
||||
import android.app.Activity;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.PersistableBundle;
|
||||
import android.os.UserManager;
|
||||
import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.satellite.SatelliteManager;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@@ -45,8 +43,6 @@ import androidx.preference.PreferenceCategory;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.RestrictedDashboardFragment;
|
||||
import com.android.settingslib.HelpUtils;
|
||||
import com.android.settingslib.widget.FooterPreference;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -54,7 +50,6 @@ import java.util.Set;
|
||||
public class SatelliteSetting extends RestrictedDashboardFragment {
|
||||
private static final String TAG = "SatelliteSetting";
|
||||
private static final String PREF_KEY_CATEGORY_HOW_IT_WORKS = "key_category_how_it_works";
|
||||
private static final String KEY_FOOTER_PREFERENCE = "satellite_setting_extra_info_footer_pref";
|
||||
private static final String KEY_SATELLITE_CONNECTION_GUIDE = "key_satellite_connection_guide";
|
||||
private static final String KEY_SUPPORTED_SERVICE = "key_supported_service";
|
||||
|
||||
@@ -67,7 +62,6 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
|
||||
private SatelliteManager mSatelliteManager;
|
||||
private PersistableBundle mConfigBundle;
|
||||
private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
private String mSimOperatorName = "";
|
||||
private boolean mIsServiceDataType = false;
|
||||
private boolean mIsSmsAvailableForManualType = false;
|
||||
|
||||
@@ -95,6 +89,7 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
|
||||
use(SatelliteSettingAboutContentController.class).init(mSubId);
|
||||
use(SatelliteSettingAccountInfoController.class).init(mSubId, mConfigBundle,
|
||||
mIsSmsAvailableForManualType, mIsServiceDataType);
|
||||
use(SatelliteSettingFooterController.class).init(mSubId, mConfigBundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,10 +106,7 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
|
||||
Log.d(TAG, "SatelliteSettings: KEY_SATELLITE_ATTACH_SUPPORTED_BOOL is false, "
|
||||
+ "do nothing.");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
mSimOperatorName = getSystemService(TelephonyManager.class).getSimOperatorName(mSubId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -122,7 +114,6 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
boolean isSatelliteEligible = isSatelliteEligible();
|
||||
updateHowItWorksContent(isSatelliteEligible);
|
||||
updateFooterContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,34 +145,6 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
|
||||
supportedService.setSummary(R.string.summary_supported_service_for_manual_type);
|
||||
}
|
||||
|
||||
private void updateFooterContent() {
|
||||
// More about satellite messaging
|
||||
FooterPreference footerPreference = findPreference(KEY_FOOTER_PREFERENCE);
|
||||
if (footerPreference != null) {
|
||||
int summary = mConfigBundle.getBoolean(KEY_EMERGENCY_MESSAGING_SUPPORTED_BOOL)
|
||||
? R.string.satellite_setting_summary_more_information
|
||||
: R.string.satellite_setting_summary_more_information_no_emergency_messaging;
|
||||
footerPreference.setSummary(getResources().getString(summary, mSimOperatorName));
|
||||
|
||||
final String[] link = new String[1];
|
||||
link[0] = readSatelliteMoreInfoString();
|
||||
if (link[0] != null && !link[0].isEmpty()) {
|
||||
footerPreference.setLearnMoreAction(view -> {
|
||||
if (!link[0].isEmpty()) {
|
||||
Intent helpIntent = HelpUtils.getHelpIntent(mActivity, link[0],
|
||||
this.getClass().getName());
|
||||
if (helpIntent != null) {
|
||||
mActivity.startActivityForResult(helpIntent, /*requestCode=*/ 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
footerPreference.setLearnMoreText(
|
||||
getString(R.string.more_about_satellite_messaging));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSatelliteEligible() {
|
||||
if (isCarrierRoamingNtnConnectedTypeManual()) {
|
||||
return mIsSmsAvailableForManualType;
|
||||
@@ -218,10 +181,6 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
private String readSatelliteMoreInfoString() {
|
||||
return mConfigBundle.getString(KEY_SATELLITE_INFORMATION_REDIRECT_URL_STRING, "");
|
||||
}
|
||||
|
||||
private boolean isCarrierRoamingNtnConnectedTypeManual() {
|
||||
return CARRIER_ROAMING_NTN_CONNECT_MANUAL == mConfigBundle.getInt(
|
||||
KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT, CARRIER_ROAMING_NTN_CONNECT_AUTOMATIC);
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* 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 static android.telephony.CarrierConfigManager.KEY_EMERGENCY_MESSAGING_SUPPORTED_BOOL;
|
||||
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ENTITLEMENT_SUPPORTED_BOOL;
|
||||
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_INFORMATION_REDIRECT_URL_STRING;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.PersistableBundle;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.Html;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.network.telephony.TelephonyBasePreferenceController;
|
||||
import com.android.settingslib.HelpUtils;
|
||||
import com.android.settingslib.widget.FooterPreference;
|
||||
|
||||
/** A controller for showing the dynamic disclaimer of Satellite service. */
|
||||
public class SatelliteSettingFooterController extends TelephonyBasePreferenceController {
|
||||
private static final String TAG = "SatelliteSettingFooterController";
|
||||
@VisibleForTesting
|
||||
static final String KEY_FOOTER_PREFERENCE = "satellite_setting_extra_info_footer_pref";
|
||||
|
||||
private PersistableBundle mConfigBundle = new PersistableBundle();
|
||||
private String mSimOperatorName;
|
||||
|
||||
public SatelliteSettingFooterController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
void init(int subId, PersistableBundle configBundle) {
|
||||
mSubId = subId;
|
||||
mConfigBundle = configBundle;
|
||||
mSimOperatorName = mContext.getSystemService(TelephonyManager.class).getSimOperatorName(
|
||||
subId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
updateFooterContent(screen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus(int subId) {
|
||||
return AVAILABLE_UNSEARCHABLE;
|
||||
}
|
||||
|
||||
private void updateFooterContent(PreferenceScreen screen) {
|
||||
// More about satellite messaging
|
||||
FooterPreference footerPreference = screen.findPreference(KEY_FOOTER_PREFERENCE);
|
||||
if (footerPreference == null) {
|
||||
return;
|
||||
}
|
||||
footerPreference.setSummary(
|
||||
Html.fromHtml(getFooterContent(), Html.FROM_HTML_SEPARATOR_LINE_BREAK_LIST_ITEM));
|
||||
final String link = readSatelliteMoreInfoString();
|
||||
if (link.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
footerPreference.setLearnMoreAction(view -> {
|
||||
Intent helpIntent = HelpUtils.getHelpIntent(mContext, link, this.getClass().getName());
|
||||
if (helpIntent != null) {
|
||||
mContext.startActivityForResult(mContext.getPackageName(),
|
||||
helpIntent, /*requestCode=*/ 0, null);
|
||||
}
|
||||
});
|
||||
footerPreference.setLearnMoreText(
|
||||
mContext.getString(R.string.more_about_satellite_connectivity));
|
||||
}
|
||||
|
||||
private String getFooterContent() {
|
||||
String result = "";
|
||||
result = mContext.getString(R.string.satellite_footer_content_section_0) + "\n\n";
|
||||
result += getHtmlStringCombination(R.string.satellite_footer_content_section_1);
|
||||
result += getHtmlStringCombination(R.string.satellite_footer_content_section_2);
|
||||
result += getHtmlStringCombination(R.string.satellite_footer_content_section_3);
|
||||
result += getHtmlStringCombination(R.string.satellite_footer_content_section_4);
|
||||
result += getHtmlStringCombination(R.string.satellite_footer_content_section_5);
|
||||
if (!mConfigBundle.getBoolean(KEY_EMERGENCY_MESSAGING_SUPPORTED_BOOL)) {
|
||||
result += getHtmlStringCombination(R.string.satellite_footer_content_section_6);
|
||||
}
|
||||
if (mConfigBundle.getBoolean(KEY_SATELLITE_ENTITLEMENT_SUPPORTED_BOOL)) {
|
||||
result += getHtmlStringCombination(R.string.satellite_footer_content_section_7,
|
||||
mSimOperatorName);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private String getHtmlStringCombination(int resId) {
|
||||
String prefix = "<li> ";
|
||||
String subfix = "</li>";
|
||||
return prefix + mContext.getString(resId) + subfix;
|
||||
}
|
||||
|
||||
private String getHtmlStringCombination(int resId, Object... value) {
|
||||
String prefix = "<li> ";
|
||||
String subfix = "</li>";
|
||||
return prefix + mContext.getString(resId, value) + subfix;
|
||||
}
|
||||
|
||||
private String readSatelliteMoreInfoString() {
|
||||
return mConfigBundle.getString(KEY_SATELLITE_INFORMATION_REDIRECT_URL_STRING);
|
||||
}
|
||||
}
|
||||
@@ -159,7 +159,7 @@ public class SatelliteSettingsPreferenceCategoryController
|
||||
@Override
|
||||
public void onResult(Boolean result) {
|
||||
mIsSatelliteSupported.set(result);
|
||||
Log.d(TAG, "Satellite requestIsSupported : " + result);
|
||||
Log.d(TAG, "Satellite requestIsSupported onResult : " + result);
|
||||
SatelliteSettingsPreferenceCategoryController.this.displayPreference();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user