Restrict ApnEditor settings
- Finish ApnEditor settings if user is not an admin - Finish ApnEditor settings if user has DISALLOW_CONFIG_MOBILE_NETWORKS restriction Bug: 279902472 Test: manual test atest -c ApnEditorTest (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:4e18e7414c674a1c5bc69961c03499849b4aefd2) Merged-In: Iecdbbff7e21dfb11e3ba385858747a220cfd3e04 Change-Id: Iecdbbff7e21dfb11e3ba385858747a220cfd3e04
This commit is contained in:
committed by
Cherrypicker Worker
parent
8bb22c308d
commit
5a17d39db7
@@ -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