[Script] Shell Intent - Xoom Android Development

I'm trying to make a shell script for my xoom that launches google maps and loads a kml file, am start -a android.intent.action.VIEW -d h--p://myserver.com/kml.kml (its blocking me from the http) is not working, Any suggestions? it just displays the file contents in the browser..

try using the ip or putting myserver.com into /system/etc/hosts

Related

Moving Power Manager Pro to /system/app

Long post but, hopefully an easy answer that someone can walk me through. I have fully rooted my EVO along with the NAND. I'm trying to move/install (?) Power Manager Pro into the /system/app folder to get full rights so it can turn GPS on/off. The website for the app says that I need to do the following:
After root is obtained you need to install the application into the /system/app directory so that it has enough permission to change the location settings. Open a Terminal Emulator app and execute the following command to copy the application to the sdcard (for the full version the name of the application is /data/app/com.acme.android.powermanagerpro.apk):
su
cp /data/app/com.acme.android.powermanager.apk /sdcard/PowerManager.apk
If you can't find the application in /data/app try /data/apps-private/
Then, un-install Power Manager from the device
Execute the following commands in the terminal emulator to remount the /system directory as read/write and to install the application into the /system/app directory:
su
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
cp /sdcard/PowerManager.apk /system/app
If you prefer to use adb from your computer, execute these commands:
adb remount
adb shell cp /sdcard/PowerManager.apk /system/app
Several users have utilized root explorer from the Google marketplace to simplify this process.
I have Root Explorer so I would like to do it through there is possible, but I can't seem to get it to work without it getting a FC when it opens after trying to move it.
hmmm, it might be force closing because the system is not mounted as read/write. Never used the app before so I dont know. But you can search the market for terminal emulator and then follow the steps the showed above. It looks like it should work.
...or you could do it through adb shell if you are connected to your 'puter
Trying it in Terminal Emulator with no luck... Wondering if the path is right or if i need to change that? It says:
xport PATH=/data/local/bin:$PATH
$su
cp /data/app.acme.android.powermanagerpro.apk /sdcard/PowerManager.apk
cp: not found
the path seems right (I assume you mean export and not xport). I dont think you need anything special on the rom to access cp through terminal emulator...
Have you tried hooking it up to a computer and entering it through adb shell to see if that works?

[Q] Internet was working, upon reboot stopped

Hello all,
I'd like to preface this by saying this is a Cricket phone. Even if you know nothing about Cricket you may be able to help, so please read on. Note: because it's a Cricket phone I'm using autostart and a script to connect to the internet.
So a few days ago I messed up my phone to the point where it wouldn't boot. After that I had to learn how to flash (I didn't know before) and so I'm very new to all of this.
Here's what I've done:
- I flashed to the official 2.2, EC05
- I restored my data from my old nandroid backup
- I edited my phone's PRL and then went into QPST and changed the info so it will connect to the internet
- I copied autostart.sh to /data/opt/ and made sure the /opt/ director is 777 and the autostart.sh is 755
- I copied u2nl to /system/bin/ and made sure it was 755
I don't really have any questions about any of that because after I did this and restarted the internet was working fine. It worked fine for a few hours, then I had to restart my phone and now all of the sudden it's not working.
Autostart is launching when the phone starts, and it's being given superuser permissions, but the internet is not working.
- I can see the 3g symbol at the top of my phone, and arrows move in both directions
I think it might be an app that I've got installed that's blocking connectivity, however I've been disabling them and I'm still not getting anywhere. Does anyone have any clue why this could be happening?
Just wanted to edit and also ask: if it is an app blocking my connectivity, why did it work at all? The first time I restarted after granting autostart superuser ability, the internet worked fine for hours and hours. It was only after I restarted the phone again that the internet went away.
Thanks.
Maybe its with autostart app. Maybe something got changed when your phone booted up and now its affecting your internet. Is anything working that involves a data connection?
Sent From My Evo Killer!
musclehead84 said:
Maybe its with autostart app. Maybe something got changed when your phone booted up and now its affecting your internet. Is anything working that involves a data connection?
Sent From My Evo Killer!
Click to expand...
Click to collapse
Nothing that involves data is working, but everything (internet and data) was working when I first restarted the phone.
After playing with it all day I thought the AutoKiller app might have been causing the problems, but then this evening it got even worse. Initially my AutoStart app would run on boot, but the internet wouldn't work. Now the AutoStart app isn't even running on boot, and I'm 100% sure I've got it installed. I removed all apps that had anything to do with apps that run on boot or data control, and it still won't run on boot.
I don't really understand why but this AutoStart app will not consistently AutoStart anymore, and even when it did a few hours ago the data connection would only work on the first restart, and then it would AutoStart but the connection wouldn't work.
Does anyone have any idea? It's a pain in the butt to have a smartphone that doesn't do anything except text/calls
Maybe try to Clear you Cache in CWM. I had to do that once because I lost data.
Maybe even try doing a Fix Permissions in CWM.
hopefully it is this easy. If not sorry :O
For anyone who is interested I believe I have solved the problem.
According to a few other people here on the forums the stock 2.2 does not allow Autostart to work, so it may work once or twice but will not regularly work.
I got around this by using the Locale Execute Plugin which is a plugin written for the Locale app, however it can be used independently of the Locale app (read: you do not have to buy the Locale app, you can download the Execute plugin free and use it without Locale). I used Tasker to setup an On Boot trigger, and have it running the Locale Execute Script which launches Autostart.sh and allows my internet to connect.
I noticed the internet was still acting funny and removed my Autokiller app as well as my Phone Prioritizer app (I was using this to make sure my actual phone had priority over all other apps, it was running a script every 30 minutes). The internet seems to be functioning well now.
Here is a copy of my autostart.sh file (create a file called autostart.sh and edit it with notepad, copy and paste this code then save)
Code:
#!/system/bin/sh
export PROXYHOST=wap.mycricket.com
export PROXYPORT=8080
export MMSHOST=mms.mycricket.com
export MMSPORT=80
#you shouldn't have to edit anything below this line
export PATH="$PATH:/system/bin"
until netcfg|grep -v DOWN|awk '{print $1}'|grep -v wlan|grep -v lo >/dev/null 2>&1 ; do sleep 1 ; done
export INTERFACE=`netcfg|grep -v DOWN|awk '{print $1}'|grep -v wlan|grep -v lo`
export PROXYIP=`ping -c 1 $PROXYHOST|grep PING|cut -d\) -f1|cut -d\( -f2`
export MMSIP=`ping -c 1 $MMSHOST|grep PING|cut -d\) -f1|cut -d\( -f2`
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -F
iptables -t nat -F
iptables -X
iptables -t nat -A OUTPUT -o $INTERFACE -p 6 -d $MMSIP --dport $MMSPORT -j DNAT --to-destination $MMSIP:$MMSPORT
#iptables -t nat -A OUTPUT -o $INTERFACE -p 6 --dport 80 -j DNAT --to-destination $PROXYIP:$PROXYPORT
iptables -t nat -A OUTPUT -o $INTERFACE -p 6 ! -d $PROXYIP ! --dport $PROXYPORT -j REDIRECT --to-port 1025
u2nl $PROXYIP $PROXYPORT 127.0.0.1 1025 >/dev/null 2>&1 &
sh -c "sleep 5;kill `ps|grep nk.bla.android.autostart|grep -v grep|awk '{print $2}'`" >/dev/null 2>&1 &
exit 0
Here's a step-by-step breakdown of what I did:
I used:
Tasker (paid app)
Locale Execute Plugin (free app - (link)(link2))
Root Explorer (paid app)
Patience
- Created autostart.sh file and copied it to my SD card
- Copied u2nl file to the SD card (link - download the token419_cricket_data_setup_1.2.zip, it's located in system/bin/ within that zip)
- Opened the "Root Explorer" app and copied the Autostart.sh file, then browsed to /data/ and created a folder called "opt".
- Pasted autostart.sh in /data/opt/ and made sure it was 755 (long press then go to permissions and check User: read/write/execute, Group: read/execute, Others: read/execute).
- Copied u2nl from the SD card and pasted it to /system/bin/ on my phone, made sure it also had 755 permissions
- Downloaded Locale Execute Plugin (link)(link2)
(note: since your phone is not connected to the internet, connect to a wifi network to download this app from the market)
- Launched Tasker and created a new rule > event > system > device boot
- Added an action > plugin > execute
- Entered "@!/data/opt/autostart.sh" and saved (the @ tells it to not send you a popup when it runs, the ! gives it superuser permissions)
- Saved by pushing the back arrow on my phone's touchscreen
- Clicked "apply"
- Rebooted, and clicked "allow" when Locale Execute Plugin requested superuser permissions
That's it, my internet started working after this. I had to remove those other previously mentioned apps, but that was just me. If your internet isn't working after doing this, first make sure you did everything right. If it's still not working try to think of any apps you have that might be overwriting the autostart.sh file's settings. If worst comes to worst, start uninstalling apps until it works again. Reboots will be required after you uninstall an app.
Hopefully this helps someone out there.
Glad u got it man.
Sent From My Evo Killer!

SOLVED! Python on the command line (scripts on post #17)

Hello everyone,
If your just reading this, skip to page 2 to save me some embarassment... Been a learning curve.
Go here .... http://forum.xda-developers.com/showpost.php?p=47607547&postcount=17
First post here and well I hope it's in the right place. I am definitely a novice programmer, am a little comfortable writing small python scripts which leads to this...
I got my phone rooted, I have sl4a ( It Nice! I like it. You like dogs?), and I just got my CM 10 source on Ubuntu 10 like Google recommends. I got adb working and Terminal IDE so I originally wanted to get python to be able to be called by the bash shell it provides ( I think its bash). I sorta got it working for a single session but what a drag, and I would get an error along the lines that the title suggests, so I,m not happy about that.
I also managed to get a copy of python from com.googlecode.pythonforandroid into /system/bin/ and now when I type "python" into an ADB shell I get the python interpreter!!! Whoo hooo, but I still got that same error. A "import sys", "import ephem", and maybe a few more workes but still something is wrong it said something thiss stuff here..
"""[email protected]:/data/data # python
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
'import site' failed; use -v for traceback
Python 2.6.2 (r262:71600, Mar 20 2011, 16:54:21)
[GCC 4.4.3] on linux-armv7l
Type "help", "copyright", "credits" or "license" for more information.
>>>
"""
update/bump
Ok so looking at the error message again it seems that it wants two prefixes for the $PYTHONHOME variable, I assume two paths and the secon one is to the executable that I put in /system/bin/ which is already in my path hence why python is callable. I had also fumbled around haphazardly with my $PATH vriables the other day and may have added the path to some of the libs python was asking for such as libpython2.6.so, I think I added the directory that lib is found in to my path (its found in "/data/data/com.googlecode.pythonforandroid/files/python/lib/" I think, need to double check that one), so thats what ive done that made this 'click' so to speak into popping out the python interpretor.
Also I found this file...MSM8960_lpm.rc but I forgot from where it came. It looks as if it contains some global variables that get set during boot, am I right?
This is the top part of it...
"""
on early-init
start ueventd
on init
sysclktz 0
loglevel 3
# setup the global environment
export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
export LD_LIBRARY_PATH /vendor/lib:/system/lib
export ANDROID_BOOTLOGO 1
export ANDROID_ROOT /system
export ANDROID_ASSETS /system/app
export ANDROID_DATA /data
export EXTERNAL_STORAGE /mnt/sdcard
export EXTERNAL_STORAGE2 /mnt/sdcard/external_sd
export USBHOST_STORAGE /mnt/sdcard/usbStorage
export ASEC_MOUNTPOINT /mnt/asec
export LOOP_MOUNTPOINT /mnt/obb
export BOOTCLASSPATH /system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/core-junit.jar
"""
So I am thinking that if I set the paths to my Python exec and libs here, as well as Paths for Lua, Perl, JRuby, Python 2.7, Etc, etc then I would have an assortment of scripting languages to launch into ffrom ADB, am I right? This would help me and others write scripts for ADB in many languages to do repetitive grunt work from scripts.
Any advice would be great as it works but its like python is injured, "import os" didnt work ;( but "import sys" did
It would also be nice if these same vriables could be set for Terminal Emulator, Terminal IDE, and the like, I know SSH is in the works with T. IDE and that one has telnet though I havent figured that out yet.
What should I do? This seems like an OS related issue but if the interpreter is there and compiled for arm and the libs aswell why would this not work?
python -v output
this is the "python -v" output to show what's happening, maybe it'll help....
"""
[email protected]:/ # python -v
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
'import site' failed; traceback:
ImportError: No module named site
Python 2.6.2 (r262:71600, Mar 20 2011, 16:54:21)
[GCC 4.4.3] on linux-armv7l
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import os
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named os
>>>
# clear __builtin__._
# clear sys.path
# clear sys.argv
# clear sys.ps1
# clear sys.ps2
# clear sys.exitfunc
# clear sys.exc_type
# clear sys.exc_value
# clear sys.exc_traceback
# clear sys.last_type
# clear sys.last_value
# clear sys.last_traceback
# clear sys.path_hooks
# clear sys.path_importer_cache
# clear sys.meta_path
# clear sys.flags
# clear sys.float_info
# restore sys.stdin
# restore sys.stdout
# restore sys.stderr
# cleanup __main__
# cleanup[1] zipimport
# cleanup[1] signal
# cleanup[1] exceptions
# cleanup[1] _warnings
# cleanup sys
# cleanup __builtin__
# cleanup ints: 3 unfreed ints
# cleanup floats
[email protected]:/ #
"""
That snippet you posted is from the init.rc inside the boot.img...so yes, it has all sorts of initialization code
CNexus said:
That snippet you posted is from the init.rc inside the boot.img...so yes, it has all sorts of initialization code
Click to expand...
Click to collapse
Ok, so I'll so some reading on setting $PYTHONHOME variable and others, I need to learn how that all works anyways. Most if not all of what I find documents how to set the variables for Windows, Mac, or Linux and not for Android. I will do my best to use that knowledge to fit this situation. I also need to dive around the file system a bit more and find all those libs and try to get the paths set for those to work with ADB and not just SL4A.
If I can do that maybe some more Linux programs/commands can be moved into Android's system, I know alot of the GUI apps for Linux have dependencies for python and gtk and qt, those modules might be portable to Android if they haven't already done so. Not to mention the other interpreters like Perl. To be perfectly honest what I want to do is port over Kali's toolset (at least the cmd line tools) over to android to they can be run from a terminal emulator or adb its self. Thats what I want to do with it, then wrap it all up into a ROM and build it. I know they have already compiled most of Kali's and BackTrack's programs on ARM so I was thinking of pulling those apps from there after an upgrade and then moving them into Androids system e.g /system/bin : /system/lib : /etc/* and so on, if the file systems are too different I suppose I can add directories and make a PATH for them or add them to $PATH once I learn how all that works.
Any good documentation on related issued anyone might be able to link to would be great, I'll be droppin by every so often while I'm grinding through google, thanks in advance for any help and thank you for your time, a bit of a read I suppose.
Environment variables like that would need to be set inside the boot.img, so if you want to unpack it and see exactly how things are defined and what other files are there (good exercise all around IMO), grab my tools from over here and unpack it for yourself and take a look:
cool tools
CNexus said:
Environment variables like that would need to be set inside the boot.img, so if you want to unpack it and see exactly how things are defined and what other files are there (good exercise all around IMO), grab my tools from over here and unpack it for yourself and take a look:
Click to expand...
Click to collapse
Well I downloaded twrp 2.3.1.0-d2spr and I used the split_boot tool in the package and got a little tree of files including the init.rc and the other msm one, they seem very similar if not identical (?), weird.
I just have a quick question, do I need to repack all this at a certain size? In other words, if I make any changes in the ramdisk image will it refuse to boot? I browsed over some sites and read somewhere that if I changed the kernal image it would fail a hash check and that the type of hashing ( I use bubble bags, but that's for another forum). How much attention do I need to pay to the size of these files I may alter before I repack and flash to the device?
Edge-Case said:
Well I downloaded twrp 2.3.1.0-d2spr and I used the split_boot tool in the package and got a little tree of files including the init.rc and the other msm one, they seem very similar if not identical (?), weird.
I just have a quick question, do I need to repack all this at a certain size? In other words, if I make any changes in the ramdisk image will it refuse to boot? I browsed over some sites and read somewhere that if I changed the kernal image it would fail a hash check and that the type of hashing ( I use bubble bags, but that's for another forum). How much attention do I need to pay to the size of these files I may alter before I repack and flash to the device?
Click to expand...
Click to collapse
Yes, actually. You need to repack at certain offsets/addresses or the device will be unable to read it properly
Run the boot_info script on your .img file and it will give you everything you need to know to repack the boot.img correctly
First you gotta repack the ramdisk (repack_ramdisk [optional out file])
Then after you do that, you can use the mkbootimg binary along with the info from my boot_info script to make a new boot.img with the right offsets
I've done a ton of boot.img splitting, so here's what it should look like (I forget the cmdline parameter)
Code:
mkbootimg --kernel KERNEL --ramdisk RAMDISK --base 0x80200000 --oversize 2048 --cmdline 'android.I.don't.remember.this.one' --ramdiskaddr 0x81500000 -o new_boot.img
Sent from my S3 on Sense 5 (you jelly?)
CNexus said:
Yes, actually. You need to repack at certain offsets/addresses or the device will be unable to read it properly
Run the boot_info script on your .img file and it will give you everything you need to know to repack the boot.img correctly
First you gotta repack the ramdisk (repack_ramdisk [optional out file])
Then after you do that, you can use the mkbootimg binary along with the info from my boot_info script to make a new boot.img with the right offsets
I've done a ton of boot.img splitting, so here's what it should look like (I forget the cmdline parameter)
Code:
mkbootimg --kernel KERNEL --ramdisk RAMDISK --base 0x80200000 --oversize 2048 --cmdline 'android.I.don't.remember.this.one' --ramdiskaddr 0x81500000 -o new_boot.img
Sent from my S3 on Sense 5 (you jelly?)
Click to expand...
Click to collapse
Thanks,
I actually just got the CWM ROM manager, I updated my CWM and am backing up my rom now, its pretty much stock lacking updates cuz of root I think, I eventually wanna get over to CM or some other rom but CM seems to be supported pretty well.
1) So the backup just finished a second ago, can I pull a boot image out of that? :EDIT: Check. I saw it in the recovered folder.
2) I'll use the boot info on that img when I get it.
3) I guess this is all for testing the variables and getting interpreters to run from adb and T.E. after that I need to install CM 10 to get some blobs, thats all thats hanging me up from modifying the source to build my own version, this is great exercise as it will need to be done when building this "Cyano-Kali" or whatever, I was also thinking "Kali0id" as in Kalioid and Kali zero i.d.
ok well I did some messing around and I got this lill chroot setup working from adb which is kool, I just took a no gui kali.img and a script I found to chroot into it ( Maybe Google "Weaponizing Android"), it needs a lil investigating though I get a couple errors, it looks like it was modified from a chroot into ubuntu (arm).
I put the script into /system/xbin/ and then made it executable (that seems to be the only place I could chmod), I looked at the sript at it points to a coded directory for the kali.img which is something like "/storage/sdcard0/kali/kail.img". This puts the script in a location that is already in the environ variable and you can call it from any cwd by typing "kali".
Note: Interesting tip (may be trivial to the pros), typing "bash" gives me a colorful interface and the bash interpreter, this is good for a first command when entering the terminal or adb because then you can modify the bash rc file found in "/system/etc/bash/" (I think, I'll double check later.*FIXED*).
So, I think I might be able to mod those variables there to include PYTHONPATH, PYTHONHOME, etc...
Then when I launch bash i should be able to launch python and whatever else. (*Check*, it works but you must first "bash" and then "python" to allow the bashrc file to get ran and add PYTHONHOME and PYTHONPATH to the enviroment)
I think the first shell that you get put into is shell and not bash but maybe I'm wrong.
*side note, If you want to su into bash its best ime to do that first, then bash, otherwise when you su while in bash you loose the color, idk why.
heres my results so far...
Code:
[email protected]:~$ adb devices
List of devices attached
xxxxxxxxxx device
[email protected]:~$ adb shell
[email protected]:/ $ su
[email protected]:/ # bash
void endpwent()(3) is not implemented on Android
localhost / # kali
ioctl LOOP_SET_FD failed: Device or resource busy
mount: Device or resource busy
net.ipv4.ip_forward = 1
[[email protected] ~$ cd .. && ls
bin dev home lost+found mnt proc run selinux sys usr
boot etc lib media opt root sbin srv tmp var
[[email protected] /$ which macchanger
/usr/bin/macchanger
[[email protected] /$ which ophcrack
/usr/bin/ophcrack
[[email protected] /$ which reaver
/usr/bin/reaver
[[email protected] /$ which aircrack-ng
/usr/bin/aircrack-ng
[[email protected] /$ python --version
Python 2.7.3
[[email protected] /$ perl --version
This is perl 5, version 14, subversion 2 (v5.14.2) built for arm-linux-gnueabi-thread-multi-64int
(with 80 registered patches, see perl -V for more detail)
Copyright 1987-2011, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
[[email protected] /$ bash --version
GNU bash, version 4.2.37(1)-release (arm-unknown-linux-gnueabi)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[[email protected] /$ python
Python 2.7.3 (default, Jan 2 2013, 22:35:13)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import sys
>>>
[[email protected] /$ exit
Shutting down Kali ARM
failed: Device or resource busy
losetup: /dev/block/loop255: Device or resource busy
localhost / # exit
1|[email protected]:/ # ^D
1|[email protected]:/ $ ^D
[email protected]:~$
Does anybody know how to mount an external sdcard from the command line on the Debian version of Linux on Android?
Is that even possible, like driver wise and what not?
Nice!
To mount it, first you would need it's device name or UUID..
Sent from my S3 on Sense 5 (you jelly?)
Success!
Alright! I got Python working from the terminal emulator!
I ended up copying the files that got installed by the original installer into my system/ lib, xbin, and, bin directories I just kinda put stuff here or there and then I just got one error about platform independent libraries instead of both dependent and independent. I'm alil add about things sometimes. Then about ten minutes ago while chilling on the patio the syntax for the PythonHome and path variables became clear to me. So i changed it to export and wrapped the paths in quotes and figured out the prefix : exec_prefex thing.
Now python works!!!!!!! ill run it on adb tomorrow and show the results as well as exactly how to get it working after i figure out exactly what i did right. It was probably the last thing.
Edge-Case said:
Alright! I got Python working from the terminal emulator!
I ended up copying the files that got installed by the original installer into my system/ lib, xbin, and, bin directories I just kinda put stuff here or there and then I just got one error about platform independent libraries instead of both dependent and independent. I'm alil add about things sometimes. Then about ten minutes ago while chilling on the patio the syntax for the PythonHome and path variables became clear to me. So i changed it to export and wrapped the paths in quotes and figured out the prefix : exec_prefex thing.
Now python works!!!!!!! ill run it on adb tomorrow and show the results as well as exactly how to get it working after i figure out exactly what i did right. It was probably the last thing.
Click to expand...
Click to collapse
Nice
Sent from my S3 on Sense 5 (you jelly?)
Solution !
Ok I got everything cleaned up a bit, lets see whats going on here...
So hopefully bash is preinstalled for everyone, I just found it, the only changes I made in the past week are installing...
1) CyanogenMod, I believe you will need to already be rooted, have busybox, and a custom recovery to get this far. If you can get CyanogenMod working then you'll probably be able to replicate this, mayeb even with just root and busybox on a stock sprint rom, idk.
2) SL4A along with Python 2.6, Perl, and JRuby. (I hope normal ruby programs can be ran will JRuby, if not I'll either mod the programs or port ruby to android or look for another port.
3) Terminal IDE. This could have been a source of bash if it wasn't native to android or the Terminal Emulator/busybox.
Once you have The above, at least python 2.6 with SL4A, Terminal Emulator, Busybox, and root.
You can (the file system maybe different for different phones but since we are in a specific place of this forum I'll stick with what I found on my phone specifically)
Use a root browser and find a way to remount your file system to read/write or r/w or rw mode so you can write to /system directory. It is located in the / directory of the entire system, not just the sdcard0 partition.
You can open a terminal and type "set" to get a closer look at whats happening here on Android. We are mainly interested in the Environment Variables.
What I did was copy
"/storage/sdcard0/com.googlecode.pythonforandroid/extras/python" ----> "/system/etc/python" ##THIS IS A DIRECTORY
"/data/data/com.googlecode.pythonforandroid/files/python/lib/python2.6" ----> "/system/lib/python2.6" ##THIS IS A DIRECTORY
"/data/data/com.googlecode.pythonforandroid/files/python/bin/python" -> "/system/xbin/python ##THIS IS A FILE, IT IS AN EXECUTABLE!
"/"/data/data/com.googlecode.pythonforandroid/files/python/lib/" ----> "/system/lib/python2.6/" ##WE WANT ALL THE "*.so" FILES NEXT TO THE ORIGIONAL "*/PYTHON2.6/" DIR IN THE "DATA/DATA/" SIDE OF THE TREE TO BE COPIED TO THE SYSTEM SIDE AND INTO THE "/system/lib/python2.6/" DIR NEXT TO THE "/system/lib/python2.6/lib-dynload/" DIR
We want our "/system/lib/python2.6" directory to contain the following :
"/lib-dynload" is a dir; and all the .so files from earlier there are about 8 with a fresh install of python and no modules, some of you may already know how to incorporate modules from this point, but I still need to do some experimenting.
---------------------------------------------------------
OK
if you still following then your gonna wanna do the following
go to "/system/etc/bash" and open the bashrc file, we need to add PYTHONPATH and PYTHONHOME to it, this is how I set it up....
About half way down it will read
Code:
"""
# set some environment variables
HOME=/sdcard
TERM=linux (maybe change this to "Administrator" but that may break something)
"""
# Our additions follow:
export PYTHONHOME="/system/etc/python:/system/xbin/python"
export PYTHONPATH="/system/etc/python:/system/lib/python2.6/lib-dynload:/system/lib/python2.6"
Ok, now if you go to your teminal emulator or ADB shell you can type:
bash [press enter]
python [press enter]
and check out the results
or
su [enter]
bash [enter]
python [enter]
and see what happens
whats happening is that your PYTHONHOME and PYTHONPATH variables are being set when you enter bash, and since they are exported from the bashrc file they get carried over to any child activities that may spawn, such as "python". Correct me if I am wrong.
I may have forgot some little file I put somewere a few days ago or something so let me know if it doesn't work for you i'll do my best to help you get it working on your phone to,
other then finding a rc file for the shell that you start with when you launch the terminal or any other process maybe even, I may need to do what CNex suggested and complete the change in a boot.img to flash to my phone. that should result in the variables being passed to all activities.
Peace yo
Any questions I'll drop around if this dies of from here, well live and let die I suppose.
Just a screen shot
Just a screen shot.
I found the "mkshrc" file in "/system/etc" today so I added the PATHs to that file and now when teminal emulator starts it has access to python's libs. ("/system/etc/mkshrc" should be the location)
I've run into two problems, the first I can live with, the second is only more reason to port Kali's toolset into android.
1) I can't yet access the pydocs for interactive help, for example...
Code:
[email protected]:~$ adb shell
[email protected]:/ $ python
dlopen libpython2.6.so
Python 2.6.2 (r262:71600, Mar 20 2011, 16:54:21)
[GCC 4.4.3] on linux-armv7l
Type "help", "copyright", "credits" or "license" for more information.
>>> import android
>>> help (android)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/site.py", line 431, in __call__
File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/pydoc.py", line 1720, in __call__
File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/pydoc.py", line 1766, in help
File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/pydoc.py", line 1508, in doc
File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/pydoc.py", line 1314, in pager
File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/pydoc.py", line 1338, in getpager
File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/tempfile.py", line 286, in mkstemp
File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/tempfile.py", line 254, in gettempdir
File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/tempfile.py", line 201, in _get_default_tempdir
IOError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']
>>>
And
2) When I chroot into Kali.img the PYTHONPATH and PYTHONHOME variables get carried over and interfear with python within Kali. ????
Work around: is just modifing "bashrc" then when you want python or other inerpreters launch bash first and call kali from shell.
Solution: is porting Kali's Toolkit and more Linux programs and commands into Android. Then release as rom or give instructions on how to set up.
No Really, I think I got it figured out this time.
If your running python 2.6 via Py4a then youll use the first script to access python from the command line or over adb, you'll need su to but it in /system/bin or /system/xbin and to use this command to write to the system partition "mount -wo remount systemfs /system" when your done use "mount -ro remount systemfs /system" (with out the quotes of course).
Note: adbd can only be ran as root, so this method will only work as root. Also I had some trouble disconnecting from adb as "exit", it hung till I unplugged the phone from usb. But, still I got to run scripts python that utilize the androids api with-out having to directly open sl4a and then the python interpreter from there.
Note2: Maybe one who was slick enough could get the source for sl4a and pick out the server and facade code, then make a little dex to be ran from the command-line instead of starting the server via "am" and instead of using sockets, maybe ashmem to share the JSON results that get sent back to python.
This is the script for 2.6 :​
Code:
#!/system/bin/sh
am start -a com.googlecode.android_scripting.action.LAUNCH_SERVER \
-n com.googlecode.android_scripting/.activity.ScriptingLayerServiceLauncher \
--ei com.googlecode.android_scripting.extra.USE_SERVICE_PORT 54326
export AP_PORT=54326
export AP_HOST=127.0.0.1
adbd &
export EXTERNAL_STORAGE=/mnt/sdcard/com.googlecode.pythonforandroid
export PY4A=/data/data/com.googlecode.pythonforandroid/files/python
export PY4A_EXTRAS=$EXTERNAL_STORAGE/extras
PYTHONPATH=$EXTERNAL_STORAGE/extras/python
PYTHONPATH=${PYTHONPATH}:$PY4A/lib/python2.6/lib-dynload
export PYTHONPATH
export TEMP=$EXTERNAL_STORAGE/extras/python/tmp
export HOME=/sdcard
export PYTHON_EGG_CACHE=$TEMP
export PYTHONHOME=$PY4A
export LD_LIBRARY_PATH=$PY4A/lib
$PYTHONHOME/bin/python "[email protected]"
This one is for 3.2 :​
Code:
#!/system/bin/sh
am start -a com.googlecode.android_scripting.action.LAUNCH_SERVER \
-n com.googlecode.android_scripting/.activity.ScriptingLayerServiceLauncher \
--ei com.googlecode.android_scripting.extra.USE_SERVICE_PORT 54332
export AP_PORT=54332
export AP_HOST=127.0.0.1
adbd &
export EXTERNAL_STORAGE=/mnt/sdcard/com.googlecode.python3forandroid
export PY34A=/data/data/com.googlecode.python3forandroid/files/python3
export PY4A_EXTRAS=$EXTERNAL_STORAGE/extras
PYTHONPATH=$EXTERNAL_STORAGE/extras/python3
PYTHONPATH=${PYTHONPATH}:$PY34A/lib/python3.2/lib-dynload
export PYTHONPATH
export TEMP=$EXTERNAL_STORAGE/extras/python3/tmp
export HOME=/sdcard
export PYTHON_EGG_CACHE=$TEMP
export PYTHONHOME=$PY34A
export LD_LIBRARY_PATH=$PY34A/lib
$PYTHONHOME/bin/python3 "[email protected]"
Explanation:​-First, the server which handles calls to Android's APIs gets starts by it's activity with am and port is set.
-Second, AP_PORT and AP_HOST get exported so that android.py will have its parameters set to interact with the "facade"
-Third, adbd gets started in the background (I cant give a full explanation, but I found the RPC mechanism between the python interpreter and the sl4a server when android.py is imported and droid.* is attempted)
-Fourth, Python's environment variables get set, doing it this way helps to avoid copying the whole python installation to /system (as I did in the past ), just put one of these scripts in /system/bin or /system/xbin and name it "python" then chmod the script "chmod 755 python" you will be able to call the interpreter and put the shabang in your python scripts (ie "#!/system/bin/python").
-Fifth, launch the interpreter.
Here is a short session over adb:​
Code:
[email protected]:/ # python
dlopen libpython2.6.so
Python 2.6.2 (r262:71600, Mar 20 2011, 16:54:21)
[GCC 4.4.3] on linux-armv7l
Type "help", "copyright", "credits" or "license" for more information.
>>> import android
>>> droid = android.Android()
>>> droid.makeToast("Hello!")
Result(id=0, result=None, error=None)
>>> droid.getLastKnownLocation()
Result(id=1, result={u'passive': {u'bearing': 0, u'altitude': 0, u'time': 1384816643565L, u'longitude': -67.551754299999999,
u'provider': u'network', u'latitude': 96.0520909, u'speed': 0, u'accuracy': 3533}, u'network': {u'bearing': 0, u'altitude': 0, u'time':
1384816643565L, u'longitude': -67.551754299999999, u'provider': u'network', u'latitude': 96.0520909, u'speed': 0, u'accuracy':
3533}, u'gps': None}, error=None)
>>> exit()
And some credit to others:
http://code.google.com/p/python-for...sh?r=997929b1bbaa53cdf76acfff419ec13c13f869b7
http://stackoverflow.com/questions/10839879/python-sl4a-development
Those are links to where I got some info from to help put this together. The adbd thing was just trying "adb forward tcp:xxxx tcp:xxxx" but that didn't work, so I tried adbd forward tcp:xxxx tcp:xxxx and it looked like it hung there, so I ctl^ c and then just adbd and it hung there again, but when used the "&" to background it and then went to python to try android.py, it worked:good:
And for a lot of fun, go here:
http://code.google.com/p/android-scripting/wiki/ApiReference
-or here-
http://www.mithril.com.au/android/doc/index.html

[Q] How to use adb to replace music dir

The music files on my phone are all in subdirectories of /sdcard/Music . If I wanted to replace the existing songs with new files from my pc, would I use the following commands:
adb shell rm -rf /sdcard/Music
adb shell mkdir /sdcard/Music
adb push c:\music /sdcard/Music
If not, what should I use? (To answer the obvious 'why don't you try it' question, because I'm nervous about rm and want to see if there's something better.)
Is there an adb command that would cause the google music player to rescan for songs? If not, I'd use one of the rescan apps in the playstore or reboot.
foosion said:
The music files on my phone are all in subdirectories of /sdcard/Music . If I wanted to replace the existing songs with new files from my pc, would I use the following commands:
adb shell rm -rf /sdcard/Music
adb shell mkdir /sdcard/Music
adb push c:\music /sdcard/Music
If not, what should I use? (To answer the obvious 'why don't you try it' question, because I'm nervous about rm and want to see if there's something better.)
Is there an adb command that would cause the google music player to rescan for songs? If not, I'd use one of the rescan apps in the playstore or reboot.
Click to expand...
Click to collapse
yes, those commands are correct.
to rescan your library, a app would be the easiest way and you don't require a pc to trigger the media scan.
beekay201 said:
to rescan your library, a app would be the easiest way and you don't require a pc to trigger the media scan.
Click to expand...
Click to collapse
Is there any way to trigger a rescan using adb?
FWIW, I'm using python on a pc to script the adb commands, so I'd like to do everything in one step if possible.
i heard somewhere for this: adb shell "am broadcast -a -d "
so try this:
adb -d shell "am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///mnt/sdcard/Music/"

Disable wifi direct?

Is there a way to disable the wifi direct broadcast while leaving normal wifi/bluetooth operational?
Alternatively, is there a way to switch the channel that wifi-direct is broadcast on?
Currently, it defaults to the same channel that my router is broadcasting on. This is annoying for a number of reasons:
1) My router's signal overpowers my remote and it often takes fiddling to make it reconnect. I switched to a bluetooth solution.
2) Aside from being useless, the wifi-direct signal could potentially be causing wifi interference with my other devices.
3) I live in an apartment complex so wifi overcrowding/noise is already a problem that doesn't need adding to. I'm not using the signal - I may as well turn it off.
I have a rooted fire TV 2 and I'm at least somewhat familiar with adb-shell. I assume there's some config file that I can pull, edit, and push - I just have no idea where it's located.
Been digging into this as well. It keeps causing other devices to loose connection.
@ExaltedVanguard
Fire TV 2 Gen use Wi-Fi Direct for communicate with own remote
Search https://forum.xda-developers.com/fire-tv/general/total-mod-playing-fire-complete-t3629990 (OP and other posts)
Thanks, I found the information I needed in that post. I've condensed the relevant instructions here:
Connect to rooted FireTV via adb
Pull the file /system/etc/permissions/android.hardware.wifi.direct.xml to your computer so you can edit it.
Code:
adb pull /system/etc/permissions/android.hardware.wifi.direct.xml
Comment out the <permissions> group (all 3 lines) by putting a # at the start of each line.
Code:
#<permissions>
# <feature name="android.hardware.wifi.direct" />
#</permissions>
Push the file back to your firetv (somewhere you have write permissions)
Code:
adb push /local/path/android.hardware.wifi.direct.xml /sdcard/android.hardware.wifi.direct.xml
open up adb shell and use the following commands (requires root, you may be prompted to grant permissions on the firetv itself):
Code:
su
mount -o rw,remount /system
cp /sdcard/android.hardware.wifi.direct.xml /system/etc/permissions/android.hardware.wifi.direct.xml
chmod 644 /system/etc/permissions/android.hardware.wifi.direct.xml
chown root:root /system/etc/permissions/android.hardware.wifi.direct.xml
What this does is switch to root, remount the /system drive with read/write (rather than read-only), overwrite the old file with our edited one, and correct the read/write access of the file itself.
Reboot. Watching through wifi analyzer, wifi direct will turn on very briefly during boot, then be disabled.
I have 2 fire sticks with same issues, both are on 6.0.0.2 so no way to be rooted right now. Any other ideas to disable wifi-direct?
It worked!
ExaltedVanguard said:
Thanks, I found the information I needed in that post. I've condensed the relevant instructions here:
Connect to rooted FireTV via adb
Pull the file /system/etc/permissions/android.hardware.wifi.direct.xml to your computer so you can edit it.
Code:
adb pull /system/etc/permissions/android.hardware.wifi.direct.xml
Comment out the <permissions> group (all 3 lines) by putting a # at the start of each line.
Code:
#<permissions>
# <feature name="android.hardware.wifi.direct" />
#</permissions>
Push the file back to your firetv (somewhere you have write permissions)
Code:
adb push /local/path/android.hardware.wifi.direct.xml /sdcard/android.hardware.wifi.direct.xml
open up adb shell and use the following commands (requires root, you may be prompted to grant permissions on the firetv itself):
Code:
su
mount -o rw,remount /system
cp /sdcard/android.hardware.wifi.direct.xml /system/etc/permissions/android.hardware.wifi.direct.xml
chmod 644 /system/etc/permissions/android.hardware.wifi.direct.xml
chown root:root /system/etc/permissions/android.hardware.wifi.direct.xml
What this does is switch to root, remount the /system drive with read/write (rather than read-only), overwrite the old file with our edited one, and correct the read/write access of the file itself.
Reboot. Watching through wifi analyzer, wifi direct will turn on very briefly during boot, then be disabled.
Click to expand...
Click to collapse
Many thanks for the above guide - I joined XDA so I could pass on my gratitude, worked like a charm
Rich LD said:
Many thanks for the above guide - I joined XDA so I could pass on my gratitude, worked like a charm
Click to expand...
Click to collapse
Thanks so much guys for this solution and running through it.
I'm about to attempt the root method on the Fire TV 2 stick that requires shorting pins. Before I do I thought I'd ask and see what the other effects of doing this were. Does your remote still work? Bluetooth was unaffected right? So I assume that even if the wifi remotes stopped working I could get a Bluetooth one and use that. After having done this about a month ago any other unintended consequences?
Thanks
Disable Amazon Fire TV stick Direct WiFi instructions for not a programmer.?
ExaltedVanguard said:
Thanks, I found the information I needed in that post. I've condensed the relevant instructions here:
Connect to rooted FireTV via adb
Pull the file /system/etc/permissions/android.hardware.wifi.direct.xml to your computer so you can edit it.
Code:
adb pull /system/etc/permissions/android.hardware.wifi.direct.xml
Comment out the <permissions> group (all 3 lines) by putting a # at the start of each line.
Code:
#<permissions>
# <feature name="android.hardware.wifi.direct" />
#</permissions>
Push the file back to your firetv (somewhere you have write permissions)
Code:
adb push /local/path/android.hardware.wifi.direct.xml /sdcard/android.hardware.wifi.direct.xml
open up adb shell and use the following commands (requires root, you may be prompted to grant permissions on the firetv itself):
Code:
su
mount -o rw,remount /system
cp /sdcard/android.hardware.wifi.direct.xml /system/etc/permissions/android.hardware.wifi.direct.xml
chmod 644 /system/etc/permissions/android.hardware.wifi.direct.xml
chown root:root /system/etc/permissions/android.hardware.wifi.direct.xml
What this does is switch to root, remount the /system drive with read/write (rather than read-only), overwrite the old file with our edited one, and correct the read/write access of the file itself.
Reboot. Watching through wifi analyzer, wifi direct will turn on very briefly during boot, then be disabled.
Click to expand...
Click to collapse
I've been dying to disable the Direct WiFi being broadcast from my Amazon Tv fire sticks! So mad that there isn't a setting to turn it off! I'm not a programmer...wondering if you could please explain what a rooted FireTV stick is? Thanks!
I have an Amazon fire stick and it shows up as an available wifi connection. It shows DIRECT-7z-FireTV_4ba2. And it says to enter password but I don't know what it is. Does anyone know how to sign into this?
Cathyapn said:
I have an Amazon fire stick and it shows up as an available wifi connection. It shows DIRECT-7z-FireTV_4ba2. And it says to enter password but I don't know what it is. Does anyone know how to sign into this?
Click to expand...
Click to collapse
No idea. it is for a WiFi direct remote. What are you trying to do?
Cathyapn said:
I have an Amazon fire stick and it shows up as an available wifi connection. It shows DIRECT-7z-FireTV_4ba2. And it says to enter password but I don't know what it is. Does anyone know how to sign into this?
Click to expand...
Click to collapse
That wifi connection is for the remote. It's not meant to be signed in.
lol
ExaltedVanguard said:
Thanks, I found the information I needed in that post. I've condensed the relevant instructions here:
Connect to rooted FireTV via adb
Pull the file /system/etc/permissions/android.hardware.wifi.direct.xml to your computer so you can edit it.
Code:
adb pull /system/etc/permissions/android.hardware.wifi.direct.xml
Comment out the <permissions> group (all 3 lines) by putting a # at the start of each line.
Code:
#<permissions>
# <feature name="android.hardware.wifi.direct" />
#</permissions>
Push the file back to your firetv (somewhere you have write permissions)
Code:
adb push /local/path/android.hardware.wifi.direct.xml /sdcard/android.hardware.wifi.direct.xml
open up adb shell and use the following commands (requires root, you may be prompted to grant permissions on the firetv itself):
Code:
su
mount -o rw,remount /system
cp /sdcard/android.hardware.wifi.direct.xml /system/etc/permissions/android.hardware.wifi.direct.xml
chmod 644 /system/etc/permissions/android.hardware.wifi.direct.xml
chown root:root /system/etc/permissions/android.hardware.wifi.direct.xml
What this does is switch to root, remount the /system drive with read/write (rather than read-only), overwrite the old file with our edited one, and correct the read/write access of the file itself.
Reboot. Watching through wifi analyzer, wifi direct will turn on very briefly during boot, then be disabled.
Click to expand...
Click to collapse
What are the consequences of this? Will the remote will work? If yes, what will stop working?
ExaltedVanguard said:
Thanks, I found the information I needed in that post. I've condensed the relevant instructions here:
Connect to rooted FireTV via adb
Pull the file /system/etc/permissions/android.hardware.wifi.direct.xml to your computer so you can edit it.
Code:
adb pull /system/etc/permissions/android.hardware.wifi.direct.xml
Comment out the <permissions> group (all 3 lines) by putting a # at the start of each line.
Code:
#<permissions>
# <feature name="android.hardware.wifi.direct" />
#</permissions>
Push the file back to your firetv (somewhere you have write permissions)
Code:
adb push /local/path/android.hardware.wifi.direct.xml /sdcard/android.hardware.wifi.direct.xml
open up adb shell and use the following commands (requires root, you may be prompted to grant permissions on the firetv itself):
Code:
su
mount -o rw,remount /system
cp /sdcard/android.hardware.wifi.direct.xml /system/etc/permissions/android.hardware.wifi.direct.xml
chmod 644 /system/etc/permissions/android.hardware.wifi.direct.xml
chown root:root /system/etc/permissions/android.hardware.wifi.direct.xml
What this does is switch to root, remount the /system drive with read/write (rather than read-only), overwrite the old file with our edited one, and correct the read/write access of the file itself.
Reboot. Watching through wifi analyzer, wifi direct will turn on very briefly during boot, then be disabled.
Click to expand...
Click to collapse
I followed the above instructions and executed them on rooted firestick (tank). After reboot, it couldn't connect to any wifi network. In fact, under settings>network section, there were no wifi related options. There it was just showing the text as wired ethernet (disconnected). And after I revert to the original xml file, everything returned to normal.
Please let me know, how to disable only the wifi direct and keep the wifi feature as it is.

Categories

Resources