diff options
author | Lifu Tang <lifu@google.com> | 2015-04-02 12:05:46 -0700 |
---|---|---|
committer | Lifu Tang <lifu@google.com> | 2015-04-09 10:10:12 -0700 |
commit | d033285ca7789b464f15cde149bef7df3ad2e1a3 (patch) | |
tree | b6a0ac9989aea6f6e808525bfe9fdd952b6654db /src | |
parent | 390910b333c9badbfc0dab5b851853ef82e95502 (diff) | |
download | packages_apps_Settings-d033285ca7789b464f15cde149bef7df3ad2e1a3.zip packages_apps_Settings-d033285ca7789b464f15cde149bef7df3ad2e1a3.tar.gz packages_apps_Settings-d033285ca7789b464f15cde149bef7df3ad2e1a3.tar.bz2 |
Worked around back button navigation issue
Calling startWithFragmentAsUser() without specifying FLAG_ACTIVITY_NEW_TASK to
the intent starting the fragment could cause a native stack corruption. See
b/17523189. However, adding that flag and start the preference panel with the
same UserHandler will make it impossible to use back button to return to the
previous screen. See b/20042570.
We work around this issue by adding FLAG_ACTIVITY_NEW_TASK to the intent, while
doing another check here to call startPreferencePanel() instead of
startWithFragmentAsUser() when we're calling it as the same user.
Bug: 20042570
Change-Id: I26b269414f410912b77aaa553a3fccebfa148659
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/SettingsActivity.java | 32 | ||||
-rw-r--r-- | src/com/android/settings/fuelgauge/PowerUsageDetail.java | 10 |
2 files changed, 25 insertions, 17 deletions
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java index eecf7a2..df9b9ad 100644 --- a/src/com/android/settings/SettingsActivity.java +++ b/src/com/android/settings/SettingsActivity.java @@ -928,17 +928,31 @@ public class SettingsActivity extends Activity */ public void startPreferencePanelAsUser(String fragmentClass, Bundle args, int titleRes, CharSequence titleText, UserHandle userHandle) { - String title = null; - if (titleRes < 0) { - if (titleText != null) { - title = titleText.toString(); - } else { - // There not much we can do in that case - title = ""; + // This is a workaround. + // + // Calling startWithFragmentAsUser() without specifying FLAG_ACTIVITY_NEW_TASK to the intent + // starting the fragment could cause a native stack corruption. See b/17523189. However, + // adding that flag and start the preference panel with the same UserHandler will make it + // impossible to use back button to return to the previous screen. See b/20042570. + // + // We work around this issue by adding FLAG_ACTIVITY_NEW_TASK to the intent, while doing + // another check here to call startPreferencePanel() instead of startWithFragmentAsUser() + // when we're calling it as the same user. + if (userHandle.getIdentifier() == UserHandle.myUserId()) { + startPreferencePanel(fragmentClass, args, titleRes, titleText, null, 0); + } else { + String title = null; + if (titleRes < 0) { + if (titleText != null) { + title = titleText.toString(); + } else { + // There not much we can do in that case + title = ""; + } } + Utils.startWithFragmentAsUser(this, fragmentClass, args, + titleRes, title, mIsShortcut, userHandle); } - Utils.startWithFragmentAsUser(this, fragmentClass, args, - titleRes, title, mIsShortcut, userHandle); } /** diff --git a/src/com/android/settings/fuelgauge/PowerUsageDetail.java b/src/com/android/settings/fuelgauge/PowerUsageDetail.java index e3c8dab..8d01eea 100644 --- a/src/com/android/settings/fuelgauge/PowerUsageDetail.java +++ b/src/com/android/settings/fuelgauge/PowerUsageDetail.java @@ -259,14 +259,8 @@ public class PowerUsageDetail extends Fragment implements Button.OnClickListener args.putIntArray(PowerUsageDetail.EXTRA_DETAIL_TYPES, types); args.putDoubleArray(PowerUsageDetail.EXTRA_DETAIL_VALUES, values); - // This is a workaround, see b/17523189 - 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)); - } + caller.startPreferencePanelAsUser(PowerUsageDetail.class.getName(), args, + R.string.details_title, null, new UserHandle(userId)); } public static final int ACTION_DISPLAY_SETTINGS = 1; |