michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: package org.mozilla.gecko.background.healthreport; michael@0: michael@0: import org.mozilla.gecko.background.common.log.Logger; michael@0: michael@0: import android.content.BroadcastReceiver; michael@0: import android.content.Context; michael@0: import android.content.Intent; michael@0: michael@0: /** michael@0: * Watch for notifications to start Health Report background services. michael@0: * michael@0: * Some observations: michael@0: * michael@0: * From the Android documentation: "Also note that as of Android 3.0 the user michael@0: * needs to have started the application at least once before your application michael@0: * can receive android.intent.action.BOOT_COMPLETED events." michael@0: * michael@0: * We really do want to launch on BOOT_COMPLETED, since it's possible for a user michael@0: * to run Firefox, shut down the phone, then power it on again on the same day. michael@0: * We want to submit a health report in this case, even though they haven't michael@0: * launched Firefox since boot. michael@0: */ michael@0: public class HealthReportBroadcastReceiver extends BroadcastReceiver { michael@0: public static final String LOG_TAG = HealthReportBroadcastReceiver.class.getSimpleName(); michael@0: michael@0: /** michael@0: * Forward the intent to an IntentService to do background processing. michael@0: */ michael@0: @Override michael@0: public void onReceive(Context context, Intent intent) { michael@0: Logger.debug(LOG_TAG, "Received intent - forwarding to BroadcastService."); michael@0: Intent service = new Intent(context, HealthReportBroadcastService.class); michael@0: service.putExtras(intent); michael@0: service.setAction(intent.getAction()); michael@0: context.startService(service); michael@0: } michael@0: }