Support restarting app when obfuscated

This commit is contained in:
topjohnwu
2019-11-03 02:55:12 -05:00
parent 14ba002cbc
commit 0c9feedb37
14 changed files with 46 additions and 57 deletions

View File

@ -4,6 +4,8 @@ import android.app.Activity;
import android.app.AlertDialog;
import android.app.Application;
import android.app.ProgressDialog;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
@ -11,6 +13,7 @@ import android.util.Log;
import com.topjohnwu.magisk.net.ErrorHandler;
import com.topjohnwu.magisk.net.Networking;
import com.topjohnwu.magisk.net.ResponseListener;
import com.topjohnwu.magisk.obfuscate.Mapping;
import com.topjohnwu.magisk.obfuscate.RawData;
import com.topjohnwu.magisk.utils.APKInstall;
@ -48,7 +51,11 @@ public class DownloadActivity extends Activity {
// Download and relaunch the app
Networking.get(apkLink)
.setErrorHandler(err)
.getAsFile(MANAGER_APK, f -> ProcessPhoenix.triggerRebirth(this));
.getAsFile(MANAGER_APK, apk -> {
Intent intent = new Intent()
.setComponent(new ComponentName(this, Mapping.inverse("a.r")));
ProcessPhoenix.triggerRebirth(this, intent);
});
} else {
// Download and upgrade the app
Application app = getApplication();

View File

@ -7,9 +7,14 @@ import static com.topjohnwu.magisk.DynAPK.Data;
public class Mapping {
private static Map<String, String> map = new HashMap<>();
private static Map<String, String> inverseMap;
static {
map.put("a.x", "androidx.work.impl.background.systemjob.SystemJobService");
inverseMap = new HashMap<>(map.size());
for (Map.Entry<String, String> e : map.entrySet()) {
inverseMap.put(e.getValue(), e.getKey());
}
}
public static String get(String name) {
@ -17,13 +22,14 @@ public class Mapping {
return n != null ? n : name;
}
public static String inverse(String name) {
String n = inverseMap.get(name);
return n != null ? n : name;
}
public static Data data() {
Map<String, String> componentMap = new HashMap<>(map.size());
for (Map.Entry<String, String> e : map.entrySet()) {
componentMap.put(e.getValue(), e.getKey());
}
Data data = new Data();
data.componentMap = componentMap;
data.componentMap = inverseMap;
return data;
}