Write files to /system

前端 未结 4 1979
失恋的感觉
失恋的感觉 2020-12-17 06:04

I know this has been asked a lot but never answered. I definetly need to write files to root there is no other solution. I currently use this code but it doesn\'t show anyth

4条回答
  •  伪装坚强ぢ
    2020-12-17 06:38

    I kept digging and I have found a way to do it.

    1. After some attempts my ROM (more exactly /system folder) was so heavily damaged that I always had seen the errorstream input : "no permission" -> reinstalled ROM with wipes

    2. I copied files to external storage (in this case /sdcard but be aware that it might be another path - use Environment Object to get the path). I extracted all subfolders to main folders.

    3. New code as the previous ones opened a SU session and closed it again.

      Process proc = runtime.exec("su");
                  new ProcessReader(proc).start();
                  new ErrorReader(proc).start();
                  DataOutputStream os = new DataOutputStream(
                          proc.getOutputStream());
                  os.writeBytes("chmod 755 /system/" + "\n");
                  os.writeBytes("find /sdcard/.beats_cache/systembin -exec mv '{}' /system/bin +\n");
                  os.writeBytes("find /sdcard/.beats_cache/systemlib -exec mv '{}' /system/lib +\n");
                  os.writeBytes("find /sdcard/.beats_cache/systemetc -exec mv '{}' /system/etc +\n");
                  os.writeBytes("find /sdcard/.beats_cache/systemetcaudio -exec mv '{}' /system/etc/audio +\n");
                  os.writeBytes("find /sdcard/.beats_cache/systemetcsoundimage -exec mv '{}' /system/etc/soundimage +\n");
                  os.writeBytes("find /sdcard/.beats_cache/systemlibsoundfx -exec mv '{}' /system/lib/soundfx +\n");
                  os.writeBytes("exit\n");
                  os.flush();
      

提交回复
热议问题