Controle a tablet remotely with ADB - Android Q&A, Help & Troubleshooting

I have a small local network:
• A router not connected to the Internet
• 20 tablets that connect to it
• a computer under linux with LAMP
• a computer under windows with WAMP
When I want to install new apps on the tablets, I have to plug them one by one into a computer and run ADB commands. Would it be possible to execute these commands over WiFi? All tablets are rooted and the network is secure because there is no internet access. So I wouldn't be afraid to use security holes to carry out adb commands over WiFi.
Example of remarkable ADB commands:
• Place files on the tablet: adb push C:/APPLICATIONS/TitaniumBackup/ /sdcard/
• Install several applications: for %f in (C:\ APPLICATIONS\*.Apk) do adb install -t -g -r "%f"
• Start an application: adb shell am start -n com.package.name/com.package.name.ActivityName
•take photos
• activate or deactivate wifi
• Re-boot the tablet: adb reboot
• etc.
I would like to be able to do this on all 20 tablets via the wifi network rather than plugging them one by one into my computer.
Thank you in advance for any ideas you can share with me.

Michael5713 said:
I have a small local network:
• A router not connected to the Internet
• 20 tablets that connect to it
• a computer under linux with LAMP
• a computer under windows with WAMP
When I want to install new apps on the tablets, I have to plug them one by one into a computer and run ADB commands. Would it be possible to execute these commands over WiFi? All tablets are rooted and the network is secure because there is no internet access. So I wouldn't be afraid to use security holes to carry out adb commands over WiFi.
Click to expand...
Click to collapse
Keyword: Wireless ADB. See also here.

Michael5713 said:
I have a small local network:
• A router not connected to the Internet
• 20 tablets that connect to it
• a computer under linux with LAMP
• a computer under windows with WAMP
When I want to install new apps on the tablets, I have to plug them one by one into a computer and run ADB commands. Would it be possible to execute these commands over WiFi? All tablets are rooted and the network is secure because there is no internet access. So I wouldn't be afraid to use security holes to carry out adb commands over WiFi.
Example of remarkable ADB commands:
• Place files on the tablet: adb push C:/APPLICATIONS/TitaniumBackup/ /sdcard/
• Install several applications: for %f in (C:\ APPLICATIONS\*.Apk) do adb install -t -g -r "%f"
• Start an application: adb shell am start -n com.package.name/com.package.name.ActivityName
•take photos
• activate or deactivate wifi
• Re-boot the tablet: adb reboot
• etc.
I would like to be able to do this on all 20 tablets via the wifi network rather than plugging them one by one into my computer.
Thank you in advance for any ideas you can share with me.
Click to expand...
Click to collapse
Yes, android supports ADB over WiFi.
Do a google search for:
"ADB over Wifi"
Sent from my SM-S767VL using Tapatalk

Yes, indeed, the answer was easily found on the web. I asked it because that day I split one big issue into several smaller ones to post requests on your forum. And I never imagined it would be so easy to connect 20 tablets to each other using a local wifi network and adb. The app jwoegerbauer recommended to me is just wonderful. Now I can:
- simultaneously install an application on the 20 tablets from my PC:
FOR /F "skip=1" %x IN ('adb devices') DO start adb -s %x install -r "my-apk.apk"
- uninstall an application on the 20 tablets
- place folders or files I want where I want on all the tablets (they are rooted):
FOR /F "skip=1" %x IN ('adb devices') DO start adb -s %x push C:/my-file/ /sdcard/
- take a file from each tablet or delete it
- even take a screenshot of the tablet I want:
adb -s 192.168.43.122:5555 shell screencap /sdcard/testadb/screen.png
or 20 tablets:
FOR /F "skip=1" %x IN ('adb devices') DO start adb -s %x shell screencap /sdcard/testadb/screen.png
Many thanks to jwoegerbauer for recommending the Wireless ADB application to me.
However, I would like to explore the matter further. The problem I'm looking to solve is to manage a group of tablets without internet and without having to pay an MDM (Android mobile device manager). With ADB, I can install and uninstall applications and send or receive files. Here is what remains to be done:
- I am learning how to remotely change the settings of my 20 tablets. Imagine how tedious it is to turn on the wifi on each of the tablets, then select a network and enter the password. Sometimes I need to turn off wifi or change networks on all tablets. I also have to change the default display or font size. Last week, I've had to set the time and time zone on each one because "network provided time" does not work in a local area network not connected to the Internet. I will tell you which adb formulas I have tested if anyone is interested.
- I also started an other thread on xda-developers: Remotely modify the settings of an android application. Indeed, it takes a plenty of time to manually change the preferences and datas of an application already installed on 20 tablets. If you have any ideas on this, I'd be happy to read your ideas on the forum.

AFAIK USB hubs with 20 ports exist

Related

[Q] How to fix edit of platform.xml gone wrong on Note3 SM-N9005?

I did a search and have found similar threads. However, people seem to have been intelligent and back up stuff or installed recovery apps before screwing around with their phones. I did not.
I have a Samsung Note3. Kit Kat 4.4.2 installed OTA once I had it up and running. I rooted it. However, the version of Kit-kat has a famous issue in that it would not allow apps to write to the SD card. I found a site with manual instructions to edit the platform.xml to overcome this issue. The site is as below:
winaero.com/blog/unlock-external-sd-card-writing-for-all-apps-in-android-4-4-kitkat/
However, something went awry after rebooting. I could not see anything on my SD card and I was unable to edit the platform.xml. A solution seemed to be to flash the ROM (using ODIN 3.07). I did this and currently have Baseband version N9005XXUENB1 and Build Number KOT49H.N9005XXUENB7
However, the still has lots of issues. I can stick in a password on wifi and connect to the network but it does not actually communicate with the internet. The H with up and down arrows appears for 3g connectivitiy but also does not work. Bluetooth does not work. Youtube has stopped working errors are common. I am unable to install any apps as cannot use play store, etc. I have pictures and mp3s on my SD card but gallery comes up empty as does music app. The only "file explorer" I seem to have is "my files" app. It comes up as empty (although it shows Total storage available for both SD memory and device storage as using 25/32 and 22/29 respectively.
I am guessing that flashing the ROM did not remedy the corrupt platform.xml in the permissions folder. I think the folder path was etc/permission/platform.xml although am not an expert with android. I was hoping someone might be able to give me a solution to fix the issue. Preferably a completely fresh and clean wipe type solution. Although as I am a "newbie" the greater the simplicity of the solution the better.
Apologies for the length of this issue!
T
laconical said:
I did a search and have found similar threads. However, people seem to have been intelligent and back up stuff or installed recovery apps before screwing around with their phones. I did not.
I have a Samsung Note3. Kit Kat 4.4.2 installed OTA once I had it up and running. I rooted it. However, the version of Kit-kat has a famous issue in that it would not allow apps to write to the SD card. I found a site with manual instructions to edit the platform.xml to overcome this issue. The site is as below:
winaero.com/blog/unlock-external-sd-card-writing-for-all-apps-in-android-4-4-kitkat/
However, something went awry after rebooting. I could not see anything on my SD card and I was unable to edit the platform.xml. A solution seemed to be to flash the ROM (using ODIN 3.07). I did this and currently have Baseband version N9005XXUENB1 and Build Number KOT49H.N9005XXUENB7
However, the still has lots of issues. I can stick in a password on wifi and connect to the network but it does not actually communicate with the internet. The H with up and down arrows appears for 3g connectivitiy but also does not work. Bluetooth does not work. Youtube has stopped working errors are common. I am unable to install any apps as cannot use play store, etc. I have pictures and mp3s on my SD card but gallery comes up empty as does music app. The only "file explorer" I seem to have is "my files" app. It comes up as empty (although it shows Total storage available for both SD memory and device storage as using 25/32 and 22/29 respectively.
I am guessing that flashing the ROM did not remedy the corrupt platform.xml in the permissions folder. I think the folder path was etc/permission/platform.xml although am not an expert with android. I was hoping someone might be able to give me a solution to fix the issue. Preferably a completely fresh and clean wipe type solution. Although as I am a "newbie" the greater the simplicity of the solution the better.
Apologies for the length of this issue!
T
Click to expand...
Click to collapse
Sounds like a bit of a pickle. Since you know that Odin is working and the firmware you have at least flashes correctly, I'd consider installing a custom recovery, backing up EFS folder (and the rom too, just in case there is some weird issue with Odin the 2nd time around) , then wipe everything - /system included. This will make your phone not be able to boot up at all because it will wipe the OS off. Then just boot directly to Download and redo the firmware flash. Something else to consider since you do have the international version, is that some of the firmwares you install might be more carrier or region specific, so there might be a better option to install. I know that there is a some slightly newer version that has NC2 in it as I was trying to fix one of these phones the other day that could not register on any network and ran across that build. Do you remember the build number of the software before you started modding?
Hello. Thanks for the reply.
I am going to ask what are probably very obvious questions but I am a little out of my depth.
1) What does installing a custom recovery involve?
2)How would I backup the EFS directory? When I had ES file explorer I would have been able to try and find it. However, as it is I do not know how to find the directory and back it up. I have connected the phone to a windows laptop and it shows up as note3 but there are no folders or files visible in either the phone or on the card.
3) What is the procedure to "wipe everything"?
I think the final part I know how to do with ODIN. Just go to download boot and load and run odin with the ROM.
I got the BTU ROM is that not for the UK? I tried looking up what NC2 was but did not really find anything the explained what it is.
Thanks again and sorry for the ignorance on my side.
Let's put the custom recovery and all that on the back burner for now.
Was your phone unlocked from the factory or did you get it from a carrier? If from a carrier, which, and is it unlocked now or you are still using it with the original carrier? This one is for Vodaphone http://www.sammobile.com/firmwares/3/?download=27401 but if you are unlocked, it should work anyway, I believe.
Thanks to the people for their replies. I managed to solve the issue as below.
As mentioned previously I had flashed using ODIN and BTU version of N9005XXUENB7. The only other thing that was then required was to enter the recovery (I think power + volume up + home and then release power once samsung name appears). I then selected wipe data/factory. A reboot later and everything was solved.
es0tericcha0s said:
Sounds like a bit of a pickle. Since you know that Odin is working and the firmware you have at least flashes correctly, I'd consider installing a custom recovery, backing up EFS folder (and the rom too, just in case there is some weird issue with Odin the 2nd time around) , then wipe everything - /system included. This will make your phone not be able to boot up at all because it will wipe the OS off. Then just boot directly to Download and redo the firmware flash. Something else to consider since you do have the international version, is that some of the firmwares you install might be more carrier or region specific, so there might be a better option to install. I know that there is a some slightly newer version that has NC2 in it as I was trying to fix one of these phones the other day that could not register on any network and ran across that build. Do you remember the build number of the software before you started modding?
Click to expand...
Click to collapse
Hi, The other day i tried to fix the Platform.xml. on my S5. i noticed sometime after that when i move files using the "My files" app, the phone would not refresh the files so that they would show up in gallery, videos etc.. I tried to undo the Media_rw by using SD Maid to find the Platform.xml and Axel to rewrite the Xml. In the platform.xml. i deleted the Media_rw and replaced the old xml with the old (original) one. I rebooted my phone. On swiping to open the screen i noticed alot of apps crashing one after the other. I when back to SD Maid and searched for Platform.xml and opened it with Axel but it said file not found.. i can not use the internet, i cant use most apps, i cant even use the Kies on my computer. I cant save anything to the storage either. I really need help. Odin is the only thing i can use. but i dont know how i can reset the xml files on my phone.. What exactly am i do to?
please
christaph3r said:
Hi, The other day i tried to fix the Platform.xml. on my S5. i noticed sometime after that when i move files using the "My files" app, the phone would not refresh the files so that they would show up in gallery, videos etc.. I tried to undo the Media_rw by using SD Maid to find the Platform.xml and Axel to rewrite the Xml. In the platform.xml. i deleted the Media_rw and replaced the old xml with the old (original) one. I rebooted my phone. On swiping to open the screen i noticed alot of apps crashing one after the other. I when back to SD Maid and searched for Platform.xml and opened it with Axel but it said file not found.. i can not use the internet, i cant use most apps, i cant even use the Kies on my computer. I cant save anything to the storage either. I really need help. Odin is the only thing i can use. but i dont know how i can reset the xml files on my phone.. What exactly am i do to?
please
Click to expand...
Click to collapse
Hey, I was wondering if you ever got a fix on this without factory reset. I am having the exact same issue.
Same boat here. Please someone help!
woahs said:
Hey, I was wondering if you ever got a fix on this without factory reset. I am having the exact same issue.
Click to expand...
Click to collapse
I am having exact same problem. After editing the platform.xml, my Note 3 is behaving the same way: no access to any storage area (including USB drive), no remote access/online access (even though WIFI and 4G appear to connect just fine), most apps fail with 'Unfortunately ... has stopped' error message, no Google Play...
I really don't want to do a factory reset, but really, does it even help? Is there a way to put the platform.xml back? Is there a way to access the phone via USB cable?
vbcomer said:
I am having exact same problem. After editing the platform.xml, my Note 3 is behaving the same way: no access to any storage area (including USB drive), no remote access/online access (even though WIFI and 4G appear to connect just fine), most apps fail with 'Unfortunately ... has stopped' error message, no Google Play...
I really don't want to do a factory reset, but really, does it even help? Is there a way to put the platform.xml back? Is there a way to access the phone via USB cable?
Click to expand...
Click to collapse
Update: I went ahead and successfully install the all-in-one file to the phone via Odin, but it still has the same issues. Can someone give a hint? thanks
FIX!!!
Hi I'm a god at searching(hence the Go)but an Noob(hence the obie) to Dev on Android but a computer techy(in other words I fix computers upgrade ETC.) Now if you followed EXACT instructions you SHOULD have the Backup copy of platform.xml. If not reply and I'll give those instructions.
So I did the same as this post did to get my issue as well but there's a SOLUTION I just found W/o getting rid of your loved files and its easy!
1. Download the ADB also included in The Android SDK by Google (approx. 3XX MB)
2. DOWNLOAD Root Explorer.APK
3. Extract ADB Dev kit( name should be roughly adt-bundle-windows-x86_64-20140702.zip)Note: I prefered it at C:\Android it avoided Name too long error
4. Open CMD Type: cd C:\<location ADB was extracted>\sdk\platform-tools(if you followed my note it will be "C:\Android\adt-bundle-windows-x86_64-20140702\sdk\platform-tools") and press enter... HINT TO COPY PASTE IN CMD RIGHT CLICK SAVES TIME!!!!
5. Install Root Explorer so you can backup your files(if any) I was unlucky having none on the phone but SD storage is ok!
To do this type ADB INSTALL <Location of Root explorer.exe> For standard windows users with default download locations it would be "C:\Users\<USER NAME>\Downloads\Root Explorer v3.1.9.apk" <COPY PASTE
6. Copy the original back to System>ETC>Permissions and overwrite
7. Factory reset!
Links?
sorry guys bt i have the same note 3 and i delete the platform.xml file .....i did a factory reset bt nothing happened ...can u help plz
Re:FIX!
But you have to set the permissions of platform.xml as 0777.Right?
Step 5 how should it works
Android Goobie said:
Hi I'm a god at searching(hence the Go)but an Noob(hence the obie) to Dev on Android but a computer techy(in other words I fix computers upgrade ETC.) Now if you followed EXACT instructions you SHOULD have the Backup copy of platform.xml. If not reply and I'll give those instructions.
So I did the same as this post did to get my issue as well but there's a SOLUTION I just found W/o getting rid of your loved files and its easy!
1. Download the ADB also included in The Android SDK by Google (approx. 3XX MB)
2. DOWNLOAD Root Explorer.APK
3. Extract ADB Dev kit( name should be roughly adt-bundle-windows-x86_64-20140702.zip)Note: I prefered it at C:\Android it avoided Name too long error
4. Open CMD Type: cd C:\<location ADB was extracted>\sdk\platform-tools(if you followed my note it will be "C:\Android\adt-bundle-windows-x86_64-20140702\sdk\platform-tools") and press enter... HINT TO COPY PASTE IN CMD RIGHT CLICK SAVES TIME!!!!
5. Install Root Explorer so you can backup your files(if any) I was unlucky having none on the phone but SD storage is ok!
To do this type ADB INSTALL <Location of Root explorer.exe> For standard windows users with default download locations it would be "C:\Users\<USER NAME>\Downloads\Root Explorer v3.1.9.apk" <COPY PASTE
6. Copy the original back to System>ETC>Permissions and overwrite
7. Factory reset!
Links?
Click to expand...
Click to collapse
Hi have next message in the install root step could you help me please
Android Debug Bridge version 1.0.31
-a - directs adb to listen on all interfaces for a connection
-d - directs command to the only connected USB device
returns an error if more than one USB device is present.
-e - directs command to the only running emulator.
returns an error if more than one emulator is r
unning.
-s <specific device> - directs command to the device or emulator with
the given
serial number or qualifier. Overrides ANDROID_SERIAL
environment variable.
-p <product name or path> - simple product name like 'sooner', or
a relative/absolute path to a product
out directory like 'out/target/product/sooner'.
If -p is not specified, the ANDROID_PRODUCT_OUT
environment variable is used, which must
be an absolute path.
-H - Name of adb server host (default: localhost)
-P - Port of adb server (default: 5037)
devices [-l] - list all connected devices
('-l' will also list device qualifiers)
connect <host>[:<port>] - connect to a device via TCP/IP
Port 5555 is used by default if no port number
is specified.
disconnect [<host>[:<port>]] - disconnect from a TCP/IP device.
Port 5555 is used by default if no port number
is specified.
Using this command with no additional arguments
will disconnect from all connected TCP/IP devices.
device commands:
adb push [-p] <local> <remote>
- copy file/dir to device
('-p' to display the transfer progress)
adb pull [-p] [-a] <remote> [<local>]
- copy file/dir from device
('-p' to display the transfer progress)
('-a' means copy timestamp and mode) adb sync [ <directory> ] - copy host->device only if changed
(-l means list but don't copy)
(see 'adb help all')
adb shell - run remote shell interactively
adb shell <command> - run remote shell command
adb emu <command> - run emulator console command
adb logcat [ <filter-spec> ] - View device log
adb forward --list - list all forward socket connections.
the format is a list of lines with the followin
g format:
<serial> " " <local> " " <remote> "\n" adb forward <local> <remote> - forward socket connections
forward specs are one of:
tcp:<port>
localabstract:<unix domain socket name>
localreserved:<unix domain socket name>
localfilesystem:<unix domain socket name>
dev:<character device name>
jdwp:<process pid> (remote only) adb forward --no-rebind <local> <remote>
- same as 'adb forward <local> <remote>' but fails
if <local> is already forwarded
adb forward --remove <local> - remove a specific forward socket connection
adb forward --remove-all - remove all forward socket connections
adb jdwp - list PIDs of processes hosting a JDWP transport
adb install [-l] [-r] [-d] [-s] [--algo <algorithm name> --key <hex-encoded ke
y> --iv <hex-encoded iv>] <file>
- push this package file to the device and install it
('-l' means forward-lock the app)
('-r' means reinstall the app, keeping its data)
('-d' means allow version code downgrade)
('-s' means install on SD card instead of inter
nal storage)
('--algo', '--key', and '--iv' mean the file is
encrypted already)
adb uninstall [-k] <package> - remove this app package from the device
('-k' means keep the data and cache directories)
adb bugreport - return all information from the device
that should be included in a bug report.
adb backup [-f <file>] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all]
[-system|-nosystem] [<packages...>]
- write an archive of the device's data to <file>
.
If no -f option is supplied then the data is written
to "backup.ab" in the current directory.
(-apk|-noapk enable/disable backup of the .apks themselves
in the archive; the default is noapk.)
(-obb|-noobb enable/disable backup of any installed apk expansion
(aka .obb) files associated with each application; the default is noobb.)
(-shared|-noshared enable/disable backup of the device's
shared storage / SD card contents; the default is noshared.)
(-all means to back up all installed applications)
(-system|-nosystem toggles whether -all automatically includes
system applications; the default is to include system apps)
(<packages...> is the list of applications to be backed up. If
the -all or -shared flags are passed, then the package
list is optional. Applications explicitly given on the
command line will be included even if -nosystem would
ordinarily cause them to be omitted.) adb restore <file> - restore device contents from the <file> backup
archive
adb help - show this help message
adb version - show version num
scripting:
adb wait-for-device - block until device is online
adb start-server - ensure that there is a server running
adb kill-server - kill the server if it is running
adb get-state - prints: offline | bootloader | device
adb get-serialno - prints: <serial-number>
adb get-devpath - prints: <device-path>
adb status-window - continuously print device status for a specifie
d device
adb remount - remounts the /system partition on the device re
ad-write
adb reboot [bootloader|recovery] - reboots the device, optionally into the boo
tloader or recovery program
adb reboot-bootloader - reboots the device into the bootloader
adb root - restarts the adbd daemon with root permissions
adb usb - restarts the adbd daemon listening on USB
adb tcpip <port> - restarts the adbd daemon listening on TCP on the specified port
networking:
adb ppp <tty> [parameters] - Run PPP over USB.
Note: you should not automatically start a PPP connection.
<tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1 [parameters] - Eg. defaultroute debug dump local notty usepeerdns
adb sync notes: adb sync [ <directory> ]
<localdir> can be interpreted in several ways:
- If <directory> is not specified, both /system and /data partitions will be updated.
- If it is "system" or "data", only the corresponding partition is updated.
environmental variables:
ADB_TRACE - Print debug information. A comma separated list of the following values
1 or all, adb, sockets, packets, rwx, usb, sync, sysdeps, transport, jdwp
ANDROID_SERIAL - The serial number to connect to. -s takes priority over this if given.
ANDROID_LOG_TAGS - When used with the logcat option, only these debug tags are printed.

How to create a shelf icon that executes a shell programm call?

Hey everyone,
I am looking for a way to activate sleep mode of my chromebook manually in order to save battery without having to log out or power off all the time (it's connected to an external display, so closing the lid doesn't trigger it).
So far I found out that calling "powerd_dbus_suspend" from the shell does the trick, but as you can imagine, using the shell and actually typing the command every time is not really a solution.
Is there a way to create a chrome os app that executes this program call, so I can put it in my shelf and just click it to activate sleep?
I'm not really good at .json, maybe there's a way? Or any other suggestions?
Thanks alot!
Markus
I would like to know it too. Anyone?
Sneets said:
Hey everyone,
I am looking for a way to activate sleep mode of my chromebook manually in order to save battery without having to log out or power off all the time (it's connected to an external display, so closing the lid doesn't trigger it).
So far I found out that calling "powerd_dbus_suspend" from the shell does the trick, but as you can imagine, using the shell and actually typing the command every time is not really a solution.
Is there a way to create a chrome os app that executes this program call, so I can put it in my shelf and just click it to activate sleep?
I'm not really good at .json, maybe there's a way? Or any other suggestions?
Thanks alot!
Markus
Click to expand...
Click to collapse
Run a tiny web server like lighttpd in the shell on a weird port, restrict to localhost. Set up index.php to run system (whatever);
Then bookmark the 127.0.0.1: xxxx URL
Which system call invokes power_dbus_suspend?
Thanks Parrotgeek1. Working off your excellent suggestion I installed a lightweight local server on ChromeOS (Web Server for Chrome with the 200 OK! icon) and built a small framework app that is served from local storage. I'm all set up to call chrome.app.??? from my JavaScript. Which API provides the power_dbus_suspend capability? I looked through the Power and System APIs and I don't see anything. - Thanks!
Sneets said:
Hey everyone,
I am looking for a way to activate sleep mode of my chromebook manually in order to save battery without having to log out or power off all the time (it's connected to an external display, so closing the lid doesn't trigger it).
So far I found out that calling "powerd_dbus_suspend" from the shell does the trick, but as you can imagine, using the shell and actually typing the command every time is not really a solution.
Is there a way to create a chrome os app that executes this program call, so I can put it in my shelf and just click it to activate sleep?
I'm not really good at .json, maybe there's a way? Or any other suggestions?
Thanks alot!
Markus
Click to expand...
Click to collapse
Have you tried this simple extension? Keep Awake
https://chrome.google.com/webstore/...lb?utm_source=chrome-app-launcher-info-dialog
What I do is have the shell tab pinned, and press [up arrow] for the command then hit [enter]. Probably not ideal if you use the shell a lot as you have to step through recently used commands.
Re: Pkt_Lnt's post
Thanks Pkt_Lnt. That app only deals with disabling the normal sleep behavior, not causing it, and in particular not causing it when an external monitor is connected. I'm looking for something like Sneets has requested, to invoke a powerd_dbus_suspend command that will force the system to sleep (and turn off an external monitor). Per Parrotgeek1's comment, I've got a little app now sitting on the shelf that is all set to call some system command to invoke powerd_dbus_suspend, only I'm looking for what command to call, from JavaScript.
I managed to find a way to do something similar with the Secure Shell app. During the process of figuring it out, I also found that I was able to create a homescreen shortcut on my Android tablet which when tapped sends a shell command to the Chromebook.
This method might be overkill somewhat, but, anyway, what I did was as follows:
Installed Secure Shell extension; setup sshd on the Chromebook (by making a symlink in /etc/init/ pointing to /usr/share/chromeos-ssh-config/init/openssh-server-conf); rebooted; added public key from ConnectBot (Android app) to ~/.ssh/authorized_keys in order to test connection; setup Android homescreen shortcut to send shell command; created profile in Secure Shell app on Chromebook to connect to [email protected]/my local IP address; generated keys on Chromebook (in ~/.ssh); added generated public key to ~/.ssh/authorized_keys; imported newly-generated private/public key pair within Secure Shell app (one by one); created bookmark link to [email protected] profile in shelf, and, finally, added required command to profile in Secure Shell.
It works well! It looks like any command can be added to the 'Arguments' field in Secure Shell, with the syntax:
Code:
-- thecommand
Although I guess commands that need sudo would require a connection to [email protected], instead of chronos. (-t argument lets you use sudo, but then sending a line break/ENTER seems to be needed)
The window opened with the click does hang around - I haven't figured out if it's possible to avoid this - but it does at least seem to persistently remember the size and position to which it's set.
I posted up some further details at http://nolirium.blogspot.com/shell-command-shelf-shortcut-chromeos.html
Impressive! But a bit more than I'm looking to do
@Nolirum - I read your blogspot doc and your procedure's pretty impressive. Frankly it's a little beyond me and beyond what I'm looking for. If you ever run across a way to invoke powerd_dbus_suspend a little more directly please post here as well. You clearly have a strong grasp of the issues!
Nolirum said:
I managed to find a way to do something similar with the Secure Shell app. During the process of figuring it out, I also found that I was able to create a homescreen shortcut on my Android tablet which when tapped sends a shell command to the Chromebook.
This method might be overkill somewhat, but, anyway, what I did was as follows:
Installed Secure Shell extension; setup sshd on the Chromebook (by making a symlink in /etc/init/ pointing to /usr/share/chromeos-ssh-config/init/openssh-server-conf); rebooted; added public key from ConnectBot (Android app) to ~/.ssh/authorized_keys in order to test connection; setup Android homescreen shortcut to send shell command; created profile in Secure Shell app on Chromebook to connect to [email protected]/my local IP address; generated keys on Chromebook (in ~/.ssh); added generated public key to ~/.ssh/authorized_keys; imported newly-generated private/public key pair within Secure Shell app (one by one); created bookmark link to [email protected] profile in shelf, and, finally, added required command to profile in Secure Shell.
It works well! It looks like any command can be added to the 'Arguments' field in Secure Shell, with the syntax:
Code:
-- thecommand
Although I guess commands that need sudo would require a connection to [email protected], instead of chronos. (-t argument lets you use sudo, but then sending a line break/ENTER seems to be needed)
The window opened with the click does hang around - I haven't figured out if it's possible to avoid this - but it does at least seem to persistently remember the size and position to which it's set.
Click to expand...
Click to collapse
This really is impressive! Thanks for the extremely detailed explanation.
I was able to follow along completely and get the SSH argument "powerd_dbus_suspend" working.
However, I got to thinking. I was wondering if this could be extended to use an alias stored in ~/.bashrc?
After doing some research of my own and using various parameters and arguments, I was unsuccessful.
The goal is to have a linux app (through crouton) be run using xiwi with just a single bookmark by utilizing an alias.
Any thoughts?
UPDATE:
Of course just a few moments later I figured this out! Rather than dealing with an alias stored in ~/.bashrc and ensuring ssh had access, typing the entire alias command as an argument worked. Now I can run Steam directly from a shelf bookmark. All it took was replacing "powerd_dbus_suspend" with "-- sudo enter-chroot xiwi steam" in the argument.
Thanks again!
DandyRandyMarsh said:
This really is impressive! Thanks for the extremely detailed explanation.
I was able to follow along completely and get the SSH argument "powerd_dbus_suspend" working.
Click to expand...
Click to collapse
No problem! I think it's perhaps overly detailed if anything. Might be easier to follow if I cut it down a bit.
DandyRandyMarsh said:
Now I can run Steam directly from a shelf bookmark. All it took was replacing "powerd_dbus_suspend" with "-- sudo enter-chroot xiwi steam" in the argument.
Click to expand...
Click to collapse
Nice!
Adding crouton single app shortcuts is a cool idea which I hadn't considered. Does it work OK for you with sudo in the command, even straight after booting up? ...You didn't have to setup sudoing without a password via sudoers.d or anything?
Inspired by your post I added xiwi to my chroot to try it out. I seem to remember experiencing quite unbearable lag and slowness when running a full desktop via xiwi in the past, but with single apps there doesn't seem to be any noticeable performance hit (this is on an armv7 Asus Flip, with the chroot on a slooow USB drive).
In order to not have to enter my sudo password, in the argument I put:
Code:
-t -- echo mypassword | sudo -S sh /media/removable/3/bin/enter-chroot xiwi firefox
Maybe I'm missing something? Is there a better way, perhaps?
Anyway, since I have rootfs verification switched off, I also tried saving a similar command to a file in /usr/bin, and putting the filename in the argument instead. This works, too, and I suppose could potentially be useful e.g. in the case of needing to run a more convoluted sequence of commands with a shortcut.
Nolirum said:
Adding crouton single app shortcuts is a cool idea which I hadn't considered. Does it work OK for you with sudo in the command, even straight after booting up? ...You didn't have to setup sudoing without a password via sudoers.d or anything?
Click to expand...
Click to collapse
I'm not entirely familiar with exactly how my process worked, but I do not have any sudo password required within shell.
Here's the list of steps I followed allowing me to use sudo commands in the SSH Arguments box.
As a side note, this is the crouton installation I am running on an ASUS c302.
sudo sh ~/Downloads/crouton -r trusty -t unity,touch,xiwi,extension
Setup Bookmarks that Run Shell Commands
1. Installed Secure Shell extension
2. Open crosh with Ctrl+Atl+T
3. Enter Command: shell
4. Enter Command: sudo su -
5. Enter Command: sudo /usr/share/vboot/bin/make_dev_ssd.sh --force --remove_rootfs_verification
6. Enter Command: reboot
7. Let Chrome OS reboot
8. Open crosh with Ctrl+Atl+T
9. Enter Command: shell
10. Enter Command: sudo su -
11. Enter Command: mount –o remount rw /
12. Close current crosh window
13. Open a new crosh with Ctrl+Atl+T
14. Enter Command: shell
15. Enter Command: sudo ln -s /usr/share/chromeos-ssh-config/init/openssh-server.conf /etc/init/openssh-server.conf
16. Enter Command: sudo initctl reload-configuration
17. Enter Command: sudo initctl start openssh-server
18. Enter Command: cd ~/.ssh/
19. Enter Command: ssh-keygen
“Enter file in which…” *LEAVE BLANK*
“Enter passphrase” *LEAVE BLANK*
“Enter same passphrase” * LEAVE BLANK*​20. Enter Command: cat /home/chronos/user/.ssh/id_rsa.pub >> /home/chronos/user/.ssh/authorized_keys
21. Enter Command: cp -a /home/chronos/user/.ssh/id_rsa* /home/chronos/user/Downloads
22. Close current crosh terminal and open Secure Shell extension
23. Select [New Connection]
24. Click Import… and select “id_rsa”
25. Click Import… again and select “id_rsa.pub”
26. Enter chronos as the username and localhost as the hostname
27. Enter a shorthand name replacing the text in the top cell “[email protected]”
28. Click Enter. If prompted, enter “yes” to continue connecting
29. Bookmark the page that is open which should end in, "#profile-id:_ _ _ _"
DONE. Now time to add some commands to automate.
Open Secure Shell and select the connection created. In the arguments box, start with two dashes -- and follow it your desired shell command.
Examples:
-- sudo startunity
-- sudo startgnome
-- sudo enter-chroot xiwi steam
-- sudo enter-chroot xiwi wine microWord​
Next Steps... Getting Custom Shelf Icons
Now here I am running into some issues. Rather than have all these icons be the same, I was hoping to customize them.
Followed a strategy found on reddit, Change Shelf Icon for Website, but this only works if the site already had an "apple-touch-icon" set. Also, tried to inject the entire code myself which I couldn't get to work. Unfortunately, I think that since this bookmark is created from a Secure Shell, there are some issues.
I have already tried adding in code for this into the site, but it is having no effect. If someone could make this work then we're really looking good here.
DandyRandyMarsh said:
I'm not entirely familiar with exactly how my process worked, but I do not have any sudo password required within shell.
Click to expand...
Click to collapse
Oh, I see what you mean. You are saying that you can sudo in the shell generally, without being prompted for a password, right?
Was that the default setup on your CB (after switching to Dev mode)? Or did you have to configure it manually for passwordless sudoing...
DandyRandyMarsh said:
Here's the list of steps I followed allowing me to use sudo commands in the SSH Arguments box.
Click to expand...
Click to collapse
Nice work summarizing the steps. :highfive: It's probably easier to follow, listed out like that. One slight addendum, perhaps - at step 29, it might be good to clarify the "add to shelf" procedure. Especially because of the following...
DandyRandyMarsh said:
Next Steps... Getting Custom Shelf Icon
Now here I am running into some issues. Rather than have all these icons be the same, I was hoping to customize them.
Click to expand...
Click to collapse
Happily it turns out that, when you add shortcuts to the shelf on Chrome OS like this, a minimal app is created for each one, with its own manifest.json, and icon.pngs. Our shell shortcuts were getting created with blank pngs by default (the black box with P in the center).
So, all we need to do, is get some icons, find the right folder for our shelf shortcut apps, then copy our new icons into them!
For instance, here's how I made a nice shiny icon for my single app shelf shortcut to Firefox.
Prepared icons:
Created a temporary folder in ~/Downloads to store downloaded icons.
Prepared a set of icons in ~/Downloads/firefox. (I downloaded mine from findicons.com).
Six sizes are required - from 32px to 256. To avoid any manifest editing, saved them as *size*.png
e.g. 32.png; 48.png; 64.png; 96.png; 128.png; 256.png
Located folder to copy icons to:
It is easiest to do this directly after clicking "add to shelf"
EITHER:
To change dir into the most recently modified extension icon subfolder automatically, the following one-liner worked for me*.
Code:
shell
cd ~/Extensions/&&cd $(ls -v1td */ | head -1)/*/icons&&ls
A list of blank icons (*.png) should be visible. If so, the new icons can simply be copied over these, e.g..
Code:
sudo cp ~/Downloads/firefox/* .
*YMMV with this particular one-liner - sometimes there's an extra 'temp' folder in ~/Extensions, which stops it working as expected. If you get an error after running the command, simply use the slightly more manual method to locate the folder, as detailed below.
OR:
(slightly more manual method).
Code:
shell
ls -ltr ~/Extensions
Checked the date/times - the most recently added folder is at the bottom. Then,
Code:
cd themostrecentlyaddedfolder
(or, the folder modified at the date/time that the shortcut was "added to shelf"). Then,
Code:
cd */icons
ls
sudo cp ~/Downloads/firefox/* .
I then repeated the above with a new SSH argument and a set of Ubuntu icons, for a custom startxfce4 shortcut, too.
Then just did sudo restart ui, and enjoyed the shiny new shelf icons!
I am hopeful that these changes will get picked up by CrOS's sync, thus getting backed-up and restored automatically. At this point I am not sure if that will be the case, but I don't see why it wouldn't.
Another way?
Another way to approach this, since you're modifying system stuff anyway, might be to edit crosh at /usr/bin/crosh. It's a regular ol' dash/bash shell program, and you can create a shortcut to it on the shelf by opening crosh (ctrl-alt-T), then right click the top right of the browser and select More Tools --> Add to shelf...
Clicking the newly-created link (which looks like an "N") will launch /usr/bin/crosh in a tab. Changing the default behavior of /usr/bin/crosh could accomplish your goal to do whatever you want. With some experimenting, you might even be able to pass arguments to make it do different things depending on how it's opened (via ALT-CTRL-T vs from the shelf-- dunno if it can read the url used to call crosh), but at the very least you could do something like have it run whatever you want it to run if a second modifier key is held down (or if it isn't...), otherwise return to normal operation. A menu w/1 sec timeout could do this as well, ie--
Doing [THE THING YOU WANT] in 2 seconds (press SPACE for crosh)... /
Note there's no proof-of-concept here. Just throwing it out as an idea that I'm pretty sure would work... Someone might even create a neat extension that allows crosh to use scripts/plugins to execute different system operations beyond the stock ones that are built-in via single-clicks... If it worked, it might be a little simplier than via the SSH extension and you wouldn't have to run any extra daemons.
ft
This is probably harder, but a third way, which probably is the "right" way is to see how the crosh extension works and learn about opening the hterm.Terminal instance chrome.terminalprivate object directly, sending it output, and closing it in the same way crosh does it. There's a file in the crosh extension at js/crosh.js that shows the basics of how it's done:
var terminal = new hterm.Terminal(profileName);
And then you can do stuff with it. You could then create an extension that could handle multiple shelf-icons (say by appending ?COMMAND=ls to the URL to do different shell commands(. The security implications for this would probably be huge obviously.
Update: More on embedding hterm is here.
Nolirum said:
I managed to find a way to do something similar with the Secure Shell app. During the process of figuring it out, I also found that I was able to create a homescreen shortcut on my Android tablet which when tapped sends a shell command to the Chromebook.
I posted up some further details at http://nolirium.blogspot.com/shell-command-shelf-shortcut-chromeos.html
Click to expand...
Click to collapse
Nice post - Some good food for thought, changing up the contents of crosh etc directly is an interesting idea.
fattire said:
Another way to approach this, since you're modifying system stuff anyway, might be to edit crosh at /usr/bin/crosh. It's a regular ol' dash/bash shell program, and you can create a shortcut to it on the shelf by opening crosh (ctrl-alt-T), then right click the top right of the browser and select More Tools --> Add to shelf...
Click to expand...
Click to collapse
Interesting! ....Aaaaand, now I've broken crosh. lol. Lucky I had my SSH shortcut setup... (actually, we can still get into the VTs with CtrlAltF2 etc anyway).
Some good potential for experimentation with this, definitely.
fattire said:
This is probably harder, but a third way, which probably is the "right" way is to see how the crosh extension works and learn about opening the hterm.Terminal instance chrome.terminalprivate object directly, sending it output, and closing it in the same way crosh does it. There's a file in the crosh extension at js/crosh.js that shows the basics of how it's done:
Click to expand...
Click to collapse
Again, very interesting. Now you come to mention it, an approach such as this does seem like it might be do-able without too much messing around (maybe)...
Any possible method we can get e.g. an extension to 'talk' to the shell is worth looking into I think; as you say, if we can cut out the middleman (ssh) and maybe do it more elegantly, that might be pretty useful indeed.

Script to Hide System Apps from Launcher - Stock English Firmware

Hello,
Even tho I am very upset because my brand new Amazfit Pace has broken GPS (courtesy of GearBest, I am requesting a DOA replacement), here is a (maybe) useful script to hide unused system apps from launcher, either builtin or custom one. Made for 1.3.4f US firmware but may work with other versions (it may not hide all apps tho).
You can do it wirelessly if you enable watch's WiFi and keep screen on (anox' PaceOn app from XDA recommended):
Code:
adb connect WATCH_IP
where WATCH_IP is your actual IP on watch. Then uncompress the file and move it to where you have adb:
Code:
adb push amazfit_hide_apps.sh /sdcard/
or copy it to watch's internal memory (/sdcard), then:
Code:
adb shell sh /sdcard/amazfit_hide_apps.sh
If you want to get the log file:
Code:
adb pull /sdcard/loghide.txt
As a bonus, this Java app can be used to view and control watch via ADB only:
https://github.com/MajeurAndroid/Adb-Remote-Screen
Cheers

How To Guide Remove Microsoft Bloat

In the spirit of removing stubborn pre-installed APKs from freshly unpacked Android devices, I would like to share the apps I removed using adb and the commands used to do so.
I personally do not use Office or Bing so these were my primary targets, but I also removed OneDrive, OneNote, Outlook and Edge as well.
This is step-by-step for Windows users:
1. Download platform-tools from https://dl.google.com/android/repository/platform-tools-latest-windows.zip
2. Extract to C:\ (or a place of your choosing)
3. Open a command prompt from your start menu by typing "cmd" in your Windows search bar.
4. You should see something like: C:\Users\YourUsername_>
5. Type "cd C:\platform-tools" and press Return/Enter
6. You should now see C:\platform-tools>
7. Plug in your device with a USB cable and ensure you have turned Developer Options on your device (search Google for how to do this if unsure)
8. Type "adb shell" and you should get an Unauthorized message in the command prompt window followed by a pop-up on your device asking if you trust the computer you are connected to.
9. Select the option to trust the computer you are connected to.
10. Type adb shell again and hit Enter/Return and you should see a unique alpha-numeric device ID show in the command prompt now.
11. Begin uninstalling the packages you wish to no longer be stuck on your Surface Duo 2 with the command below.
12. Repeat the command below for each package/app you wish to uninstall.
pm uninstall --user 0 <package name from the list below goes here>
(Below are the packages I have personally removed line by line and still have stable experience on the device. Most are evident in the package name of what was removed. I will update the list as I remove more.)
com.microsoft.amp.apps.bingnews
com.microsoft.office.officelens
com.microsoft.skydrive
com.microsoft.amp.apps.bingnews.overlay.duo2
com.microsoft.office.onenote
com.microsoft.bing
com.microsoft.office.outlook
com.microsoft.office.officehubrow
com.microsoft.surface.office.outlook.overlay.duo2
com.microsoft.surface.tips
com.microsoft.bing.overlay.duo2
com.microsoft.surface.onedrive.overlay.duo2
com.microsoft.teams
com.microsoft.todos
com.microsoft.emmx (Edge Browser)
com.microsoft.windowsintune.companyportal
Hi. Somewhat cautious of doing anything that bricks my Duo 2 - I use many of the Microsoft apps, so I'm more interested in removing the Google suite of apps. Does the above approach work for Google apps too?

[Guide] Linux on Wear OS!

THIS IS ONLY TESTED IN WEAR OS 3 ON A GALAXY WATCH 4
THOUGH THIS SHOULD WORK ON ALL WATCHES AND OLDER VERSIONS OF WEAR OS
Requirements:
ADB installed on your computer
Have your wear OS device connected to the same network as you computer
A bit of patience, this works in a very weird way!
Downloading apks and installing them
Firstly enable adb and adb debugging over WiFi on your wear OS device
Then download the latest apks:
Termux
MultiVnc If you want a graphical environment on Linux
When you have the apks run these commands:
Code:
adb connect IP_OF_YOUR_WEAR_OS_DEVICE
You might be able to see your ip under the button for enabling adb debugging over wifi
Then run these commands in the downloads folder
Code:
adb -s " IP_OF_YOUR_WEAR_OS_DEVICE" install NAME_OF_THE_DOWNLOADED_TERMUX_APK_FILE
and
Code:
adb -s " IP_OF_YOUR_WEAR_OS_DEVICE" install NAME_OF_THE_DOWNLOADED_MULTI-VNC_APK_FILE
BE AWARE THAT YOU MIGHT HAVE TO RESTART THE ADB CONNECTION, SOMETIMES IT MAY FREEZE.
to do that run
Code:
adb disconnect
then
Code:
adb connect IP_OF_YOUR_WEAR_OS_DEVICE
Installing Linux in Termux
Stay awake sleepyhead!
To make everything easier enable the option in Termux to keep your watch awake, this will save you from so much trouble.
First open up Termux, then long press the black background.
Then press the three dots and choose the option "More...".
Scroll down until you see the option "Keep screen on", turn on that.
Keyboard?
I've discovered that there's a problem with Wear OS keyboards, for some reason they might not interact properly with certain android applications.
So open up Termux in your Wear OS device and see if you can write anything in Termux.
If that works, see if there's any enter button on your keyboard and see if it works.
If Termux gave any response to what you entered then skip this part and head straight for "The Linux multiverse!"
If the enter button doesn't work then you gotta install an android keyboard.
The best keyboard I've found that also works on round Wear OS devices is "Unexpected keyboard"
Download the keyboard and run:
Code:
adb -s " IP_OF_YOUR_WEAR_OS_DEVICE" install NAME_OF_THE_DOWNLOADED_KEYBOARD_APK_FILE
When the keyboard is installed change you default keyboard into the previously installed keyboard.
The Linux multiverse!
On your ANDROID PHONE install Andronix.
In there you will have a lot of options for installing Linux on Termux. You can choose whatever you want!
When you've chosen what you want, then Andronix will copy a command to your phones clipboard.
Oh no!
This is where you might only have a few options!
The problems is that you have to get the command from your phone to your Wear OS device, though your Wear OS device might not even let you copy and paste!
Though there is a way to bypass this, ANDROID APPS! The easiest way is to install messenger lite(not messenger for Wear OS).
First download Messenger lite. (source for the messenger download link)
Then In the downloads folder run:
Code:
adb -s " IP_OF_YOUR_WEAR_OS_DEVICE" install NAME_OF_THE_DOWNLOADED_MESSENGER_APK_FILE
Log into messenger on your phone and your Wear OS device.
On your phone send the command Andronix gave you, to yourself in messenger.
Then open up messenger on your Wear OS device and long press the command and select copy!
Now the biggest hassle is gone!
The long, really long awakening
Now that you've copied the command, enter Termux. Then long press the black background and press paste.
NOW DON'T TOUCH ANYTHING, so that you don't accidentally change anything in the command.
From your computer run:
Code:
adb shell input keyevent 66
Try to remember this command, or put it somewhere easy to copy. You'll need it pretty often. (this command serves as an enter button)
The installation of Linux will now begin, there will be some Y/N questions, just choose the default options by running:
Code:
adb shell input keyevent 66
After a while you might get questions about region, keyboard and such.
use
Code:
adb shell input keyevent 66
to scroll down when it says [MORE]
then use
Code:
adb shell input text "NUMBER/WORD"
(don't remove the parentheses)
then again use
Code:
adb shell input keyevent 66
as an enter button
It might also ask you for a vnc password, choose a small and easy password.
FINALLY LINUX!
You should now have Linux installed on your Wear Os device. Go do whatever you want with it.
Just remember that your Wear OS device uses arm, so if you wanna use x86 applications, then you gotta use Box64 if you have a 64-bit processor and Box86 if you have a 32-bit processor
Start Linux(Linux might automatically start after installation)
First run:
Code:
adb shell input text "ls"
Code:
adb shell input keyevent 66
This will run the ls command.
Look for a file closely name to start-SOME_LINUX_DISTRO.sh or start-andronix.sh
then run:
Code:
adb shell input text "./start-SOME_LINUX_DISTRO"
then
Code:
adb shell input keyevent 66
BOOM Linux is now running :3
What about GUI?
If you installed a Linux version with a graphical interface then you either gotta use a VNC to display anything on your watch
run
Code:
adb shell input text "vncserver-start"
then
Code:
adb shell input keyevent 66
then
Code:
adb shell input keyevent 66
The terminal will say " New 'remote-desktop' at :NUMBER on machine localhost "
remember that number
now exit Termux and start Mutli-Vnc
Scroll down to "New Connection"
in Address enter localhost
in port enter 590 and then the number. (If the number as is higher than 9, enter 59 and then the number)
Scroll down password and enter in the vnc password you chose earlier.
Then the scroll all the way down and press the big green "Connect" button!
You should now some something, maybe not a lot, but something"
You can manually set the resolution if you want, so that you're able to utilize the screen better, go here for a guide on that.
External GUI
If you actually wanna use the Linux installation, then you'll have to use an external device to view the desktop.
You can follow this guide here, as it's better at explaining then me.
You can also use this guide if you wanna use XSDL.
A tip for entering &, use the keyboard on the watch! Also the read the explanation of commands before you continue, you'll need it!
Command explanation!!
adb shell input text " " will enter any text into the connected adb device, %s is used for spaces
adb shell input keyevents will do any key event, like pressing enter, 66 is for enter
If something doesn't work, let me know. I might've missed something!

Categories

Resources