Make satellite more info url carrier configurable

guidance url link are vary per each carrier, therefore makes it carrier configurable

Bug: 330948681
Test: manually test whether URL works as intended on pixel with TMO/SKT SIM
Change-Id: I062b1e9267c6edf3289d85dc58f9ab2d9cff64d8
This commit is contained in:
Hakjun Choi
2024-03-23 02:56:19 +00:00
parent b970322d4c
commit 3c54876db7
2 changed files with 21 additions and 4 deletions

View File

@@ -11553,8 +11553,6 @@
<string name="satellite_setting_summary_more_information">Satellite messaging may take longer and is available only in some areas. Weather and certain structures may affect your satellite connection. Calling by satellite isn\u2019t available. Emergency calls may still connect.\n\nIt may take some time for account changes to show in Settings. Contact your carrier for details.</string> <string name="satellite_setting_summary_more_information">Satellite messaging may take longer and is available only in some areas. Weather and certain structures may affect your satellite connection. Calling by satellite isn\u2019t available. Emergency calls may still connect.\n\nIt may take some time for account changes to show in Settings. Contact your carrier for details.</string>
<!-- more about satellite messaging [CHAR_LIMIT=NONE] --> <!-- more about satellite messaging [CHAR_LIMIT=NONE] -->
<string name="more_about_satellite_messaging">More about satellite messaging</string> <string name="more_about_satellite_messaging">More about satellite messaging</string>
<!-- URL for more info about satellite messaging [CHAR LIMIT=60] -->
<string name="more_info_satellite_messaging_link" translatable="false"></string>
<!-- Title for Apn settings in mobile network settings [CHAR LIMIT=60] --> <!-- Title for Apn settings in mobile network settings [CHAR LIMIT=60] -->
<string name="mobile_network_apn_title">Access Point Names</string> <string name="mobile_network_apn_title">Access Point Names</string>

View File

@@ -16,6 +16,8 @@
package com.android.settings.network.telephony; package com.android.settings.network.telephony;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_INFORMATION_REDIRECT_URL_STRING;
import android.app.Activity; import android.app.Activity;
import android.app.settings.SettingsEnums; import android.app.settings.SettingsEnums;
import android.content.Intent; import android.content.Intent;
@@ -23,7 +25,9 @@ import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.PersistableBundle;
import android.os.UserManager; import android.os.UserManager;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.telephony.satellite.SatelliteManager; import android.telephony.satellite.SatelliteManager;
@@ -60,7 +64,9 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
private Activity mActivity; private Activity mActivity;
private TelephonyManager mTelephonymanager; private TelephonyManager mTelephonymanager;
private CarrierConfigManager mCarrierConfigManager;
private SatelliteManager mSatelliteManager; private SatelliteManager mSatelliteManager;
private PersistableBundle mConfigBundle;
private int mSubId; private int mSubId;
public SatelliteSetting() { public SatelliteSetting() {
@@ -78,6 +84,7 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
mActivity = getActivity(); mActivity = getActivity();
mTelephonymanager = mActivity.getSystemService(TelephonyManager.class); mTelephonymanager = mActivity.getSystemService(TelephonyManager.class);
mCarrierConfigManager = mActivity.getSystemService(CarrierConfigManager.class);
mSatelliteManager = mActivity.getSystemService(SatelliteManager.class); mSatelliteManager = mActivity.getSystemService(SatelliteManager.class);
mSubId = mActivity.getIntent().getIntExtra(SUB_ID, mSubId = mActivity.getIntent().getIntExtra(SUB_ID,
SubscriptionManager.INVALID_SUBSCRIPTION_ID); SubscriptionManager.INVALID_SUBSCRIPTION_ID);
@@ -134,7 +141,7 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
preference.setSummary(spannable); preference.setSummary(spannable);
/* The link will lead users to a guide page */ /* The link will lead users to a guide page */
preference.setOnPreferenceClickListener(pref -> { preference.setOnPreferenceClickListener(pref -> {
String url = getResources().getString(R.string.more_info_satellite_messaging_link); String url = readSatelliteMoreInfoString(mSubId);
if (!url.isEmpty()) { if (!url.isEmpty()) {
Uri uri = Uri.parse(url); Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, uri); Intent intent = new Intent(Intent.ACTION_VIEW, uri);
@@ -163,7 +170,7 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
operatorName)); operatorName));
final String[] link = new String[1]; final String[] link = new String[1];
link[0] = getResources().getString(R.string.more_info_satellite_messaging_link); link[0] = readSatelliteMoreInfoString(mSubId);
footerPreference.setLearnMoreAction(view -> { footerPreference.setLearnMoreAction(view -> {
if (!link[0].isEmpty()) { if (!link[0].isEmpty()) {
Intent helpIntent = HelpUtils.getHelpIntent(mActivity, link[0], Intent helpIntent = HelpUtils.getHelpIntent(mActivity, link[0],
@@ -192,6 +199,18 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
} }
} }
private String readSatelliteMoreInfoString(int subId) {
if (mConfigBundle == null) {
mConfigBundle = mCarrierConfigManager.getConfigForSubId(subId,
KEY_SATELLITE_INFORMATION_REDIRECT_URL_STRING);
if (mConfigBundle.isEmpty()) {
Log.d(TAG, "SatelliteSettings: getDefaultConfig");
mConfigBundle = CarrierConfigManager.getDefaultConfig();
}
}
return mConfigBundle.getString(KEY_SATELLITE_INFORMATION_REDIRECT_URL_STRING, "");
}
private static void loge(String message) { private static void loge(String message) {
Log.e(TAG, message); Log.e(TAG, message);
} }