[Pls Help] How to run shell command from code in non-rooted Android phones? - Android Q&A, Help & Troubleshooting

Dear Sirs/Madams,
I'm new to Android development and I'm writing my very first Android apps but recently I have encounter the below problem:
I want to call reboot command in non-rooted phone but as you know, reboot command needs root permission.
I want my app to run in both rooted and non-rooted phones. For rooted phones there is no problem.
However for non-rooted phones, I am trying to find a way to restart it without root permission.
I have been thinking of calling shell command in non-rooted phones (E.g, adb shell reboot), but I don't know how to put the script file
to an apk file and excecute the script within java code.
Therefore I'd like to ask for your help to solve this problem.
Thank you very much

Related

Root info

I have used the instantroot method of rooting my fone (hero)
How do i know if it has worked ?
is there a new app or terminal window installed lets me control apps and settings etc
The easiest way to test if the device is rooted is to open another command prompt in the tools dir and type
adb root
If it returns that adb is already running in root, then you're all set.
Try google next time.

[Q] ADB inside Android?

I'm sorry If I'm missing something really obvious, or if this question has been asked before, but I didn't find anything in the search, so here goes:
Firstly, as the title suggests, I'm wondering whether it would be possible to run ADB (Android Debug Bridge) inside an existing Android device. I saw this, but what I want is to be able to compile an ADB binary (plus any necessary libraries) for Android, put it on my sdcard, and run ADB commands from within a terminal emulator.
Secondly, I'm wondering whether, after installing ADB on one device (device #1), I could connect that device and another device (device #2) together, and use device #1 to perform ADB commands on device #2 (for example, rooting device #2 without needing a PC).
So..... Would it be possible?
This would fare better in the Android Q&A forum. I'll flag it to the forum mod and ask them to move it
Done, and Thank You Sir.
adb
pokepal101 said:
I'm sorry If I'm missing something really obvious, or if this question has been asked before, but I didn't find anything in the search, so here goes:
Firstly, as the title suggests, I'm wondering whether it would be possible to run ADB (Android Debug Bridge) inside an existing Android device. I saw this, but what I want is to be able to compile an ADB binary (plus any necessary libraries) for Android, put it on my sdcard, and run ADB commands from within a terminal emulator.
Secondly, I'm wondering whether, after installing ADB on one device (device #1), I could connect that device and another device (device #2) together, and use device #1 to perform ADB commands on device #2 (for example, rooting device #2 without needinig a PC).
So..... Would it be possible?
Click to expand...
Click to collapse
I want to start by saying I'm no expert, but to the best of my knowledge, this is how it works.
adb runs native on android, the android property is ro.secure=1 this is found in the default.prop file. ADB is run in user privilege mode with this property setting. Not all of the adb shell commands will work with the device in this mode. With ro.secure=0 property setting, adb will run with root user privileges and all adb shell commands will function. There is an adb comand that when issued will return the value of the setting, but off the top of my head I could not tell you it. The file default.prop is part of the boot.img and will load every time the device is booted, so to edit the file the boot.img would have to be unpacked, edited, repacked, and pushed to the device boot partition.
I don't know why you would want to connect two smartphones using adb and don't know if it is even possible. It is probably best to run the binary with a script on the device where you want it installed. Good Luck with your project.
Sorry, I don't think I quite understand....
fdaconta said:
Not all of the adb shell commands will work with the device in this mode
Click to expand...
Click to collapse
I'm sorry if I'm not making myself clear, but I'm talking about running the ADB client/server on an android phone (normally done on a development computer), not the ADB daemon.
fdaconta said:
It is probably best to run the binary with a script on the device where you want it installed
Click to expand...
Click to collapse
That's also not possible, as the script involves running some complicated ADB-ish things like "adb restore" and running while device #2 is turned off - hence the need for device #1.

[Q]

Hi,
I'm trying to run a bash script on Android without root access (Nexus 4) using Terminal IDE app. Script fails with output "parent shell dies". I tried to run the same script on Ubuntu on Android phone with root access and script worked fine. In both cases I used the same version of bash shell. Does anyone know how can I solve this?

Can't get ADB root access - What else could I try?

Hi there
I fiddle largely with MTK based phones and when I tweak a phone, I normally only need ADB root access. So my general process has been to:
1. OEM Unlock the device
2. unpack the boot.img and change the default.prop values (ro.adb.secure etc) to allow ADB root access.
3. Use ADB to get temporary write access using adb Root, then ADB remount Rw. Then you can pull and push files.
However I have an MT8735b, Android 7.0, Alps based device that will simply not give me ADB root access. so when I run "adb remount rw" or any of the equivalent shell scripts you can use instead, it just won't give me write access.
So I heard that newer phones based on these chipsets and also ones like 6737M are locking the device up in other ways.
My question is, does anyone have any ideas or knows anything I could try to get root access?
Any help is much appreciated.

Granting root permissions to another user

First I have googled until my fingers bled knowing the answer is out there and apologize in advance if it has been covered in these forums elsewhere.
I have an android appliance running 4.3, I have root access via adb shell. What I want to do is grant root access to the standard users so I have root access using telnet. This is NOT a phone, it will NOT be on the internet so I do not need to worry about root being open to the world. I just need to be able to shell into it and be able to run any command needed via the normal user in telnet. Changing the user permissions seems like an easy way but all linux style sudo and user commands fail (it's a very cut down install in this machine).
Any help would be appreciated,
J
Bump, Anyone?

Categories

Resources