Merge "Expose locations from NotifStackScrollLayout"
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java
index f415c85..5454b46 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -1033,18 +1033,18 @@
public void runCreateUser() {
String name;
- int relatedUserId = -1;
+ int userId = -1;
int flags = 0;
String opt;
while ((opt = nextOption()) != null) {
- if ("--relatedTo".equals(opt)) {
+ if ("--profileOf".equals(opt)) {
String optionData = nextOptionData();
if (optionData == null || !isNumber(optionData)) {
System.err.println("Error: no USER_ID specified");
showUsage();
return;
} else {
- relatedUserId = Integer.parseInt(optionData);
+ userId = Integer.parseInt(optionData);
}
} else if ("--managed".equals(opt)) {
flags |= UserInfo.FLAG_MANAGED_PROFILE;
@@ -1062,14 +1062,14 @@
name = arg;
try {
UserInfo info = null;
- if (relatedUserId < 0) {
+ if (userId < 0) {
info = mUm.createUser(name, flags);
} else {
if (Process.myUid() != 0) {
System.err.println("Error: not running as root.");
return;
}
- info = mUm.createRelatedUser(name, flags, relatedUserId);
+ info = mUm.createProfileForUser(name, flags, userId);
}
if (info != null) {
System.out.println("Success: created user id " + info.id);
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index d386eff..9d6a340 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -605,11 +605,11 @@
public static final int RECENT_IGNORE_UNAVAILABLE = 0x0002;
/**
- * Provides a list that also contains recent tasks for user
- * and related users.
+ * Provides a list that contains recent tasks for all
+ * profiles of a user.
* @hide
*/
- public static final int RECENT_INCLUDE_RELATED = 0x0004;
+ public static final int RECENT_INCLUDE_PROFILES = 0x0004;
/**
* Return a list of the tasks that the user has recently launched, with
diff --git a/core/java/android/content/pm/UserInfo.java b/core/java/android/content/pm/UserInfo.java
index 6f1d4f8..f53aa4c 100644
--- a/core/java/android/content/pm/UserInfo.java
+++ b/core/java/android/content/pm/UserInfo.java
@@ -71,7 +71,7 @@
public static final int FLAG_MANAGED_PROFILE = 0x00000020;
- public static final int NO_RELATED_GROUP_ID = -1;
+ public static final int NO_PROFILE_GROUP_ID = -1;
public int id;
public int serialNumber;
@@ -80,7 +80,7 @@
public int flags;
public long creationTime;
public long lastLoggedInTime;
- public int relatedGroupId;
+ public int profileGroupId;
/** User is only partially created. */
public boolean partial;
@@ -94,7 +94,7 @@
this.name = name;
this.flags = flags;
this.iconPath = iconPath;
- this.relatedGroupId = NO_RELATED_GROUP_ID;
+ this.profileGroupId = NO_PROFILE_GROUP_ID;
}
public boolean isPrimary() {
@@ -137,7 +137,7 @@
creationTime = orig.creationTime;
lastLoggedInTime = orig.lastLoggedInTime;
partial = orig.partial;
- relatedGroupId = orig.relatedGroupId;
+ profileGroupId = orig.profileGroupId;
}
public UserHandle getUserHandle() {
@@ -162,7 +162,7 @@
dest.writeLong(creationTime);
dest.writeLong(lastLoggedInTime);
dest.writeInt(partial ? 1 : 0);
- dest.writeInt(relatedGroupId);
+ dest.writeInt(profileGroupId);
}
public static final Parcelable.Creator<UserInfo> CREATOR
@@ -184,6 +184,6 @@
creationTime = source.readLong();
lastLoggedInTime = source.readLong();
partial = source.readInt() != 0;
- relatedGroupId = source.readInt();
+ profileGroupId = source.readInt();
}
}
diff --git a/core/java/android/os/IUserManager.aidl b/core/java/android/os/IUserManager.aidl
index 6e6c06d..1192a45 100644
--- a/core/java/android/os/IUserManager.aidl
+++ b/core/java/android/os/IUserManager.aidl
@@ -28,13 +28,13 @@
*/
interface IUserManager {
UserInfo createUser(in String name, int flags);
- UserInfo createRelatedUser(in String name, int flags, int relatedUserId);
+ UserInfo createProfileForUser(in String name, int flags, int userHandle);
boolean removeUser(int userHandle);
void setUserName(int userHandle, String name);
void setUserIcon(int userHandle, in Bitmap icon);
Bitmap getUserIcon(int userHandle);
List<UserInfo> getUsers(boolean excludeDying);
- List<UserInfo> getRelatedUsers(int userHandle);
+ List<UserInfo> getProfiles(int userHandle);
UserInfo getUserInfo(int userHandle);
boolean isRestricted();
void setGuestEnabled(boolean enable);
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 1ec5cd5..520a08c 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -410,20 +410,29 @@
}
/**
- * Creates a user with the specified name and options.
+ * Renamed, just present to avoid multi project commit.
+ * TODO delete.
+ * @hide
+ */
+ public UserInfo createRelatedUser(String name, int flags, int relatedUserId) {
+ return createProfileForUser(name, flags, relatedUserId);
+ }
+
+ /**
+ * Creates a user with the specified name and options as a profile of another user.
* Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
*
* @param name the user's name
* @param flags flags that identify the type of user and other properties.
* @see UserInfo
- * @param relatedUserId new user will be related to this user id.
+ * @param userHandle new user will be a profile of this use.
*
* @return the UserInfo object for the created user, or null if the user could not be created.
* @hide
*/
- public UserInfo createRelatedUser(String name, int flags, int relatedUserId) {
+ public UserInfo createProfileForUser(String name, int flags, int userHandle) {
try {
- return mService.createRelatedUser(name, flags, relatedUserId);
+ return mService.createProfileForUser(name, flags, userHandle);
} catch (RemoteException re) {
Log.w(TAG, "Could not create a user", re);
return null;
@@ -454,15 +463,26 @@
}
/**
- * Returns information for all users related to userId
- * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
- * @param userHandle users related to this user id will be returned.
- * @return the list of related users.
+ * Renaming, left to avoid multi project commit.
+ * TODO Delete.
* @hide
*/
public List<UserInfo> getRelatedUsers(int userHandle) {
+ return getProfiles(userHandle);
+ }
+
+ /**
+ * Returns list of the profiles of userHandle including
+ * userHandle itself.
+ *
+ * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
+ * @param userHandle profiles of this user will be returned.
+ * @return the list of profiles.
+ * @hide
+ */
+ public List<UserInfo> getProfiles(int userHandle) {
try {
- return mService.getRelatedUsers(userHandle);
+ return mService.getProfiles(userHandle);
} catch (RemoteException re) {
Log.w(TAG, "Could not get user list", re);
return null;
diff --git a/core/java/com/android/internal/inputmethod/InputMethodUtils.java b/core/java/com/android/internal/inputmethod/InputMethodUtils.java
index 03a053c..f9e5569 100644
--- a/core/java/com/android/internal/inputmethod/InputMethodUtils.java
+++ b/core/java/com/android/internal/inputmethod/InputMethodUtils.java
@@ -504,7 +504,7 @@
private String mEnabledInputMethodsStrCache;
private int mCurrentUserId;
- private int[] mRelatedUserIds = new int[0];
+ private int[] mCurrentProfileIds = new int[0];
private static void buildEnabledInputMethodsSettingString(
StringBuilder builder, Pair<String, ArrayList<String>> pair) {
@@ -537,17 +537,16 @@
mCurrentUserId = userId;
}
- public void setRelatedUserIds(int[] relatedUserIds) {
+ public void setCurrentProfileIds(int[] currentProfileIds) {
synchronized (this) {
- mRelatedUserIds = relatedUserIds;
+ mCurrentProfileIds = currentProfileIds;
}
}
- public boolean isRelatedToOrCurrentUser(int userId) {
+ public boolean isCurrentProfile(int userId) {
synchronized (this) {
- if (userId == mCurrentUserId) return true;
- for (int i = 0; i < mRelatedUserIds.length; i++) {
- if (userId == mRelatedUserIds[i]) return true;
+ for (int i = 0; i < mCurrentProfileIds.length; i++) {
+ if (userId == mCurrentProfileIds[i]) return true;
}
return false;
}
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentTasksLoader.java b/packages/SystemUI/src/com/android/systemui/recent/RecentTasksLoader.java
index 9d2d6ee..ab2ad96 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentTasksLoader.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentTasksLoader.java
@@ -368,7 +368,7 @@
final ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
final List<ActivityManager.RecentTaskInfo> recentTasks = am.getRecentTasksForUser(1,
- ActivityManager.RECENT_IGNORE_UNAVAILABLE | ActivityManager.RECENT_INCLUDE_RELATED,
+ ActivityManager.RECENT_IGNORE_UNAVAILABLE | ActivityManager.RECENT_INCLUDE_PROFILES,
UserHandle.CURRENT.getIdentifier());
TaskDescription item = null;
if (recentTasks.size() > 0) {
@@ -441,7 +441,7 @@
final List<ActivityManager.RecentTaskInfo> recentTasks =
am.getRecentTasks(MAX_TASKS, ActivityManager.RECENT_IGNORE_UNAVAILABLE
- | ActivityManager.RECENT_INCLUDE_RELATED);
+ | ActivityManager.RECENT_INCLUDE_PROFILES);
int numTasks = recentTasks.size();
ActivityInfo homeInfo = new Intent(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_HOME).resolveActivityInfo(pm, 0);
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java
index f75ea92..7ab40b0 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java
@@ -165,7 +165,7 @@
am.getRecentTasks(2,
ActivityManager.RECENT_WITH_EXCLUDED |
ActivityManager.RECENT_IGNORE_UNAVAILABLE |
- ActivityManager.RECENT_INCLUDE_RELATED);
+ ActivityManager.RECENT_INCLUDE_PROFILES);
if (recentTasks.size() > 1 &&
mRecentsPanel.simulateClick(recentTasks.get(1).persistentId)) {
// recents panel will take care of calling show(false) through simulateClick
diff --git a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
index 1a616a0..227e19d 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
@@ -221,7 +221,7 @@
Bitmap loadFirstTaskThumbnail() {
ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RecentTaskInfo> tasks = am.getRecentTasksForUser(1,
- ActivityManager.RECENT_IGNORE_UNAVAILABLE | ActivityManager.RECENT_INCLUDE_RELATED,
+ ActivityManager.RECENT_IGNORE_UNAVAILABLE | ActivityManager.RECENT_INCLUDE_PROFILES,
UserHandle.CURRENT.getIdentifier());
for (ActivityManager.RecentTaskInfo t : tasks) {
// Skip tasks in the home stack
@@ -239,7 +239,7 @@
boolean hasFirstTask() {
ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RecentTaskInfo> tasks = am.getRecentTasksForUser(1,
- ActivityManager.RECENT_IGNORE_UNAVAILABLE | ActivityManager.RECENT_INCLUDE_RELATED,
+ ActivityManager.RECENT_IGNORE_UNAVAILABLE | ActivityManager.RECENT_INCLUDE_PROFILES,
UserHandle.CURRENT.getIdentifier());
for (ActivityManager.RecentTaskInfo t : tasks) {
// Skip tasks in the home stack
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java
index 90c83d0..928c732 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java
@@ -376,7 +376,7 @@
// Get the recent tasks
List<ActivityManager.RecentTaskInfo> tasks = am.getRecentTasksForUser(25,
ActivityManager.RECENT_IGNORE_UNAVAILABLE |
- ActivityManager.RECENT_INCLUDE_RELATED, UserHandle.CURRENT.getIdentifier());
+ ActivityManager.RECENT_INCLUDE_PROFILES, UserHandle.CURRENT.getIdentifier());
Collections.reverse(tasks);
Console.log(Constants.DebugFlags.App.TimeSystemCalls,
"[RecentsTaskLoader|getRecentTasks]",
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index bad5641..e5e287d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -134,7 +134,7 @@
protected PopupMenu mNotificationBlamePopup;
protected int mCurrentUserId = 0;
- final protected SparseArray<UserInfo> mRelatedUsers = new SparseArray<UserInfo>();
+ final protected SparseArray<UserInfo> mCurrentProfiles = new SparseArray<UserInfo>();
protected int mLayoutDirection = -1; // invalid
private Locale mLocale;
@@ -244,21 +244,21 @@
String action = intent.getAction();
if (Intent.ACTION_USER_SWITCHED.equals(action)) {
mCurrentUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
- updateRelatedUserCache();
+ updateCurrentProfilesCache();
if (true) Log.v(TAG, "userId " + mCurrentUserId + " is in the house");
userSwitched(mCurrentUserId);
} else if (Intent.ACTION_USER_ADDED.equals(action)) {
- updateRelatedUserCache();
+ updateCurrentProfilesCache();
}
}
};
- private void updateRelatedUserCache() {
- synchronized (mRelatedUsers) {
- mRelatedUsers.clear();
+ private void updateCurrentProfilesCache() {
+ synchronized (mCurrentProfiles) {
+ mCurrentProfiles.clear();
if (mUserManager != null) {
- for (UserInfo related : mUserManager.getRelatedUsers(mCurrentUserId)) {
- mRelatedUsers.put(related.id, related);
+ for (UserInfo user : mUserManager.getProfiles(mCurrentUserId)) {
+ mCurrentProfiles.put(user.id, user);
}
}
}
@@ -361,24 +361,23 @@
filter.addAction(Intent.ACTION_USER_ADDED);
mContext.registerReceiver(mBroadcastReceiver, filter);
- updateRelatedUserCache();
+ updateCurrentProfilesCache();
}
public void userSwitched(int newUserId) {
// should be overridden
}
- public boolean notificationIsForCurrentOrRelatedUser(StatusBarNotification n) {
+ public boolean notificationIsForCurrentProfiles(StatusBarNotification n) {
final int thisUserId = mCurrentUserId;
final int notificationUserId = n.getUserId();
if (DEBUG && MULTIUSER_DEBUG) {
Log.v(TAG, String.format("%s: current userid: %d, notification userid: %d",
n, thisUserId, notificationUserId));
}
- synchronized (mRelatedUsers) {
+ synchronized (mCurrentProfiles) {
return notificationUserId == UserHandle.USER_ALL
- || thisUserId == notificationUserId
- || mRelatedUsers.get(notificationUserId) != null;
+ || mCurrentProfiles.get(notificationUserId) != null;
}
}
@@ -1258,7 +1257,7 @@
updateNotificationVetoButton(oldEntry.row, notification);
// Is this for you?
- boolean isForCurrentUser = notificationIsForCurrentOrRelatedUser(notification);
+ boolean isForCurrentUser = notificationIsForCurrentProfiles(notification);
if (DEBUG) Log.d(TAG, "notification is " + (isForCurrentUser ? "" : "not ") + "for you");
// Restart the ticker if it's still running
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index e7f96dc..2257aaa 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -1078,8 +1078,8 @@
Entry ent = mNotificationData.get(N-i-1);
if (!(provisioned || showNotificationEvenIfUnprovisioned(ent.notification))) continue;
- // TODO How do we want to badge notifcations from related users.
- if (!notificationIsForCurrentOrRelatedUser(ent.notification)) continue;
+ // TODO How do we want to badge notifcations from profiles.
+ if (!notificationIsForCurrentProfiles(ent.notification)) continue;
final int vis = ent.notification.getNotification().visibility;
if (vis != Notification.VISIBILITY_SECRET) {
@@ -1138,7 +1138,7 @@
Entry ent = mNotificationData.get(N-i-1);
if (!((provisioned && ent.notification.getScore() >= HIDE_ICONS_BELOW_SCORE)
|| showNotificationEvenIfUnprovisioned(ent.notification))) continue;
- if (!notificationIsForCurrentOrRelatedUser(ent.notification)) continue;
+ if (!notificationIsForCurrentProfiles(ent.notification)) continue;
if (isLockscreenPublicMode()
&& ent.notification.getNotification().visibility
== Notification.VISIBILITY_SECRET
@@ -2150,7 +2150,7 @@
if (!isDeviceProvisioned()) return;
// not for you
- if (!notificationIsForCurrentOrRelatedUser(n)) return;
+ if (!notificationIsForCurrentProfiles(n)) return;
// Show the ticker if one is requested. Also don't do this
// until status bar window is attached to the window manager,
diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java
index 5fb6405..e69c9a4 100644
--- a/services/core/java/com/android/server/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/InputMethodManagerService.java
@@ -445,7 +445,7 @@
return;
} else if (Intent.ACTION_USER_ADDED.equals(action)
|| Intent.ACTION_USER_REMOVED.equals(action)) {
- updateRelatedUserIds();
+ updateCurrentProfileIds();
return;
} else {
Slog.w(TAG, "Unexpected intent " + intent);
@@ -689,7 +689,7 @@
// mSettings should be created before buildInputMethodListLocked
mSettings = new InputMethodSettings(
mRes, context.getContentResolver(), mMethodMap, mMethodList, userId);
- updateRelatedUserIds();
+ updateCurrentProfileIds();
mFileManager = new InputMethodFileManager(mMethodMap, userId);
mSwitchingController = new InputMethodSubtypeSwitchingController(mSettings);
mSwitchingController.resetCircularListLocked(context);
@@ -805,7 +805,7 @@
private void switchUserLocked(int newUserId) {
mSettings.setCurrentUserId(newUserId);
- updateRelatedUserIds();
+ updateCurrentProfileIds();
// InputMethodFileManager should be reset when the user is changed
mFileManager = new InputMethodFileManager(mMethodMap, newUserId);
final String defaultImiId = mSettings.getSelectedInputMethod();
@@ -826,14 +826,14 @@
}
}
- void updateRelatedUserIds() {
- List<UserInfo> relatedUsers =
- UserManager.get(mContext).getRelatedUsers(mSettings.getCurrentUserId());
- int[] relatedUserIds = new int[relatedUsers.size()]; // relatedUsers will not be null
- for (int i = 0; i < relatedUserIds.length; i++) {
- relatedUserIds[i] = relatedUsers.get(i).id;
+ void updateCurrentProfileIds() {
+ List<UserInfo> profiles =
+ UserManager.get(mContext).getProfiles(mSettings.getCurrentUserId());
+ int[] currentProfileIds = new int[profiles.size()]; // profiles will not be null
+ for (int i = 0; i < currentProfileIds.length; i++) {
+ currentProfileIds[i] = profiles.get(i).id;
}
- mSettings.setRelatedUserIds(relatedUserIds);
+ mSettings.setCurrentProfileIds(currentProfileIds);
}
@Override
@@ -931,7 +931,7 @@
+ mSettings.getCurrentUserId() + ", calling pid = " + Binder.getCallingPid()
+ InputMethodUtils.getApiCallStack());
}
- if (uid == Process.SYSTEM_UID || mSettings.isRelatedToOrCurrentUser(userId)) {
+ if (uid == Process.SYSTEM_UID || mSettings.isCurrentProfile(userId)) {
return true;
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 39fbb65..ac6f684 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -1019,7 +1019,7 @@
final ActivityThread mSystemThread;
int mCurrentUserId = 0;
- int[] mRelatedUserIds = new int[0]; // Accessed by ActivityStack
+ int[] mCurrentProfileIds = new int[0]; // Accessed by ActivityStack
private UserManagerService mUserManager;
private final class AppDeathRecipient implements IBinder.DeathRecipient {
@@ -1078,7 +1078,7 @@
static final int IMMERSIVE_MODE_LOCK_MSG = 37;
static final int PERSIST_URI_GRANTS_MSG = 38;
static final int REQUEST_ALL_PSS_MSG = 39;
- static final int START_RELATED_USERS_MSG = 40;
+ static final int START_PROFILES_MSG = 40;
static final int UPDATE_TIME = 41;
static final int FIRST_ACTIVITY_STACK_MSG = 100;
@@ -1693,9 +1693,9 @@
requestPssAllProcsLocked(SystemClock.uptimeMillis(), true, false);
break;
}
- case START_RELATED_USERS_MSG: {
+ case START_PROFILES_MSG: {
synchronized (ActivityManagerService.this) {
- startRelatedUsersLocked();
+ startProfilesLocked();
}
break;
}
@@ -5208,7 +5208,7 @@
userId);
}
}
- scheduleStartRelatedUsersLocked();
+ scheduleStartProfilesLocked();
}
}
}
@@ -6863,8 +6863,8 @@
maxNum < N ? maxNum : N);
final Set<Integer> includedUsers;
- if ((flags & ActivityManager.RECENT_INCLUDE_RELATED) != 0) {
- includedUsers = getRelatedUsersLocked(userId);
+ if ((flags & ActivityManager.RECENT_INCLUDE_PROFILES) != 0) {
+ includedUsers = getProfileIdsLocked(userId);
} else {
includedUsers = new HashSet<Integer>();
}
@@ -16317,19 +16317,19 @@
* user switch happens or when a new related user is started in the
* background.
*/
- private void updateRelatedUserIdsLocked() {
- final List<UserInfo> relatedUsers = getUserManagerLocked().getRelatedUsers(mCurrentUserId);
- int[] relatedUserIds = new int[relatedUsers.size()]; // relatedUsers will not be null
- for (int i = 0; i < relatedUserIds.length; i++) {
- relatedUserIds[i] = relatedUsers.get(i).id;
+ private void updateCurrentProfileIdsLocked() {
+ final List<UserInfo> profiles = getUserManagerLocked().getProfiles(mCurrentUserId);
+ int[] currentProfileIds = new int[profiles.size()]; // profiles will not be null
+ for (int i = 0; i < currentProfileIds.length; i++) {
+ currentProfileIds[i] = profiles.get(i).id;
}
- mRelatedUserIds = relatedUserIds;
+ mCurrentProfileIds = currentProfileIds;
}
- private Set getRelatedUsersLocked(int userId) {
+ private Set getProfileIdsLocked(int userId) {
Set userIds = new HashSet<Integer>();
- final List<UserInfo> relatedUsers = getUserManagerLocked().getRelatedUsers(userId);
- for (UserInfo user : relatedUsers) {
+ final List<UserInfo> profiles = getUserManagerLocked().getProfiles(userId);
+ for (UserInfo user : profiles) {
userIds.add(Integer.valueOf(user.id));
}
return userIds;
@@ -16390,15 +16390,15 @@
if (foreground) {
mCurrentUserId = userId;
- updateRelatedUserIdsLocked();
- mWindowManager.setCurrentUser(userId, mRelatedUserIds);
+ updateCurrentProfileIdsLocked();
+ mWindowManager.setCurrentUser(userId, mCurrentProfileIds);
// Once the internal notion of the active user has switched, we lock the device
// with the option to show the user switcher on the keyguard.
mWindowManager.lockNow(null);
} else {
final Integer currentUserIdInt = Integer.valueOf(mCurrentUserId);
- updateRelatedUserIdsLocked();
- mWindowManager.updateRelatedUserIds(mRelatedUserIds);
+ updateCurrentProfileIdsLocked();
+ mWindowManager.setCurrentProfileIds(mCurrentProfileIds);
mUserLru.remove(currentUserIdInt);
mUserLru.add(currentUserIdInt);
}
@@ -16618,20 +16618,21 @@
}
}
- void scheduleStartRelatedUsersLocked() {
- if (!mHandler.hasMessages(START_RELATED_USERS_MSG)) {
- mHandler.sendMessageDelayed(mHandler.obtainMessage(START_RELATED_USERS_MSG),
+ void scheduleStartProfilesLocked() {
+ if (!mHandler.hasMessages(START_PROFILES_MSG)) {
+ mHandler.sendMessageDelayed(mHandler.obtainMessage(START_PROFILES_MSG),
DateUtils.SECOND_IN_MILLIS);
}
}
- void startRelatedUsersLocked() {
- if (DEBUG_MU) Slog.i(TAG_MU, "startRelatedUsersLocked");
- List<UserInfo> relatedUsers = getUserManagerLocked().getRelatedUsers(mCurrentUserId);
- List<UserInfo> toStart = new ArrayList<UserInfo>(relatedUsers.size());
- for (UserInfo relatedUser : relatedUsers) {
- if ((relatedUser.flags & UserInfo.FLAG_INITIALIZED) == UserInfo.FLAG_INITIALIZED) {
- toStart.add(relatedUser);
+ void startProfilesLocked() {
+ if (DEBUG_MU) Slog.i(TAG_MU, "startProfilesLocked");
+ List<UserInfo> profiles = getUserManagerLocked().getProfiles(mCurrentUserId);
+ List<UserInfo> toStart = new ArrayList<UserInfo>(profiles.size());
+ for (UserInfo user : profiles) {
+ if ((user.flags & UserInfo.FLAG_INITIALIZED) == UserInfo.FLAG_INITIALIZED
+ && user.id != mCurrentUserId) {
+ toStart.add(user);
}
}
final int n = toStart.size();
@@ -16640,7 +16641,7 @@
startUserInBackground(toStart.get(i).id);
}
if (i < n) {
- Slog.w(TAG_MU, "More related users than MAX_RUNNING_USERS");
+ Slog.w(TAG_MU, "More profiles than MAX_RUNNING_USERS");
}
}
@@ -16659,7 +16660,7 @@
true, false, MY_PID, Process.SYSTEM_UID, userId);
}
- startRelatedUsersLocked();
+ startProfilesLocked();
int num = mUserLru.size();
int i = 0;
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 6ee3e07..d949ba0 100755
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -341,18 +341,17 @@
}
/**
- * Checks whether the userid is either the current user or a related user.
+ * Checks whether the userid is a profile of the current user.
*/
- private boolean isRelatedToOrCurrentUserLocked(int userId) {
- if (mCurrentUser == userId) return true;
- for (int i = 0; i < mService.mRelatedUserIds.length; i++) {
- if (mService.mRelatedUserIds[i] == userId) return true;
+ private boolean isCurrentProfileLocked(int userId) {
+ for (int i = 0; i < mService.mCurrentProfileIds.length; i++) {
+ if (mService.mCurrentProfileIds[i] == userId) return true;
}
return false;
}
boolean okToShowLocked(ActivityRecord r) {
- return isRelatedToOrCurrentUserLocked(r.userId)
+ return isCurrentProfileLocked(r.userId)
|| (r.info.flags & ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN) != 0;
}
@@ -571,7 +570,7 @@
for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
TaskRecord task = mTaskHistory.get(taskNdx);
- if (!isRelatedToOrCurrentUserLocked(task.userId)) {
+ if (!isCurrentProfileLocked(task.userId)) {
return null;
}
final ArrayList<ActivityRecord> activities = task.mActivities;
@@ -602,7 +601,7 @@
int index = mTaskHistory.size();
for (int i = 0; i < index; ) {
TaskRecord task = mTaskHistory.get(i);
- if (isRelatedToOrCurrentUserLocked(task.userId)) {
+ if (isCurrentProfileLocked(task.userId)) {
if (DEBUG_TASKS) Slog.d(TAG, "switchUserLocked: stack=" + getStackId() +
" moving " + task + " to top");
mTaskHistory.remove(i);
@@ -1766,10 +1765,10 @@
mTaskHistory.remove(task);
// Now put task at top.
int stackNdx = mTaskHistory.size();
- if (!isRelatedToOrCurrentUserLocked(task.userId)) {
+ if (!isCurrentProfileLocked(task.userId)) {
// Put non-current user tasks below current user tasks.
while (--stackNdx >= 0) {
- if (!isRelatedToOrCurrentUserLocked(mTaskHistory.get(stackNdx).userId)) {
+ if (!isCurrentProfileLocked(mTaskHistory.get(stackNdx).userId)) {
break;
}
}
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index b4f7ae6..3b6d288 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -219,8 +219,8 @@
));
private static final String EXTRA_INTERCEPT = "android.intercept";
- // Users related to the current user.
- final protected SparseArray<UserInfo> mRelatedUsers = new SparseArray<UserInfo>();
+ // Profiles of the current user.
+ final protected SparseArray<UserInfo> mCurrentProfiles = new SparseArray<UserInfo>();
private static final int MY_UID = Process.myUid();
private static final int MY_PID = Process.myPid();
@@ -1120,9 +1120,9 @@
} else if (action.equals(Intent.ACTION_USER_SWITCHED)) {
// reload per-user settings
mSettingsObserver.update(null);
- updateRelatedUserCache(context);
+ updateCurrentProfilesCache(context);
} else if (action.equals(Intent.ACTION_USER_ADDED)) {
- updateRelatedUserCache(context);
+ updateCurrentProfilesCache(context);
}
}
};
@@ -2458,12 +2458,12 @@
/**
* Determine whether the userId applies to the notification in question, either because
* they match exactly, or one of them is USER_ALL (which is treated as a wildcard) or
- * because it matches a related user.
+ * because it matches one of the users profiles.
*/
- private boolean notificationMatchesUserIdOrRelated(NotificationRecord r, int userId) {
- synchronized (mRelatedUsers) {
+ private boolean notificationMatchesCurrentProfiles(NotificationRecord r, int userId) {
+ synchronized (mCurrentProfiles) {
return notificationMatchesUserId(r, userId)
- || mRelatedUsers.get(r.getUserId()) != null;
+ || mCurrentProfiles.get(r.getUserId()) != null;
}
}
@@ -2561,7 +2561,7 @@
final int N = mNotificationList.size();
for (int i=N-1; i>=0; i--) {
NotificationRecord r = mNotificationList.get(i);
- if (!notificationMatchesUserIdOrRelated(r, userId)) {
+ if (!notificationMatchesCurrentProfiles(r, userId)) {
continue;
}
@@ -2676,15 +2676,15 @@
exceptionPackages);
}
- private void updateRelatedUserCache(Context context) {
+ private void updateCurrentProfilesCache(Context context) {
UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
int currentUserId = ActivityManager.getCurrentUser();
if (userManager != null) {
- List<UserInfo> relatedUsers = userManager.getRelatedUsers(currentUserId);
- synchronized (mRelatedUsers) {
- mRelatedUsers.clear();
- for (UserInfo related : relatedUsers) {
- mRelatedUsers.put(related.id, related);
+ List<UserInfo> profiles = userManager.getProfiles(currentUserId);
+ synchronized (mCurrentProfiles) {
+ mCurrentProfiles.clear();
+ for (UserInfo user : profiles) {
+ mCurrentProfiles.put(user.id, user);
}
}
}
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index 7f55464..a39e958 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -92,7 +92,7 @@
private static final String ATTR_NEXT_SERIAL_NO = "nextSerialNumber";
private static final String ATTR_PARTIAL = "partial";
private static final String ATTR_USER_VERSION = "version";
- private static final String ATTR_RELATED_GROUP_ID = "relatedGroupId";
+ private static final String ATTR_PROFILE_GROUP_ID = "profileGroupId";
private static final String TAG_USERS = "users";
private static final String TAG_USER = "user";
private static final String TAG_RESTRICTIONS = "restrictions";
@@ -257,26 +257,26 @@
}
@Override
- public List<UserInfo> getRelatedUsers(int userId) {
+ public List<UserInfo> getProfiles(int userId) {
checkManageUsersPermission("query users");
synchronized (mPackagesLock) {
UserInfo user = getUserInfoLocked(userId);
ArrayList<UserInfo> users = new ArrayList<UserInfo>(mUsers.size());
for (int i = 0; i < mUsers.size(); i++) {
- UserInfo ui = mUsers.valueAt(i);
- if (!areRelatedUsers(user, ui)) {
+ UserInfo profile = mUsers.valueAt(i);
+ if (!isProfileOf(user, profile)) {
continue;
}
- users.add(ui);
+ users.add(profile);
}
return users;
}
}
- private boolean areRelatedUsers(UserInfo user1, UserInfo user2) {
- return user1.relatedGroupId != UserInfo.NO_RELATED_GROUP_ID &&
- user1.relatedGroupId == user2.relatedGroupId &&
- user1.id != user2.id;
+ private boolean isProfileOf(UserInfo user, UserInfo profile) {
+ return user.id == profile.id ||
+ (user.profileGroupId != UserInfo.NO_PROFILE_GROUP_ID
+ && user.profileGroupId == profile.profileGroupId);
}
@Override
@@ -684,9 +684,9 @@
if (userInfo.partial) {
serializer.attribute(null, ATTR_PARTIAL, "true");
}
- if (userInfo.relatedGroupId != UserInfo.NO_RELATED_GROUP_ID) {
- serializer.attribute(null, ATTR_RELATED_GROUP_ID,
- Integer.toString(userInfo.relatedGroupId));
+ if (userInfo.profileGroupId != UserInfo.NO_PROFILE_GROUP_ID) {
+ serializer.attribute(null, ATTR_PROFILE_GROUP_ID,
+ Integer.toString(userInfo.profileGroupId));
}
serializer.startTag(null, TAG_NAME);
@@ -771,7 +771,7 @@
long salt = 0L;
String pinHash = null;
int failedAttempts = 0;
- int relatedGroupId = UserInfo.NO_RELATED_GROUP_ID;
+ int profileGroupId = UserInfo.NO_PROFILE_GROUP_ID;
long lastAttemptTime = 0L;
boolean partial = false;
Bundle restrictions = new Bundle();
@@ -809,8 +809,14 @@
pinHash = parser.getAttributeValue(null, ATTR_PIN_HASH);
failedAttempts = readIntAttribute(parser, ATTR_FAILED_ATTEMPTS, 0);
lastAttemptTime = readLongAttribute(parser, ATTR_LAST_RETRY_MS, 0L);
- relatedGroupId = readIntAttribute(parser, ATTR_RELATED_GROUP_ID,
- UserInfo.NO_RELATED_GROUP_ID);
+ profileGroupId = readIntAttribute(parser, ATTR_PROFILE_GROUP_ID,
+ UserInfo.NO_PROFILE_GROUP_ID);
+ if (profileGroupId == UserInfo.NO_PROFILE_GROUP_ID) {
+ // This attribute was added and renamed during development of L.
+ // TODO Remove upgrade path by 1st May 2014
+ profileGroupId = readIntAttribute(parser, "relatedGroupId",
+ UserInfo.NO_PROFILE_GROUP_ID);
+ }
String valueString = parser.getAttributeValue(null, ATTR_PARTIAL);
if ("true".equals(valueString)) {
partial = true;
@@ -849,7 +855,7 @@
userInfo.creationTime = creationTime;
userInfo.lastLoggedInTime = lastLoggedInTime;
userInfo.partial = partial;
- userInfo.relatedGroupId = relatedGroupId;
+ userInfo.profileGroupId = profileGroupId;
mUserRestrictions.append(id, restrictions);
if (salt != 0L) {
RestrictionsPinState pinState = mRestrictionsPinStates.get(id);
@@ -964,25 +970,25 @@
}
}
- private int getNextRelatedGroupIdLocked() {
- int maxGroupId = UserInfo.NO_RELATED_GROUP_ID;
+ private int getNextProfileGroupIdLocked() {
+ int maxGroupId = UserInfo.NO_PROFILE_GROUP_ID;
for (int i = 0; i < mUsers.size(); i++) {
UserInfo ui = mUsers.valueAt(i);
- if (maxGroupId < ui.relatedGroupId) {
- maxGroupId = ui.relatedGroupId;
+ if (maxGroupId < ui.profileGroupId) {
+ maxGroupId = ui.profileGroupId;
}
}
return maxGroupId + 1;
}
@Override
- public UserInfo createRelatedUser(String name, int flags, int relatedUserId) {
+ public UserInfo createProfileForUser(String name, int flags, int userId) {
checkManageUsersPermission("Only the system can create users");
- if (relatedUserId != UserHandle.USER_OWNER) {
- Slog.w(LOG_TAG, "Only user owner can have related users");
+ if (userId != UserHandle.USER_OWNER) {
+ Slog.w(LOG_TAG, "Only user owner can have profiles");
return null;
}
- return createUserInternal(name, flags, relatedUserId);
+ return createUserInternal(name, flags, userId);
}
@Override
@@ -991,16 +997,16 @@
return createUserInternal(name, flags, UserHandle.USER_NULL);
}
- private UserInfo createUserInternal(String name, int flags, int relatedUserId) {
+ private UserInfo createUserInternal(String name, int flags, int profileId) {
final long ident = Binder.clearCallingIdentity();
UserInfo userInfo = null;
try {
synchronized (mInstallLock) {
synchronized (mPackagesLock) {
- UserInfo relatedUser = null;
- if (relatedUserId != UserHandle.USER_NULL) {
- relatedUser = getUserInfoLocked(relatedUserId);
- if (relatedUser == null) return null;
+ UserInfo profile = null;
+ if (profileId != UserHandle.USER_NULL) {
+ profile = getUserInfoLocked(profileId);
+ if (profile == null) return null;
}
if (isUserLimitReachedLocked()) return null;
int userId = getNextAvailableIdLocked();
@@ -1013,12 +1019,12 @@
Environment.getUserSystemDirectory(userInfo.id).mkdirs();
mUsers.put(userId, userInfo);
writeUserListLocked();
- if (relatedUser != null) {
- if (relatedUser.relatedGroupId == UserInfo.NO_RELATED_GROUP_ID) {
- relatedUser.relatedGroupId = getNextRelatedGroupIdLocked();
+ if (profile != null) {
+ if (profile.profileGroupId == UserInfo.NO_PROFILE_GROUP_ID) {
+ profile.profileGroupId = getNextProfileGroupIdLocked();
+ writeUserLocked(profile);
}
- userInfo.relatedGroupId = relatedUser.relatedGroupId;
- writeUserLocked(relatedUser);
+ userInfo.profileGroupId = profile.profileGroupId;
}
writeUserLocked(userInfo);
mPm.createNewUserLILPw(userId, userPath);
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index f327a35..2e5b8de 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -304,14 +304,14 @@
/**
* Current user when multi-user is enabled. Don't show windows of
- * non-current user. Also see mRelatedUserIds.
+ * non-current user. Also see mCurrentProfileIds.
*/
int mCurrentUserId;
/**
- * Users related to the current user. These are also allowed to show windows
+ * Users that are profiles of the current user. These are also allowed to show windows
* on the current user.
*/
- int[] mRelatedUserIds = new int[0];
+ int[] mCurrentProfileIds = new int[0];
final Context mContext;
@@ -5229,16 +5229,16 @@
ShutdownThread.rebootSafeMode(mContext, confirm);
}
- public void updateRelatedUserIds(final int[] relatedUserIds) {
+ public void setCurrentProfileIds(final int[] currentProfileIds) {
synchronized (mWindowMap) {
- mRelatedUserIds = relatedUserIds;
+ mCurrentProfileIds = currentProfileIds;
}
}
- public void setCurrentUser(final int newUserId, final int[] relatedUserIds) {
+ public void setCurrentUser(final int newUserId, final int[] currentProfileIds) {
synchronized (mWindowMap) {
mCurrentUserId = newUserId;
- mRelatedUserIds = relatedUserIds;
+ mCurrentProfileIds = currentProfileIds;
mAppTransition.setCurrentUser(newUserId);
mPolicy.setCurrentUserLw(newUserId);
@@ -5254,10 +5254,9 @@
}
/* Called by WindowState */
- boolean isRelatedToOrCurrentUserLocked(int userId) {
- if (userId == mCurrentUserId) return true;
- for (int i = 0; i < mRelatedUserIds.length; i++) {
- if (mRelatedUserIds[i] == userId) return true;
+ boolean isCurrentProfileLocked(int userId) {
+ for (int i = 0; i < mCurrentProfileIds.length; i++) {
+ if (mCurrentProfileIds[i] == userId) return true;
}
return false;
}
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 2c0e99e..dff75ef 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -1249,7 +1249,7 @@
}
return win.mShowToOwnerOnly
- && !mService.isRelatedToOrCurrentUserLocked(UserHandle.getUserId(win.mOwnerUid));
+ && !mService.isCurrentProfileLocked(UserHandle.getUserId(win.mOwnerUid));
}
private static void applyInsets(Region outRegion, Rect frame, Rect inset) {