Merge "Fix a bug where the wrong profile is queried"
This commit is contained in:
@@ -9423,14 +9423,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
throw new IllegalArgumentException("Must explicitly specify a user handle ("
|
throw new IllegalArgumentException("Must explicitly specify a user handle ("
|
||||||
+ "UserHandle.CURRENT not supported)");
|
+ "UserHandle.CURRENT not supported)");
|
||||||
}
|
}
|
||||||
final UserManager um;
|
final UserManager um = mContext.getSystemService(UserManager.class);
|
||||||
try {
|
if (!um.isManagedProfile(profile.getIdentifier())) {
|
||||||
um = mContext.createContextAsUser(profile, 0 /* flags */)
|
|
||||||
.getSystemService(UserManager.class);
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
throw new IllegalArgumentException("Profile does not exist");
|
|
||||||
}
|
|
||||||
if (!um.isManagedProfile()) {
|
|
||||||
throw new IllegalArgumentException("Profile must be a managed profile");
|
throw new IllegalArgumentException("Profile must be a managed profile");
|
||||||
}
|
}
|
||||||
// Strictly speaking, mOemNetworkPreferences should only be touched on the
|
// Strictly speaking, mOemNetworkPreferences should only be touched on the
|
||||||
|
|||||||
@@ -578,6 +578,7 @@ public class ConnectivityServiceTest {
|
|||||||
final UserManager umMock = createContextAsUser(userHandle, 0 /* flags */)
|
final UserManager umMock = createContextAsUser(userHandle, 0 /* flags */)
|
||||||
.getSystemService(UserManager.class);
|
.getSystemService(UserManager.class);
|
||||||
doReturn(value).when(umMock).isManagedProfile();
|
doReturn(value).when(umMock).isManagedProfile();
|
||||||
|
doReturn(value).when(mUserManager).isManagedProfile(eq(userHandle.getIdentifier()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user