mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 01:35:35 +00:00
Bug 1225980 - Add a startGecko static method to GeckoService, to be used for GeckoCustomTabsService.warmup() r=rbarker
This commit is contained in:
parent
5df0c97c52
commit
bf12b08d30
@ -11,6 +11,8 @@ import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.File;
|
||||
@ -205,4 +207,30 @@ public class GeckoService extends Service {
|
||||
public IBinder onBind(final Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void startGecko(final GeckoProfile profile, final String args, final Context context) {
|
||||
if (GeckoThread.isLaunched()) {
|
||||
if (DEBUG) {
|
||||
Log.v(LOGTAG, "already launched");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GeckoAppShell.ensureCrashHandling();
|
||||
GeckoAppShell.setApplicationContext(context);
|
||||
GeckoThread.onResume();
|
||||
|
||||
GeckoThread.init(profile, args, null, false);
|
||||
GeckoThread.launch();
|
||||
|
||||
if (DEBUG) {
|
||||
Log.v(LOGTAG, "warmed up (launched)");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,9 @@ import android.support.customtabs.CustomTabsService;
|
||||
import android.support.customtabs.CustomTabsSessionToken;
|
||||
import android.util.Log;
|
||||
|
||||
import org.mozilla.gecko.GeckoProfile;
|
||||
import org.mozilla.gecko.GeckoService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -18,6 +21,7 @@ import java.util.List;
|
||||
*/
|
||||
public class GeckoCustomTabsService extends CustomTabsService {
|
||||
private static final String LOGTAG = "GeckoCustomTabsService";
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
@Override
|
||||
protected boolean updateVisuals(CustomTabsSessionToken sessionToken, Bundle bundle) {
|
||||
@ -28,9 +32,12 @@ public class GeckoCustomTabsService extends CustomTabsService {
|
||||
|
||||
@Override
|
||||
protected boolean warmup(long flags) {
|
||||
Log.v(LOGTAG, "warmup()");
|
||||
if (DEBUG) {
|
||||
Log.v(LOGTAG, "warming up...");
|
||||
}
|
||||
|
||||
GeckoService.startGecko(GeckoProfile.initFromArgs(this, null), null, getApplicationContext());
|
||||
|
||||
// Pretend warmup was successful
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user