Add getProfileParentId (1/2)

Bluetooth service needs to natively access id of parent profile. Add
method exposing it.

Test: cts-tradefed run cts-dev -m DevicePolicyManager --test
com.android.cts.devicepolicy.ManagedProfileTest#testBluetooth
Bug: 69284968
Change-Id: I697906f2959b0736c1d3cc6af7560c27d77ce11b
This commit is contained in:
Jakub Pawlowski
2017-11-15 14:50:43 -08:00
parent 9b08e4cb8d
commit 0f1f5b7953
2 changed files with 17 additions and 0 deletions

View File

@@ -35,6 +35,10 @@ interface IUserManager {
* DO NOT MOVE - UserManager.h depends on the ordering of this function.
*/
int getCredentialOwnerProfile(int userHandle);
int getProfileParentId(int userHandle);
/*
* END OF DO NOT MOVE
*/
UserInfo createUser(in String name, int flags);
UserInfo createProfileForUser(in String name, int flags, int userHandle,

View File

@@ -714,6 +714,19 @@ public class UserManagerService extends IUserManager.Stub {
}
}
@Override
public int getProfileParentId(int userHandle) {
checkManageUsersPermission("get the profile parent");
synchronized (mUsersLock) {
UserInfo profileParent = getProfileParentLU(userHandle);
if (profileParent == null) {
return userHandle;
}
return profileParent.id;
}
}
private UserInfo getProfileParentLU(int userHandle) {
UserInfo profile = getUserInfoLU(userHandle);
if (profile == null) {