0

I currently do it manually each time after my phone is restarted. I connect using adb and running this

adb shell sh /sdcard/AFolder/ascript.sh "a-dummy-argument" &

Then I just disconnect the cable and script continue working.

How I can achieve the same thing on non rooted Android 7.0 and Android 9.0 devices(I have 2 and I would like to do this on both)? I would like to avoid rooting. From what I was reading it can not be done without rooting. My question is, would it be possible to install TWRP, backup stock ROM, modify stock ROM so that it would have an additional file ascript.sh (or run it from sd card) which will be started at startup. Then flash this modified ROM, to avoid doing this manually. Is this possible?

Note: adb via tcp I believe is not an option as to make adb work via tcp on non rooted device after each reboot we need to connect the device to PC first to switch to tcpip, so we back to the task how to avoid after reboot connecting phone to PC.

8
  • play.google.com/store/apps/details?id=com.ryosoftware.initd btw android doesn't have bash it uses MirBSD Korn Shell
    – alecxs
    Feb 7 '20 at 6:42
  • Also there are other apps which can execute scripts on boot. Termux offers a paid add-on: Termux Boot for the same purpose. But apps cannot execute scripts with the privileges adb has. So most of the times running shell scripts without root access or at least adb shell permissions is not very useful. Feb 7 '20 at 10:05
  • 1
    @alecxs workarounds do exist, many other apps also use. User needs to connect to PC at least once after reboot. Or have to run adbd in TCP mode somehow. Feb 7 '20 at 15:20
  • 1
    @user1325696 explicitly root isn't necessarily required in order to always run adbd in TCP mode. On non-SAR devices with unlocked bootloader it's possible to set persist.adb.tcp.port or service.adb.tcp.port permanently by unpacking boot.img. // "so we back to the task how to avoid after reboot connecting phone to PC" Three apps are already mentioned for reference. You can find more similar solutions. Feb 8 '20 at 0:51
  • 1
    @user1325696 yes it's definitely possible to modify boot.img without rooting main OS. Feb 10 '20 at 5:03
3

This app, called LADB — Local ADB Shell, can open an adb wifi shell without ever needing to connect to the PC:

https://play.google.com/store/apps/details?id=com.draco.ladb

Unfortunately you have to cut and paste your commands into it for now, I'm trying to get him to add editable shortcuts. It's a fairly new app.

1
  • unfortunately not compatible with android 7.0
    – alecxs
    Jan 19 '21 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.