зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1221270 - Turn GeckoService into an IntentService; r=snorp
We want GeckoService to handle intents from the system, e.g. an intent from the alarm manager.
This commit is contained in:
Родитель
a3dc010161
Коммит
4666b1c14e
|
@ -5,34 +5,55 @@
|
|||
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import android.app.Service;
|
||||
import android.app.IntentService;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
public class GeckoService extends IntentService {
|
||||
|
||||
public class GeckoService extends Service {
|
||||
private static final String LOGTAG = "GeckoService";
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
@Override
|
||||
|
||||
public GeckoService() {
|
||||
super("GeckoService");
|
||||
}
|
||||
|
||||
@Override // Service
|
||||
public void onCreate() {
|
||||
GeckoAppShell.ensureCrashHandling();
|
||||
GeckoAppShell.setApplicationContext(getApplicationContext());
|
||||
|
||||
super.onCreate();
|
||||
|
||||
if (DEBUG) {
|
||||
Log.d(LOGTAG, "Created");
|
||||
}
|
||||
GeckoThread.ensureInit(/* args */ null, /* action */ null);
|
||||
GeckoThread.launch();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override // Service
|
||||
public void onDestroy() {
|
||||
// TODO: Make sure Gecko is in a somewhat idle state
|
||||
// because our process could be killed at anytime.
|
||||
|
||||
if (DEBUG) {
|
||||
Log.d(LOGTAG, "Destroyed");
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
@Override // IntentService
|
||||
protected void onHandleIntent(final Intent intent) {
|
||||
|
||||
if (intent == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We are on the intent service worker thread.
|
||||
if (DEBUG) {
|
||||
Log.d(LOGTAG, "Handling " + intent.getAction());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче