DISALLOW_CONFIG_MOBILE_NETWORKS for Mobile Network

- Avoid intent start MobileNetworkSettings page
 - Avoid Mobile network preference show on screen

Flag: EXEMPT bug fix
Fix: 289232540
Test: Manual test. see b/289232540#28
Test: atest passed

Change-Id: I25b75673fbc0758dc06ca15f890e5dee0ea1367f
This commit is contained in:
tomhsu
2024-08-07 07:18:08 +00:00
committed by Tom Hsu
parent 1010a85eda
commit e7cc2791f6
3 changed files with 12 additions and 3 deletions

View File

@@ -241,6 +241,8 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
if (mSubsGearPref == null) {
mPreferenceGroup.removeAll();
mSubsGearPref = new MutableGearPreference(mContext, null);
mSubsGearPref
.checkRestrictionAndSetDisabled(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS);
mSubsGearPref.setOnPreferenceClickListener(preference -> {
connectCarrierNetwork();
return true;

View File

@@ -202,6 +202,11 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings impleme
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (isUiRestricted()) {
Log.d(LOG_TAG, "Mobile network page is disallowed.");
finish();
return;
}
if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
Log.d(LOG_TAG, "Invalid subId, get the default subscription to show.");

View File

@@ -41,11 +41,13 @@ public class MutableGearPreference extends GearPreference {
@Override
public void setGearEnabled(boolean enabled) {
boolean state = false;
if (mGear != null) {
mGear.setEnabled(enabled);
mGear.setImageAlpha(enabled ? VALUE_ENABLED_ALPHA : mDisabledAlphaValue);
state = enabled && !(isDisabledByAdmin() || isDisabledByEcm());
mGear.setEnabled(state);
mGear.setImageAlpha(state ? VALUE_ENABLED_ALPHA : mDisabledAlphaValue);
}
mGearState = enabled;
mGearState = state;
}
@Override