Merge "Restrict ApnEditor settings" into udc-dev am: 64c88a192a
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/23982512 Change-Id: Ic052e568818d4829fe40250e00679742fc816263 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -25,6 +25,7 @@ import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.PersistableBundle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Telephony;
|
||||
import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
@@ -281,6 +282,11 @@ public class ApnEditor extends SettingsPreferenceFragment
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
if (isUserRestricted()) {
|
||||
Log.e(TAG, "This setting isn't available due to user restriction.");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
setLifecycleForAllControllers();
|
||||
|
||||
@@ -1453,6 +1459,23 @@ public class ApnEditor extends SettingsPreferenceFragment
|
||||
return apnData;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean isUserRestricted() {
|
||||
UserManager userManager = getContext().getSystemService(UserManager.class);
|
||||
if (userManager == null) {
|
||||
return false;
|
||||
}
|
||||
if (!userManager.isAdminUser()) {
|
||||
Log.e(TAG, "User is not an admin");
|
||||
return true;
|
||||
}
|
||||
if (userManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
|
||||
Log.e(TAG, "User is not allowed to configure mobile network");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static class ApnData {
|
||||
/**
|
||||
|
Reference in New Issue
Block a user