Skip to content

Commit 5fc6266

Browse files
Amith YamasaniAndroid (Google) Code Review
authored andcommitted
Merge "Resolve the correct home intent for secondary users" into jb-mr1-dev
2 parents dc531fa + 259d5e5 commit 5fc6266

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

services/java/com/android/server/am/ActivityManagerService.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,8 +2150,7 @@ boolean startHomeActivityLocked(int userId, UserStartedState startingUser) {
21502150
intent.addCategory(Intent.CATEGORY_HOME);
21512151
}
21522152
ActivityInfo aInfo =
2153-
intent.resolveActivityInfo(mContext.getPackageManager(),
2154-
STOCK_PM_FLAGS);
2153+
resolveActivityInfo(intent, STOCK_PM_FLAGS, userId);
21552154
if (aInfo != null) {
21562155
intent.setComponent(new ComponentName(
21572156
aInfo.applicationInfo.packageName, aInfo.name));
@@ -2174,6 +2173,29 @@ boolean startHomeActivityLocked(int userId, UserStartedState startingUser) {
21742173
return true;
21752174
}
21762175

2176+
private ActivityInfo resolveActivityInfo(Intent intent, int flags, int userId) {
2177+
ActivityInfo ai = null;
2178+
ComponentName comp = intent.getComponent();
2179+
try {
2180+
if (comp != null) {
2181+
ai = AppGlobals.getPackageManager().getActivityInfo(comp, flags, userId);
2182+
} else {
2183+
ResolveInfo info = AppGlobals.getPackageManager().resolveIntent(
2184+
intent,
2185+
intent.resolveTypeIfNeeded(mContext.getContentResolver()),
2186+
flags, userId);
2187+
2188+
if (info != null) {
2189+
ai = info.activityInfo;
2190+
}
2191+
}
2192+
} catch (RemoteException e) {
2193+
// ignore
2194+
}
2195+
2196+
return ai;
2197+
}
2198+
21772199
/**
21782200
* Starts the "new version setup screen" if appropriate.
21792201
*/

services/java/com/android/server/am/ActivityStack.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,10 @@ public void handleMessage(Message msg) {
422422
}
423423

424424
final ActivityRecord topRunningActivityLocked(ActivityRecord notTop) {
425-
// TODO: Don't look for any tasks from other users
426425
int i = mHistory.size()-1;
427426
while (i >= 0) {
428427
ActivityRecord r = mHistory.get(i);
429-
if (!r.finishing && r != notTop) {
428+
if (!r.finishing && r != notTop && r.userId == mCurrentUser) {
430429
return r;
431430
}
432431
i--;
@@ -435,11 +434,10 @@ final ActivityRecord topRunningActivityLocked(ActivityRecord notTop) {
435434
}
436435

437436
final ActivityRecord topRunningNonDelayedActivityLocked(ActivityRecord notTop) {
438-
// TODO: Don't look for any tasks from other users
439437
int i = mHistory.size()-1;
440438
while (i >= 0) {
441439
ActivityRecord r = mHistory.get(i);
442-
if (!r.finishing && !r.delayedResume && r != notTop) {
440+
if (!r.finishing && !r.delayedResume && r != notTop && r.userId == mCurrentUser) {
443441
return r;
444442
}
445443
i--;
@@ -457,12 +455,12 @@ final ActivityRecord topRunningNonDelayedActivityLocked(ActivityRecord notTop) {
457455
* @return Returns the HistoryRecord of the next activity on the stack.
458456
*/
459457
final ActivityRecord topRunningActivityLocked(IBinder token, int taskId) {
460-
// TODO: Don't look for any tasks from other users
461458
int i = mHistory.size()-1;
462459
while (i >= 0) {
463460
ActivityRecord r = mHistory.get(i);
464461
// Note: the taskId check depends on real taskId fields being non-zero
465-
if (!r.finishing && (token != r.appToken) && (taskId != r.task.taskId)) {
462+
if (!r.finishing && (token != r.appToken) && (taskId != r.task.taskId)
463+
&& r.userId == mCurrentUser) {
466464
return r;
467465
}
468466
i--;
@@ -1400,7 +1398,7 @@ final boolean resumeTopActivityLocked(ActivityRecord prev, Bundle options) {
14001398
// Launcher...
14011399
if (mMainStack) {
14021400
ActivityOptions.abort(options);
1403-
return mService.startHomeActivityLocked(0, null);
1401+
return mService.startHomeActivityLocked(mCurrentUser, null);
14041402
}
14051403
}
14061404

0 commit comments

Comments
 (0)