Start PowerUsageDetails fragment in the correct activity

Make sure the stack does not get corrupted by running a fragment as a
managed profile in an activity that runs as primary profile.

Bug:17523189

Change-Id: I7a066a411c7995ffe44b73c6dc27b24eec85b5b3
This commit is contained in:
Zoltan Szatmary-Ban
2014-09-22 17:14:08 +01:00
parent 2bfd4a5f2c
commit d50c7a8878
2 changed files with 10 additions and 2 deletions

View File

@@ -613,6 +613,8 @@ public final class Utils {
int titleResId, CharSequence title, boolean isShortcut, UserHandle userHandle) { int titleResId, CharSequence title, boolean isShortcut, UserHandle userHandle) {
Intent intent = onBuildStartFragmentIntent(context, fragmentName, args, titleResId, Intent intent = onBuildStartFragmentIntent(context, fragmentName, args, titleResId,
title, isShortcut); title, isShortcut);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
context.startActivityAsUser(intent, userHandle); context.startActivityAsUser(intent, userHandle);
} }

View File

@@ -259,8 +259,14 @@ public class PowerUsageDetail extends Fragment implements Button.OnClickListener
args.putIntArray(PowerUsageDetail.EXTRA_DETAIL_TYPES, types); args.putIntArray(PowerUsageDetail.EXTRA_DETAIL_TYPES, types);
args.putDoubleArray(PowerUsageDetail.EXTRA_DETAIL_VALUES, values); args.putDoubleArray(PowerUsageDetail.EXTRA_DETAIL_VALUES, values);
caller.startPreferencePanelAsUser(PowerUsageDetail.class.getName(), args, // This is a workaround, see b/17523189
R.string.details_title, null, new UserHandle(userId)); if (userId == UserHandle.myUserId()) {
caller.startPreferencePanel(PowerUsageDetail.class.getName(), args,
R.string.details_title, null, null, 0);
} else {
caller.startPreferencePanelAsUser(PowerUsageDetail.class.getName(), args,
R.string.details_title, null, new UserHandle(userId));
}
} }
public static final int ACTION_DISPLAY_SETTINGS = 1; public static final int ACTION_DISPLAY_SETTINGS = 1;