I just need help at best way for me to build a simple app to request for root, then dd install a kernel
dd if=boot.img of=/dev/block/mmcblk0p14
and then give option to reboot.
Thanks for any advice
carl1961 said:
I just need help at best way for me to build a simple app to request for root, then dd install a kernel
dd if=boot.img of=/dev/block/mmcblk0p14
and then give option to reboot.
Thanks for any advice
Click to expand...
Click to collapse
Just a tip, I'm assuming this app will work only for your device or similar partitioned devices. You could read the mounts file under proc using java and extract the Mount path instead of hard coding it. And executing shell commands can be done using JNI system() calls or from java it's Runtime.getRuntime().exec(ddcommandhere);
MasterAwesome said:
Just a tip, I'm assuming this app will work only for your device or similar partitioned devices. You could read the mounts file under proc using java and extract the Mount path instead of hard coding it. And executing shell commands can be done using JNI system() calls or from java it's Runtime.getRuntime().exec(ddcommandhere);
Click to expand...
Click to collapse
thanks for the advice, my issue right know is still l amd still learning android studio. I cannot figure out how and where to use this command. all apk guides I find is for like online and hello world LOL
carl1961 said:
thanks for the advice, my issue right know is still l amd still learning android studio. I cannot figure out how and where to use this command. all apk guides I find is for like online and hello world LOL
Click to expand...
Click to collapse
Well, let android studio create a project for you, you'll have an activity there run your code from there on another thread that's not the main ui thread.
carl1961 said:
thanks for the advice, my issue right know is still l amd still learning android studio. I cannot figure out how and where to use this command. all apk guides I find is for like online and hello world LOL
Click to expand...
Click to collapse
perhaps you can just use a button in your MainActivity
And override the onClickListener
Then put that command(RunTime.getRunTime().exec().. in that method. Easy
Sent from my A0001 using Tapatalk 2
Vivek_Neel said:
perhaps you can just use a button in your MainActivity
And override the onClickListener
Then put that command(RunTime.getRunTime().exec().. in that method. Easy
Sent from my A0001 using Tapatalk 2
Click to expand...
Click to collapse
Thanks @Vivek_Neel, might get time this weekend to try that
Related
Hey guys, need some help with this one from some of you with more android/linux experience than me.
In my continuing quest to make Blackhole as customizable as possible I've been working on a way for users to easily install paid apps (legally downloaded of course), and stuff that I don't have available in rom manager in one easy step at the same time the rom is installed. In pursuit of this goal I've found that it's possible for the update-script file inside a clockworkmod zip to call a script in the zip as well. I've gotten it to say it's run the script, but it doesn't do what it's supposed to. here's what i've got:
#! /bin/
busybox cp /sdcard/app/* /system/app/
When I type the command into a terminal on the phone it works. When I open an adb shell and type "bash install.sh" it works. But when I get the update.zip to run the script, or run it in root explorer it just says it's run it, but doesn't do anything.
Is there something I'm missing about how to call the script? Do I need to somehow add the bash program to the zip file so it can run the script right? Has anyone ever done something like this who can point me in the right direction?
do you have an output you can show us?
Sent from my SCH-I500 using XDA App
This is a shot in the dark but does writing to /system/app require root permissions? It could be that you've given your terminal app root, so it runs under su. But when the script is being executed it does not have root and fails, but perhaps the output is being held back a bit and you're not seeing the permission denied.
Steve_ ?!
whoa, didn't expect it to be you of all people
Anyhoo, this is a bit off topic, but I've got a small request, can you somehow make BlackHole 2.4 an option on Rom manager? I don't have DL09 so I can't use 3.0, but I really like the ability to select everything to customize, instead of me going and installing one thing at a time....
Why not just add the following to the end of the update-script:
Code:
copy_dir /sdcard/app SYSTEM:
Also, is the SDCard mounted by default when the phone boots to recovery? If it isn't, or it isn't mounted while the update is processing, that will also cause the problem.
wizang said:
This is a shot in the dark but does writing to /system/app require root permissions? It could be that you've given your terminal app root, so it runs under su. But when the script is being executed it does not have root and fails, but perhaps the output is being held back a bit and you're not seeing the permission denied.
Click to expand...
Click to collapse
Could very well be, it's not showing me any output when i run it the two ways it doesn't work, just says it's been run.
vegittoss15 said:
Steve_ ?!
whoa, didn't expect it to be you of all people
Anyhoo, this is a bit off topic, but I've got a small request, can you somehow make BlackHole 2.4 an option on Rom manager? I don't have DL09 so I can't use 3.0, but I really like the ability to select everything to customize, instead of me going and installing one thing at a time....
Click to expand...
Click to collapse
Haha, caught me. I was trying to remain incognito Yeah, i'll get 2.4 loaded back up on rom manager for you today. But if you flash 3.0 it will upgrade you to DL09 and the DJ05 kernels and modem are compatible, or at least no one i know of has had issues.
imnuts said:
Why not just add the following to the end of the update-script:
Code:
copy_dir /sdcard/app SYSTEM:
Also, is the SDCard mounted by default when the phone boots to recovery? If it isn't, or it isn't mounted while the update is processing, that will also cause the problem.
Click to expand...
Click to collapse
sdcard is mounted when you go to recovery, because it's got to access the update.zip file on it to install anything. I'll try your code, do you know what to put after SYSTEM: to make it go to the /app directory? thanks for the idea, it's a different way to go, i didn't think about the fact the update-script could access the device if you don't use the "package" tag.
Don't you need to add "sh" to the bin directory and define the script as so:
#! /bin/sh
if you want it to execute properly..
dcow90 said:
Don't you need to add "sh" to the bin directory and define the script as so:
#! /bin/sh
if you want it to execute properly..
Click to expand...
Click to collapse
normally yes, but there doesn't seem to be a /bin/sh directory on my fascinate, only /bin and that's where the cp and mv and cat, etc. are.
I made a script to do this forever ago on my G1 when it first came out... Let me see if I can find it.
This has been done lots of times before. If you look around on xda there are some backup scripts which do the same thing.
Sent from my SCH-I500
imnuts said:
Why not just add the following to the end of the update-script:
Code:
copy_dir /sdcard/app SYSTEM:
Also, is the SDCard mounted by default when the phone boots to recovery? If it isn't, or it isn't mounted while the update is processing, that will also cause the problem.
Click to expand...
Click to collapse
Well I gave that a shot, and i think it could work, but the recovery wouldnt do it. it says "non-package source path not yet supported" good idea tho.
yutsoku said:
I made a script to do this forever ago on my G1 when it first came out... Let me see if I can find it.
Click to expand...
Click to collapse
If you can that would be great.
n0yd said:
This has been done lots of times before. If you look around on xda there are some backup scripts which do the same thing.
Sent from my SCH-I500
Click to expand...
Click to collapse
I spent a good bit of time searching and most of the scripts I found were much more complex than what i need, or were written to run on a computer, which i've already done.
sonofskywalker3 said:
normally yes, but there doesn't seem to be a /bin/sh directory on my fascinate, only /bin and that's where the cp and mv and cat, etc. are.
Click to expand...
Click to collapse
Thats not the point. You need to set a shell interpreter, not a path. Cwm uses busybox sh, which is in /bin in recovery mode. Google search shebang
Sent from my SCH-I500 using XDA App
jt1134 said:
Thats not the point. You need to set a shell interpreter, not a path. Cwm uses busybox sh, which is in /bin in recovery mode. Google search shebang
Sent from my SCH-I500 using XDA App
Click to expand...
Click to collapse
Going to go ahead and parade my stupidity in front of everyone here:
so does that mean i'm right using #! /bin/ or that it should be #! /bin/sh/ or something else entirely? I'm so confused.
sonofskywalker3 said:
Going to go ahead and parade my stupidity in front of everyone here:
so does that mean i'm right using #! /bin/ or that it should be #! /bin/sh/ or something else entirely? I'm so confused.
Click to expand...
Click to collapse
#!/bin/sh for scripts in recovery. #!/system/bin/sh for scripts in android.
Sent from my SCH-I500 using XDA App
I am new to programming Java. Can anyone help me with source code for a simple android app that copies one file from sdcard to any directory in Phone. I have eclipse and emulator setup for testing.
cheers
Im not into java... but you could write a small bash script!
Bashs can be run from a terminal (connectbot, irrsi, ssh-server)
Or you simply use the app (GScript), where you can add your own scripts and run them just with 1 click!
Code:
#!/system/bin/sh
file=/sdcard/FOLDER_OF_FILE/FILES_I_WANT_TO_COPY
target=/TARGET_FOR_FILE
cp -frv $file $target
Hope I could help you...
I would try searching stackoverflow.com ....
.... be prepared though, file operations in Android are not a quick 2 lines of code.
sebsch1991 said:
Im not into java... but you could write a small bash script!
Bashs can be run from a terminal (connectbot, irrsi, ssh-server)
Or you simply use the app (GScript), where you can add your own scripts and run them just with 1 click!
Code:
#!/system/bin/sh
file=/sdcard/FOLDER_OF_FILE/FILES_I_WANT_TO_COPY
target=/TARGET_FOR_FILE
cp -frv $file $target
Hope I could help you...
Click to expand...
Click to collapse
Thanks for reply. But i am looking for a pure android app and not script or adb commands via terminal !
@eatmold
eatmold said:
I would try searching stackoverflow.com ....
.... be prepared though, file operations in Android are not a quick 2 lines of code.
Click to expand...
Click to collapse
Thanks a lot man, i look forward to see some code soon .....
user_000 said:
I am new to programming Java. Can anyone help me with source code for a simple android app that copies one file from sdcard to any directory in Phone. I have eclipse and emulator setup for testing.
cheers
Click to expand...
Click to collapse
First of all, you can't copy a file to any directory on the phone. The app can only write to directories to which it has permission to write. Second, some parts of the phone can't be written to at all because the filesystem is read-only. Third, file I/O is non-trivial in the dalvik VM. It would take a substantial amount of code to do what you want.
Do you have some goal in mind for this starter project? There is the "Hello World" project at http://developer.android.com if you just want some example code.
Gene Poole said:
First of all, you can't copy a file to any directory on the phone. The app can only write to directories to which it has permission to write. Second, some parts of the phone can't be written to at all because the filesystem is read-only. Third, file I/O is non-trivial in the dalvik VM. It would take a substantial amount of code to do what you want.
Do you have some goal in mind for this starter project? There is the "Hello World" project at http://developer.android.com if you just want some example code.
Click to expand...
Click to collapse
Well the aim is to get an idea of how a very simple app can work on phone. So it can even be copying a file from one directory of SDcard to another directory on SDcard on Phone. And also lets assume that we have the permission to write to any directory on phone (i.e superuser or its writable etc).
Yea 'hello world' is a nice example and on the same lines a simple non-gui app to copy file is what i am looking for. It will give a good overview of how to do some basic I/O operation on phone via android app.
cheers
If you want to do this as a Java learning experience, then you'll probably want to handle the file I/O using strictly Java which can be a real pain. Nonetheless, all you need is here:
http://developer.android.com/reference/java/io/package-summary.html
although, typically things like file I/O are best left to the operating system which is usually more optimized for that sort of thing--especially when the OS is *nix. To leverage the OS to do your dirty work natively, you can use the Runtime class:
http://developer.android.com/reference/java/lang/Runtime.html
Thanks for the references. But interest is to see a working code on an Android device and not Java as a whole. So a simple app source code can be a really good starting point. Hello World is good first example but does not include I/O, so someone with experience can lead the newbies in a good way by showing a simple example.
Come on guys share some experience !
Here's the NANO text editor for the Android. This is not completely my work, I just compiled the threads I found on the net and made the flashable zip only.
I tested a little bit with Terminal Emulator and seems like it's working fine.
Enjoy.
Installation: Just flash with recovery. Requires aprrox. 1.5mb space in System partition.
Hi
Thanks, i didn't try it ('cause I already have nano) but i think this flashable solution is the easier for installing nano! :good:
Great!!
Thanks
What is that
Sent from my HTC Desire using xda app-developers app
SeeZaar said:
What is that
Sent from my HTC Desire using xda app-developers app
Click to expand...
Click to collapse
An editor like vi/vim for *nix based machines. I would say more friendlier than vi/vim.
And what is vi/vim? XD
Sent from my HTC Desire using xda app-developers app
Moving to Desire Themes and Apps as this shouldn't have been in dev to begin with.
theGanymedes said:
Here's the NANO text editor for the Android. This is not completely my work, I just compiled the threads I found on the net and made the flashable zip only.
I tested a little bit with Terminal Emulator and seems like it's working fine.
Enjoy.
Installation: Just flash with recovery. Requires aprrox. 1.5mb space in System partition.
Click to expand...
Click to collapse
Thank you but I can't save file after editing, because I can't press "^" and "0" at a time ......
Any workaround ?
Thanks again in advance for salutation
monitorstudioworker said:
Thank you but I can't save file after editing, because I can't press "^" and "0" at a time ......
Any workaround ?
Thanks again in advance for salutation
Click to expand...
Click to collapse
Maybe you can look at the "settings" section of your terminal emulator. Some emulators make Volume Up key as Control character etc.
theGanymedes said:
Maybe you can look at the "settings" section of your terminal emulator. Some emulators make Volume Up key as Control character etc.
Click to expand...
Click to collapse
Thanks for replying, but I mostly used it in recovery via aroma file manager, and there's no setting so far ...
I want to edit updater-script without rebooting and computer I have zip and unzip binary yet, but no text editor (echo "" >> is not a good way to do my work)
Much thanks, it works!
Hi,
I'm writing an android application which have to run a android shell script as root. But I don't know how to do that . Can anyone help me?
It's a very simple application with a button in the middle of the screen and if I press that button the script should be executed as root. :good:
Use
Process p = Runtime.getRuntime().exec("su");
p.getOutputStream().write("your command".getBytes());
EmptinessFiller said:
Use
Process p = Runtime.getRuntime().exec("su");
p.getOutputStream().write("your command".getBytes());
Click to expand...
Click to collapse
Thank you for tour reply, :good:
I have one more question. How can i show the output of the script to the user in something like a popup message?
supergerrit said:
Thank you for tour reply, :good:
I have one more question. How can i show the output of the script to the user in something like a popup message?
Click to expand...
Click to collapse
You can use superuser libraries like libSuperuser by chainfire, or RootTools by stericsson to execute the script which can handle the output for you. You can assign the output to a String and then display it in a dialogbox.
See these links -
How to SU
RootTools
supergerrit said:
Thank you for tour reply, :good:
I have one more question. How can i show the output of the script to the user in something like a popup message?
Click to expand...
Click to collapse
You would need
say if your prcess is Process p
Scanner s = new Scanner(p.getInputStream)
while(s.hasNextLine){
//s.nextLine() will give the process output
}
Sent from my GT-S5302 using Tapatalk 2
gh0stslayer said:
You can use superuser libraries like libSuperuser by chainfire, or RootTools by stericsson to execute the script which can handle the output for you. You can assign the output to a String and then display it in a dialogbox.
See these links -
How to SU
RootTools
Click to expand...
Click to collapse
Thank you so much for your reply. The links helped me so much! :good:
But i have one more question:
Can i also run multi line shell schripts from a file in the assets folder?
Example: i have a file: 'scripfile'. I put this one in the assets folder of the application. How can i run that file?
supergerrit said:
Thank you so much for your reply. The links helped me so much! :good:
But i have one more question:
Can i also run multi line shell schripts from a file in the assets folder?
Example: i have a file: 'scripfile'. I put this one in the assets folder of the application. How can i run that file?
Click to expand...
Click to collapse
I can think of one way to do it. Like sak-venom1997 posted above, you can read the file one line at a time and save it to a String array or a list and pass the String array to the superuser library
PHP:
List<String> Shell.SH.run(List<String> commands)
or
List<String> Shell.SH.run(String[] commands)
Will it work for non rooted devices??
sak-venom1997 said:
You would need
say if your prcess is Process p
Scanner s = new Scanner(p.getInputStream)
while(s.hasNextLine){
//s.nextLine() will give the process output
}
Sent from my GT-S5302 using Tapatalk 2
Click to expand...
Click to collapse
Will the codes be applicable for non rooted device? or it will run on all the devices..?
If it is for non rooted... then can you please suggest me how can I access shell.. or run shell commands without rooting the device.
nitinsao said:
Will the codes be applicable for non rooted device? or it will run on all the devices..?
If it is for non rooted... then can you please suggest me how can I access shell.. or run shell commands without rooting the device.
Click to expand...
Click to collapse
If you take a look here
http://su.chainfire.eu/#how-call
you will notice this-
PHP:
List<String> Shell.SH.run(String command)
which I believe can be used for executing shell without root. Now I haven't tried it, so I am not sure, but it's worth a shot.
Hello,
I have developed a quite simple perl script (parse some files, make lists, remove other files) and would like to be able to run it from my phone rather than copying the working directory to my pc and then execute the script.
Could someone please give me some light on how to do? If I write this in shell script, would it be more convenient?
Thanks in advance
Br1ce said:
Hello,
I have developed a quite simple perl script (parse some files, make lists, remove other files) and would like to be able to run it from my phone rather than copying the working directory to my pc and then execute the script.
Could someone please give me some light on how to do? If I write this in shell script, would it be more convenient?
Thanks in advance
Click to expand...
Click to collapse
Yes, if you make it into a shell script you can do anything with it. You can simply drop into your /system/bin and then call it from any folder.
Heisenberg420 said:
Yes, if you make it into a shell script you can do anything with it. You can simply drop into your /system/bin and then call it from any folder.
Click to expand...
Click to collapse
I guess I have to try then. Thanks!
Br1ce said:
I guess I have to try then. Thanks!
Click to expand...
Click to collapse
Might be worth it to take a look at this:
https://play.google.com/store/apps/details?id=org.androidideas.scriptlauncher
Actually after discussing this with a friend, I' m going to develop a complete application that will have other features. These scripts are doing quite basic stuff so it should be doable.
SL4A looks interesting though, I might still play a little bit with it