michael@0: /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*- 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.webapp; michael@0: michael@0: import android.content.BroadcastReceiver; michael@0: import android.content.Context; michael@0: import android.content.Intent; michael@0: import android.util.Log; michael@0: michael@0: /** michael@0: * This BroadcastReceiver is registered in the AndroidManifest.xml.in file. michael@0: * michael@0: *

It listens for intents sent by synthesized APKs when the task has been ended. michael@0: * e.g. when the user has swiped it out of the Recent Apps List.

michael@0: * michael@0: */ michael@0: public class TaskKiller extends BroadcastReceiver { michael@0: michael@0: private static final String LOGTAG = "GeckoWebappTaskKiller"; michael@0: michael@0: @Override michael@0: public void onReceive(Context context, Intent intent) { michael@0: String packageName = intent.getStringExtra("packageName"); michael@0: int slot = Allocator.getInstance(context).getIndexForApp(packageName); michael@0: if (slot >= 0) { michael@0: EventListener.killWebappSlot(context, slot); michael@0: } else { michael@0: Log.w(LOGTAG, "Asked to kill " + packageName + " but this runtime (" + context.getPackageName() + ") doesn't know about it."); michael@0: } michael@0: } michael@0: michael@0: }