Merge "DISALLOW_CONFIG_MOBILE_NETWORKS for Mobile Network" into main

This commit is contained in:
Tom Hsu
2024-08-12 04:29:41 +00:00
committed by Android (Google) Code Review
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