From 32ae6cd6c644d6ab1dd97a162ebdf78306e0cdbb Mon Sep 17 00:00:00 2001 From: Chenxia Liu Date: Thu, 13 Jun 2013 18:58:26 -0700 Subject: [PATCH] Bug 873072 - Launching settings from Android system notification crashes if Gecko has been killed. r=sriram --- .../android/base/DataReportingNotification.java | 5 +++-- mobile/android/base/GeckoApp.java | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/mobile/android/base/DataReportingNotification.java b/mobile/android/base/DataReportingNotification.java index 219142a8e45..e8d18567e7f 100644 --- a/mobile/android/base/DataReportingNotification.java +++ b/mobile/android/base/DataReportingNotification.java @@ -44,8 +44,9 @@ public class DataReportingNotification { if ((!dataPrefs.contains(PREFS_POLICY_NOTIFIED_TIME)) || (DATA_REPORTING_VERSION != dataPrefs.getInt(PREFS_POLICY_VERSION, -1))) { - // Launch Data Choices fragment when notification is clicked. - Intent prefIntent = new Intent(context, GeckoPreferences.class); + // Launch main App to launch Data choices when notification is clicked. + Intent prefIntent = new Intent(GeckoApp.ACTION_LAUNCH_SETTINGS); + prefIntent.setClassName(AppConstants.ANDROID_PACKAGE_NAME, AppConstants.BROWSER_INTENT_CLASS); // Build launch intent based on Android version. if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { diff --git a/mobile/android/base/GeckoApp.java b/mobile/android/base/GeckoApp.java index fc8a2b6bf2d..96543e69a29 100644 --- a/mobile/android/base/GeckoApp.java +++ b/mobile/android/base/GeckoApp.java @@ -145,6 +145,7 @@ abstract public class GeckoApp public static final String ACTION_DEBUG = "org.mozilla.gecko.DEBUG"; public static final String ACTION_BOOKMARK = "org.mozilla.gecko.BOOKMARK"; public static final String ACTION_LOAD = "org.mozilla.gecko.LOAD"; + public static final String ACTION_LAUNCH_SETTINGS = "org.mozilla.gecko.SETTINGS"; public static final String ACTION_INIT_PW = "org.mozilla.gecko.INIT_PW"; public static final String SAVED_STATE_IN_BACKGROUND = "inBackground"; public static final String SAVED_STATE_PRIVATE_SESSION = "privateSession"; @@ -1434,6 +1435,14 @@ abstract public class GeckoApp }, 1000 * 5 /* 5 seconds */); } + // Check if launched from data reporting notification. + if (ACTION_LAUNCH_SETTINGS.equals(action)) { + Intent settingsIntent = new Intent(GeckoApp.sAppContext, GeckoPreferences.class); + // Copy extras. + settingsIntent.putExtras(intent); + startActivity(settingsIntent); + } + //app state callbacks mAppStateListeners = new LinkedList(); @@ -1783,6 +1792,12 @@ abstract public class GeckoApp GeckoAppShell.sendEventToGecko(GeckoEvent.createURILoadEvent(uri)); } else if (ACTION_ALERT_CALLBACK.equals(action)) { processAlertCallback(intent); + } if (ACTION_LAUNCH_SETTINGS.equals(action)) { + // Check if launched from data reporting notification. + Intent settingsIntent = new Intent(GeckoApp.sAppContext, GeckoPreferences.class); + // Copy extras. + settingsIntent.putExtras(intent); + startActivity(settingsIntent); } }