NTN connected type is manual, UI status shall be checked by callback.
- Manual type shall check with onCarrierRoamingNtnAvailableServicesChanged - Automatic type check shall check with getAttachRestrictionReasonsForCarrier Flag: EXEMPT bug fix Fix: b/387523217 Test: Manual test Change-Id: Id28885a0972a7f7d6c43ae22149b6e3e49d7f374
This commit is contained in:
@@ -16,6 +16,10 @@
|
||||
|
||||
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_SMS;
|
||||
|
||||
@@ -23,7 +27,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.PersistableBundle;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.TelephonyCallback;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.satellite.NtnSignalStrength;
|
||||
@@ -53,17 +56,18 @@ import java.util.Set;
|
||||
public class SatelliteSettingPreferenceController extends
|
||||
TelephonyBasePreferenceController implements DefaultLifecycleObserver {
|
||||
private static final String TAG = "SatelliteSettingPreferenceController";
|
||||
|
||||
CarrierConfigCache mCarrierConfigCache;
|
||||
SatelliteManager mSatelliteManager;
|
||||
private TelephonyManager mTelephonyManager = null;
|
||||
@VisibleForTesting
|
||||
final CarrierRoamingNtnModeCallback mCarrierRoamingNtnModeCallback =
|
||||
new CarrierRoamingNtnModeCallback();
|
||||
|
||||
CarrierConfigCache mCarrierConfigCache;
|
||||
SatelliteManager mSatelliteManager;
|
||||
private TelephonyManager mTelephonyManager = null;
|
||||
@Nullable
|
||||
private Boolean mIsSatelliteEligible = null;
|
||||
private boolean mIsServiceDataType = false;
|
||||
private boolean mIsSatelliteSmsAvailableForManualType = false;
|
||||
private boolean mIsCarrierSatelliteAttachSupported = false;
|
||||
private boolean mIsCarrierRoamingNtnConnectedTypeManual = false;
|
||||
|
||||
public SatelliteSettingPreferenceController(@NonNull Context context, @NonNull String key) {
|
||||
super(context, key);
|
||||
@@ -72,6 +76,14 @@ public class SatelliteSettingPreferenceController extends
|
||||
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
|
||||
public int getAvailabilityStatus(int subId) {
|
||||
if (!Flags.carrierEnabledSatelliteFlag()) {
|
||||
@@ -83,11 +95,7 @@ public class SatelliteSettingPreferenceController extends
|
||||
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;
|
||||
return mIsCarrierSatelliteAttachSupported ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -130,6 +138,8 @@ public class SatelliteSettingPreferenceController extends
|
||||
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, true);
|
||||
intent.putExtra(SatelliteSetting.SUB_ID, mSubId);
|
||||
intent.putExtra(SatelliteSetting.EXTRA_IS_SERVICE_DATA_TYPE, mIsServiceDataType);
|
||||
intent.putExtra(SatelliteSetting.EXTRA_IS_SMS_AVAILABLE_FOR_MANUAL_TYPE,
|
||||
mIsSatelliteSmsAvailableForManualType);
|
||||
mContext.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
@@ -146,39 +156,54 @@ public class SatelliteSettingPreferenceController extends
|
||||
logd("init(), subId=" + subId);
|
||||
mSubId = 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) {
|
||||
if (preference == null) {
|
||||
logd("updateSummary - no Preference");
|
||||
return;
|
||||
}
|
||||
if (mSatelliteManager == null) {
|
||||
logd("updateSummary - no SatelliteManager");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Set<Integer> restrictionReason =
|
||||
mSatelliteManager.getAttachRestrictionReasonsForCarrier(mSubId);
|
||||
boolean isSatelliteEligible = !restrictionReason.contains(
|
||||
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);
|
||||
|
||||
if (mIsCarrierRoamingNtnConnectedTypeManual) {
|
||||
preference.setSummary(mIsSatelliteSmsAvailableForManualType
|
||||
? R.string.satellite_setting_enabled_summary
|
||||
: R.string.satellite_setting_disabled_summary);
|
||||
} else {
|
||||
try {
|
||||
Set<Integer> restrictionReason =
|
||||
mSatelliteManager.getAttachRestrictionReasonsForCarrier(mSubId);
|
||||
boolean isSatelliteEligible = !restrictionReason.contains(
|
||||
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
|
||||
class CarrierRoamingNtnModeCallback extends TelephonyCallback implements
|
||||
TelephonyCallback.CarrierRoamingNtnListener {
|
||||
@@ -197,12 +222,11 @@ public class SatelliteSettingPreferenceController extends
|
||||
logd("Satellite preference is not initialized yet");
|
||||
return;
|
||||
}
|
||||
if (isDataAvailable) {
|
||||
mIsServiceDataType = true;
|
||||
mPref.setTitle(R.string.title_satellite_setting_connectivity);
|
||||
} else if (isSmsAvailable) {
|
||||
mPref.setTitle(R.string.satellite_setting_title);
|
||||
}
|
||||
mIsServiceDataType = isDataAvailable;
|
||||
mIsSatelliteSmsAvailableForManualType = isSmsAvailable;
|
||||
mPref.setTitle(isDataAvailable ? R.string.title_satellite_setting_connectivity
|
||||
: R.string.satellite_setting_title);
|
||||
updateSummary(mPref);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user