summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2014-08-29 21:37:27 -0700
committerAmith Yamasani <yamasani@google.com>2014-08-29 22:06:16 -0700
commit1df1473008c24487701c5bc15f39ed9f9697f421 (patch)
treef3c285d16af9bfd1db7860b1647967c1c93b40aa /core/java
parent8b63a2bf503f7feca5c24f1cf9bca657dac9eb25 (diff)
downloadframeworks_base-1df1473008c24487701c5bc15f39ed9f9697f421.zip
frameworks_base-1df1473008c24487701c5bc15f39ed9f9697f421.tar.gz
frameworks_base-1df1473008c24487701c5bc15f39ed9f9697f421.tar.bz2
Make it possible to remove current user
Due to the async nature of switching users, it's not possible to switch and remove immediately. So mark the switch target user as soon as the user switch is requested, so that a remove will proceed without failing at stopUserLocked(). Also, fix a similar problem with deleting the current guest and switching to a new guest. It was attempting to remove the current user which will result in a failed stopping of the user. Added a way to mark the current guest for deletion so that a new one can be created, switched to and the old one deleted. If runtime fails, old guest is already marked for deletion and will be cleaned up on restart. Bug: 17321533 Change-Id: I4be0fb956227e0bb95588b5b1f2867fb1e655c0d
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/os/IUserManager.aidl1
-rw-r--r--core/java/android/os/UserManager.java16
2 files changed, 17 insertions, 0 deletions
diff --git a/core/java/android/os/IUserManager.aidl b/core/java/android/os/IUserManager.aidl
index 713fcd8..3286627 100644
--- a/core/java/android/os/IUserManager.aidl
+++ b/core/java/android/os/IUserManager.aidl
@@ -52,4 +52,5 @@ interface IUserManager {
void removeRestrictions();
void setDefaultGuestRestrictions(in Bundle restrictions);
Bundle getDefaultGuestRestrictions();
+ boolean markGuestForDeletion(int userHandle);
}
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index e215669..f793667 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -676,6 +676,22 @@ public class UserManager {
}
/**
+ * @hide
+ * Marks the guest user for deletion to allow a new guest to be created before deleting
+ * the current user who is a guest.
+ * @param userHandle
+ * @return
+ */
+ public boolean markGuestForDeletion(int userHandle) {
+ try {
+ return mService.markGuestForDeletion(userHandle);
+ } catch (RemoteException re) {
+ Log.w(TAG, "Could not mark guest for deletion", re);
+ return false;
+ }
+ }
+
+ /**
* Sets the user as enabled, if such an user exists.
* Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
* Note that the default is true, it's only that managed profiles might not be enabled.