Hi guys, I made a little screen-cast of the routine used to root an android emulator.
Here's the video version, but I wrote the text version under it too.
Prerequisities
su binary : http://d-h.st/qZ2
busybox binary : http://d-h.st/IIv
Superuser apk : http://d-h.st/Et5
(These instructions are assuming you're on ubuntu or an other debian-based linux distro, but it should be pretty easy to adapt to batch if you're on windows.)
Instructions
1) First, create a new AVD in Eclipse or in terminal
Here's the manpage for the emulator :
Code:
Android Emulator usage: emulator [options] [-qemu args]
options:
-sysdir <dir> search for system disk images in <dir>
-system <file> read initial system image from <file>
-datadir <dir> write user data into <dir>
-kernel <file> use specific emulated kernel
-ramdisk <file> ramdisk image (default <system>/ramdisk.img
-image <file> obsolete, use -system <file> instead
-initdata <file> same as '-init-data <file>'
-data <file> data image (default <datadir>/userdata-qemu.img
-partition-size <size> system/data partition size in MBs
-cache <file> cache partition image (default is temporary file)
-cache-size <size> cache partition size in MBs
-no-cache disable the cache partition
-nocache same as -no-cache
-sdcard <file> SD card image (default <system>/sdcard.img
-snapstorage <file> file that contains all state snapshots (default <datadir>/snapshots.img)
-no-snapstorage do not mount a snapshot storage file (this disables all snapshot functionality)
-snapshot <name> name of snapshot within storage file for auto-start and auto-save (default 'default-boot')
-no-snapshot perform a full boot and do not do not auto-save, but qemu vmload and vmsave operate on snapstorage
-no-snapshot-save do not auto-save to snapshot on exit: abandon changed state
-no-snapshot-load do not auto-start from snapshot: perform a full boot
-snapshot-list show a list of available snapshots
-no-snapshot-update-time do not do try to correct snapshot time on restore
-wipe-data reset the user data image (copy it from initdata)
-avd <name> use a specific android virtual device
-skindir <dir> search skins in <dir> (default <system>/skins)
-skin <name> select a given skin
-no-skin don't use any emulator skin
-noskin same as -no-skin
-dynamic-skin dynamically construct a skin of given size, requires -skin WxH option
-memory <size> physical RAM size in MBs
-netspeed <speed> maximum network download/upload speeds
-netdelay <delay> network latency emulation
-netfast disable network shaping
-trace <name> enable code profiling (F9 to start)
-show-kernel display kernel messages
-shell enable root shell on current terminal
-no-jni disable JNI checks in the Dalvik runtime
-nojni same as -no-jni
-logcat <tags> enable logcat output with given tags
-no-audio disable audio support
-noaudio same as -no-audio
-audio <backend> use specific audio backend
-raw-keys disable Unicode keyboard reverse-mapping
-radio <device> redirect radio modem interface to character device
-port <port> TCP port that will be used for the console
-ports <consoleport>,<adbport> TCP ports used for the console and adb bridge
-onion <image> use overlay PNG image over screen
-onion-alpha <%age> specify onion-skin translucency
-onion-rotation 0|1|2|3 specify onion-skin rotation
-scale <scale> scale emulator window
-dpi-device <dpi> specify device's resolution in dpi (default 165)
-http-proxy <proxy> make TCP connections through a HTTP/HTTPS proxy
-timezone <timezone> use this timezone instead of the host's default
-dns-server <servers> use this DNS server(s) in the emulated system
-cpu-delay <cpudelay> throttle CPU emulation
-no-boot-anim disable animation for faster boot
-no-window disable graphical window display
-version display emulator version number
-report-console <socket> report console port to remote socket
-gps <device> redirect NMEA GPS to character device
-keyset <name> specify keyset file name
-shell-serial <device> specific character device for root shell
-tcpdump <file> capture network packets to file
-bootchart <timeout> enable bootcharting
-charmap <file> use specific key character map
-prop <name>=<value> set system property on boot
-shared-net-id <number> join the shared network, using IP address 10.1.2.<number>
-nand-limits <nlimits> enforce NAND/Flash read/write thresholds
-memcheck <flags> enable memory access checking
-gpu <mode> set hardware OpenGLES emulation mode
-camera-back <mode> set emulation mode for a camera facing back
-camera-front <mode> set emulation mode for a camera facing front
-webcam-list lists web cameras available for emulation
-screen <mode> set emulated screen mode
-force-32bit always use 32-bit emulator
-qemu args... pass arguments to qemu
-qemu -h display qemu help
-verbose same as '-debug-init'
-debug <tags> enable/disable debug messages
-debug-<tag> enable specific debug messages
-debug-no-<tag> disable specific debug messages
-help print this help
-help-<option> print option-specific help
-help-disk-images about disk images
-help-keys supported key bindings
-help-debug-tags debug tags for -debug <tags>
-help-char-devices character <device> specification
-help-environment environment variables
-help-keyset-file key bindings configuration file
-help-virtual-device virtual device management
-help-sdk-images about disk images when using the SDK
-help-build-images about disk images when building Android
-help-all prints all help content
2) Then, open a terminal (ctrl+alt+T) and type the following command in order to start you freshly created emulator with a bigger /system partition so we can push the su & busybox binaries :
Code:
emulator -avd yourNewAvdName -partition-size 256 -no-snapshot-load
Wait for the emulator to boot.
3) Now, cd to the directory where you put the binaries and the apk you downloaded in the prerequisities, and issue the following comands in your terminal :
Code:
adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock0 /system
adb push su /system/xbin/su
adb push busybox /system/xbin/busybox
adb install Superuser.apk
adb shell
chmod 06755 /system/xbin/su
chmod 06755 /system/xbin/busybox
4) Enjoy your Rooted emulator
However, you might need to go through these steps every time you start this emulator, to avoid this hassle, here's a script containing those commands : rootavd.sh
Simply put it where you put the binaries, cd to this location and enter the following command to execute it :
Code:
bash rootavd.sh
...since many thanked you apparently it worked to many but why didn't it to me?
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Why's this so? I've tried many similar guides, and it makes sense for this to work but it always shows the above (permision denied) and there's absolutely no other way to test applications that require root, for better or worse :/
Obviously I've followed the step it's not that it is hard to do so gave the right permissions but still no root?
Sth's on with the chmod commands?
Thanks for the guide and attention...
PS: It probably doesn't work in JellyBean'd AVD? :/
Stevethegreat said:
...since many thanked you apparently it worked to many but why didn't it to me?
Why's this so? I've tried many similar guides, and it makes sense for this to work but it always shows the above (permision denied) and there's absolutely no other way to test applications that require root, for better or worse :/
Obviously I've followed the step it's not that it is hard to do so gave the right permissions but still no root?
Sth's on with the chmod commands?
Thanks for the guide and attention...
PS: It probably doesn't work in JellyBean'd AVD? :/
Click to expand...
Click to collapse
Yeah, I believe it's been patched in jellybean.
However, you can use Jar of Beans, which is a community-built pre-rooted jb emulator.
Sadly it seems to be windows only. I'll post a guide if I manage to run it on linux through WINE
I know this is a little old of a post but i wanted to point out that i noticed a lot of people (when i was searching for a solution) having a hard time trying to get,
emulator -avd youravdhere -partition-size 256 -no-snapshot-load, to work correctly or not popup at all.
After a little research i noticed that you should add
./emulator to the first part instead of just "emulator"
hope this helps anyone. (credits goes to another person on another site i take no credit just spreading the knowledge)
kamakazidreamer said:
I know this is a little old of a post but i wanted to point out that i noticed a lot of people (when i was searching for a solution) having a hard time trying to get,
emulator -avd youravdhere -partition-size 256 -no-snapshot-load, to work correctly or not popup at all.
After a little research i noticed that you should add
./emulator to the first part instead of just "emulator"
hope this helps anyone. (credits goes to another person on another site i take no credit just spreading the knowledge)
Click to expand...
Click to collapse
You don't necessarily need that. As far as I know the only situation in which you might need this is on a Linux system. (Not sure about Mac)
And even in this case it depends. You can also add the tools directory to your PATH variable. Then you won't need it.
So not all people will need this but some definitely will. So thanks for that.
nikwen said:
You don't necessarily need that. As far as I know the only situation in which you might need this is on a Linux system. (Not sure about Mac)
And even in this case it depends. You can also add the tools directory to your PATH variable. Then you won't need it.
So not all people will need this but some definitely will. So thanks for that.
Click to expand...
Click to collapse
guess i should have pointed out i was using xubuntu to do all this haha.
Hello
Can you redownload files for rooting emulator?
I downloaded files from another source, but it doesn't work with it.
kolia2221 said:
Hello
Can you redownload files for rooting emulator?
I downloaded files from another source, but it doesn't work with it.
Click to expand...
Click to collapse
Can anyone help me?
Android L
Will this work on an Android L avd
i have nand backup generated from galaxy s2 . can i restore this backup on rooted avd s2
or virtual machine??
akhilnarang said:
Will this work on an Android L avd
Click to expand...
Click to collapse
I've had no luck so far, followed the guide but SuperSU tells me that "su is not present" and that "he cannot install it".
Anyone succeded in rooting a 5.0 AVD?
I am trying to get xposed framework going in remix os to get xprivacy. I am running remix os in virtualbox and I am having trouble getting adb set up. Remix os is similar to android x86 so has anyone been able to get xposed working in either remix os or android x86 marshmallow?
Related
Skrulladams figured out a way to get Linux onto the Droid X, Droid 2 / Global, Droid Pro, and DEFY (Really any modern motoblur phone with a locked bootloader.) Supposedly the Atrix has it as well? Technically, according to wikipedia, motoblurexists on the CLIQ/DEXT, Backflip, Devour, Flipout, Charm, and Flipside as well. I can't tell you whether or not this method works for those phones, maybe somebody could verify. While I was researching methods to get this all to work I found different methods for the original Droid, I am assuming that the version of blur on any phone from the OG droid/milestone is different, because the installation method seems somewhat less locked-down.
First you will need a Linux image. I suggest getting yours from Ruan over at androidclone.com
Ubuntu Laika-Beta1.2a.rar
The commands have to be issued from Linux or a virtual machine of Linux as far as I know. I downloaded VirtualBox and used a copy of Ubuntu 10.10 that I had laying around. You could use the image you downloaded above with VirtualBox. PuTTYcyg seems like a better alternative, but I haven't used it.
When setting up your linux virtual machine you might want to make your username "noob" like I did, it will allow you to copy and paste my commands.
The first thing you will need is the android sdk.
Click here to get it
Using and installing it is a little confusing. I just extracted it to my desktop.
You will have to run /tools/android, I did this by dragging and dropping the icon into a terminal window and hitting enter. You have to install the platform-tools. ADB will be downloaded to the platform-tools folder inside the SDK folder.
VirtualBox allows you to capture a USB device inside your virtual machine inside the menu. Devices -> Motorola ####
Inside your virtual machine you will need to copy ubuntu.img from the Laika-Beta1.2a.rar you donloaded earlier to your home directory. While still in the home directory create a new folder simply called "ubuntu."
Your phone has to be rooted and you need a terminal emulator. Most custom ROMs have this by default, but there are many options.
Next, open up a terminal emulator on your phone and execute some commands:
Code:
su
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
mkdir /data/local/mnt
Back on your virtual machine in a terminal:
Code:
sudo losetup /dev/loop0 /home/noob/ubuntu.img
sudo mount -t ext2 /dev/loop0 /home/noob/ubuntu
Dirty_Jerz has an alternate method, Click here for his thread. so it is now up to you whether you'd have everything on your internal storage or SD card. My method uses the internal storage, his uses the SD card. If you'd rather use his, stop here.
Here you will want to remove a symbolic link in /home/noob/ubuntu/usr/bin that screws this method. You can do this by:
Code:
sudo rm /home/noob/ubuntu/usr/bin/X11
Then I remove security stuff:
Code:
sudo chmod 777 /home/noob/ubuntu
sudo '/home/noob/Desktop/android-sdk-linux_x86/platform-tools/adb' shell
chmod 777 /data/local/mnt
exit
sudo '/home/noob/Desktop/android-sdk-linux_x86/platform-tools/adb' push /home/noob/ubuntu /data/local/mnt
This is going to take about 2 and a half hours so I suggest you find something else to do while it copies over.
When it's all done you will need to copy a script over in order to chroot (boot from inside android) into Ubuntu.
Download this script! (specific for this install method!)
Username: androidclone.com
Password: androidclone.com
Click to expand...
Click to collapse
This script belongs in /system/bin so you will have to put it there. The easiest way to do that would be to copy it to your sdcard and then use your terminal emulator to move it.
Code:
su
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
cd /sdcard
cp bootubuntu /system/bin
cd /system/bin
chmod 777 bootubuntu
Now you can boot into Ubuntu from any directory as long as your terminal emulator has superuser.
Code:
su
bootubuntu
Once inside there are some commands that need to be run in order to get a functional UI.
I got these from this site He seems to have a lot of extra configuration instructions which may or may not help you.
Code:
mount -t devpts devpts /dev/pts
mount -t proc proc /proc
mount -t sysfs sysfs /sys
-Xvnc commands-
Code:
export DISPLAY=localhost:0.0
Xvnc -localhost -geometry 854x480 -depth 24 -deferupdate 0
-start your gui-
Code:
startlxde
I prefer xfce though, personally.
--------problems----------
"/bin/sh can't access tty: job control turned off" upon chrooting
Terminal emulators from within the UI don't work.
*DRIVERS*
Touch screen support/UI enhancements for touch screen.
androidVNC
Might not be an ideal solution. I still noticed what seemed to be some graphical lag. There could be a setting that can get it running better, but an app optimized for high speed localhost operation
Chrooting a prebuild image causes all kinds of problems because the proper post-installation scripts are not run. Some programs ignore these errors, and for others they error out. I have yet to find a good solution for this but I have found hints:
Check out this page
Seems a little outdated, but maybe somebody will find a way to make a method like this work.
What we really seem to need is a custom kernel/ROM/distro team that can work on these issues.
-----other alternatives?-------
First I tried kubuntu mobile. It was very buggy so I gave up on it.
Ubuntu netbook edition has been slammed by some for being bloated, but it's ARM port should be lightweight. From screenshots it looks like it has a great UI. The problem is getting gnome to start, it encounters some error and doesn't load.
fedora has a mobile edition that looked good, I think they are somehow involved with Meego which now seems doomed. I'm not sure how similar to android it is or if it is worth the effort.
Check this out
Many of you may already know about the QEMU for android app, but we should be able to cross-compile it to use within our chroot.
I looked into wine, it should be a dead-end since we aren't on x86 architecture and it doesn't do any emulation.
VMware will be releasing a version for android.
Also while playing around I thought about porting iOS on to an android phone. It should be possible.
Pics!
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
This could potentialy be used to get truly custom ROMs on the D2/DX/Motoblur ridden phones. Honeycomb here I come!
Sir, if you could use this to port newer versions of android and other operating systems such as meego and maybe even webos, you are truly the savior of our locked phones :O
Sent from my BLAZING FAST Droid 2 Global using the XDA app
From my understanding (not a coder or even a regular linux user), a chroot environment is just running an OS within your OS. Meego (maybe I'm thinking of Maemo?) should definitely be possible, I think there is an ARM build somewhere. Fedora was involved with them in some way, and I think might have an ARM build of one of their older releases.
Truly custom ROMs? Not sure, maybe Linux on the phone will be of help to devs?
I was hoping maybe Droid 2 bootstrapper could be modified to fastboot into the install. That still wouldn't be a true bootloader unlock and we still have drivers to worry about and might not even be possible, just an idea.
Well, we might be able to hijack to boot to maybe run CyanogenMod(at last!) . I can for sure, that would rule. I used CM on my old phone(the ultra moddable Droid Eris(HTC FTW!)), and it was the greatest rom I've ever seen
Sent from my DROID2 using XDA Premium App
It is possible to port it to Milestone 2?
Sent from my T-Mobile G1 using Tapatalk
This is a sweet little tutorial that I've been following and I'm excited to get Ubuntu up and running... if I do get it up and running. Problematic mentions a problem where '/bin/sh can't access tty; job control turned off' and I also hit this. I'm pretty new too linux, I've only really got into it upon the purchase and rooting of my Droid 2 and I haven't been able to find anything that can help me fix this problem. Has anyone else gotten past this and had ubuntu running on the Droid 2? Or could someone point me in the right direction? Any help is appreciated.
Can u mirror Ubuntu Laika-Beta1.2a ?. I can't download at filefactory now. Or can I use another ubuntu image ?
Can someone answer? Is it possible to run it on Milestone 2?
It is possible to port it to Milestone 2?
Click to expand...
Click to collapse
Should be. There shouldn't be enough differences between the two for this to not work. I have a hard time thinking of a scenario where this wouldn't work for an andrioid phone. I think the main requirement is having a fairly recent version of busybox installed.
Can u mirror Ubuntu Laika-Beta1.2a ?. I can't download at filefactory now. Or can I use another ubuntu image ?
Click to expand...
Click to collapse
You can use any armel image of Linux. Currently I think this mainly applies to Ubuntu, there should be ARM builds for other distros out there, but these are tough to find. A skilled enough developer should be able to port any distro they wish.
Problematic mentions a problem where '/bin/sh can't access tty; job control turned off' and I also hit this.
Click to expand...
Click to collapse
This seems to be a bug from chrooting a preinstall image without any kind of real setup. I found you can do a lot of this manually, (If you're interested try googling the MAKEDEV command, I think that generated ttys for me.) but I'm still searching for a real solution. Currently I'm considering trying the debootstrap method, the "ubuntu-netbook-10.10-preinstalled-netbook-armel+omap.img" image could be the ticket as well.
thanks, i'll try with Ubuntu-Netbook 10.10
Please Help
hello i am trying this and am getting hung up on the
"sudo mount -t ext2 /dev/loop0 /home/noob/ubuntu" am getting this
wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
looking at dmesg i see this
EXT2-fs (loop0): error: couldn't mount because of unsupported optional features (4)
any ideas?
bootubuntu script
hello. it seems i'm unable to log into androidclone.com are you able to post the bootubuntu script?
link
I think this could be the script you looking for, gonna try this out on my flipout when i get home
https://www.ebower.com/docs/droidx-hacking/
I've noticed with a lot of CM10-based ROM's (possibly even others), I am unable to get root ADB access.
On the ROM's that have it, I set the Root access to Apps and ADB
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
I can reboot, fix permissions, clear caches, but no matter what, Android Commander is never able to get Root access
This isn't the case on some ROM's I've tried though. Android Commander is able to get Root access just fine without me needing to do anything.
To name some ROM's that I can't get Root access with:
CyanogenMod 10 Nightly (9/4)
AndroidME CM10 N7 1.0.0
As for what ROM's had working Root access, I can't exactly recall correctly :/ But I think these had it working:
Codename Android 3.4.1
Team EOS 3 *JELLYBEAN* Nightlies (confirmed working ADB root)
Is there something else I should possibly be doing to get Root access on CM10-based ROM's?
Boot a unsigned kernel then ./adb remount
PS: it is effective until you reboot
Sent from my Nexus 7 using Tapatalk 2
"The Root access : No" because you'r using the rom which have a "secured adb" (even when you'r rooted)
Download the "adbd insecure" in this thread and "Enable insecure adbd", you can get "Root access: OK" in any rom
http://forum.xda-developers.com/show....php?t=1687590
adb root
The real reason behind adb root or insecure adb is the adb daemon in the device running at root permissions. In pre-Android 4.1 versions, this is usually decided by some initialisation script(like init.rc) at boot time. The script checks for value in default.prop,local.propand other environment variables.
If it finds build.prop,default.prop or local.prop property file with ro.secure=0 adbd is allowed to run as root. You'll get adb root and hence will be able to do commands like adb remount,adb root and adb shell's prompt'll be # by default. The user may be displayed as [email protected] or [email protected] adb GUIs like Android Commander and QtADB will get to work in Root mode.
But,if it's ro.secure=1, adb daemon is made to work in secure mode, and adb won't change to root mode on issuing adb root command. However, if su binary is present in $PATH, u can still call su command from adb shell. But, it's not enough for Android Commander to get Root Access. It is possible to attain adb root through any one of the following methods:
1.For CyanoGenMod based ROMs there is an option in Settings->Developer Settings->Root access to control root access. Choose ADB only or Apps and ADB in options to get adb root.
2.Else use adbd Insecure app by chainfire if you have a rooted device. This is useful, especially for Android 4.1+ devices.
3.Or, you may manually edit default.prop to set it's value to 0, but original default.prop will be restored from boot partition everytime you reboot(this is the reason why adb Insecure cannot permanently do adb root, though there is an option to repeat the rooting procedure everytime the device boots). This method is called temporary adb root. On pre-Android 4.0 ROMs default.prop file was located in / directory. I read that from Android 4.x this file is in ramdisk and so more difficult to edit. But Android 4.0 has local.prop which is easier to modify than default.prop( See method 5)
4.For permanent adb root, you'll have to extract boot.img, change default.prop, repack and then flash it back to device.
5. In Android 4.0 there's local.prop file in /data partition. Setting ro.secure=0 in this file will do adb root permanently. Else you can set another property ro.kernel.qemu=1 in the same file. But, this value makes the system think that it is running in an android emulator. Many exploits and root methods set this property temporarily to gain root. But, it may cause side effects if used permanently. Setting ro.secure=0 is recommended. Do this command in terminal app or adb shell:
echo ro.secure=0 >/data/local.prop
or you can manually copy a local.prop file with ro.secure=0 as it's content to /data.
6.Note that method 3,4 and 5 won't work in Android 4.0 Jelly Bean onwards. According to Dan Rosenburg(drjbliss in XDA),the researcher who discovered adb root emulator exploit and many other exploits, Jelly Bean doesn't parse any property files to set the ownership of adb daemon. The stock adbd will have to be replaced with an insecure one to gain adb root. But still,as adbd is located in /sbin whose contents are reloaded everytime on reboot from boot.img, it won't be permanent.
7. For permanent adb root, you may flash an insecure boot.img(one that contains and insecure adbd)
8. If you're really desperate and can't get adb root to work with any of the above methods use an exploit. Most of the adb based rooting methods utilise some exploit to make the adb daemon run as root. By studying the exploit and implementing it you could gain adb root atleast temporarily.I'm not recommending this method but as a last resort you could try them.
Acknowledgements: Thanks to Dan Rosenberg for explaining the reasons behind adb root, especially the one in Jelly Bean.
get root access with root commander
Question to that fantastic answer above.http://forum.xda-developers.com/images/smilies/good.gif
How do I push back my modified build.prop?
I have HDC S3 Ex v2 hung in bootloop, after changing vm heapsize to 60 from 64.(Tried 128 but it didn´t stick, so tried this and it unfortunately worked)
I have managed to start in recovery mode even though it´s chinese there, don´t understand, I can communicate through Android commander to pull the files but cannot push them back due to no "root access".
I installed the "insecure ADB" via Commander but it does no good when I can´t load android.
I have no backup. It is rooted Android 4.1.2 by Fastcardtech. has busybox installed
Use su in adb shell
Use adb shell and elevate to root access by using su
Code:
su
.
Now, if you get # prompt instead of $ sign you have root on adb shell. But, still you don't have adb root. So, don't try to push the files or use Android Commander. Instead we use shell commands to do the same.
First Remount /system partition as writeable.
i.To do this first type
Code:
mount
and find out system's device name and file system from the list. In case of my device (and many Stock ICS devices) this device name would be /dev/block/mtdblock?. ? varies for each device. I had /system as mtdblock8 with ext3 file system.
ii. Now type the following command
Code:
mount -o remount,rw -t <filesys> /dev/block/mtdblock? /system
use the number you have for '?' and the filesystem for <filesys>.
Now Copy the modified file to some readable location on the device, say /sdcard or /data/local/tmp. Then copy the build.prop to /system using cat command
Code:
cat /sdcard/build.prop > /system/build.prop
Hope it works!
Closer...
HEXcube said:
Use adb shell and elevate to root access by using su
Code:
su
.
Now, if you get # prompt instead of $ sign you have root on adb shell. But, still you don't have adb root. So, don't try to push the files or use Android Commander.
Copy the modified file to some readable location on the device, say /sdcard or /data/local/tmp. Then copy the build.prop to /system using cat command
Code:
cat /sdcard/build.prop > /system/build.prop
Hope it works!
Click to expand...
Click to collapse
Thank you! But...
After more than one hour installing android-sdk, I got the # ( I thought the shell through android-commander was the same first)
but it says Read only file system
Another thread suggested "remount rw" before pushing but thats not something adb shell recognices "not found".
Am I only missing the adress of my device when trying remount?
Any suggestions?
Renount /system as rw
Oh, i forgot! You've to remount /system as Read Write. I've edited the above post to include that.
You need not have installed the whole Android SDK(unless you develop for Android). It's the same adb that Android Commander or QtADB uses. You can even use adb as a standalone tool along with the required libraries(dlls on windows). Now that you have installed the Android SDK, it doesn't matter.
Yes! Yes! Yes!
HEXcube said:
Oh, i forgot! You've to remount /system as Read Write. I've edited the above post to include that.
Click to expand...
Click to collapse
:good::good::good::victory::victory::victory:
It worked! Thank you so much! A new phone useless was really disappointing, but happy again
Set heap size back to 64. Maybe I´ll dare set it to 128 another day... The phone has horrible ram performance, hoping that would cure it.
Uninstallation of an app of 6-7 mb takes at least 45 sec. My old Blade with cyanogen does that in less than 10.
Hard part was understanding my system name /dev/block/mmcblk1p1 cause it wrote /storage/sdcard vfat after it.
I saw ext4 in other part and asssumed it was that system cause it had "ro" after it.
Thank you again. You now introduced me into some new territory. Not just flashing modded roms in recovery mode.
But I will search out one modded rom so I can overclock some.
So I set up the rPi with rdesktop, gedit, ntfs-3g, Samba, Hamachi, Privoxy and rsync to build my NAS and VPN. I have two external hard drives (2 TB and 500 GP) plugged in to a powered USB hub. I also have the powered USB hub powering the rPi. I'll reference the links I used as I go along, this wasn't hard to do.
I'll say it right now, if I can figure it out, anyone can.
First off if you haven't put Rasbian on your rPi, go do it and then come back....you're back already? Great, let's get started.
I don't like having to plug in a monitor, keyboard and mouse every time I want to access my rPi, so go ahead and do it the first time for the setup. Now that you have your peripherals all set up, let's install rdesktop so we don't have to do this again.
Open the terminal and then:
sudo apt-get install rdesktop
then get the IP address and write it down:
ifconfig eth0
Great. Now you can keep working on it as you have it set up or you can access it from another computer. IF you're on linux, go to your terminal and enter:
rdesktop ipaddress from above -g 90% (the -g 90% tells rdesktop to launch at 90% of the size of your screen. If you want something larger or smaller, suit yourself.) Sign in as your user id and password for your rPi.
Since I'm not a big nano fan, I like to use gedit, let's install it now:
sudo apt-get install gedit
Now I initially followed this guide to set up Samba, http://elinux.org/R-Pi_NAS. We'll walk through the relevant parts. Let's install Samba:
sudo apt-get install samba samba-common-bin
If you're prompted to continue then say yes. Copy the the samba config file, in case we mess it up.
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old
On the link above we're told to use nano to update our config file, as I said, I don't like it. The great thing about Linux is, if you don't like something, you don't have to use it. So we won't use it...much.
Let's work on that config file:
sudo gedit /etc/samba/smb.conf
Search for security (ctrl + F and type security, then press enter) and you'll find the following:
# security = user
Go ahead and remove the #, so we just have:
security = user
Now let's search for homes and change:
read only = yes
to
read only = no
Now save and close the file. Run the following command to restart Samba:
sudo /etc/init.d/samba restart
You'll see the following:
Stopping Samba daemons: nmdb smdb
Starting Samba daemons: nmdb smdb
Samba comes configured with your user id defined, assuming it's pi we will now allow pi to be a Samba user.
sudo smbpasswd -a pi
You'll need to enter the password twice and then pi will be setup as the samba user id. If you would like to add an additional user(not required), then do the following:
sudo useradd marty -m -G users
sudo smbpasswd marty
You'll be asked to enter the password for marty twice now.
Now let's make a shared folder to house our main storage (this will be for user pi, not for marty):
sudo mkdir /home/pi/shared
We also need to make a folder to house our backups:
sudo mkdir /home/pi/backup
Once more we need to edit the Samba configuration file, this time we are telling it about the shared folder we just created. So let's go do that:
sudo gedit /etc/samba/smb.conf
Scroll down to the end of the file and add the following:
[public]
comment = Public Storage
path = /home/pi/shared
valid users = @users
force group = users
create mask = 0660
directory mask = 0771
read only = no
Now save and close the file. Run the following command to restart Samba:
sudo /etc/init.d/samba restart
You'll see the following:
Stopping Samba daemons: nmdb smdb
Starting Samba daemons: nmdb smdb
Now we are getting ready to start mapping our drives, so let's make sure we have support for NTFS-formatted disks.
sudo apt-get install ntfs-3g
Great, good job!
Let's go find our hard drives that we have mounted so we can get them setup to do their jobs. Run the following command to determine where they are currently located in our file system:
sudo fdisk - l
You'll see something like this:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Now let's look at the results:
/dev/mcblk0 - This is the SD Card that Rasbian is running on.
/dev/sda - This is the 2 TB hard drive that I am using for my main storage.
/dev/sdb - This is the 500 GB hard drive that I am going to use for backing up my family pictures and business documents.
The next step is to mount the hard drives to the folders we created earlier. Before we do this we need to make sure that they are not currently mounted. We are going to do this the easy way, open the file explorer as root:
sudo pcmanfm
and you will probably see the two hard drives mounted, simply client the unmount button beside each one. then close the file manager. Now let's mount the hard drives to their permanet location:
sudo mount /dev/sda1 /home/pi/shared
sudo mount /dev/sdb1 /home/pi/backup
Great job, now we have access from our home folder to both of these drives. But we need to make this happen automatically on boot, easy:
sudo gedit /etc/fstab
Now in the fstab file add the following two lines below the line that starts with /dev/mcblk0p2
/dev/sda1 /home/pi/shared auto noatime 0 0
/dev/sdb1 /home/pi/backup auto noatime 0 0
Make sure you tab where you see the spaces above. Now save and close the file. We are set now, the drives will auto-mount to our home folders when we reboot.
Now it's time to get started with our backups, we need the software first:
sudo apt-get install rsync
(that was hard huh!)
Well we've reached the point where we have to use nano. It's not that hard, but it's definitely different than using a text editor. You will need to use your arrow keys to move up and down and then to save the file you'll need to press 'Ctrl + X' and then you'll be prompted to accept by pressing 'y'. We are now going to configure our backups. I used the guide found on How to Geek, as my inspiration for this, but I've modified a few things to work better for me. I want to give them credit for the idea though. If you read their article they instruct you to setup your backup to run nightly, however I thought that was bit much, so I decided to educate myself and figure out how to modify this. I found this link, which explains how crontab works. Basically crontab takes this entry to determine when it will execute the command that follows:
# Minute Hour Day of Month Month Day of Week Command
# (0-59) (0-23) (1-31) (1-12 or Jan-Dec) (0-6 or Sun-Sat)
0 2 12 * 0,6 rsync
I wanted to have my backups running at alternating times and only a couple of times a week, so let's go ahead and configure that:
crontab -e
Now you are in nano, navigate down to the bottom of the list and enter the following:
0 2 * * 0,3 rsync -av --delete /home/pi/shares/Pictures /home/pi/backup
0 2 * * 1,5 rsync -av --delete /home/pi/shares/busdocs /home/pi/backup
Now save the file, 'Ctrl + X' and then confirm 'y'. So let me explain what we just set up, I'll go through the first line:
0 - 0 minutes
2 - 2 hours (2 AM)
* - Any day of the month.
* - Any month.
0,3 - Run this on Sunday and Wenesday. (0 - Sunday, 1 - Monday, 2 - Tuesday, etc)
rsync - Command to be ran.
-av - archive and verbose
- -delete - (MAKE sure there are TWO dashes - -, there should not be a space between these.) This parameter tells rsync to delete any file on the to folder that is not on the from folder, so if you remove a file in your main storage it will be removed in you backup.
/home/pi/shares/Pictures - This is the from folder.
/home/pi/backup - This is the to folder.
This last step is optional but recommended. Let's go ahead and run rsync for two reasons, to verify that it can successfully back up your data and to get the biggest backup done.
rsync -av --delete /home/pi/shares/Pictures /home/pi/backup
Depending on how much data you are backing up, this could take a while. When I first ran it I backed up around 40 GB of pictures and it took about 2 1/2 to 3 hours. So go get some coffee and relax.
So your backup is set and ready to run! You did it! And it wasn't even that hard!
There may be a better way to set this up, but this what worked for me, I hope you've enjoyed getting your rPi setup as a NAS with auto backups!
One final piece, setup Hamachi so you can access your files remotely (yes you can already do it if you have SSH installed (which you should.)) Go to logmein.com and create a free account and set up your network. You can install this on Linux, Mac and windoze.
sudo apt-get update
sudo apt-get install --fix-missing lsb lsb-core (this will take a bit)
sudo dpkg -1 --force-architecture --force-depends logmein-hamachi_2.1.0.86-1_armel.deb
( the above line is dash dash force dash architecture and then dash dash force dash depends)
Now set up hamachi on the rPi:
sudo hamachi login
sudo hamachi attach [INSERT LOGMEIN.COM EMAIL HERE]
sudo hamachi set-nick [INSERT A NICKNAME FOR YOUR RASPBERRY PI]
Now back on your computer on logmein.com, go to your networks and grant the Pi permissions to join your network and write down the network ID (a 9-digit number) for that network.
Back on the rPi:
sudo hamachi do-join [THE NETWORK ID YOU WROTE DOWN]
Now start SSH so you can reach the rPi remotely:
sudo /etc/init.d/ssh start
You should test out the set up now by SSH'ing into the rPi at the virtual IP on the logmein.com site, it will be something like 25.xx.xx.xx:
ssh [email protected]
Now you can access your rPi remotely (outside of your network.)
You can also remote desktop into the pi at the new virtual IP address:
rdesktop 25.xx.xx.xx -g 70%
Here are the links that pulled knowledge from for all of this.:
http://www.howtogeek.com/139433/how-to-turn-a-raspberry-pi-into-a-low-power-network-storage-device/
http://linux.about.com/library/cmd/blcmdl1_rsync.htm
http://www.pantz.org/software/cron/croninfo.html
http://elinux.org/R-Pi_NAS
This is what I have planned, but with a twist.
I plan to connect my Seagate Expansion 2TB desktop drive to the rPi. I intend to write a script that will run as a daemon and will check if I have connected my phone to the rPi and if detected, it will backup the images to my drive.
Will share it once successfully implemented. My rPi arrives next week.
Tapatalked from Desire S running Andromadus
suku_patel_22 said:
This is what I have planned, but with a twist.
I plan to connect my Seagate Expansion 2TB desktop drive to the rPi. I intend to write a script that will run as a daemon and will check if I have connected my phone to the rPi and if detected, it will backup the images to my drive.
Will share it once successfully implemented. My rPi arrives next week.
Tapatalked from Desire S running Andromadus
Click to expand...
Click to collapse
That sounds awesome! I would definitely be interested in seeing that!!!
Hey guys,
I was looking for a way to install some Linux applications on the FireTV. After trying out optware (which installs a package manager to android systems) with little success, I ended up installing a Debian Chroot on the external USB. The following is a list of apps which now run almost natively on the firetv:
- Transmission 2.82/couchpotato/sickbeard
- openssh
- nano
- x11 environment
- vnc server
- ftp server
I hope these instructions will be useful for some people. Your firetv needs to be rooted for this to work. The process is relatively quick and as easy as it can get. The tricky part is to let The Debian environment boot when the FireTV boots. Here we go:
1. First, get DebKit from Google Play
2. Sideload DebKit onto the FireTV and start it up
3. Grant DebKit Root Permissions
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
4. Push the Menu Button on your FireTV remote and go to settings
5. Select the image Location. I created a folder called debian on the external USB device. The USB works natively through the new FireTV firmware.
6. For the image size I decided to make it 2GB. At first I had a 1GB image but I quickly ran out of space installing the x11 environment
7. Under Debian Distribution I would recommend installing Jessie since it gives you the latest Transmission version. With wheezy you get v 2.6 which does not let you choose folders through the web ui.
8. Go back to the main menu and choose "Install". Follow the onscreen instructions.
At this point you should have a working Debian installation on your FireTV.
9. The first thing we want to do is install openssh to create a login into the chroot. To log into your new Debian installation use
"adb connect 192.168.1.x" (firetv ip) and "adb shell"
10. Once you are logged into the firetv shell, execute "debkit mount" , then "debkit chroot".
11. Inside the chroot execute "apt-get update && apt-get install openssh". You will see a few error messages which are caused by the environment variables of the android shell. When using nano for example you'll notice that the enter key doesn't work. On a full size keyboard you can use the other enter key to confirm though.
12. Now try logging in to your debian chroot with ssh [email protected]" (firetv ip)
AUTOSTART
In order to autostart your debian chroot I created the following script.
1. Go to the android shell and remount /system in rw ( mount -o remount,rw /system )
2. Create or edit /system/etc/install-recovery-2.sh which will autostart (vi /system/etc/install-recovery-2.sh, then chmod 755 /system/etc/install-recovery-2.sh)
3. Here is my complete autostart script. I have all my media connected to my router which has a NFS server running:
Code:
#!/system/bin/sh
sleep 20
busybox mount -o remount,rw /
busybox mkdir -p /mnt/nfs.TV
busybox mkdir -p /mnt/nfs.Movies
busybox chmod 777 /mnt/nfs.TV
busybox chmod 777 /mnt/nfs.Movies
busybox remount,ro /
su --mount-master -c "busybox mount -o nolock,hard,intr,rw -t nfs 192.168.10.1:/mnt/TV /mnt/nfs.TV"
su --mount-master -c "busybox mount -o nolock,hard,intr,rw -t nfs 192.168.10.1:/mnt/Movies /mnt/nfs.Movies"
/data/data/com.mizusoft.debkit/files/debkit mount
sleep 5
busybox mount --bind /mnt/nfs.TV /data/data/com.mizusoft.debkit/files/mnt/mnt/TV
busybox mount --bind /mnt/nfs.Movies /data/data/com.mizusoft.debkit/files/mnt/mnt/Movies
busybox mount --bind /mnt/nfs.Movies/Music /sdcard/MPD/music
sleep 5
/data/data/com.mizusoft.debkit/files/bin/chroot /data/data/com.mizusoft.debkit/files/mnt/ /bin/bash -c "/home/ssh.sh"
4. I mount my nfs shares to the FireTV and then bind them inside the chroot.
5. Here are the contents of /home/ssh.sh which is a script to start the chroot ssh
Code:
/usr/sbin/sshd
sleep 10
/usr/bin/ssh [email protected] "/home/startup.sh"
6. and the contents of /home/startup.sh
Code:
/etc/init.d/transmission-daemon start
/etc/init.d/couchpotato start
/etc/init.d/cron start
7. What you end up with is a FireTV which runs Debian on the side. I've had this setup for the last two months and can say that so far the performance of Kodi does not seem to suffer of having the Debian Chroot running at the same time.
I hope this tutorial will be helpful for people who are looking for ways to extend the use of their FireTV.
Cheers,
Chris
mrchrister said:
Hey guys,
I was looking for a way to install some Linux applications on the FireTV. After trying out optware (which installs a package manager to android systems) with little success, I ended up installing a Debian Chroot on the external USB. The following is a list of apps which now run almost natively on the firetv:
- Transmission 2.82/couchpotato/sickbeard
- openssh
- nano
- x11 environment
- vnc server
- ftp server
I hope these instructions will be useful for some people. Your firetv needs to be rooted for this to work. The process is relatively quick and as easy as it can get. The tricky part is to let The Debian environment boot when the FireTV boots. Here we go:
1. First, get DebKit from Google Play
2. Sideload DebKit onto the FireTV and start it up
3. Grant DebKit Root Permissions
4. Push the Menu Button on your FireTV remote and go to settings
5. Select the image Location. I created a folder called debian on the external USB device. The USB works natively through the new FireTV firmware.
6. For the image size I decided to make it 2GB. At first I had a 1GB image but I quickly ran out of space installing the x11 environment
7. Under Debian Distribution I would recommend installing Jessie since it gives you the latest Transmission version. With wheezy you get v 2.6 which does not let you choose folders through the web ui.
8. Go back to the main menu and choose "Install". Follow the onscreen instructions.
At this point you should have a working Debian installation on your FireTV.
9. The first thing we want to do is install openssh to create a login into the chroot. To log into your new Debian installation use
"adb connect 192.168.1.x" (firetv ip) and "adb shell"
10. Once you are logged into the firetv shell, execute "debkit mount" , then "debkit chroot".
11. Inside the chroot execute "apt-get update && apt-get install openssh". You will see a few error messages which are caused by the environment variables of the android shell. When using nano for example you'll notice that the enter key doesn't work. On a full size keyboard you can use the other enter key to confirm though.
12. Now try logging in to your debian chroot with ssh [email protected]" (firetv ip)
AUTOSTART
In order to autostart your debian chroot I created the following script.
1. Go to the android shell and remount /system in rw ( mount -o remount,rw /system )
2. Create or edit /system/etc/install-recovery-2.sh which will autostart (vi /system/etc/install-recovery-2.sh, then chmod 755 /system/etc/install-recovery-2.sh)
3. Here is my complete autostart script. I have all my media connected to my router which has a NFS server running:
Code:
#!/system/bin/sh
sleep 20
busybox mount -o remount,rw /
busybox mkdir -p /mnt/nfs.TV
busybox mkdir -p /mnt/nfs.Movies
busybox chmod 777 /mnt/nfs.TV
busybox chmod 777 /mnt/nfs.Movies
busybox remount,ro /
su --mount-master -c "busybox mount -o nolock,hard,intr,rw -t nfs 192.168.10.1:/mnt/TV /mnt/nfs.TV"
su --mount-master -c "busybox mount -o nolock,hard,intr,rw -t nfs 192.168.10.1:/mnt/Movies /mnt/nfs.Movies"
/data/data/com.mizusoft.debkit/files/debkit mount
sleep 5
busybox mount --bind /mnt/nfs.TV /data/data/com.mizusoft.debkit/files/mnt/mnt/TV
busybox mount --bind /mnt/nfs.Movies /data/data/com.mizusoft.debkit/files/mnt/mnt/Movies
busybox mount --bind /mnt/nfs.Movies/Music /sdcard/MPD/music
sleep 5
/data/data/com.mizusoft.debkit/files/bin/chroot /data/data/com.mizusoft.debkit/files/mnt/ /bin/bash -c "/home/ssh.sh"
4. I mount my nfs shares to the FireTV and then bind them inside the chroot.
5. Here are the contents of /home/ssh.sh which is a script to start the chroot ssh
Code:
/usr/sbin/sshd
sleep 10
/usr/bin/ssh [email protected] "/home/startup.sh"
6. and the contents of /home/startup.sh
Code:
/etc/init.d/transmission-daemon start
/etc/init.d/couchpotato start
/etc/init.d/cron start
7. What you end up with is a FireTV which runs Debian on the side. I've had this setup for the last two months and can say that so far the performance of Kodi does not seem to suffer of having the Debian Chroot running at the same time.
I hope this tutorial will be helpful for people who are looking for ways to extend the use of their FireTV.
Cheers,
Chris
Click to expand...
Click to collapse
Definitely Cool! Are you strictly using it for the apps you've mentioned or have you found other uses? More screenshots would be awesome--video would be the best. But don't want you to go through too much trouble. I'm very curious to see how it runs in real time, but I'm not likely to have a chance to try it in the foreseeable future. Thanks a lot for sharing though!
BTW--whats the boot time like? It'd be nice to run sickbeard on it if I'm able to switch back and forth fire os/ debian.
Hey Klit,
when I have a bit more time on my hands I might add a video tutorial , it's definately a pretty straight forwarded process if you don't fear using the terminal. the debian environment is only accessible through a terminal so you cant switch between fire os and a debian window manager . The boot time is not affected by loading the debian chroot since the debian stuff loads after fire os is loaded. Sickbeard works great btw!
What mode is Debian running in and is it a visual UI desktop?
While I am here,I must ask,can someone attempt to get a full Linux running using Xserver for maximum performance and make some detailed instructions afterward,I couldn't figure it out myself.
I had a version of Linux running with a UI desktop and a few browsers that worked decent.
Though this done with a slower method and made visible using a VNC app.
It's been so long since I ran it,and I forgot how to start it,and haven't used it since.
It would be nice to have a full Linux OS running via Xserver at high performance,enough to run several cool things smoothly without the framedrops and jitters that VNC gets.
This tutorial is based on Debootstrap, so it installs Debian into a "subdirectory" of fire os. In this case it mounts a 2GB image from the external USB to the Firetv. When you ssh into this environment it will feel like a debian server and you can do most things you can do in debian. you can read more about this over here:
https://wiki.debian.org/Debootstrap
I have a vncserver running on the firetv with fluxbox as my window manager. it runs great but this is not a dual boot setup with debian coexisting on the firetv.
Thanks for the detailed instructions, OP! I wonder if this would work as a Terraria server... TShock is simply too much for the Raspberry Pi.
I would like to install Debian and remove fire OS completely. Does any one have instructions or a link? Thank you.
https://github.com/freedreno/freedreno/wiki/FireTV
Fire TV Stick?
Great work! I can't wait to get the time to try it out myself.
It sounds like you did this on the Fire TV installing Debian on an external USB drive. Did I get that correct? Can this be done on a Fire TV Stick which has no external USB option?
Also, it looks like both Debian and Android run simultaneously based on your comments, is that correct? Does anyone know if there is a way to set it so Android launches when HDMI is plugged in and Debian launches when HDMI is not plugged in and not both simultaneously?
This is a posting mostly on concepts and what is possible with adb scripting, and a few best practices on how to implement it to be actually usable.
So what is this about?
Lets say you'd want to start Pandora on your FireTV and start a specific playlist with just a click or two on your smartphone. Favorite songs, skip tracks, and so on and so forth.
Of course this is only the tip of the iceberg of what is possible.
Things you need.
- a (preferably rooted) FireTV or FireTV stick (tested and working on firmware version 5.0.5)
- an android smartphone
- preferably a PC with adb installed to get things going
This is how you do it.
The way automation works is mostly using adb touch events (essentially "click on coordinates x y" on a 1920 1080 screen (for example)), and using adb key events (input keyevent 19 = click "up" once (for example), google android keyevents to get a full list, or read on for a link), separated by specified amounts of sleep [seconds] (for example sleep 10) inputs to give the FireTV enough time to execute the commands.
To repeat -
a touch event looks like this:
Code:
input tap 960 978 && sleep 0.8
a key input event look like this:
Code:
input keyevent 19 && input keyevent 19 && sleep 0.8
(input "up" twice, then sleep for 0.8 seconds
you can find other keyevent codes here:
http://stackoverflow.com/questions/7789826/adb-shell-input-events)
You use && (a bash scripting "linking" item) to link several commands together. (Essentially - once the previous command is finished, continue to the next, then continue to the next, then continue to the..)
The first usable example you should learn is how to start Kodi using adb scripting:
Code:
adb shell monkey -p org.xbmc.kodi 1 && sleep 5 && exit
To find the process name (f.e. org.xbmc.kodi) of a specific app, launch the app, then adb into the fire tv, open a shell (adb shell), then use ps | grep kodi to show all running processes with the word kodi in their process name. Replace kodi to find others.
Because much of this process relies on you being able to specify certain x y coordinates to "touch on" via adb scripting - the next command you should learn is to pull a screencapture off your FireTV to your desktop.
This is done via:
Code:
adb shell screencap -p /sdcard/screencap.png
adb pull /sdcard/screencap.png ~/Desktop/screencap.png
Notice that ~/Desktop/screencap.png is a filepath on a system running either Linux or MacOS - if you are running adb from a Windows mashine (to set things up, later we move script execution to your Android smartphone - promised.. ), you might have to specify a different path.
Using those screenshots you can grab x y coordinates quite easily (using an image editing program starting from the top left corner of each image). You use those x y coordinates to set up adb touch events later.
-
Once you have completed a certain script (f.e. start Pandora - navigate to playlists, start a specific playlist) and tested it success fully via the PC (much easer to write them there than on a smartphone.. ) - you can start to move them over to the smartphone side.
Here is how you do that.
Since google has removed adb as an executable binary from Android from Marshmallow forward - you have to use an app to compensate.
The app you want to use is "Remote ADB Shell":
http://forum.xda-developers.com/showthread.php?p=68972640
(In that thread you also find two complex examples of FiretTV scripting I use quite frequently - and a write up on how to modify the scripts to work with the app.)
Because "Remote ADB Shell" currently only supports a shell history lookup in case you don't want to write the entire script into the command line each time, there is a final step you should go through to make launching the scripts from your android smartphone more feasible.
Create a folder (preferably in /system) on the Fire TV and move all scripts as individual .sh files into that folder. Name them appropriately (f.e. /system/scripts/pandora_start.sh). Make them executable (chmod 755).
(The fastest way to do both steps on a rooted (necessary to move the .sh scripts to a folder in /system - which also is necessary - because NOTHING on /sdcard/ can be set to be executable (Android security)) Fire TV is to use Total Commander (App is in the Amazon Appstore).)
Then execute the script files (just text files with the actual lines of scripting you did beforehand, and the file extension .sh) from "Remote ADB Shell". (f.e. by typing in /system/scripts/pandora_start.sh && exit )
Notice that when you write the script files (.sh), or execute scripts form "Remote ADB Shell" - you have to leave out the "adb shell" part at the start of every command. As "Remote ADB Shell" will start you in the adb shell per default, so you don't have to address it, the app does that for you.
If you need a little more assistance on the last part (how to get this working on an Android Smartphone), read my two postings in http://forum.xda-developers.com/showthread.php?p=68972640 - it should make things a little easier to grasp. (You can find specific examples and a screenshot of how it looks in the end there.)
Also - don't forget to always exit cleanly out of the shell and adb, because the Fire TV only allows one adb connection at a time. In "Remote ADB Shell" it is enough to type in exit into the shell (add && exit to every command you execute there), if you connect from a PC - you might have to exit adb using adb disconnect, to establish another adb connection.
Also - don't forget, that you can restart the adb server on the Fire TV via the settings toggle (adb off then back on), if you cant establish a connection.
If you don't know what this is about, or how to use adb (adb connect IP .... I wont explain this in detail here...), too bad.
It's an actually easy and worthwhile way to get to know what is possible via adb and command line scripting on the Fire TV.
If you are stuck, I'm happy to assist - so ask questions if you have to. But don't ask for step by steps.
Start with thinking, contemplating and trial and error first.
When you create the folder and/or move files to said folder in /system - make sure you don't delete any other directories and or files there "by accident". Behave responsibly.
so long
h.
EDIT: reading better maybe the part I'm interested more is script executing more than "virtual touching". Still useful for me and with much potential.
Great post!
If I understood correctly I can use this method to pm enable / disable FTV Launcher on my stick (disabled to gain ram and enabled when I need to use launcher for stuff like installing new apps). Did I get it? I'm at work right now but ill check it out later.
Thanks.
Thats possible with "Remote ADB Shell" alone, yes. (Its history feature is enough to store those two (enable and disable) commands so you dont have to type them in each time.. )
The point of the tutorial is to also teach you that, furthermore - you can write scripts that launch (or close) apps and "virtually touch" on specific locations on the screen, or send remote keypresses, or both - multiple times in a row (as long as you want to make the script.. ), so you don't have to do repetitive tasks (like launching a specific music app and then get a specific playlist to play) manually over and over again - you can automate it.
This is especially useful as you can use both touch and remote keypresses as inputs - which allows you to easily do specific (repeditive) tasks in sideloaded apps - that arent fully usable with the remote alone. (And we all know that switching to a virtual mouse app sometimes is just bothersome. Then switching back to the remote just to scroll a page - is agony. )
-
Had a slight mistake in the tutorial, regarding putting the folder for your scripts in root. Turns out the FireTV wipes (?) folders from root it doesnt recognize - so you have to create the folder in /system instead. There your scripts will survive a reboot.
(f.e. /system/scripts/pandora_start.sh )
-
The reason why I advice you to save the shell scripts as .sh files in a local folder and not just "type them into Remote ADB Shell" is that, if you write scripts to automate certain launch/touch/navigation/... behaviors - the command line scripts all look like this:
Code:
monkey -p com.netease.cloudmusic 1 && sleep 5 && input tap 960 978 && sleep 0.8 && input keyevent 19 && input keyevent 19 && input keyevent 19 && sleep 0.3 && input keyevent 20 && input keyevent 20 && input keyevent 20 && sleep 0.3 && input tap 50 960 && sleep 0.8 && exit
So in Remote ADB Shell it becomes hard to differentiate between them. If you put them as named .sh files in lets say the /system/scripts/ folder (you created ) - the command line history in Remote ADB Shell (just longpress on the command line to pop it up) will look much nicer - (as you launch said scripts - by entering
Code:
/system/scripts/pandora_start.sh && exit
instead of
Code:
monkey -p com.netease.cloudmusic 1 && sleep 5 && input tap 960 978 && sleep 0.8 && input keyevent 19 && input keyevent 19 && input keyevent 19 && sleep 0.3 && input keyevent 20 && input keyevent 20 && input keyevent 20 && sleep 0.3 && input tap 50 960 && sleep 0.8 && exit
Also it allows you to name the scripts, set up a naming scheme, ... so to basically remember what they are called.
Found another app, that lets you store and execute shell commands on a Fire TV locally. The app works great with my automation scripts as well.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
https://play.google.com/store/apps/details?id=de.hp.terminalshortcut
So now - everyone can write shell scripts that can be executed on the Fire Tv from the smartphone - using "Remote ADB Shell":
https://play.google.com/store/apps/details?id=com.cgutman.androidremotedebugger
or from the FireTV itself - using
"Terminal Shortcut Pro"
https://play.google.com/store/apps/details?id=de.hp.terminalshortcut
Yay!
edit: To write the scripts into "Terminal Shortcut Pro" (to copy them letter by letter, basically) I use webkey ( https://play.google.com/store/apps/details?id=com.webkey ), with adaway blocking webkey.cc (because I don't need the cloud feature) - also, the webkey app tends to grab all remaining CPU power while you are watching movies - so I don't have its autostart enabled and kill the app regularly after using it - that said, its the most useful method to use a laptop to navigate the FIre TV I have come by - entering even long scripts with it, just takes seconds (depending on your type speed.. ).
EDIT #2: It was a stupid question since I just noticed the script contents under the script name. Sorry.
EDIT: Do the PRO features work on FTV Stick without Google Play market installed?
<Off topic, sorry>: Can the market be actually installed in a fully working way? That should be great.
that's great. Are those launcher enable / disable script the usual pm instructions or different? is so could you share them?
Thanks.
Usual commands, you see them in the screenshots. There are a few contextual checkboxes in the program that are used (run as root, don't notify on finish (afair), ..) but thats it. && exit on the end does work as well, but isn't required.
Terminal shortcut pro has an import/export function that is handy, but the file format it uses sadly is not plaintext.
I have the playstore installed on my device - so I cant say that Terminal shortcut pro (paid version) would work without it. I doubt it.
Thank you for this great post! Unfortunately "input tap" and "screencap" methods are really slow. Are there any tricks to improve performance?