[TUT] Automate actions on your FireTV using an android smartphone - Fire TV General

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?

Related

[Q] busybox throwing "precmd" errors after rooting ICS

Hello,
Thanks for looking at this post! I wanted to post it to the rooting thread, but I'm too much of a noob to have access to developer threads. I searched around (both here and google), but couldn't find any useful info on my problem.
I'll get right to the point. I rooted my Acer A500 (after doing an OTA update to 4.0.3), as per the instructions on this thread:
http://forum.xda-developers.com/showthread.php?t=1546593
Everything seems to have worked well (I have root access, etc), but there is something quirky with Busybox. Every time I type a command in terminal (it doesn't matter which - I use both connectbot and terminal emulator), I get a "precmd: not found" message (even for simple things like directory changes). The odd thing is: the commands work, but I still get the message. For instance, if I ask for a directory listing, I'll get the listing, and at the end, it will say precmd: not found (usually with the name of the command it's referencing, e.g. bash: precmd: not found).
It seems to be looking for it in /system/xbin/bash, but bash is in /data/local; I tried creating a symlink but it didn't work ("link failed Cross-device link"). This is really a nuisance, and I'd like to try installing some linux user-land tools, but I fear the outcome might be disastrous if the busybox tools are misconfigured somehow.
I'd appreciate and help/suggestions. Many thanks.
mdhobbes said:
"precmd: not found" message
Click to expand...
Click to collapse
Connectbot seems to set shell variable 'PS1' to "$(precmd)[email protected]$HOSTNAME:${PWD:-?} $ ".
It means your shell (the busybox's ash applet) will try to use output from 'precmd' as a part of a command prompt.
So when 'precmd' was not provided, error messages will be generated wenever a prompt was to be shown.
Though the messages should be safe to ignore, you may get rid of them by setting something harmless to PS1 like:
PS1="> "​, or reset PS1 by:
unset PS1​from your (busybox) shell.
# The same method should work for terminal emulator.
precmd is a shell function.
To display it run this from the default shell:
Code:
typeset -f
You will see something like
Code:
function precmd {
typeset e=$?
let " e " && print -n "$e|"
}
If you add that to one of your shell's startup files (".profile", ".bashrc", etc.) you will have a working precmd.
It works (function runs), but shows nothing neither 0 or error code. What is it?
[edit]
Nvm, my fault, figured it out

[TUTORIAL] Desktop app to control your Device

Hi all, this is not mine.
Credit goes to - http://code.google.com/p/androidscreencast/
I'm sharing with this you.
Installation
1 - Install the android sdk (download here)
2 - Connect your device through USB cable and ensure it's detected with "adb devices"
3 - Make sure you have Java Runtime Environnement 5 or later installed.
4 - Click HERE -http://androidscreencast.googlecode.com/svn/trunk/AndroidScreencast/dist/androidscreencast.jnlp . You can launch it by typing "javaws androidscreencast.jnlp" from a command line.
If mouse/keyboard control doesn't work, open a command line and type :
**adb shell
**su
**chmod 777 /data/dalvik-cache
**cd /data/dalvik-cache
**chmod 777 ./
Features
**Mouse and keyboard control FOR ROOTED DEVICES ONLY
**Landscape mode (right click)
**Video recording
**Basic file browser
Current limitations
**Slow refresh rate (about 4-5 fps)
**Not all keycode are mapped. See KeyMapping
Todo
**Automatic screen rotation based on the device current state.
**Improve speed
**Audio redirection
How can i help ?
Just visit here - http://code.google.com/p/androidscreencast/
and Donate them
For Installation-
Copy the downloaded androidscreencast.jnlp file to anywhere you want.
Run Command Prompt.
Go to the folder that u have placed aandroidscreencast.jnlp
Type this javaws androidscreencast.jnlp

Setting up NAS with Auto Backups on the rPi

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!!!

[How-To] Root an Android Virtual Device (AVD) [Video]

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?

Workaround to remap home key

Hello! So I gave up a lot of time ago on having a custom launcher that was opened automatically instead of the stock launcher, but a while ago I thought about a way of using adb logcat to catch the events that launch the stock launcher and replace it with Wolf Launcher (or any other app, actually).
Disclaimer: this method requires a home server where you can run a docker instance or a bash script. It does not work directly inside FireTV.
I have not noticed any performance degradation in the firetv itself, and the latency is almost unnoticeable, to the point I can't even see a frame of the stock launcher (check video below).
I have put together a little script that will run a docker ubuntu instance, in which I then run this command:
./adb logcat '*:I' | grep --line-buffered "ActivityManager: START u0 {act=android.intent.action.MAIN cat=\[android.intent.category.HOME\] flg=0x10[0-9]00000 cmp=com.amazon.tv.launcher/.ui.HomeActivity_vNext" | xargs -I {} ./adb shell am start -n com.wolf.firelauncher/.screens.launcher.LauncherActivity
It will look for lines in the logcat that start the activity "com.amazon.tv.launcher/.ui.HomeActivity_vNext", which happens whenever you tap the home button or choose a firetv profile.
Then it sends a command to open the Wolf Launcher (am start -n com.wolf.firelauncher/.screens.launcher.LauncherActivity).
It can be modified to either listen to other action, or to launch any other app instead of the Wolf Launcher. Hope it's useful
The wallpaper goes to Amazon, for blocking every nice thing we find with updates
Hello @daavm , can you explain how to run that script? I mean, do i need to boot from Ubuntu and open a command window or can I run it on Windows 10?
I have a Fire Tv 4k Stick with wolf launcher, but there is no way i can delete the stock launcher and my son is always pressing the home button to find some videogames i dont want him to. The problem is that Amazon doesnt allow me to hide the recommendations so my only hope is to set the home button to launch the wolf launcher so the kid wont be able to find the %%%%% videogames.
Thank you
but there is no way i can delete the stock launcher a
Click to expand...
Click to collapse
I opened the remote and affixed cello tape on the place where home button is pressed.
Viola -- I also used KODI as default launch after boot using this https[://]f-droid[.]org/packages/news.androidtv.launchonboot/
Queaven said:
Hello @daavm , can you explain how to run that script? I mean, do i need to boot from Ubuntu and open a command window or can I run it on Windows 10?
I have a Fire Tv 4k Stick with wolf launcher, but there is no way i can delete the stock launcher and my son is always pressing the home button to find some videogames i dont want him to. The problem is that Amazon doesnt allow me to hide the recommendations so my only hope is to set the home button to launch the wolf launcher so the kid wont be able to find the %%%%% videogames.
Thank you
Click to expand...
Click to collapse
I guess you could adapt it for Windows, but this makes use of grep, which is a linux module, so you would need to rewrite the script... You can try Ubuntu WSL (https://ubuntu.com/wsl) and run it there I guess
alpenmmilch said:
I opened the remote and affixed cello tape on the place where home button is pressed.
Viola -- I also used KODI as default launch after boot using this https[://]f-droid[.]org/packages/news.androidtv.launchonboot/
Click to expand...
Click to collapse
Hey any idea if firestick supports external control protocols? I stumbled on a Siri shortcut that allows me to control my tcl tv with siri and I’m wondering if I can do the same with the firestick, there has to be a way tho because how else would the firestick app work?
Thanks for sharing!
From your video it looks very good.
I did something with Tasker, when I click on home it shows the Amazon launcher and jumps into Wolf Launcher, but you can clearly see the delay. Takes 1-2 seconds till Wolf Launcher is on.
Why do I need a Linux server with a Docker container?
The command is an ADB command?
Can I just run Remote ADB Shell on my smartphone and connect to my FireTV and copy & paste your code?
Falcon_X said:
Thanks for sharing!
From your video it looks very good.
I did something with Tasker, when I click on home it shows the Amazon launcher and jumps into Wolf Launcher, but you can clearly see the delay. Takes 1-2 seconds till Wolf Launcher is on.
Why do I need a Linux server with a Docker container?
The command is an ADB command?
Can I just run Remote ADB Shell on my smartphone and connect to my FireTV and copy & paste your code?
Click to expand...
Click to collapse
The docker container is just what I decided to use because I use Unraid on my home server. You can just do it on a linux machine without docker. It's just adb, yes.
Not sure how Tasker does it so can't help you with the delay. Haven't used Remote ADB Shell either, so I don't know. Sounds like it would work, but not sure how you would keep it in the background.
daavm said:
The docker container is just what I decided to use because I use Unraid on my home server. You can just do it on a linux machine without docker. It's just adb, yes.
Not sure how Tasker does it so can't help you with the delay. Haven't used Remote ADB Shell either, so I don't know. Sounds like it would work, but not sure how you would keep it in the background.
Click to expand...
Click to collapse
doesn't work. Sadly.
With your command, I got the error, that ./adb doesn't exist. Is adb a file or a folder?
I've tried to create this folder, but as I don't have root access I can't create a folder inside root.
I changed the paths in your command to /storage/emulated/0/adb but I get the error:
/storage/emulated/0/adb: can't execute: Is a directory
/storage/emulated/0/adb: Permission denied
Tried the same with creating a file called adb inside the adb folder - but the same Permission denied
Falcon_X said:
doesn't work. Sadly.
With your command, I got the error, that ./adb doesn't exist. Is adb a file or a folder?
I've tried to create this folder, but as I don't have root access I can't create a folder inside root.
I changed the paths in your command to /storage/emulated/0/adb but I get the error:
/storage/emulated/0/adb: can't execute: Is a directory
/storage/emulated/0/adb: Permission denied
Tried the same with creating a file called adb inside the adb folder - but the same Permission denied
Click to expand...
Click to collapse
? you are trying to run this in the fire tv directly, you have to run it from a linux machine. Download the platform-tools.zip for Android, unzip it, and you will have the adb file there. Again, run this in a linux machine, not inside the fire tv.
I have created a Docker container using the following command on my Synology nas:
sudo docker run -i -t --network=host ubuntu:latest /bin/bash -c "apt-get update && apt-get install -y android-tools-adb && /bin/bash"
With adb connect x.x.x.x:5555 I create a connection to the device and with adb shell I open a command line.
I have removed the ./ before the adb in the script.
But I don't know if it will work like this, I will get my Fire Cube tomorrow.
@daavm
I believe you have connected the device to the docker container via usb and are not running the script remotely.
I would have to find a way to build a Docker container that would automate this and run it remotely if it worked that way.
poyo1975 said:
I have created a Docker container using the following command on my Synology nas:
sudo docker run -i -t --network=host ubuntu:latest /bin/bash -c "apt-get update && apt-get install -y android-tools-adb && /bin/bash"
With adb connect x.x.x.x:5555 I create a connection to the device and with adb shell I open a command line.
I have removed the ./ before the adb in the script.
But I don't know if it will work like this, I will get my Fire Cube tomorrow.
@daavm
I believe you have connected the device to the docker container via usb and are not running the script remotely.
I would have to find a way to build a Docker container that would automate this and run it remotely if it worked that way.
Click to expand...
Click to collapse
No, I haven't connected the device via usb. I do the 'adb connect x.x.x.x:5555' as well. But that doesn't change anything.
You don't have to open the shell. Just run the script in the container.
I've created a Docker aswell, the same way poyo1975 did. Container is running.
I can connect via ADB to my FireTV in the shell from my server, but you said the script needs to run in the container and we don't have to open the shell.
I use Portainer for my Docker containers, I copied and pasted your command in the "command field" and clicked on "deploy container".
I get the error:
failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "./adb": stat ./adb: no such file or directory: unknown
Still to dumb to understand the whole thing, for me it's more like a trial and error. Hope to get another hint from you daavm
Hi Falcon_X,
I also use portainer, you can build yourself an image.
I have attached my dockerfile and 2 script files.
Just click in Portainer under image build new image and then in the web editor paste the content of the dockerfile.Under upload paste the two script files and click on build.You have to give the image a name for example ubuntu-adb.The adb-connect script file you have to edit with an editor and change the ip address of your firetv.After the image is built you can under the tab container create a new container with the name you gave when creating the image.
At every container restart a connection to the firetv is established and the script of daavm is started.
Should work, but I can only test it tomorrow.
Many thanks to daavm for his script
Falcon_X said:
I've created a Docker aswell, the same way poyo1975 did. Container is running.
I can connect via ADB to my FireTV in the shell from my server, but you said the script needs to run in the container and we don't have to open the shell.
I use Portainer for my Docker containers, I copied and pasted your command in the "command field" and clicked on "deploy container".
I get the error:
failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "./adb": stat ./adb: no such file or directory: unknown
Still to dumb to understand the whole thing, for me it's more like a trial and error. Hope to get another hint from you daavm
Click to expand...
Click to collapse
Again, ./adb will only work if you have downloaded platform-tools zip and unzipped it (which has adb inside). Alternatively, you can do apt install adb, and replace "./adb" by just "adb"
As an update, I now use the following script as a custom script in a linuxserver/webtop container (check linuxserver docs on how to use custom scripts):
Bash:
#!/bin/bash
echo "**** Installing ADB ****"
apt update && apt install -y adb
adb connect 192.168.0.97:5555
while true; do adb logcat | grep -G --line-buffered "ActivityManager: START u0 {act=\(com\.amazon\.tv\.action\.LAUNCH_PROFILE_PICKER\|android\.intent\.action\.MAIN cat=\[android\.intent\.category\.HOME\]\) flg=0x10\(0\|1\|2\)00000 cmp=com\.amazon\.\(tv\.launcher/\.ui\.HomeActivity_vNext\|ftv\.profilepicker/\.ui\.PickerActivity\)" | xargs -I {} adb shell am start -n com.wolf.firelauncher/.screens.launcher.LauncherActivity; done
I included the profile picker listener because I didn't want to have to select the profile every single time.
Awesome. Works flawlessly. Thank you!
Running on a old debian based raspberry pi zero.
Thanks again to daavm and poyo1875. Works!
Update: Only works until you shutdown the FireTV :-(
thanks
daavm said:
As an update, I now use the following script as a custom script in a linuxserver/webtop container (check linuxserver docs on how to use custom scripts):
Bash:
#!/bin/bash
echo "**** Installing ADB ****"
apt update && apt install -y adb
adb connect 192.168.0.97:5555
while true; do adb logcat | grep -G --line-buffered "ActivityManager: START u0 {act=\(com\.amazon\.tv\.action\.LAUNCH_PROFILE_PICKER\|android\.intent\.action\.MAIN cat=\[android\.intent\.category\.HOME\]\) flg=0x10\(0\|1\|2\)00000 cmp=com\.amazon\.\(tv\.launcher/\.ui\.HomeActivity_vNext\|ftv\.profilepicker/\.ui\.PickerActivity\)" | xargs -I {} adb shell am start -n com.wolf.firelauncher/.screens.launcher.LauncherActivity; done
I included the profile picker listener because I didn't want to have to select the profile every single time.
Click to expand...
Click to collapse
thanks! it's looks worked!
i have 2 questions
1. The adb log looks like this, is it normal?
2. Oops, when i press home, I can still see the Amazon home page, it will start after about 1 second.
Code:
Starting: Intent { cmp=com.wolf.firelauncher/.screens.launcher.LauncherActivity }
Warning: Activity not started, its current task has been brought to the front
Starting: Intent { cmp=com.wolf.firelauncher/.screens.launcher.LauncherActivity }
Warning: Activity not started, its current task has been brought to the front
Starting: Intent { cmp=com.wolf.firelauncher/.screens.launcher.LauncherActivity }
Warning: Activity not started, its current task has been brought to the front
...
SevenFXD said:
thanks
thanks! it's looks worked!
i have 2 questions
1. The adb log looks like this, is it normal?
2. Oops, when i press home, I can still see the Amazon home page, it will start after about 1 second.
Code:
Starting: Intent { cmp=com.wolf.firelauncher/.screens.launcher.LauncherActivity }
Warning: Activity not started, its current task has been brought to the front
Starting: Intent { cmp=com.wolf.firelauncher/.screens.launcher.LauncherActivity }
Warning: Activity not started, its current task has been brought to the front
Starting: Intent { cmp=com.wolf.firelauncher/.screens.launcher.LauncherActivity }
Warning: Activity not started, its current task has been brought to the front
...
Click to expand...
Click to collapse
The Adb log looks the same for me, too.
When I press home, I don't see the Amazon Launcher.
But when I shutdown the FireTV and my container is still running, it just shows: -- waiting for device --
When I turn the FireTV back on, it's still not recognized (IP is still the same).
Looks like I have to connect via ABD and re-run the script every time again, when I turn on the FireTV after a shutdown.
Can someone confirm this or is it just me?

Categories

Resources