I want to make my app become system app programmatically. I managed to do it in my phone with root and busybox. any idea how achieve this without busybox?
Runtime.getRuntime().exec(new String[] { "su", "-c", "mount -o rw,remount -t yaffs2 /system; " +
"cp `ls /data/app/xxx*` /system/app; " +
"rm /data/app/xxx*; " +
"mount -o ro,remount -t yaffs2 /system; " +
"reboot" });
Beside this, I also faced another issue. If i switch back my app from system app > user app and reboot. Android system still recognize my app as system app even though the app already reside in /data/app.
I use code below to check whether my app is system app:
android.content.pm.ApplicationInfo.FLAG_SYSTEM
Refer the below code to move user app apk into system app apk in rooting device with the help of RootTools method .
PackageInfo paramPackageInfo = null;
try {
paramPackageInfo = this.getPackageManager().getPackageInfo(
this.getPackageName(), 0);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
ApplicationInfo localApplicationInfo = paramPackageInfo.applicationInfo;
String str1 = "/system/app/" + localApplicationInfo.packageName
+ ".apk";
String str2 = "busybox mv " + localApplicationInfo.sourceDir + " "
+ str1;
RootTools.remount("/system", "rw");
RootTools.remount("/mnt", "rw");
CommandCapture command = new CommandCapture(0, str2,
"busybox chmod 644 " + str1);
try {
RootTools.getShell(true).add(command).waitForFinish();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (TimeoutException e) {
e.printStackTrace();
} catch (RootDeniedException e) {
e.printStackTrace();
}
RootTools.remount("/system", "ro");
RootTools.remount("/mnt", "ro");
Necessary of Busybox and superuser app while use the above code in your application.