mobile/android/base/background/healthreport/HealthReportBroadcastReceiver.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 package org.mozilla.gecko.background.healthreport;
michael@0 6
michael@0 7 import org.mozilla.gecko.background.common.log.Logger;
michael@0 8
michael@0 9 import android.content.BroadcastReceiver;
michael@0 10 import android.content.Context;
michael@0 11 import android.content.Intent;
michael@0 12
michael@0 13 /**
michael@0 14 * Watch for notifications to start Health Report background services.
michael@0 15 *
michael@0 16 * Some observations:
michael@0 17 *
michael@0 18 * From the Android documentation: "Also note that as of Android 3.0 the user
michael@0 19 * needs to have started the application at least once before your application
michael@0 20 * can receive android.intent.action.BOOT_COMPLETED events."
michael@0 21 *
michael@0 22 * We really do want to launch on BOOT_COMPLETED, since it's possible for a user
michael@0 23 * to run Firefox, shut down the phone, then power it on again on the same day.
michael@0 24 * We want to submit a health report in this case, even though they haven't
michael@0 25 * launched Firefox since boot.
michael@0 26 */
michael@0 27 public class HealthReportBroadcastReceiver extends BroadcastReceiver {
michael@0 28 public static final String LOG_TAG = HealthReportBroadcastReceiver.class.getSimpleName();
michael@0 29
michael@0 30 /**
michael@0 31 * Forward the intent to an IntentService to do background processing.
michael@0 32 */
michael@0 33 @Override
michael@0 34 public void onReceive(Context context, Intent intent) {
michael@0 35 Logger.debug(LOG_TAG, "Received intent - forwarding to BroadcastService.");
michael@0 36 Intent service = new Intent(context, HealthReportBroadcastService.class);
michael@0 37 service.putExtras(intent);
michael@0 38 service.setAction(intent.getAction());
michael@0 39 context.startService(service);
michael@0 40 }
michael@0 41 }

mercurial