Files
firefox/mobile/android/base/java/org/mozilla/gecko/FennecKiller.java
T
Dylan Roeh 792b9b3d4d Bug 1494748 - Add a service to kill the Fennec process when the user swipes-to-kill Fennec. r=snorp
Leaving the Fennec process running after a swipe-to-kill puts Fennec in an unrecoverable state; this ensures we kill the process anytime a user swipes-to-kill Fennec and therefore lets us recover as usual.
2018-11-20 09:35:29 -06:00

37 lines
1.1 KiB
Java

/* -*- 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/. */
package org.mozilla.gecko;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.Process;
import android.util.Log;
public class FennecKiller extends Service {
private static final String LOGTAG = "GeckoFennecKiller";
private static final String BROWSERAPP = "org.mozilla.gecko.BrowserApp";
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onTaskRemoved(Intent intent) {
if (intent != null && intent.getComponent() != null &&
BROWSERAPP.equals(intent.getComponent().getClassName())) {
Process.killProcess(Process.myPid());
}
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return Service.START_NOT_STICKY;
}
}