Talkback is not getting enabled through adb shell - automation

I've tried the command adb shell settings put secure enabled_accessibility_services com.android.talkback/com.google.android.marvin.talkback.TalkBackService to enable talkback from adb shell. It's toggling the ui button which signifies the status of talkback, but talkback is not actually getting enabled.
I am trying to enable talkback programmatically for android 6.0. Is there any other way thorough which I can enable it?

Commands to toggle TalkBack:
// disable
adb shell settings put secure enabled_accessibility_services com.android.talkback/com.google.android.marvin.talkback.TalkBackService
// enable
adb shell settings put secure enabled_accessibility_services com.google.android.marvin.talkback/com.google.android.marvin.talkback.TalkBackService
Kudos to #zeh

Are you running this alongside any other accessibility services or UI Automation (which utilizes the accessibility APIs)? Accessibility services are only allowed to run one at a time, and attempting otherwise will cause exceptions all over the place. Check LogCat and see if TalkBack is attempting to start up, but throwing exceptions when doing so.

For convenience, I use a shell script to toggle this setting.
output=$(adb shell settings get secure enabled_accessibility_services)
if [[ "$output" == "com.android.talkback/com.google.android.marvin.talkback.TalkBackService" ]]; then
adb shell settings put secure enabled_accessibility_services com.google.android.marvin.talkback/com.google.android.marvin.talkback.TalkBackService
else
adb shell settings put secure enabled_accessibility_services com.android.talkback/com.google.android.marvin.talkback.TalkBackService
fi

Related

Reload a React Native app on an Android device manually via command line

I'd like to manually force a Reload of my React Native app on demand without physically shaking the device. (I'm getting carpal tunnel.)
I know that Live Reload / Hot Reload are available. I'm looking for a on-demand command line solution.
Using the cmd line you can send a command to the Android device.
adb shell input text "RR"
This command tells the Android device to type the character "R" twice which is the React Native command to Reload on Android.
The adb shell command has many useful features many of which are described here:
ADB Shell Input Events
To open the developer menu:
adb shell input keyevent 82
Just posting it here in case you didn't know this trick
long press the menu button in your android device. Then you'll get this menu
tap the reload option and you are good to go
I use the following command. It doesn't reload the app, but it brings up the developper menu on the device, so I can then press the "Reload" option:
adb shell input keyevent KEYCODE_MENU
I develop with a real device (not the emulator) and sending the "double-R" through adb doesn't work (it just shows the keyboard and types 2 Rs).
Add the following script to your package.json:
"android-shake": "adb shell input keyevent 82"
Then you will be able to call
yarn android-shake
If you are looking for ios then checkout my answer on this link
One trick would be to add this command on ~/.bashrc profile in the case you're using unix.
use your favorite editor (ex: nano on Ubuntu) and type nano ~/.bashrc
on the end of file write alias rnreload='adb shell input text "RR"'
save it and run source ~/.bashrc in order to active it.
Now whenever you need, just type rnreload on a terminal.
Next time you enter your computer it should be already done.
Also, there's the possibility to add an other alias as well: alias rnshake='adb shell input keyevent 82' which "shakes" android. You can use it to access other commands like Hot Reloading, Debugger, Inspector, etc.
Made an autohotkey script to reload and open the menu with keyboard shortcuts.
^+r:: run, %comspec% /c adb shell input text "RR",,hide
^+e:: run, %comspec% /c adb shell input keyevent 82,,hide
ctrl+shift+r to reload
ctrl+shift+e to open dev menu
If you're on a Mac and using Hammerspoon, you can put the following bit of code in your ~/.hammerspoon/init.lua file:
hyper = {'ctrl', 'alt', 'cmd'}
placid = {'ctrl', 'cmd'}
-- React native reload JS on connected device
hs.hotkey.bind(placid, 'R', function()
os.execute('/Users/peter/Library/Android/sdk/platform-tools/adb shell input text "RR"')
end)
-- React native show dev menu on connected device
hs.hotkey.bind(hyper, 'R', function()
os.execute('/Users/peter/Library/Android/sdk/platform-tools/adb shell input keyevent 82')
end)
the os.execute command doesn't load your ENV (doing so would make running commands really slow), so make sure to run which adb in your terminal to figure out what the exact path to adb is. (in my case it was /Users/peter/Library/Android/sdk/platform-tools/adb).
Now you can reload your app using ctrl+cmd+R and show the dev menu using ctrl+option+cmd+R from anywhere and without even bothering to cmd-tab out of your favorite editor!
For device you have just to shake your device than a menu appears so click on Reload

Install .safariextz from command line

I am running into an issue with MacOS 10.10 and Safari 8.0 where Selenium driver cannot establish connection with SafariDriver. Details in this thread: https://code.google.com/p/selenium/issues/detail?id=7933. To run tests locally, the workaround is to download Selenium 2.44.0, extract the package, and doubleclick on SafariDriver.safariextz to install. However through SSH connection this does not work. I want to install the SafariDriver.safariextz from command line, before each test run. Any clues on how to install the .safariextz file from command line?
Update: Just verified that every time Safari is started from SSH connection (/Applications/Safari.app/Contents/MacOS/Safari) all the extensions are removed (Safari-> Preferences->Extensions is empty).
If you are on the same machine, AppleScript should work:
# this first part might not be needed
osascript -e 'tell application "Safari"
activate
end tell'
osascript -e 'ignoring application responses
tell application "Safari"
open "'"/path/to/SafariDriver.safariextz"'"
end tell
end ignoring
tell application "System Events"
tell process "Safari"
set frontmost to true
repeat until (exists window 1) and subrole of window 1 is "AXDialog" -- wait until the dialog is displayed.
delay 1
end repeat
click button 1 of front window -- install
end tell
end tell'
If that fails, then you might have to enable access for assistive devices and applications by opening System Preferences > Security & Privacy > Privacy > Accessibility and check the applications you want to allow access (Safari, etc...).
More info: https://support.apple.com/en-us/HT202866
Jacob Salmela also has created a utility to do this from command line:
http://jacobsalmela.com/os-x-yosemite-enable-access-assistive-devices-command-line/
The following workaround did trick for me:
After the upgrade Safari extensions are part of the keychain, and over SSH the user does not have access to the login keychain. The solution is to grant that access for EACH ssh session.
security -v unlock-keychain -p <password> ~/Library/Keychains/login.keychain
Then opening Safari with the step below should work
/Applications/Safari.app/Contents/MacOS/Safari
For a 'permanent' solution add a build step, to execute shell script as follows:
#!/bin/bash
keychain="~/Library/Keychains/login.keychain"
security unlock-keychain -p <password> ${keychain} &>/dev/null
if [ $? -ne 0 ];then
echo "Cannot open keychain ${keychain}"
exit 1
fi
As explained here http://sap-production.github.io/xcode-maven-plugin/site/howto/HandlingKeychainsInMasterSlaveEnvironment.html.

Running qemu remotely (via ssh)

I have a server that I am experimenting with, and sometimes I want to work from home so I installed the 'ssh daemon' (namely, 'sshd') and I can ssh to the server. This works fine. But when I try to run a virtual machine on the server with 'qemu', I get the following error Could not initialize SDL(No available video device) - exiting.
Is it possible to run qemu via ssh connection?
Note, I do not want to see the visual interface to the VM that I'm launching. I just want to to run.
Try qemu -curses
or qemu -nographic
to bypass the SDL
Best way to resolve this is to add -X to your ssh parameters.
e.g. ssh -X user#server
This will allow the window created by QEMU to be X-Forwarded through SSH to you. It doesn't matter if you want to view the window or not, if QEMU can't open it, it will consider it a fatal error and you will get the error you described.
You can disable the video card:
qemu -vga none (...options...)
You could also pipe the screen to VNC instead of SDL - the following will provide a VNC server on port 5901:
qemu -vnc :1 (...options...)
qemu-system-i386 -curses works like charm..
And to exit from that, use ESC + 2 then q + ENTER.
I had this problem too.
I think bitwise can't open a new terminal window like qemu does.
You can write make clean qemu-nox in terminal, instead of just make clean qemu and it will launch it in the same window.
This worked for me

Use dolphin (or other browser) like yakuake

I often want to open a file browser to open a file and then close the browser.
Is there a way (a plasmoid, a dolphin plugin, another browser...) which could allow me to have a file browser "in the style of" yakuake? (i.e. unfolding with a shortcut, and re-folding when I chose the file I want)
Took me some time, but finally managed to get what you want (and eventually, what I also want :) with xdotool (on Ubuntu sudo apt-get install xdotool).
With this script, you can have any application behave like you asked:
#!/bin/bash
SEARCHED_WINDOW=$1
COMMAND=${2:-$SEARCHED_WINDOW}
SEARCHED_WINDOW_CLASSNAME=toggleApp$SEARCHED_WINDOW
WINDOW_ID=$(xdotool search --classname $SEARCHED_WINDOW_CLASSNAME)
VISIBLE_WINDOW_ID=$(xdotool search --onlyvisible --classname $SEARCHED_WINDOW_CLASSNAME 2>/dev/null)
if [ -z "$WINDOW_ID" ]; then
$COMMAND 2>/dev/null &
pid=$!
NEW_WINDOW_ID=$(xdotool search --onlyvisible --sync --pid $pid 2>/dev/null)
xdotool set_window --classname $SEARCHED_WINDOW_CLASSNAME $NEW_WINDOW_ID
xdotool windowfocus $NEW_WINDOW_ID
elif [ -z "$VISIBLE_WINDOW_ID" ]; then
xdotool windowmap $WINDOW_ID
xdotool windowfocus $WINDOW_ID
else
xdotool windowunmap $VISIBLE_WINDOW_ID
fi
(Inspired from here)
You call it like this:
./toggle.sh dolphin
If the command to launch the program is different, you can add a second parameter:
./toggle.sh appName commandToLaunchApp
What this script does is the following:
If the app is not running: launch it, give window a specific class, and give window focus
If the app is running but with no visible window: make window visible and give it focus
Else, i.e. app is running and visible: hide it.
All you have left to do is map a shortcut to the above-mentionned command to launch the script. In KDE : System settings > Shortcuts and gestures > Custom shortcuts. Then Edit > New > Global shortcut > Command.
Plus, this script works with any app, should work with any EWMH compliant window manager, and allows you to have other instances of the same app (this is why I added the class trick).
The closest solution to what you want is the Widget Layer Compiz plugin.
This plugin enables you to make appear a layer on top of your workspace. You can configure this layer to hold windows of your choice, in your case that would be the file manager. It has a hide/show feature which you can bind to a hotkey.
It uses Window Matching rules to define the windows to hold.
More information on http://wiki.compiz.org/Plugins/Widget
However, this would imply that you use the Compiz compositing manager.

Trying to make a Webkit Kiosk on Debian with Raspberry Pi

I'm trying to build a Webkit Kiosk on a Raspberry Pi.
I found a good start at: https://github.com/pschultz/kiosk-browser
The things I want to do:
1) Start the kiosk without logging in (with inittab?)
Peter Schultz pointed out adding the following line:
1:2345:respawn:/usr/bin/startx -e /usr/bin/browser http://10.0.0.5/zfs/monitor tty1 /dev/tty1 2>&1
But he did not explain the steps to make this work (for noobs).
What I did is add his code to a personal git repository and cloned this repo to /usr/bin/kiosk and sudo apt-get install libwebkit-dev and sudo make.
The line to add to inittab will be:
1:2345:respawn:/usr/bin/startx -e /usr/bin/kiosk/browser http://my-kiosk-domain.com tty1 /dev/tty1 2>&1
If I do this, I generate a loop or some kind...
If you want to automatically load a browser full screen in kiosk mode every time you turn on the rpi you can add one of these two lines to the file /etc/xdg/lxsession/LXDE/autostart
#chromium --kiosk --incognito www.google.it
#midori -i 120 -e Fullscreen -a www.google.it -p
The first is for chromium and the latter is for midori, the rpi default lightweight browser.
Hint : Since we will use the rpi as a kiosk we want to prevent the screen from going black and disable the screensaver. Edit the autostart file:
sudo pico /etc/xdg/lxsession/LXDE/autostart
find the following line and comment it using a # (it should be located at the bottom)
##xscreensaver -no-splash
and append the following lines
#xset s off
#xset -dpms
#xset s noblank
Save, reboot.
More info on
http://pikiosk.tumblr.com/post/38721623944/setup-raspberry-ssh-overclock-sta
The upvoted answer suggest to run LXDE for it. You could also do it without such a heaver desktop enviorment. You could just start midori or chromium in an X session:
xinit /usr/bin/midori -e Fullscreen -a http://www.examples.com/
xinit chromium --kiosk http://www.examples.com/
Sometimes Fullscreen mode of midori is not working as expected and midori is not using whole screen. In these cases you could map it inside a very simple window manager like MatchBox to get real fullscreen. Due to xinit you have to wrap everything in a shell script.
#!/bin/sh
matchbox-window-manager &
midori -e Fullscreen -a http://dev.mobilitylab.org/TransitScreen/screen/index/11
Autostart could be done simply be using /etc/rc.local.
More information concerning screensaver issues and an automated restart could be found here: https://github.com/MobilityLab/TransitScreen/wiki/Raspberry-Pi#running-without-a-desktop
Chromium has a dependency problem on some debian derivate for arm architecture. For Cubian you find the bug report here. I am not sure if you could install chromium on latest Raspbian without problem.
But I really could recommend midori. It's very fast and support for modern web technologies is very good. As Chromium it is using webkit as rendering engine. If you miss some html5 / css3 features consider an update of libwebkitgtk (for example by using package of debian testing).
It's possible you haven't set the DISPLAY environment variable.
Try:
export DISPLAY=:0
/usr/bin/startx /usr/bin/browser
Or, browser can also take a display argument (so you don't need the environment variable):
/usr/bin/startx /usr/bin/browser :0
This works for me on Raspbian from a standard terminal shell (I'm logged in over SSH).
Updated for the current version of Raspbian (with Pixel desktop) install with noop 2.0.
I found you need to edit in two different places to get it to work.
/etc/xdg/lxsession/LXDE/autostart
/home/pi/.config/lxsession/LXDE-pi/autostart
So my configure file is:
# #xscreensaver -no-splash
#xset s off
#xset -dpms
#xset s noblank
#chromium-browser --kiosk --incognito http://localhost
And that's it.
You should probably start with checking if /usr/bin/kiosk/browser is working at all. You should start normal X session (graphical environment) on your RaspberryPi, launch terminal, try running this command:
/usr/bin/kiosk/browser http://my-kiosk-domain.com
and see what it prints on the terminal. Is this working? Do you see any error messages?
I'm trying to build a Webkit Kiosk on a Raspberry Pi.
I think Instant WebKiosk for Raspberry Pi could be useful for you.
See: http://www.binaryemotions.com/raspberry-digital-signage/