mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-04 06:48:38 +09:00
pt 1 in reviving the android build (copied from pm 28a1, wish me luck)
This commit is contained in:
parent
efa9662725
commit
d7788a6d6d
4249 changed files with 468189 additions and 0 deletions
50
mobile/android/base/java/org/mozilla/gecko/Restarter.java
Normal file
50
mobile/android/base/java/org/mozilla/gecko/Restarter.java
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/* -*- 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 Restarter extends Service {
|
||||
private static final String LOGTAG = "GeckoRestarter";
|
||||
|
||||
private void doRestart(Intent intent) {
|
||||
final int oldProc = intent.getIntExtra("pid", -1);
|
||||
if (oldProc < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Process.killProcess(oldProc);
|
||||
Log.d(LOGTAG, "Killed " + oldProc);
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (final InterruptedException e) {
|
||||
}
|
||||
|
||||
final Intent restartIntent = (Intent)intent.getParcelableExtra(Intent.EXTRA_INTENT);
|
||||
restartIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.putExtra("didRestart", true)
|
||||
.setClassName(getApplicationContext(),
|
||||
AppConstants.MOZ_ANDROID_BROWSER_INTENT_CLASS);
|
||||
startActivity(restartIntent);
|
||||
Log.d(LOGTAG, "Launched " + restartIntent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
doRestart(intent);
|
||||
stopSelf(startId);
|
||||
return Service.START_NOT_STICKY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue