diff options
author | Amith Yamasani <yamasani@google.com> | 2014-09-03 13:17:28 -0700 |
---|---|---|
committer | Amith Yamasani <yamasani@google.com> | 2014-09-03 13:17:28 -0700 |
commit | 0e8d7d63ba439cc0604af7055679dae3d30fdc48 (patch) | |
tree | c1602cdb8d5fee4547fe06bdb8b77563344383a9 | |
parent | 0fd79c955b3745648d5f326bc784ced1e1188935 (diff) | |
download | frameworks_base-0e8d7d63ba439cc0604af7055679dae3d30fdc48.zip frameworks_base-0e8d7d63ba439cc0604af7055679dae3d30fdc48.tar.gz frameworks_base-0e8d7d63ba439cc0604af7055679dae3d30fdc48.tar.bz2 |
Add some @SystemApi tags for internal user-related APIs
Also added an internal isManagedProfile()
Bug: 17371392
Change-Id: Ibcc26771d954505cbd530192bf4a8a25a8d4cae0
-rw-r--r-- | core/java/android/app/ActivityManager.java | 8 | ||||
-rw-r--r-- | core/java/android/os/UserHandle.java | 7 | ||||
-rw-r--r-- | core/java/android/os/UserManager.java | 14 | ||||
-rw-r--r-- | services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java | 3 |
4 files changed, 29 insertions, 3 deletions
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index bc54055..3e03893 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -18,12 +18,14 @@ package android.app; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.SystemApi; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Point; import android.os.BatteryStats; import android.os.IBinder; import android.os.ParcelFileDescriptor; + import com.android.internal.app.ProcessStats; import com.android.internal.os.TransferPipe; import com.android.internal.util.FastPrintWriter; @@ -2464,7 +2466,11 @@ public class ActivityManager { } } - /** @hide */ + /** + * Gets the userId of the current foreground user. Requires system permissions. + * @hide + */ + @SystemApi public static int getCurrentUser() { UserInfo ui; try { diff --git a/core/java/android/os/UserHandle.java b/core/java/android/os/UserHandle.java index 5ce9d5c..0ff5f6a 100644 --- a/core/java/android/os/UserHandle.java +++ b/core/java/android/os/UserHandle.java @@ -234,6 +234,7 @@ public final class UserHandle implements Parcelable { * @return user id of the current process * @hide */ + @SystemApi public static final int myUserId() { return getUserId(Process.myUid()); } @@ -253,7 +254,11 @@ public final class UserHandle implements Parcelable { mHandle = h; } - /** @hide */ + /** + * Returns the userId stored in this UserHandle. + * @hide + */ + @SystemApi public int getIdentifier() { return mHandle; } diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index f793667..59220e1 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -15,6 +15,7 @@ */ package android.os; +import android.annotation.SystemApi; import android.app.ActivityManager; import android.app.ActivityManagerNative; import android.content.Context; @@ -424,6 +425,19 @@ public class UserManager { } /** + * Checks if the calling app is running in a managed profile. + * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. + * + * @return whether the caller is in a managed profile. + * @hide + */ + @SystemApi + public boolean isManagedProfile() { + UserInfo user = getUserInfo(UserHandle.myUserId()); + return user != null ? user.isManagedProfile() : false; + } + + /** * Return whether the given user is actively running. This means that * the user is in the "started" state, not "stopped" -- it is currently * allowed to run code through scheduled alarms, receiving broadcasts, diff --git a/services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java b/services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java index 6e13732..a0b8c94 100644 --- a/services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java +++ b/services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java @@ -125,7 +125,8 @@ public class UserManagerTest extends AndroidTestCase { UserInfo.FLAG_MANAGED_PROFILE, UserHandle.USER_OWNER); assertNotNull(userInfo1); assertNull(userInfo2); - + // Verify that current user is not a managed profile + assertFalse(mUserManager.isManagedProfile()); // Cleanup removeUser(userInfo1.id); } |