Auto launch new app after repackaging/restoring Manager

This commit is contained in:
topjohnwu 2018-11-27 03:24:26 -05:00
parent e8cba3524e
commit 5fb96cdcf4
4 changed files with 13 additions and 2 deletions

View File

@ -101,7 +101,7 @@ public class PatchAPK {
mm.mDB.setStrings(Const.Key.SU_MANAGER, pkg);
Data.exportPrefs();
RootUtils.uninstallPkg(Const.ORIG_PKG_NAME);
RootUtils.rmAndLaunch(Const.ORIG_PKG_NAME, pkg);
return true;
}

View File

@ -93,7 +93,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
Shell.su("cp " + uri.getPath() + " /data/local/tmp/manager.apk").exec();
if (ShellUtils.fastCmdResult("pm install /data/local/tmp/manager.apk")) {
Shell.su("rm -f /data/local/tmp/manager.apk").exec();
RootUtils.uninstallPkg(context.getPackageName());
RootUtils.rmAndLaunch(context.getPackageName(), Const.ORIG_PKG_NAME);
return;
}
Shell.su("rm -f /data/local/tmp/manager.apk").exec();

View File

@ -25,6 +25,10 @@ public class RootUtils extends Shell.Initializer {
Shell.su("db_clean " + Const.USER_ID, "pm uninstall " + pkg).exec();
}
public static void rmAndLaunch(String rm, String launch) {
Shell.su(Utils.fmt("(rm_launch %d %s %s)&", Const.USER_ID, rm, launch)).exec();
}
@Override
public boolean onInit(Context context, @NonNull Shell shell) {
Shell.Job job = shell.newJob();

View File

@ -135,3 +135,10 @@ EOF
touch hosts/auto_mount
cd /
}
rm_launch() {
db_clean $1
pm uninstall $2
monkey -p $3 1
exit
}