Merge "Fix a bug where the wrong profile is queried" am: 167cc4a044 am: 92bbfaf0a2 am: 1bc19cb6a9
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1662362 Change-Id: I5498b7eb2b1b3e4e195ac47d8d3b471496b779b6
This commit is contained in:
@@ -9525,14 +9525,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
throw new IllegalArgumentException("Must explicitly specify a user handle ("
|
||||
+ "UserHandle.CURRENT not supported)");
|
||||
}
|
||||
final UserManager um;
|
||||
try {
|
||||
um = mContext.createContextAsUser(profile, 0 /* flags */)
|
||||
.getSystemService(UserManager.class);
|
||||
} catch (IllegalStateException e) {
|
||||
throw new IllegalArgumentException("Profile does not exist");
|
||||
}
|
||||
if (!um.isManagedProfile()) {
|
||||
final UserManager um = mContext.getSystemService(UserManager.class);
|
||||
if (!um.isManagedProfile(profile.getIdentifier())) {
|
||||
throw new IllegalArgumentException("Profile must be a managed profile");
|
||||
}
|
||||
// Strictly speaking, mOemNetworkPreferences should only be touched on the
|
||||
|
||||
@@ -578,6 +578,7 @@ public class ConnectivityServiceTest {
|
||||
final UserManager umMock = createContextAsUser(userHandle, 0 /* flags */)
|
||||
.getSystemService(UserManager.class);
|
||||
doReturn(value).when(umMock).isManagedProfile();
|
||||
doReturn(value).when(mUserManager).isManagedProfile(eq(userHandle.getIdentifier()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user