[Method] Automate the Theater Mode - Wear OS General

******************************
A late note:
below contents were written in May2015, after some days I paid my attention to other things (now Oct2015).
If you are new to read, and really interested to achieve this, you may also read the following comments, which may contain some new thoughts/ better methods.
Currently my new watch system is not rooted and am not so hungry on battery. But I promise I will be back to tidy through when I got spare time.
Thanks again for reading.
******************************
I got a way to automate the "Theater mode" of my watch.
I would like my wear to auto switch to "Theater mode" at night and exit every morning to save battery. (Just too lazy to remember to switch it when sleeping ). The real problems are ①google doesn't provide an API for developers ②currently no good method to execute native standalone command on watch.
My basic idea is to simulate a double tap on power button using shell. This would not be that difficult like ②..
Seems current apps don't provide such function: like autowear, weartasker,tasker for wear.... none of them provide a function of executing command on watch.
Then I used thread of gusano38 to apply a debugging of wear from phone (pretend as a PC).
Besides, there is another thread of joschi70 on wearshell, I don't know much about bean shell, so no idea whether it can modify wear setting rather than just retrieving info.
Here are the detailed steps:
Your phones should be rooted.
A. One time record
1. debug your watch (turn on in watch developer opition)
2. use "getevent" to find "bcmpmu_on" related event, in my case, event2
3. run command "cat /dev/input/event2 > /sdcard/doubletap", double tap your power button, then use control-C to stop the command
4. There should be a "doubletap” located in you watch /sdcard
use "cat /sdcard/doubletap > /dev/input/event2" to run and test if it is working
B. After you finish step A, you can always use the following code to trigger current Theater mode
allow bluetooth debugging
Code:
[COLOR="gray"]su
adb kill-server
export HOME=/sdcard
setprop service.adb.tcp.port 5555
stop adbd
start adbd
adb forward tcp:4444 localabstract:/adb-hub
adb connect localhost:4444
sleep 2
adb -s localhost:4444 shell "input keyevent 26; cat /sdcard/doubletap > /dev/input/event2"
setprop service.adb.tcp.port -1
stop adbd
start adbd
adb kill-server
exit[/COLOR]
Also recorded a short demo video
Note: NOT recommended for daily use, maybe you prefer a simple hardware tap, but here debugging mode may make your wear unsafe (therefore this is permanent notification)
=========================================================
It has been some time since my above post, I tried beanshell and finally solved my own problem.
The disadvantage of debug is unsafe, permanent notification, and delay(e.g. my above codes need wait 2s for adb service to be ready). No one if use wearshell.
main code
Code:
import java.lang.Runtime;
import java.io.DataOutputStream;
Process su = Runtime.getRuntime().exec("su");
DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());
outputStream.writeBytes("input keyevent 26;cat /sdcard/doubletap>/dev/input/event2;");
outputStream.flush();
outputStream.writeBytes("exit\n");
outputStream.flush();
su.waitFor();
How:
Step B:
1. install wearshell
2. Prepare above main code, you can either
save to a file (e.g. doubletap.bsh) in /sdcard of watch, and call the through source("/sdcard/doubletap.bsh")
or
directly run (sometimes need to combine into one line like intent)
3. use intent to call: de.fun2code.android.wear.shell.EXEC with extra "bsh".
Now you are free to use it daily!
{
"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 is a third update: I grayed the ADB part of first post for not confusing. This time I show how I used it.
Basically I make my watch into Theater mode and turn off Bluetooth of my phone at night. In the morning do the opposite things:
Just skip the run shell step which kills "bluetooh share" app (my phone has some problem with BT).
This is just one part pf my day/night switch tasks e.g. I also have auto airplane mode and interruption mode. By the way, I don't use airplane mode to turn off bluetooth. Simply because I want my watch to connect a little longer. To do that, you can set "airplane radios" so that you decide whether or not to turn off wifi/bluetooth/etc when you go to airplane mode.
This should save battery a little if not too much. Your decision if it helps you.
my one day sample:

I was searching a solution for this.. However this is still not a daily solution! However this puts a few steps closer at least. Thanks
Sent from my SM-G920F using Tapatalk

I have updated. wearshell worth to try.

qingtest said:
I have updated. wearshell worth to try.
Click to expand...
Click to collapse
This project looks great since it would let me automate activating theater mode with Tasker and I haven't found any other ways to do it. If I understand your post correctly, I need to save the code to a file and save on my watch's storage. How do I copy the file there?

I installed the wearshell , then placed the file with the code named doubletap.bsh in watch sdcard folder and created intent in tasker exactly like in the screenshot and nothing.. The intent goes as it should (green dot on tasker) but the watch still the same..
Sent from my SM-G920F using Tapatalk

if you have sony smart watch 3 like me, can simply plug in your usb cable, otherwise I think can use Debugging over Bluetooth.
then use "adb push" to transfer the file.

In tasker the target is Activity/Service, not BroadcastReceiver.
if this does not solve, can you just paste the codes to web shell page (can also insert 'echo xxx;'), see if there is any output or error?
If error maybe it is the root permission, as you can see my sample code needs su.
well I think the key simulation function may not necessarily need root, but I had my watch rooted (my default). You can either root watch or make a little change to the java codes (so that not requiring root permission).

qingtest said:
In tasker the target is Activity/Service, not BroadcastReceiver.
if this does not solve, can you just paste the codes to web shell page (can also insert 'echo xxx;'), see if there is any output or error?
If error maybe it is the root permission, as you can see my sample code needs su.
well I think the key simulation function may not necessarily need root, but I had my watch rooted (my default). You can either root watch or make a little change to the java codes (so that not requiring root permission).
Click to expand...
Click to collapse
I was using target as activity.
The watch wakes up the screen like if o touched it in normal mode, but nothing else.
My watch it is supposed to be rooted.. I get the # when using shell, but when I saw on code that had SU it was my first though that it might not be rooted.
What changes you suggest for the code? I'm a bit dumb on code since I'm a basic self learner...
Sent from my SM-G920F using Tapatalk

It should work. For problem shooting purpose I guest you check shell and beanshell separately.
1. Make sure adb works in the command window.
The first command "input" is to simulate power press, it should 100% work.
The second command "cat" is to simulate double press, if not working you need to redo the recording.
2. Run beanshell with any command like "echo aaa" in the webpage it should 100% work [edit: print("aaa");]
3. Run my code in webpage, should work
4. Put in tasker
Let me know which step you cannot go through.

qingtest said:
It should work. For problem shooting purpose I guest you check shell and beanshell separately.
1. Make sure adb works in the command window.
The first command "input" is to simulate power press, it should 100% work.
The second command "cat" is to simulate double press, if not working you need to redo the recording.
2. Run beanshell with any command like "echo aaa" in the webpage it should 100% work
3. Run my code in webpage, should work
4. Put in tasker
Let me know which step you cannot go through.
Click to expand...
Click to collapse
I'm having problem right on the second command... using "adb shell cat /sdcard/doubletap>/dev/input/event2" returns in command prompt "The system cannot find the path specified"... however I have triple checked and I have the file doubletap.bsh in the SDCARD folder....

I pushed the doubletap.bsh file to /sdcard and it's not working for me. Running a task with the intent doesn't do anything despite showing the green dot. My watch isn't rooted so I'm sure that's a factor. When I run the code on the web interface this is the error I get
BeanShell: error code bsh.TargetError: Sourced file: inline evaluation of: ``import java.lang.Runtime; import java.io.DataOutputStream; Process su = Runtime. . . . '' : Typed variable declaration : Method Invocation exec : at Line: 3 : in file: inline evaluation of: ``import java.lang.Runtime; import java.io.DataOutputStream; Process su = Runtime. . . . '' : .exec ( "su" )
Target exception: java.io.IOException: Error running exec(). Command: [su] Working Directory: null Environment: null
Click to expand...
Click to collapse
I tried removing what I thought was calling on su permissions but couldn't get it to work, but it may just be poor syntax. Do you know what the code would be if it's not using su?
Edit:
I can't even get the echo beanshell command to run. When I enter 'echo aaa' in the webpage I get the following:
BeanShell: error code bsh.EvalError: Sourced file: inline evaluation of: ``echo aaa ;'' : Typed variable declaration : Class: echo not found in namespace : at Line: 1 : in file: inline evaluation of: ``echo aaa ;'' : echo
Click to expand...
Click to collapse

there are two files 1. doubletap 2. doubletap.bsh.
The first one includes is generated following my step A, did you check it?

sorry "echo" is only for bash.. if you are running beanshell it should be print("aaa"); which work 100%

qingtest said:
there are two files 1. doubletap 2. doubletap.bsh.
The first one includes is generated following my step A, did you check it?
Click to expand...
Click to collapse
Thanks but I'm still overlooking something.
A. One time record
1. debug your watch (turn on in watch developer opition)
2. use "getevent" to find "bcmpmu_on" related event, in my case, event2
3. run command "cat /dev/input/event2 > /sdcard/doubletap", double tap your power button, then use control-C to stop the command
4. There should be a "doubletap” located in you watch /sdcard
use "cat /sdcard/doubletap > /dev/input/event2" to run and test if it is working
Click to expand...
Click to collapse
I need to do the above first even if I'm not using the run shell command, correct? I have my watch set to ADB debugging on, but where am I entering the commands? I'm sure I'm just not understanding what to do.

qingtest said:
A. One time record
1. debug your watch (turn on in watch developer opition)
2. use "getevent" to find "bcmpmu_on" related event, in my case, event2
3. run command "cat /dev/input/event2 > /sdcard/doubletap", double tap your power button, then use control-C to stop the command
4. There should be a "doubletap” located in you watch /sdcard
use "cat /sdcard/doubletap > /dev/input/event2" to run and test if it is working
Click to expand...
Click to collapse
I assumed we could do B without A, so I guess this was the mistake.
Still I'm lacking some knowleage to where we do this and how..
Where we go for one time record and where we run all this steps? ADB to use the "getevent" and the command?
If you could ptovide some more baby steps would be helpfull! thanks
EDITk, I guess I figured it out partially
WIth command prompt and watch screen ON run "adb shell getevent" and while running double press the button (to induce theater mode).
In my phone it showed up like this in the command prompt when I double pressed the button:
I don't get the "bcmpmu_on" on any event but rater "gpnp_pon"
could not open /dev/input/event0, Out of memory
add device 1: /dev/input/event10
name: "ssp_context"
add device 2: /dev/input/event9
name: "tilt_wake_sensor"
add device 3: /dev/input/event8
name: "hrm_lib_sensor"
add device 4: /dev/input/event7
name: "meta_event"
add device 5: /dev/input/event6
name: "step_cnt_sensor"
add device 6: /dev/input/event5
name: "uncal_gyro_sensor"
add device 7: /dev/input/event4
name: "sig_motion_sensor"
add device 8: /dev/input/event3
name: "uncal_geomagnetic_sensor"
add device 9: /dev/input/event2
name: "geomagnetic_sensor"
add device 10: /dev/input/event1
name: "qpnp_pon"
/dev/input/event1: 0001 0074 00000001
/dev/input/event1: 0000 0000 00000000
/dev/input/event1: 0001 0074 00000000
/dev/input/event1: 0000 0000 00000000
/dev/input/event1: 0001 0074 00000001
/dev/input/event1: 0000 0000 00000000
/dev/input/event1: 0001 0074 00000000
/dev/input/event1: 0000 0000 00000000
NOw it's here I'm kind of stuck.. now Im trying to use in the command prompt :
adb shell sendevent cat /dev/input/event1 > /sdcard/doubletap
I event tried
adb shell su sendevent cat /dev/input/event1 > /sdcard/doubletap
and it's returning
"The system cannot find the specified path"
what I'm I missing?

insaned said:
I assumed we could do B without A, so I guess this was the mistake.
Still I'm lacking some knowleage to where we do this and how..
Where we go for one time record and where we run all this steps? ADB to use the "getevent" and the command?
If you could ptovide some more baby steps would be helpfull! thanks
EDITk, I guess I figured it out partially
WIth command prompt and watch screen ON run "adb shell getevent" and while running double press the button (to induce theater mode).
In my phone it showed up like this in the command prompt when I double pressed the button:
I don't get the "bcmpmu_on" on any event but rater "gpnp_pon"
could not open /dev/input/event0, Out of memory
add device 1: /dev/input/event10
name: "ssp_context"
add device 2: /dev/input/event9
name: "tilt_wake_sensor"
add device 3: /dev/input/event8
name: "hrm_lib_sensor"
add device 4: /dev/input/event7
name: "meta_event"
add device 5: /dev/input/event6
name: "step_cnt_sensor"
add device 6: /dev/input/event5
name: "uncal_gyro_sensor"
add device 7: /dev/input/event4
name: "sig_motion_sensor"
add device 8: /dev/input/event3
name: "uncal_geomagnetic_sensor"
add device 9: /dev/input/event2
name: "geomagnetic_sensor"
add device 10: /dev/input/event1
name: "qpnp_pon"
/dev/input/event1: 0001 0074 00000001
/dev/input/event1: 0000 0000 00000000
/dev/input/event1: 0001 0074 00000000
/dev/input/event1: 0000 0000 00000000
/dev/input/event1: 0001 0074 00000001
/dev/input/event1: 0000 0000 00000000
/dev/input/event1: 0001 0074 00000000
/dev/input/event1: 0000 0000 00000000
NOw it's here I'm kind of stuck.. now Im trying to use in the command prompt :
adb shell sendevent cat /dev/input/event1 > /sdcard/doubletap
I event tried
adb shell su sendevent cat /dev/input/event1 > /sdcard/doubletap
and it's returning
"The system cannot find the specified path"
what I'm I missing?
Click to expand...
Click to collapse
I'm stuck at the same place you are. When I run "adb shell getevent" from the command prompt I get results that show "gpnp_pon" for event1 and there's no "bcmpmu_on". So I've tried "adb shell sendevent cat /dev/input/event1 > /sdcard/doubletap" and "adb cat /dev/input/event1 > /sdcard/doubletap" and both give me the same error, "The system cannot find the path specified."

Hi I hoped to make it clear but was too lazy to wrote every detail where I assume readers were familiar with adb.
This is the answer for you two:
①You should know the basic idea is to simulate keypress.
The "input keyevent" does not have the ability to simulate a double tap, that's why we need to use adb to record.
The recorded data is put in the file "doubletap"
②From your question, I guess you are not so familiar with cmd right?
If you run "adb cat /dev/input/event1 > /sdcard/doubletap" in dos cmd, it will actually only run the command "cat /dev/input/event1 " and retrieve the result then write to a file "/sdcard/double" in windows. However, windows does not have such a path, that's why error is reported.
③ sorry I only have played with my own watch, I think the one ‘**on’ should be equivalent to my 'bcmpmu_on'.
④ To do it right, you need to quote the command like this: adb shell "cat /dev/input/event1 > /sdcard/doubletap"
Or first go into adb shell ,then run the command (like below picture)
↑After double press, press Ctrl+C to stop. Then adb will exit with "^C"
The file should already in /sdcard/, can check like below: (in your case doubletap)
Now you can simply run below command to test. should toggle theater mode 100%: (in your case doubletap)

qingtest said:
Hi I hoped to make it clear but was too lazy to wrote every detail where I assume readers were familiar with adb.
This is the answer for you two:
①You should know the basic idea is to simulate keypress.
The "input keyevent" does not have the ability to simulate a double tap, that's why we need to use adb to record.
The recorded data is put in the file "doubletap"
②From your question, I guess you are not so familiar with cmd right?
If you run "adb cat /dev/input/event1 > /sdcard/doubletap" in dos cmd, it will actually only run the command "cat /dev/input/event1 " and retrieve the result then write to a file "/sdcard/double" in windows. However, windows does not have such a path, that's why error is reported.
③ sorry I only have played with my own watch, I think the one ‘**on’ should be equivalent to my 'bcmpmu_on'.
④ To do it right, you need to quote the command like this: adb shell "cat /dev/input/event1 > /sdcard/doubletap"
Or first go into adb shell ,then run the command (like below picture)
↑After double press, press Ctrl+C to stop. Then adb will exit with "^C"
The file should already in /sdcard/, can check like below: (in your case doubletap)
Now you can simply run below command to test. should toggle theater mode 100%: (in your case doubletap)
Click to expand...
Click to collapse
I'm familiar with command prompt and know the basics with adb. I guess it was confusing that some of the steps were very detailed so I could do exactly what you wrote, but some steps were missing things and I didn't realize it. Thank you for your patience.
After doing what was in your last post I'm able to toggle theater mode from adb on my laptop while my laptop is connected, so that's great. However doing it from the Wearshell intent still doesn't work. I copied the code you posted and changed event2 to event1, but I'm pretty sure the problem is that your code uses su and my watch is not rooted. Do you know what the code would look like without using root?
This is the error I got from Wearshell
BeanShell: error code bsh.TargetError: Sourced file: inline evaluation of: ``import java.lang.Runtime; import java.io.DataOutputStream; Process su = Runtime. . . . '' : Typed variable declaration : Method Invocation exec : at Line: 3 : in file: inline evaluation of: ``import java.lang.Runtime; import java.io.DataOutputStream; Process su = Runtime. . . . '' : .exec ( "su" )
Target exception: java.io.IOException: Error running exec(). Command: [su] Working Directory: null Environment: null
Click to expand...
Click to collapse

I just updated my watch to 5.1.1, so lost root. The code is no longer working for me either. I confirm the input and cat do not necessarily need su permission.
However, I don't have an existing code for you ( i am relative new in beanshell too). Will try and share with my spare time (you are welcome to do so too )

Thanks a million for the patience to the detailed adb explanation which helped a lot!
Already working both in Adb, Wearshell and tasker intent. I have the Watch rooted..
However I DID a slight change to the code, I had to remove the " input keyevent 26" from the line, because it was causing only the screen to turn on and without it works great. The double tap on the button for theater mode doesn't need screen on anyway, so I gave it a shot to remove and it worked.
import java.lang.Runtime;
import java.io.DataOutputStream;
Process su = Runtime.getRuntime().exec("su");
DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());
outputStream.writeBytes("cat /sdcard/doubletap>/dev/input/event1;");
outputStream.flush();
outputStream.writeBytes("exit\n");
outputStream.flush();
su.waitFor();
Click to expand...
Click to collapse

Related

Really strange problem

So I was messing around with some of the system files, just trying to learn more about everything and I decided to do a wipe to put everything back to where it was and after I wiped, it gave me an error message at bootup saying that the gapps process had to be closed. I went through the regular sign in and when I got to the main screen, the screen was black. I get the top bar but nothing else.
So I tried reinstalling JFRC33 Lite. Same thing. So I tried installing JFRC33 regular. Now I cant even get by the blinking android. I dont know what the heck is going on but I know all is not lost because I can still et to the bootloader. Can anyone help me out?
Thanks.
try putting one of the updates on your SD card and naming update.zip, and then access the phone via adb shell(if you can) if you can see it with adb devices then type "adb shell wipe all" it will COMPLETELY wipe your phone and allow you to reinstall your update, you cshould be good as root after that, if not then try a .nbh file
tubaking182 said:
try putting one of the updates on your SD card and naming update.zip, and then access the phone via adb shell(if you can) if you can see it with adb devices then type "adb shell wipe all" it will COMPLETELY wipe your phone and allow you to reinstall your update, you cshould be good as root after that, if not then try a .nbh file
Click to expand...
Click to collapse
Thanks bro! I had no idea you could wipe through the pc.
one of the many things i found when i was trying to control the phone with my computer. i have a script that when i run it on my comp it auto starts tetherbot and hits the up key on the trackball then hits enter to start the proxy, then does the adb forward tcp command and then starts firefox with all the correct settings. i also found a very complicated way to send texts with my phone using my comp keyboard and adb
tubaking182 said:
one of the many things i found when i was trying to control the phone with my computer. i have a script that when i run it on my comp it auto starts tetherbot and hits the up key on the trackball then hits enter to start the proxy, then does the adb forward tcp command and then starts firefox with all the correct settings. i also found a very complicated way to send texts with my phone using my comp keyboard and adb
Click to expand...
Click to collapse
Oh? Please share. I'm very interested in ways to control the phone from the pc.
Thanks
for the time being it is not an exact science, you need a key map(one found in my thread about the computer app to control phone) and you need to know a few commands. basically to get the phone to think you pressed a button you need to have the computer send the command: adb shell keyevent ## where ## is the number that corresponds to the key you want it to press on the phone. keys are labled 0-85 but i still have yet to figure out what 0 does and a few of the keys don't work perfectly yet but that's being worked on.
secxond you need the command "adb shell am start -a android.intent.action.MAIN -n (*********/*********)" where the *******/******* equals the program you want to start. for Steel you would type:
adb shell am start -a android.intent.action.MAIN -n com.kolbysoft.steel/com.kolbysoft.steel.Steel
that will bring up steel to your home page, after that you can type adn shell input (keyevent|text) if you do text the phone only reads one word, not sure why but i am trying to fix that as well, and if you do keyevent then you need to know what number corresponds to the key you want pressed
here is an example of a script that will start tetherbot, start the socks service, and do the tcp forwarding action
#!/bin/bash
adb shell am start -a android.intent.action.MAIN -n graha.ms.tunnel/graha.ms.tunnel.TunnelConfig ##start new instance of tetherbot or bring current one to front
adb shell input keyevent 19 ###press up
adb shell input keyevent 66 ###press enter
sleep 3
adb forward tcp:1080 tcp:1080
all the commands i have found so far i got by running adb shell logcat and reading the output as i click on different applications. if you need some help with this then i would be more than happy to help, just make sure to let me know what program you are trying to run(if it's a paid app then you will need to run logcat and attach the output after running the app) if it's a free app i'll just install it and let you know how to start the app, then you can write scripts to get your phone to do certain things. i already have a script that wipes my phone, reapplys apps to SD and resets my settings, it's kinda messy but it works

[Allwinner A10][Hack] Enabling hidden USB host on some devices.

Hello everyone, just took the time to disassemble my new Ampe A90 to find a hidden USB host inside, not currently wired to anything. For VBUS switching and other stuff to work, some work had to be done, so here are the results.
The process is not for noobs, so be careful and don't blame me if you screw things up.
grab my sw-switcher module on github, use prebuilt one it's there, or compile your own: github.com/nekromant/ampe-sw-switch
Compile and drop sw-switch.ko into /vendor/modules
Something like this will work:
Code:
adb shell
mkdir /t
mount -t vfat /dev/block/nanda /t
cd /t
CTRL+C
adb push sw-switch.ko /vendor/modules/sw-switch.ko
grab a copy of these: github.com/amery/sunxi-tools
Use those to edit script.bin:
Code:
adb pull /t/script.bin
bin2fex script.bin script.fex
Edit script.fex with your favourite editor (I used emacs), look for line
usb_host_init_state = 1
and change that to
usb_host_init_state = 0
save, exit the editor, compile and push it back.
Code:
fex2bin script.fex nscript.bin
adb push ./nscript.bin /t/script.bin
adb push ./nscript.bin /t/script0.bin
Reboot.
Now once the module is inserted, you can enable it using something like this:
Code:
echo "host 1 1" > /sys/module/sw_switch/power
and disable with
Code:
echo "host 1 0" > /sys/module/sw_switch/power
First number is the host number. 0 is always the udc, the dual-role one, On Ampe A90 the host with number 1 is left on PCB with nothing attached, and host number 2 is connected to the wireless chip and managed by the 8192cu module. So it's only the first one, that needs switching.
I also threw on GUI for that, I'll put the sources to github for that later, when I get home, while now you can grab the apk atached: View attachment usb_switcher.apk
P.S. Electrically, VBUS is enabled and disabled by a GPIO line. This registers the host and enables it, but power switching might be unavaliale. Some surrounding electronics, that enable and disable VBUS might be missing, and I will only test that once I get to the lab next weekend.

(Tutorial) Setting up Linux for ADB to recognize Pantech Burst

Anyone wanting to use adb with your Pantech Burst through Ubuntu/Linux... follow these steps (these steps will make accessing adb much easier and allow abd to recognize your phone)[Please note - modifying the .bashrc in step 1 is not required; it will just make using Android SDK much easier for beginners]:
1. Modifying the PATH Environment Variable will help out immensely when it comes down to making use of SDK tools like ADB. Doing this will also allow you to execute certain protocols like ADB from ANY location. So if you're operating from the Desktop, you don't have to redirect to the SDK's platform-tools folder to make use of ADB if you need to make use of it.
To modify the PATH variable of your system, you need to edit your .bashrc file. To do so, in a terminal, execute the following command:
$ nano ~/.bashrc
You will now have the Nano text editor enabled on the terminal. Now, at the very top of the file(yes, that means go to the top and hit enter to create some space at the top. Then just copy and paste - a caveman really could do it!), enter the following:
#AndroidDev PATH
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools
Once you're finished, press CTRL + X, Y, and then hit Enter to save your changes and exit the Nano text editor.
2. Now that we have our PATH variable set up, we need to make sure our hardware will be detected once we initialize ADB. However, Ubuntu won't allow ADB access to the Android phone via USB unless the appropriate udev rule is set. This is Bug #316215. In order to get around this rule, you need to create a rule file as root.
In a terminal, execute the following command that will create the rule file. This will utilize the graphical sudo command, so that we can still have control over the file if we're not a root user.
Now, you create a file:
sudo nano /etc/udev/rules.d/51-android.rules
Copy and paste the following udev rule in the text editor that opened up which contains the new rule file we created:
SUBSYSTEM=="usb", ATTRS{idVendor}=="10a9", MODE="0666"
Once you've copied and pasted the udev rule in the text editor which contains your newly created rule file, save your changes and quit (Control+X, Y, Enter). Now that you've set your udev rule you have to reboot (shut down terminal and reopen; I also recommend unplugging your phone from usb and plugging it back in) so that ADB will be in your path.
To test your changes, open up a terminal and execute the following:
$ adb devices
You should now see:
List of devices attached
PRESTO01111085383518 device
If you see:
List of devices attached
???????????? no permissions
Reread this post and try to follow directions next time.
idProduct
To complete we can add the "idProduct"
On my computer doing in the console "lsusb":
Bus 001 Device 006: ID 10a9:6050 SK Teletech Co., Ltd
Click to expand...
Click to collapse
So, if I'm not mistaken, the line including "idProduct" would be:
SUBSYSTEM=="usb", ATTRS{idVendor}=="10a9", ATTRS{idProduct}=="6050", MODE="0666"
Click to expand...
Click to collapse
Thank you. Greetings.
worked for me!
USB debugging also needs to be on. To enable it, the USB cable must be disconnected.
My adb devices only picked it up after I switched the USB connection type to USB Storage mode. Not sure if that's necessary but it could help.
Also, slight typo here:
jackattack79 said:
In a terminal, execute the following command that will create the rule file. This will utilize the graphical sudo command, so that we can still have control over the file if we're not a root user.
Now, you create a file:
sudo nano /etc/udev/rules.d/51-android.rules
Click to expand...
Click to collapse
I think either terminal "sudo nano" or "gksudo gedit" will work just fine. But you should remove the bit about "this will utilize the graphical sudo command" when using "sudo nano" so as not to confuse people!
But anyway, thanks! The method worked and now I am off to the races.

[APP][2.2+] Remote ADB Shell

Overview
Remote ADB Shell is a simple terminal app that allows you to connect to the ADB shell service of another Android device over the network. This works in the exact same way that the "adb shell" command works on a computer. Because this app uses a native implementation of the ADB protocol in Java, it does not require root on either device or any 3rd party apps on the target device. The devices simply speak the same protocol to each other that they would to a computer running the ADB client from the Android SDK.
Features
Command history (accessible by long pressing the command box)
Send Ctrl+C (accessible by long pressing the terminal view)
Auto-scroll (with toggle accessible by long pressing the terminal view)
Screenshots
{
"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"
}
Instructions
IMPORTANT: Android 4.2.2+ devices use RSA keys to authenticate the ADB connection. These devices will need to be plugged in to a computer the first time you connect to them (from each device with this app installed). This allows them to display the public key acceptance dialog, which you must accept (and check "Always allow from this computer").
To configure a stock un-rooted target, plug the target device into a computer and run "adb tcpip 5555". This will start ADB listening on port 5555 on the target device. The device can then be unplugged and will remain configured properly until reboot.
For devices that are rooted (although it's not required), you can install one of the several "ADB WiFi" apps to enable the ADB server to listen over the network. Devices with a custom ROM may have an option to enable ADB over the network in the Developer Options pane of Settings. Using either of these methods will properly configure ADB for network access with this app. The extra step for 4.2.2+ is still required for the initial connection.
To connect to your remote Android device, type in the IP address of the device and the port number (5555 from the example above) in Remote ADB Shell. Tap Connect and it will attempt to connect to the device and start up the terminal.
Notes
This app is unique because it runs a custom ADB implementation that I wrote from scratch in Java. I plan to open-source my ADB implementation on GitHub or Google Code once I give it a bit of cleanup and documentation. Using this custom ADB implementation means that I don't require an ADB binary or root on the device running the app. Because it speaks standard ADB, it doesn't require anything special on the target either.
Please post feature requests or suggestions here and I'll do my best to work on them.
Download
The app is available on Google Play for free. https://play.google.com/store/apps/details?id=com.cgutman.androidremotedebugger
Hi, cgutman - I actually have a feature request.
But first, let me say thank you for providing this featureset in an app I already have gotten a fair amount of use out of it.
Backstory:
I use adb shell commands to automate repetitive processes on a Fire TV (Android Settop Box, connected to a TV, runs apps), like launching certain apps, performing certain actions - and so on.
I actually have about 20 actions across multiple Applescript apps on the Mac that allow me to remote controll apps like Spotify or Pandora - and your app allows me to do that from an Android device (smartphone) as well.
That said - I run into two major speedbumps.
Without a "Bookmarks" feature (store a certain shell script, give it a name, be able to edit it, execute it on click), so far I can only effectively cycle through two scripts (using the "recent history" feature in your app) - and I'd like to be able to use 20+ scripts eventually. A bookmark list (sorted by name) would be great for my purpose.
Second - to really be able to speed up the use of those items a launcher shortcut feature would be great. It could look up and reference the bookmark entries from the suggestion above - or let you set an IP and enter a command in the shortcut dialogue (Terminal Emulator does it that way). Maybe even with an auto exit option (although "&& exit" works just as well right now (*yay*) - but people would have to know to use it). Also it should allow you to name the shortcut, before creating it.
The reason why this would be great is to reduce steps. Right now I have to open the app, connect to the remote Android device, longpress on the command line entry field, select a history item, press enter - press OK once the app has finished the script, then exit the app.
It would be great to be able to automate all of this down to one launcher shortcut click.
To give you an Idea - what I am using the app for currently - here is one of the scripts I wrote today:
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
This opens the netease app and starts the "daily recommended" playlist.
Code:
input tap 60 100 && sleep 0.8 && input tap 60 100 && sleep 0.8 && input tap 60 100 && sleep 0.8 && input tap 1444 1030 && sleep 0.8 && exit
This exits the app cleanly - and so on...
Again - I've set up dozens of scripts like that on my Mac to be able to navigate Pandora, and spotify - to pull files, make screenshots, and so on and so forth. If you could implement said features (again - Terminal Emulator has them.. ) - your app would allow me to realize the same functionality on my smartphone.
Thank you for reading through my posting and contemplating the idea -
so long
h.
edit: Also thank you for already exiting the session cleanly (adb disconnect) once you type in exit. The Fire TV only allows one adb session at a time, so this is great.
Found a way to make the app a little more usable "as is" for my purposes in the meantime. Part of my problem was, that the shell scripts turned out quite complex - so I couldnt run several of them - because they weren't instantly recognizable on the run history level.
The temporary workaround for me was to move the commands as shell scripts to a folder (I named "shell") in /system on the target device and make them executable. That way the history in Remote ADB Shell stays cleaner and is better parseable by humans.
This is what it looks like now:
http://i.imgur.com/AuGFZ0a.png
Just right. Thank you.
Love this app! However I would like to ask if it were possible to send adb commands from outside the app using apps like Tasker. This could already simply be done by sending your app and intent with the ip, port and command.
I just created a Tasker Plugin myself using the AdbLib library! Have a look if you like https://play.google.com/store/apps/details?id=com.ADBPlugin
Trying to connect to my phone but I am not getting device authorization messages.
Great application, thank you.
My task:
- - the device has no Root
- in the directory / tmp there is a binary file su and SuperSU.apк for this device
- How to launch an "adb root shell tcpip:5555" using your application on the this device?
may be:?
1) adb tcpip:5555
2) adb root
3) adb tcpip:5555
4) adb remount
5) "adb shell"
6) or without "adb shell" -> adb pull ... adb pushh... adb reboot...
This is possible?
Or is this impossible in principle?
I'm having trouble installing apk's with this. The normal command that I use on Windows doesn't seem to work...
Could it be having trouble finding the file on my phone while trying to send it to my fire stick?
Kranium31 said:
I'm having trouble installing apk's with this. The normal command that I use on Windows doesn't seem to work...
Could it be having trouble finding the file on my phone while trying to send it to my fire stick?
Click to expand...
Click to collapse
You can't, it's just "adb shell" commands (where you leave out the adb shell part), not "adb install" for instance.
---------- Post added at 12:23 AM ---------- Previous post was at 12:20 AM ----------
AS2107 said:
Great application, thank you.
My task:
- - the device has no Root
- in the directory / tmp there is a binary file su and SuperSU.apк for this device
- How to launch an "adb root shell tcpip:5555" using your application on the this device?
may be:?
1) adb tcpip:5555
2) adb root
3) adb tcpip:5555
4) adb remount
5) "adb shell"
6) or without "adb shell" -> adb pull ... adb pushh... adb reboot...
This is possible?
Or is this impossible in principle?
Click to expand...
Click to collapse
The app only connects via "adb shell", so only those commands are possible, so no "adb install", "adb tcpip" or whatever. It's like typing "adb shell" on a PC and then you're able to give direct commands to the phone like moving a file with "mv /sdcard/Download/file /sdcard"
Hello I am having an issue
I want to use the adb on my own device (meaning only one device is being used)
I am able to connect the adb shell but whenever I try to type the following command it gives the error adb not found
adb shell sh /sdcard/.chaozhuo.gameassistan2/inject.sh
If anyone knows what the issue is Plz help
Thanks in advance
I just bought a 2019 Nvidia Pro. I installed your Wolf Launch and was attempting to install a widget. A prompt appears and states my device doesn't support a widget and have to run an ADB shell. Troypoint has an app for a remote adb shell as so do others, but I cannot find one for a nvidia.
In the widget binding failure the code it is telling me to type is, appwidget grantbind --package com.wolf.firelauncher --user 0
I was all set to do this but the firelauncher gave me pause. The device I am attempting this on isa 2019 Nvidia Pro v.9.0.1 + hotfix 1
need confirmation this is the correct code for my device.
Thanks,

Sprint Galaxy S6 Kernel Hackery (Broken Screen)

Hi there XDA. Long time lurker, first time poster. Many general thanks to everyone over the years.
So my screen completely gave out a couple of days, but the phone still works. I can still make voice commands etc. I recently lost my other computer where i did most of my ADBing from, so when i hook it up to my temporary laptop, adb is returning "unauthorized." Basically what I want to do is try something like: http://forum.xda-developers.com/showthread.php?t=2786395 but none of the tools i've found is allowing me to modify any of the kernel boot.img i've found. Unpacking works, but repacking is failing somewhere. It is making a .img file but when attempting to reunpack it just errors out. The new boot.img is also about 2K smaller than original which shoiuldn't be the case as I added 3 lines of text to the build.prop file.
So, I ask, does anyone know of a preexisting adb debug enabled and open (no auth required) kernel that I can fastboot? If not, does anyone know of any tools that can properly unpack/repack a boot.img for the S5. Finally, any other potential options of gaining control over my phone for the next week or so while awaiting a replacement? I can also install apps from the google play store, idk if any have services that will start automatically after rebooting that would basically give me VNC type access?
Thanks in advance for your time!
Much easier than that actually
Update:
So to get into an android phone it's actually quite easy.
To solve unauthorized device from adb:
Step 1: Reboot into recovery mode.
Step 2: Run "adb shell" from the ADK.
Step 3: backup /data/misc/adb/adb_keys [optional] by entering command "cp /data/misc/adb/adb_keys /data/misc/adb/adb_keys.bak"
Step 4: Type "exit" to leave shell.
Step 5: Using adb, push adbkey.pub (In .android of your home directory) to /data/misc/adb/adb_keys
Step 6: Reboot phone.
If you didn't already have USB debugging enabled for some reason:
Step 1: Reboot into recovery
Step 2: Run "adb shell" from the ADK.
Step 3: In the shell enter commands:
mkdir /realsystem
mount /dev/block/platform/15570000.ufs/by-name/SYSTEM /realsystem #Note: This will vary by device but should be very close to actual command.
echo "persist.service.adb.enable=1" >>/realsystem/build.prop
echo "persist.service.debuggable=1" >>/realsystem/build.prop
echo "persist.sys.usb.config=mass_storage,adb" >>/realsystem/build.prop"
reboot #Or follow above steps if both need to be done, they can be done at once.

Categories

Resources