mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-06-12 13:17:39 +02:00
Relaunch process without second process
This commit is contained in:
@ -1,37 +0,0 @@
|
||||
package com.topjohnwu.magisk;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Process;
|
||||
|
||||
import io.michaelrocks.paranoid.Obfuscate;
|
||||
|
||||
// Inspired by https://github.com/JakeWharton/ProcessPhoenix
|
||||
|
||||
@Obfuscate
|
||||
public class PhoenixActivity extends Activity {
|
||||
|
||||
private static final String PID_KEY = "pid";
|
||||
|
||||
public static void rebirth(Context context, String clzName) {
|
||||
var intent = new Intent();
|
||||
intent.setComponent(new ComponentName(context, clzName));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(PID_KEY, Process.myPid());
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Process.killProcess(getIntent().getIntExtra(PID_KEY, -1));
|
||||
var intent = getPackageManager().getLaunchIntentForPackage(getPackageName());
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
Runtime.getRuntime().exit(0);
|
||||
}
|
||||
}
|
@ -2,7 +2,9 @@ package com.topjohnwu.magisk;
|
||||
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.res.AssetManager;
|
||||
|
||||
@ -56,6 +58,14 @@ public class StubApk {
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
public static void restartProcess(Activity activity) {
|
||||
Intent intent = activity.getPackageManager()
|
||||
.getLaunchIntentForPackage(activity.getPackageName());
|
||||
activity.finishAffinity();
|
||||
activity.startActivity(intent);
|
||||
Runtime.getRuntime().exit(0);
|
||||
}
|
||||
|
||||
public static class Data {
|
||||
// Indices of the object array
|
||||
private static final int STUB_VERSION = 0;
|
||||
|
Reference in New Issue
Block a user