How to make an application become a system application?

I want my application to become a software application. I managed to do this on the phone using root and busybox. any idea how to 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" }); 

Other than that, I also ran into another problem. If I switch my application from the system application> user application and reboot. The Android system still recognizes my application as a system application, although the application is already in / data / app.

I use the following code to check if my application is a system application:

 android.content.pm.ApplicationInfo.FLAG_SYSTEM 
+4
source share
1 answer

Refer to the code below to move the user apk application to the apk system application on the root device using the 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"); 

You must use the Busybox application and the superuser when using the above code in your application.

0
source

Source: https://habr.com/ru/post/1389585/


All Articles