author | Brian Nicholson <bnicholson@mozilla.com> |
Tue, 19 Mar 2013 14:09:44 -0700 | |
changeset 125505 | 42caf484567704e1cee9918c63e37afd7d7a41c4 |
parent 125504 | 41789248e1e6d91f56ff8666ea85b5ff3d98d5be |
child 125506 | 2e9988148b18c31f4e5faef1bace455a6bedd24c |
push id | 24459 |
push user | emorley@mozilla.com |
push date | Wed, 20 Mar 2013 11:46:36 +0000 |
treeherder | mozilla-central@1d6fe70c79c5 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | kats |
bugs | 851056 |
milestone | 22.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/mobile/android/base/AndroidManifest.xml.in +++ b/mobile/android/base/AndroidManifest.xml.in @@ -160,23 +160,16 @@ #include @OBJDIR@/WebAppManifestFragment.xml.in <!-- Masquerade as the Resolver so that we can be opened from the Marketplace. --> <activity-alias android:name="com.android.internal.app.ResolverActivity" android:targetActivity=".App" android:exported="true" /> - <receiver android:name="NotificationHandler"> - <intent-filter> - <action android:name="org.mozilla.gecko.ACTION_ALERT_CLICK" /> - <action android:name="org.mozilla.gecko.ACTION_ALERT_CLEAR" /> - </intent-filter> - </receiver> - <receiver android:name="org.mozilla.gecko.GeckoUpdateReceiver"> <intent-filter> <action android:name="@ANDROID_PACKAGE_NAME@.CHECK_UPDATE_RESULT" /> </intent-filter> </receiver> <receiver android:name="org.mozilla.gecko.GeckoMessageReceiver" android:permission="@ANDROID_PACKAGE_NAME@.permissions.PASSWORD_PROVIDER">
--- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -512,17 +512,16 @@ abstract public class BrowserApp extends // without restarting. return true; } }); } @Override public void onDestroy() { - super.onDestroy(); if (mPrefObserverId != null) { PrefsHelper.removeObserver(mPrefObserverId); mPrefObserverId = null; } if (mAboutHomeContent != null) mAboutHomeContent.onDestroy(); if (mBrowserToolbar != null) mBrowserToolbar.onDestroy(); @@ -538,16 +537,18 @@ abstract public class BrowserApp extends NfcAdapter nfc = NfcAdapter.getDefaultAdapter(this); if (nfc != null) { // null this out even though the docs say it's not needed, // because the source code looks like it will only do this // automatically on API 14+ nfc.setNdefPushMessageCallback(null, this); } } + + super.onDestroy(); } @Override public void onContentChanged() { super.onContentChanged(); if (mAboutHomeContent != null) mAboutHomeContent.onActivityContentChanged(); }
--- a/mobile/android/base/GeckoApp.java +++ b/mobile/android/base/GeckoApp.java @@ -121,18 +121,16 @@ abstract public class GeckoApp } private static enum StartupAction { NORMAL, /* normal application start */ URL, /* launched with a passed URL */ PREFETCH /* launched with a passed URL that we prefetch */ } - public static final String ACTION_ALERT_CLICK = "org.mozilla.gecko.ACTION_ALERT_CLICK"; - public static final String ACTION_ALERT_CLEAR = "org.mozilla.gecko.ACTION_ALERT_CLEAR"; public static final String ACTION_ALERT_CALLBACK = "org.mozilla.gecko.ACTION_ALERT_CALLBACK"; public static final String ACTION_WEBAPP_PREFIX = "org.mozilla.gecko.WEBAPP"; 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_INIT_PW = "org.mozilla.gecko.INIT_PW"; public static final String ACTION_WIDGET = "org.mozilla.gecko.WIDGET"; public static final String SAVED_STATE_IN_BACKGROUND = "inBackground";
--- a/mobile/android/base/GeckoAppShell.java +++ b/mobile/android/base/GeckoAppShell.java @@ -1188,44 +1188,37 @@ public class GeckoAppShell Log.d(LOGTAG, "GeckoAppShell.showAlertNotification\n" + "- image = '" + aImageUrl + "'\n" + "- title = '" + aAlertTitle + "'\n" + "- text = '" + aAlertText +"'\n" + "- cookie = '" + aAlertCookie +"'\n" + "- name = '" + aAlertName + "'"); // The intent to launch when the user clicks the expanded notification - Intent notificationIntent = new Intent(GeckoApp.ACTION_ALERT_CLICK); - notificationIntent.setClassName(GeckoApp.mAppContext, - GeckoApp.mAppContext.getPackageName() + ".NotificationHandler"); + String app = GeckoApp.mAppContext.getClass().getName(); + Intent notificationIntent = new Intent(GeckoApp.ACTION_ALERT_CALLBACK); + notificationIntent.setClassName(GeckoApp.mAppContext, app); + notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); int notificationID = aAlertName.hashCode(); // Put the strings into the intent as an URI "alert:?name=<alertName>&app=<appName>&cookie=<cookie>" Uri.Builder b = new Uri.Builder(); - String app = GeckoApp.mAppContext.getClass().getName(); Uri dataUri = b.scheme("alert").path(Integer.toString(notificationID)) .appendQueryParameter("name", aAlertName) - .appendQueryParameter("app", app) .appendQueryParameter("cookie", aAlertCookie) .build(); notificationIntent.setData(dataUri); - PendingIntent contentIntent = PendingIntent.getBroadcast(GeckoApp.mAppContext, 0, notificationIntent, 0); - - // The intent to execute when the status entry is deleted by the user with the "Clear All Notifications" button - Intent clearNotificationIntent = new Intent(GeckoApp.ACTION_ALERT_CLEAR); - clearNotificationIntent.setClassName(GeckoApp.mAppContext, - GeckoApp.mAppContext.getPackageName() + ".NotificationHandler"); - clearNotificationIntent.setData(dataUri); - PendingIntent clearIntent = PendingIntent.getBroadcast(GeckoApp.mAppContext, 0, clearNotificationIntent, 0); + PendingIntent contentIntent = PendingIntent.getActivity( + GeckoApp.mAppContext, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); mAlertCookies.put(aAlertName, aAlertCookie); callObserver(aAlertName, "alertshow", aAlertCookie); - sNotificationClient.add(notificationID, aImageUrl, aAlertTitle, aAlertText, contentIntent, clearIntent); + sNotificationClient.add(notificationID, aImageUrl, aAlertTitle, aAlertText, contentIntent); } public static void alertsProgressListener_OnProgress(String aAlertName, long aProgress, long aProgressMax, String aAlertText) { int notificationID = aAlertName.hashCode(); sNotificationClient.update(notificationID, aProgress, aProgressMax, aAlertText); if (aProgress == aProgressMax) { // Hide the notification at 100%
--- a/mobile/android/base/Makefile.in +++ b/mobile/android/base/Makefile.in @@ -233,17 +233,16 @@ FENNEC_PP_JAVA_FILES = \ App.java \ MarketplaceApp.java \ WebApp.java \ WebApps.java \ GeckoActivity.java \ GeckoAppInfo.java \ GeckoAppWidgetProvider.java \ LauncherShortcuts.java \ - NotificationHandler.java \ Restarter.java \ db/BrowserContract.java \ db/BrowserProvider.java \ db/PasswordsProvider.java \ db/FormHistoryProvider.java \ db/TabsProvider.java \ db/GeckoProvider.java \ SmsManager.java \
deleted file mode 100644 --- a/mobile/android/base/NotificationHandler.java.in +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#filter substitution -package @ANDROID_PACKAGE_NAME@; - -import android.content.ActivityNotFoundException; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.net.Uri; -import android.text.TextUtils; -import android.util.Log; - -public class NotificationHandler extends BroadcastReceiver { - private static final String LOGTAG = "GeckoNotificationHandler"; - - @Override - public void onReceive(Context context, Intent intent) { - if (intent != null) - handleIntent(context, intent); - } - - protected void handleIntent(Context context, Intent notificationIntent) { - // only fire the callback if the intent was clicked, not if it was cancelled - String action = notificationIntent.getAction(); - if (App.ACTION_ALERT_CLEAR.equals(action)) - return; - - String appName = ""; - Uri data = notificationIntent.getData(); - if (data != null) { - appName = data.getQueryParameter("app"); - if (appName == null) - appName = "@ANDROID_PACKAGE_NAME@.App"; - } - - sendIntent(context, App.ACTION_ALERT_CALLBACK, - appName, - data); - } - - private void sendIntent(Context context, String action, String className, Uri data) { - Intent appIntent = new Intent(action); - - if (TextUtils.isEmpty(className)) - appIntent.setClassName(context, "@ANDROID_PACKAGE_NAME@.App"); - else - appIntent.setClassName(context, className); - - appIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - - if (data != null) - appIntent.setData(data); - - try { - Log.i(LOGTAG, "startActivity with intent: Action='" + appIntent.getAction() + - " appName='" + className + "'"); - context.startActivity(appIntent); - } catch (ActivityNotFoundException e) { - Log.e(LOGTAG, "NotificationHandler Exception: ", e); - } - } -}
--- a/mobile/android/base/NotificationService.java +++ b/mobile/android/base/NotificationService.java @@ -51,17 +51,17 @@ public class NotificationService extends * @param notificationID the unique ID of the notification * @param aImageUrl URL of the image to use * @param aAlertTitle title of the notification * @param aAlertText text of the notification * @param contentIntent Intent used when the notification is clicked * @param clearIntent Intent used when the notification is removed */ public void add(int notificationID, String aImageUrl, String aAlertTitle, - String aAlertText, PendingIntent contentIntent, PendingIntent clearIntent) { + String aAlertText, PendingIntent contentIntent) { // Remove the old notification with the same ID, if any remove(notificationID); int icon = R.drawable.ic_status_logo; Uri imageUri = Uri.parse(aImageUrl); final String scheme = imageUri.getScheme(); if ("drawable".equals(scheme)) { @@ -74,17 +74,16 @@ public class NotificationService extends } catch (final Exception e) {} // just means the resource doesn't exist imageUri = null; } final AlertNotification notification = new AlertNotification(this, notificationID, icon, aAlertTitle, aAlertText, System.currentTimeMillis(), imageUri); notification.setLatestEventInfo(this, aAlertTitle, aAlertText, contentIntent); - notification.deleteIntent = clearIntent; notification.show(); mAlertNotifications.put(notification.getId(), notification); } /** * Updates a notification. *
--- a/mobile/android/base/NotificationServiceClient.java +++ b/mobile/android/base/NotificationServiceClient.java @@ -80,23 +80,21 @@ public class NotificationServiceClient { }; /** * Adds a notification. * * @see NotificationService#add(int, String, String, String, PendingIntent, PendingIntent) */ public synchronized void add(final int notificationID, final String aImageUrl, - final String aAlertTitle, final String aAlertText, final PendingIntent contentIntent, - final PendingIntent clearIntent) { + final String aAlertTitle, final String aAlertText, final PendingIntent contentIntent) { mTaskQueue.add(new Runnable() { @Override public void run() { - mService.add(notificationID, aImageUrl, aAlertTitle, aAlertText, - contentIntent, clearIntent); + mService.add(notificationID, aImageUrl, aAlertTitle, aAlertText, contentIntent); } }); notify(); if (!mBound) { bind(); } }