Add UserManagerInternal method to get the main user id.

This adds a method to get the id of the main user on the device.

Currently this always returns the id of the system user.

Bug: 256624031
Test: atest VpnManagerServiceTest (with topic)
Merged-In: Ib36f3b372f9bf33cbb097c4af63eb43515ac835b
Change-Id: I4aa0feb68083460c6aef917337e8bfc09a6788d4
This commit is contained in:
Oli Lan
2023-01-05 17:50:41 +00:00
parent ab810ba161
commit 051f571479
2 changed files with 11 additions and 0 deletions

View File

@@ -305,4 +305,10 @@ public abstract class UserManagerInternal {
* for users that already existed on-disk from an older version of Android. * for users that already existed on-disk from an older version of Android.
*/ */
public abstract boolean shouldIgnorePrepareStorageErrors(int userId); public abstract boolean shouldIgnorePrepareStorageErrors(int userId);
/**
* Returns the user id of the main user, or {@link android.os.UserHandle#USER_NULL} if there is
* no main user.
*/
public abstract @UserIdInt int getMainUserId();
} }

View File

@@ -6359,6 +6359,11 @@ public class UserManagerService extends IUserManager.Stub {
return userData != null && userData.getIgnorePrepareStorageErrors(); return userData != null && userData.getIgnorePrepareStorageErrors();
} }
} }
@Override
public @UserIdInt int getMainUserId() {
return UserHandle.USER_SYSTEM;
}
} }
/** /**