am 37d64712: am 0141faec: Merge "Allow services to query the info for a dying user." into jb-mr1-dev
* commit '37d6471207192d3904616b6b08b970574aa73235': Allow services to query the info for a dying user.
This commit is contained in:
@@ -62,6 +62,8 @@ public class UserManagerService extends IUserManager.Stub {
|
|||||||
|
|
||||||
private static final String LOG_TAG = "UserManagerService";
|
private static final String LOG_TAG = "UserManagerService";
|
||||||
|
|
||||||
|
private static final boolean DBG = false;
|
||||||
|
|
||||||
private static final String TAG_NAME = "name";
|
private static final String TAG_NAME = "name";
|
||||||
private static final String ATTR_FLAGS = "flags";
|
private static final String ATTR_FLAGS = "flags";
|
||||||
private static final String ATTR_ICON_PATH = "icon";
|
private static final String ATTR_ICON_PATH = "icon";
|
||||||
@@ -97,6 +99,9 @@ public class UserManagerService extends IUserManager.Stub {
|
|||||||
private int[] mUserIds;
|
private int[] mUserIds;
|
||||||
private boolean mGuestEnabled;
|
private boolean mGuestEnabled;
|
||||||
private int mNextSerialNumber;
|
private int mNextSerialNumber;
|
||||||
|
// This resets on a reboot. Otherwise it keeps incrementing so that user ids are
|
||||||
|
// not reused in quick succession
|
||||||
|
private int mNextUserId = MIN_USER_ID;
|
||||||
|
|
||||||
private static UserManagerService sInstance;
|
private static UserManagerService sInstance;
|
||||||
|
|
||||||
@@ -199,7 +204,8 @@ public class UserManagerService extends IUserManager.Stub {
|
|||||||
*/
|
*/
|
||||||
private UserInfo getUserInfoLocked(int userId) {
|
private UserInfo getUserInfoLocked(int userId) {
|
||||||
UserInfo ui = mUsers.get(userId);
|
UserInfo ui = mUsers.get(userId);
|
||||||
if (ui != null && ui.partial) {
|
// If it is partial and not in the process of being removed, return as unknown user.
|
||||||
|
if (ui != null && ui.partial && !mRemovingUserIds.contains(userId)) {
|
||||||
Slog.w(LOG_TAG, "getUserInfo: unknown user #" + userId);
|
Slog.w(LOG_TAG, "getUserInfo: unknown user #" + userId);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -668,6 +674,7 @@ public class UserManagerService extends IUserManager.Stub {
|
|||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
userInfo.creationTime = (now > EPOCH_PLUS_30_YEARS) ? now : 0;
|
userInfo.creationTime = (now > EPOCH_PLUS_30_YEARS) ? now : 0;
|
||||||
userInfo.partial = true;
|
userInfo.partial = true;
|
||||||
|
Environment.getUserSystemDirectory(userInfo.id).mkdirs();
|
||||||
mUsers.put(userId, userInfo);
|
mUsers.put(userId, userInfo);
|
||||||
writeUserListLocked();
|
writeUserListLocked();
|
||||||
writeUserLocked(userInfo);
|
writeUserLocked(userInfo);
|
||||||
@@ -709,7 +716,7 @@ public class UserManagerService extends IUserManager.Stub {
|
|||||||
user.partial = true;
|
user.partial = true;
|
||||||
writeUserLocked(user);
|
writeUserLocked(user);
|
||||||
}
|
}
|
||||||
|
if (DBG) Slog.i(LOG_TAG, "Stopping user " + userHandle);
|
||||||
int res;
|
int res;
|
||||||
try {
|
try {
|
||||||
res = ActivityManagerNative.getDefault().stopUser(userHandle,
|
res = ActivityManagerNative.getDefault().stopUser(userHandle,
|
||||||
@@ -730,12 +737,13 @@ public class UserManagerService extends IUserManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void finishRemoveUser(int userHandle) {
|
void finishRemoveUser(int userHandle) {
|
||||||
|
if (DBG) Slog.i(LOG_TAG, "finishRemoveUser " + userHandle);
|
||||||
synchronized (mInstallLock) {
|
synchronized (mInstallLock) {
|
||||||
synchronized (mPackagesLock) {
|
synchronized (mPackagesLock) {
|
||||||
removeUserStateLocked(userHandle);
|
removeUserStateLocked(userHandle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (DBG) Slog.i(LOG_TAG, "Removed user " + userHandle + ", sending broadcast");
|
||||||
// Let other services shutdown any activity
|
// Let other services shutdown any activity
|
||||||
long ident = Binder.clearCallingIdentity();
|
long ident = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
@@ -804,10 +812,11 @@ public class UserManagerService extends IUserManager.Stub {
|
|||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int[] newUsers = new int[num];
|
final int[] newUsers = new int[num];
|
||||||
|
int n = 0;
|
||||||
for (int i = 0; i < mUsers.size(); i++) {
|
for (int i = 0; i < mUsers.size(); i++) {
|
||||||
if (!mUsers.valueAt(i).partial) {
|
if (!mUsers.valueAt(i).partial) {
|
||||||
newUsers[i] = mUsers.keyAt(i);
|
newUsers[n++] = mUsers.keyAt(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mUserIds = newUsers;
|
mUserIds = newUsers;
|
||||||
@@ -840,13 +849,14 @@ public class UserManagerService extends IUserManager.Stub {
|
|||||||
*/
|
*/
|
||||||
private int getNextAvailableIdLocked() {
|
private int getNextAvailableIdLocked() {
|
||||||
synchronized (mPackagesLock) {
|
synchronized (mPackagesLock) {
|
||||||
int i = MIN_USER_ID;
|
int i = mNextUserId;
|
||||||
while (i < Integer.MAX_VALUE) {
|
while (i < Integer.MAX_VALUE) {
|
||||||
if (mUsers.indexOfKey(i) < 0 && !mRemovingUserIds.contains(i)) {
|
if (mUsers.indexOfKey(i) < 0 && !mRemovingUserIds.contains(i)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
mNextUserId = i + 1;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user