Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 05ce40e1 authored by Fyodor Kupolov's avatar Fyodor Kupolov Committed by Android (Google) Code Review
Browse files

Merge "Use UserHandle instead of int for public APIs"

parents 48a09a06 385de624
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -23427,7 +23427,7 @@ package android.os {
    method public android.os.Bundle getApplicationRestrictions(java.lang.String);
    method public long getSerialNumberForUser(android.os.UserHandle);
    method public int getUserCount();
    method public long getUserCreationTime(int);
    method public long getUserCreationTime(android.os.UserHandle);
    method public android.os.UserHandle getUserForSerialNumber(long);
    method public java.lang.String getUserName();
    method public java.util.List<android.os.UserHandle> getUserProfiles();
+1 −1
Original line number Diff line number Diff line
@@ -25319,7 +25319,7 @@ package android.os {
    method public android.os.Bundle getApplicationRestrictions(java.lang.String);
    method public long getSerialNumberForUser(android.os.UserHandle);
    method public int getUserCount();
    method public long getUserCreationTime(int);
    method public long getUserCreationTime(android.os.UserHandle);
    method public android.os.UserHandle getUserForSerialNumber(long);
    method public java.lang.String getUserName();
    method public java.util.List<android.os.UserHandle> getUserProfiles();
+2 −2
Original line number Diff line number Diff line
@@ -1327,9 +1327,9 @@ public class UserManager {
     *                   calling user.
     * @return creation time in milliseconds since Epoch time.
     */
    public long getUserCreationTime(int userHandle) {
    public long getUserCreationTime(UserHandle userHandle) {
        try {
            return mService.getUserCreationTime(userHandle);
            return mService.getUserCreationTime(userHandle.getIdentifier());
        } catch (RemoteException re) {
            Log.w(TAG, "Could not get user creation time", re);
            return 0;
+6 −4
Original line number Diff line number Diff line
@@ -138,14 +138,16 @@ public class UserManagerTest extends AndroidTestCase {
        assertNotNull(profile);
        assertTrue("creationTime must be set when the profile is created",
                profile.creationTime > 0);
        assertEquals(profile.creationTime, mUserManager.getUserCreationTime(profile.id));
        assertEquals(profile.creationTime, mUserManager.getUserCreationTime(
                new UserHandle(profile.id)));

        long ownerCreationTime = mUserManager.getUserInfo(UserHandle.USER_OWNER).creationTime;
        assertEquals(ownerCreationTime, mUserManager.getUserCreationTime(UserHandle.USER_OWNER));
        assertEquals(ownerCreationTime, mUserManager.getUserCreationTime(
                new UserHandle(UserHandle.USER_OWNER)));

        try {
            int noSuchUserId = 100500;
            mUserManager.getUserCreationTime(noSuchUserId);
            mUserManager.getUserCreationTime(new UserHandle(noSuchUserId));
            fail("SecurityException should be thrown for nonexistent user");
        } catch (Exception e) {
            assertTrue("SecurityException should be thrown for nonexistent user, but was: " + e,
@@ -154,7 +156,7 @@ public class UserManagerTest extends AndroidTestCase {

        UserInfo user = createUser("User 1", 0);
        try {
            mUserManager.getUserCreationTime(user.id);
            mUserManager.getUserCreationTime(new UserHandle(user.id));
            fail("SecurityException should be thrown for other user");
        } catch (Exception e) {
            assertTrue("SecurityException should be thrown for other user, but was: " + e,