Merge cherrypicks of ['googleplex-android-review.googlesource.com/31162558'] into 25Q1-release.

Change-Id: I31785a2978327b7f62e58c9e2e4e6ba089cd1fea
This commit is contained in:
Android Build Coastguard Worker
2025-01-07 17:34:37 -08:00
2 changed files with 107 additions and 61 deletions

View File

@@ -16,6 +16,9 @@
package com.android.settings.network.telephony; package com.android.settings.network.telephony;
import static android.telephony.CarrierConfigManager.CARRIER_ROAMING_NTN_CONNECT_AUTOMATIC;
import static android.telephony.CarrierConfigManager.CARRIER_ROAMING_NTN_CONNECT_MANUAL;
import static android.telephony.CarrierConfigManager.KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL; import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_INFORMATION_REDIRECT_URL_STRING; import static android.telephony.CarrierConfigManager.KEY_SATELLITE_INFORMATION_REDIRECT_URL_STRING;
@@ -68,14 +71,15 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
static final String SUB_ID = "sub_id"; static final String SUB_ID = "sub_id";
static final String EXTRA_IS_SERVICE_DATA_TYPE = "is_service_data_type"; static final String EXTRA_IS_SERVICE_DATA_TYPE = "is_service_data_type";
static final String EXTRA_IS_SMS_AVAILABLE_FOR_MANUAL_TYPE = "is_sms_available";
private Activity mActivity; private Activity mActivity;
private CarrierConfigManager mCarrierConfigManager;
private SatelliteManager mSatelliteManager; private SatelliteManager mSatelliteManager;
private PersistableBundle mConfigBundle; private PersistableBundle mConfigBundle;
private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
private String mSimOperatorName = ""; private String mSimOperatorName = "";
private boolean mIsServiceDataType = false; private boolean mIsServiceDataType = false;
private boolean mIsSmsAvailableForManualType = false;
public SatelliteSetting() { public SatelliteSetting() {
super(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS); super(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS);
@@ -108,8 +112,8 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
mSubId = mActivity.getIntent().getIntExtra(SUB_ID, mSubId = mActivity.getIntent().getIntExtra(SUB_ID,
SubscriptionManager.INVALID_SUBSCRIPTION_ID); SubscriptionManager.INVALID_SUBSCRIPTION_ID);
mConfigBundle = fetchCarrierConfigData(mSubId);
mCarrierConfigManager = mActivity.getSystemService(CarrierConfigManager.class);
if (!isSatelliteAttachSupported(mSubId)) { if (!isSatelliteAttachSupported(mSubId)) {
Log.d(TAG, "SatelliteSettings: KEY_SATELLITE_ATTACH_SUPPORTED_BOOL is false, " Log.d(TAG, "SatelliteSettings: KEY_SATELLITE_ATTACH_SUPPORTED_BOOL is false, "
+ "do nothing."); + "do nothing.");
@@ -118,6 +122,8 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
} }
mIsServiceDataType = getIntent().getBooleanExtra(EXTRA_IS_SERVICE_DATA_TYPE, false); mIsServiceDataType = getIntent().getBooleanExtra(EXTRA_IS_SERVICE_DATA_TYPE, false);
mIsSmsAvailableForManualType = getIntent().getBooleanExtra(
EXTRA_IS_SMS_AVAILABLE_FOR_MANUAL_TYPE, false);
mSimOperatorName = getSystemService(TelephonyManager.class).getSimOperatorName(mSubId); mSimOperatorName = getSystemService(TelephonyManager.class).getSimOperatorName(mSubId);
} }
@@ -171,11 +177,13 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
the check icon with guidance that satellite is included in user's mobile plan */ the check icon with guidance that satellite is included in user's mobile plan */
messagingPreference.setTitle(R.string.title_have_satellite_plan); messagingPreference.setTitle(R.string.title_have_satellite_plan);
if (com.android.settings.flags.Flags.satelliteOemSettingsUxMigration()) { if (com.android.settings.flags.Flags.satelliteOemSettingsUxMigration()) {
Preference connectivityPreference = findPreference( if (mIsServiceDataType) {
PREF_KEY_YOUR_SATELLITE_DATA_PLAN); Preference connectivityPreference = findPreference(
connectivityPreference.setTitle(R.string.title_have_satellite_data_plan); PREF_KEY_YOUR_SATELLITE_DATA_PLAN);
connectivityPreference.setIcon(icon); connectivityPreference.setTitle(R.string.title_have_satellite_data_plan);
connectivityPreference.setVisible(true); connectivityPreference.setIcon(icon);
connectivityPreference.setVisible(true);
}
} }
} else { } else {
/* Or, it will show the blocked icon with the guidance that satellite is not included /* Or, it will show the blocked icon with the guidance that satellite is not included
@@ -191,7 +199,7 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
messagingPreference.setSummary(spannable); messagingPreference.setSummary(spannable);
/* The link will lead users to a guide page */ /* The link will lead users to a guide page */
messagingPreference.setOnPreferenceClickListener(pref -> { messagingPreference.setOnPreferenceClickListener(pref -> {
String url = readSatelliteMoreInfoString(mSubId); String url = readSatelliteMoreInfoString();
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);
@@ -224,7 +232,7 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
getSubjectString(), mSimOperatorName)); getSubjectString(), mSimOperatorName));
final String[] link = new String[1]; final String[] link = new String[1];
link[0] = readSatelliteMoreInfoString(mSubId); link[0] = readSatelliteMoreInfoString();
if (link[0] != null && !link[0].isEmpty()) { if (link[0] != null && !link[0].isEmpty()) {
footerPreference.setLearnMoreAction(view -> { footerPreference.setLearnMoreAction(view -> {
if (!link[0].isEmpty()) { if (!link[0].isEmpty()) {
@@ -243,6 +251,9 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
} }
private boolean isSatelliteEligible() { private boolean isSatelliteEligible() {
if (isCarrierRoamingNtnConnectedTypeManual()) {
return mIsSmsAvailableForManualType;
}
try { try {
Set<Integer> restrictionReason = Set<Integer> restrictionReason =
mSatelliteManager.getAttachRestrictionReasonsForCarrier(mSubId); mSatelliteManager.getAttachRestrictionReasonsForCarrier(mSubId);
@@ -254,26 +265,37 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
} }
} }
private String readSatelliteMoreInfoString(int subId) { private PersistableBundle fetchCarrierConfigData(int subId) {
if (mConfigBundle == null) { CarrierConfigManager carrierConfigManager = mActivity.getSystemService(
mConfigBundle = mCarrierConfigManager.getConfigForSubId(subId, CarrierConfigManager.class);
KEY_SATELLITE_INFORMATION_REDIRECT_URL_STRING); PersistableBundle bundle = CarrierConfigManager.getDefaultConfig();
if (mConfigBundle.isEmpty()) { try {
bundle = carrierConfigManager.getConfigForSubId(subId,
KEY_SATELLITE_ATTACH_SUPPORTED_BOOL,
KEY_SATELLITE_INFORMATION_REDIRECT_URL_STRING,
KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT);
if (bundle.isEmpty()) {
Log.d(TAG, "SatelliteSettings: getDefaultConfig"); Log.d(TAG, "SatelliteSettings: getDefaultConfig");
mConfigBundle = CarrierConfigManager.getDefaultConfig(); bundle = CarrierConfigManager.getDefaultConfig();
} }
} catch (IllegalStateException exception) {
Log.d(TAG, "SatelliteSettings exception : " + exception);
} }
return bundle;
}
private String readSatelliteMoreInfoString() {
return mConfigBundle.getString(KEY_SATELLITE_INFORMATION_REDIRECT_URL_STRING, ""); 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);
}
private boolean isSatelliteAttachSupported(int subId) { private boolean isSatelliteAttachSupported(int subId) {
PersistableBundle bundle = mCarrierConfigManager.getConfigForSubId(subId,
KEY_SATELLITE_ATTACH_SUPPORTED_BOOL); return mConfigBundle.getBoolean(KEY_SATELLITE_ATTACH_SUPPORTED_BOOL, false);
if (bundle.isEmpty()) {
Log.d(TAG, "SatelliteSettings: getDefaultConfig");
bundle = CarrierConfigManager.getDefaultConfig();
}
return bundle.getBoolean(KEY_SATELLITE_ATTACH_SUPPORTED_BOOL, false);
} }
// This is for a word which first letter is uppercase. e.g. Satellite messaging. // This is for a word which first letter is uppercase. e.g. Satellite messaging.

View File

@@ -16,6 +16,10 @@
package com.android.settings.network.telephony; package com.android.settings.network.telephony;
import static android.telephony.CarrierConfigManager.CARRIER_ROAMING_NTN_CONNECT_AUTOMATIC;
import static android.telephony.CarrierConfigManager.CARRIER_ROAMING_NTN_CONNECT_MANUAL;
import static android.telephony.CarrierConfigManager.KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL;
import static android.telephony.NetworkRegistrationInfo.SERVICE_TYPE_DATA; import static android.telephony.NetworkRegistrationInfo.SERVICE_TYPE_DATA;
import static android.telephony.NetworkRegistrationInfo.SERVICE_TYPE_SMS; import static android.telephony.NetworkRegistrationInfo.SERVICE_TYPE_SMS;
@@ -23,7 +27,6 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.PersistableBundle; import android.os.PersistableBundle;
import android.provider.Settings; import android.provider.Settings;
import android.telephony.CarrierConfigManager;
import android.telephony.TelephonyCallback; import android.telephony.TelephonyCallback;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.telephony.satellite.NtnSignalStrength; import android.telephony.satellite.NtnSignalStrength;
@@ -53,17 +56,18 @@ import java.util.Set;
public class SatelliteSettingPreferenceController extends public class SatelliteSettingPreferenceController extends
TelephonyBasePreferenceController implements DefaultLifecycleObserver { TelephonyBasePreferenceController implements DefaultLifecycleObserver {
private static final String TAG = "SatelliteSettingPreferenceController"; private static final String TAG = "SatelliteSettingPreferenceController";
CarrierConfigCache mCarrierConfigCache;
SatelliteManager mSatelliteManager;
private TelephonyManager mTelephonyManager = null;
@VisibleForTesting @VisibleForTesting
final CarrierRoamingNtnModeCallback mCarrierRoamingNtnModeCallback = final CarrierRoamingNtnModeCallback mCarrierRoamingNtnModeCallback =
new CarrierRoamingNtnModeCallback(); new CarrierRoamingNtnModeCallback();
CarrierConfigCache mCarrierConfigCache;
SatelliteManager mSatelliteManager;
private TelephonyManager mTelephonyManager = null;
@Nullable @Nullable
private Boolean mIsSatelliteEligible = null; private Boolean mIsSatelliteEligible = null;
private boolean mIsServiceDataType = false; private boolean mIsServiceDataType = false;
private boolean mIsSatelliteSmsAvailableForManualType = false;
private boolean mIsCarrierSatelliteAttachSupported = false;
private boolean mIsCarrierRoamingNtnConnectedTypeManual = false;
public SatelliteSettingPreferenceController(@NonNull Context context, @NonNull String key) { public SatelliteSettingPreferenceController(@NonNull Context context, @NonNull String key) {
super(context, key); super(context, key);
@@ -72,6 +76,14 @@ public class SatelliteSettingPreferenceController extends
mTelephonyManager = context.getSystemService(TelephonyManager.class); mTelephonyManager = context.getSystemService(TelephonyManager.class);
} }
private static void logd(String message) {
Log.d(TAG, message);
}
private static void loge(String message) {
Log.e(TAG, message);
}
@Override @Override
public int getAvailabilityStatus(int subId) { public int getAvailabilityStatus(int subId) {
if (!Flags.carrierEnabledSatelliteFlag()) { if (!Flags.carrierEnabledSatelliteFlag()) {
@@ -83,11 +95,7 @@ public class SatelliteSettingPreferenceController extends
return UNSUPPORTED_ON_DEVICE; return UNSUPPORTED_ON_DEVICE;
} }
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId); return mIsCarrierSatelliteAttachSupported ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
final boolean isSatelliteAttachSupported = carrierConfig.getBoolean(
CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL);
return isSatelliteAttachSupported ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
} }
@Override @Override
@@ -130,6 +138,8 @@ public class SatelliteSettingPreferenceController extends
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, true); intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, true);
intent.putExtra(SatelliteSetting.SUB_ID, mSubId); intent.putExtra(SatelliteSetting.SUB_ID, mSubId);
intent.putExtra(SatelliteSetting.EXTRA_IS_SERVICE_DATA_TYPE, mIsServiceDataType); intent.putExtra(SatelliteSetting.EXTRA_IS_SERVICE_DATA_TYPE, mIsServiceDataType);
intent.putExtra(SatelliteSetting.EXTRA_IS_SMS_AVAILABLE_FOR_MANUAL_TYPE,
mIsSatelliteSmsAvailableForManualType);
mContext.startActivity(intent); mContext.startActivity(intent);
return true; return true;
} }
@@ -146,39 +156,54 @@ public class SatelliteSettingPreferenceController extends
logd("init(), subId=" + subId); logd("init(), subId=" + subId);
mSubId = subId; mSubId = subId;
mTelephonyManager = mTelephonyManager.createForSubscriptionId(subId); mTelephonyManager = mTelephonyManager.createForSubscriptionId(subId);
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId);
if (carrierConfig == null) {
logd("init(), no carrier config data");
return;
}
mIsCarrierSatelliteAttachSupported = carrierConfig.getBoolean(
KEY_SATELLITE_ATTACH_SUPPORTED_BOOL);
mIsCarrierRoamingNtnConnectedTypeManual =
CARRIER_ROAMING_NTN_CONNECT_MANUAL == carrierConfig.getInt(
KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT,
CARRIER_ROAMING_NTN_CONNECT_AUTOMATIC);
} }
private void updateSummary(Preference preference) { private void updateSummary(Preference preference) {
if (preference == null) {
logd("updateSummary - no Preference");
return;
}
if (mSatelliteManager == null) { if (mSatelliteManager == null) {
logd("updateSummary - no SatelliteManager"); logd("updateSummary - no SatelliteManager");
return; return;
} }
try {
Set<Integer> restrictionReason = if (mIsCarrierRoamingNtnConnectedTypeManual) {
mSatelliteManager.getAttachRestrictionReasonsForCarrier(mSubId); preference.setSummary(mIsSatelliteSmsAvailableForManualType
boolean isSatelliteEligible = !restrictionReason.contains( ? R.string.satellite_setting_enabled_summary
SatelliteManager.SATELLITE_COMMUNICATION_RESTRICTION_REASON_ENTITLEMENT); : R.string.satellite_setting_disabled_summary);
if (mIsSatelliteEligible == null || mIsSatelliteEligible != isSatelliteEligible) { } else {
mIsSatelliteEligible = isSatelliteEligible; try {
String summary = mContext.getString( Set<Integer> restrictionReason =
mIsSatelliteEligible ? R.string.satellite_setting_enabled_summary mSatelliteManager.getAttachRestrictionReasonsForCarrier(mSubId);
: R.string.satellite_setting_disabled_summary); boolean isSatelliteEligible = !restrictionReason.contains(
preference.setSummary(summary); SatelliteManager.SATELLITE_COMMUNICATION_RESTRICTION_REASON_ENTITLEMENT);
if (mIsSatelliteEligible == null || mIsSatelliteEligible != isSatelliteEligible) {
mIsSatelliteEligible = isSatelliteEligible;
String summary = mContext.getString(
mIsSatelliteEligible ? R.string.satellite_setting_enabled_summary
: R.string.satellite_setting_disabled_summary);
preference.setSummary(summary);
}
} catch (SecurityException | IllegalStateException | IllegalArgumentException ex) {
loge(ex.toString());
preference.setSummary(R.string.satellite_setting_disabled_summary);
} }
} catch (SecurityException | IllegalStateException | IllegalArgumentException ex) {
loge(ex.toString());
preference.setSummary(R.string.satellite_setting_disabled_summary);
} }
} }
private static void logd(String message) {
Log.d(TAG, message);
}
private static void loge(String message) {
Log.e(TAG, message);
}
@VisibleForTesting @VisibleForTesting
class CarrierRoamingNtnModeCallback extends TelephonyCallback implements class CarrierRoamingNtnModeCallback extends TelephonyCallback implements
TelephonyCallback.CarrierRoamingNtnModeListener { TelephonyCallback.CarrierRoamingNtnModeListener {
@@ -197,12 +222,11 @@ public class SatelliteSettingPreferenceController extends
logd("Satellite preference is not initialized yet"); logd("Satellite preference is not initialized yet");
return; return;
} }
if (isDataAvailable) { mIsServiceDataType = isDataAvailable;
mIsServiceDataType = true; mIsSatelliteSmsAvailableForManualType = isSmsAvailable;
mPref.setTitle(R.string.title_satellite_setting_connectivity); mPref.setTitle(isDataAvailable ? R.string.title_satellite_setting_connectivity
} else if (isSmsAvailable) { : R.string.satellite_setting_title);
mPref.setTitle(R.string.satellite_setting_title); updateSummary(mPref);
}
} }
@Override @Override