Merge "[Settings] User with restriction should avoid from having entries through Settings search"

This commit is contained in:
Bonian Chen
2023-02-10 08:52:55 +00:00
committed by Android (Google) Code Review
2 changed files with 21 additions and 1 deletions

View File

@@ -49,6 +49,7 @@ import android.os.Bundle;
import android.os.PersistableBundle;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserManager;
import android.provider.Settings;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
@@ -114,6 +115,23 @@ public class MobileNetworkUtils {
public static final int NO_CELL_DATA_TYPE_ICON = 0;
public static final Drawable EMPTY_DRAWABLE = new ColorDrawable(Color.TRANSPARENT);
/**
* Return true if current user limited by UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS.
*
* Note: Guest user should have this restriction through
* GuestTelephonyPreferenceController.java.
* However, it's not help with those devices upgraded their software.
*/
public static boolean isMobileNetworkUserRestricted(Context context) {
UserManager um = context.getSystemService(UserManager.class);
boolean disallow = false;
if (um != null) {
disallow = um.isGuestUser() || um.hasUserRestriction(
UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS);
}
return disallow;
}
/**
* Returns if DPC APNs are enforced.
*/