How to get gmail address through adb shell on google glass - adb

I manage a small project where I occasionally distribute a different version of a google glass application to some (4) google glass devices manually through the adb shell. One version of the package is used for each google glass, and it depends on which gmail address the glass uses. (they all look the same)
Usually I would have to turn on the glass to see, but I was looking for a method of getting the gmail address associated with the glass through the adb shell. Is this possible?
Thank you.

There is no way I know to retrieve such info about the user.
But, you can simply put a file in the external storage containing the email account once, and then query this file when you want:
# write the user info
adb shell "echo \"xyz#gmail.com\" > /sdcard/user.info"
# get the user info
adb shell cat /sdcard/user.info
If you want this info without turning the glass on, you'll have to print a note directly on the glass ;)

Using the adb command, one way to differentiate each Glass device is through their serial numbers. You can then choose which device to install on by running the following command:
adb -s <serial number> install <apk name>.apk

Related

Is it possible to copy/paste/type (eg. a password) from an app into the Oculus Quest headset?

Currently there doesn't seem to be an easy way to copy/paste text in the Oculus Quest, nor to 'type' into a companion app and have it sent into the headset (at least that I have seen). This makes it extremely challenging to enter complex passwords from password managers, etc.
I have read some articles that say it might be possible to pair a bluetooth keyboard with the headset, which would be slightly better, but still doesn't allow me to copy/paste from my password manager.
Does anyone know of a way to achieve this?
After some Googling/SO'ing, it seems like this might be possible using the Android Debug Bridge (adb) (Oculus has their own help page for it as well)
Your device needs to be in developer mode for this to work:
Create/join an organisation in the Oculus Dashboard
Open the Oculus app on your mobile phone.
In the Settings menu, select the Oculus Quest headset that you’re using for development.
Select More Settings.
Toggle Developer Mode on.
If you're using homebrew on macOS, you can install adb with:
brew cask install android-platform-tools
Next, plug your headset into your computer with the USB-C cable. You then should be able to list connected devices:
adb devices
If it says 'unauthorized', check in the headset for a dialog box asking for permission to connect. Ticking 'always allow' will make this easier in future.
At this point, we should be good to send text to the device. In the headset, focus a field that you want to 'type' into, then use adb shell input to 'type' your text:
adb shell input text "sometext"
It seems it is also possible to send a 'paste' command using adb shell input keyevent:
adb shell input keyevent 279
In older Android devices, you could send a 'copy' command in a similar way, but this has since been deprecated:
service call clipboard 2 i32 1 i32 0 s16 "text"
It seems that on newer devices, you need to leverage an external service (eg. Clipper) to 'copy to clipboard'. Using Clipper, you can send a command in adb shell such as:
am broadcast -a clipper.set -e text "text"
There are many different inputs we can send using these methods. You can find a full list of KeyEvent's in the Android Developer Documentation.
Using one (or more) of these methods, it should be possibly to 'copy'/'paste'/'type' passwords stored in a password manager on your computer 'into' the Oculus Quest headset.

Start google course builder from Ubuntu command line

I followed these instructions to install Google CourseBuilder. Used Ubuntu via vagrant on a vm. I want to access my course site on my host windows pc since my ubuntu does not have a GUI. To do this it recommended I use the --noauth flag.
It asks for a verification code - where do I get this? See command I ran below:
Notice it says:
Go to the following link in your browser:
https://accounts.google.com....
You have to open that link in your browser(by copying and pasting or by clicking). This will present the Google Account Chooser dialog where you select the Google Account you want to deploy the course builder app with... At the end of the flow you'll be presented with a code which you then copy and paste back in your shell and Enter.
I also experienced some trouble with installation. For anyone having trouble installing Course Builder from any operating system (Windows, Linux, Mac, etc.), I made a guide and video which details how to do so:
https://www.youtube.com/watch?v=zfNQle_ZxLc
The full text guide is in the YouTube video's description.

adb command doesn't list my device

On a Macbook Pro with Yosemite -
After getting through the difficulties of getting Android SDK installed, I plug in the device, but it doesn't show. The command adb devices yields "List of devices attached" with nothing following. It's there on the USB, the About This Mac System Report shows it present on the USB.
This question looks similar to Issue setting up the development environment for ProjectTango developemnt Device but is not the same because I'm not using Eclipse.
Please ensure that USB debugging is enabled in order to enter ADB, go to Settings > About tablet > Build number and then press Build number seven times. Then press back and go to Developer options > USB debugging.
Make sure you're using the latest Google USB driver. I was having this problem (but on Win 8) and updating the driver fixed it, I'm now getting the device in adb devices and can push content to it.

How do I get bluez 5 to accept a fixed pin?

I can find nothing on how to do this. I am programming an Intel Edison in C and an Android phone in Java. I want to pair the Edison from the Android phone. I would think simple pairing (sspmode 1) would work but I get an error message on the phone about a wrong pin where no pin was requested. With sspmode 0 I get asked for a password but have no idea what it is as it is randomly generated in my NoInputNoOutput Edison. We have everything else working. If we pair from Edison manually, the rest of the code can connect and send bluetooth messages back and forth from the Edison to the phone. But pairing from Edison to any random phone that walks by is not acceptable. I think it is called Bluejacking.
I have seen some posts about using simple-agent but frankly what I understand is that BlueZ security changed so much between 4 and 5 that most all that I see doesn't work. I also see that the switch from 4 to 5 broke a lot of systems so I don't feel alone. I would try it but simple-agent is not on Edison and I have not found a procedure to install it. And as I don't know if the little I can find applies to version 5 as it all references version 4 I am feeling a little lost.
Can anyone point me in the right direction to something that will work on BlueZ 5? I am on 5.18.
The solution presented on the last post of this article does work
http://www.linuxquestions.org/questions/linux-wireless-networking-41/setting-up-bluez-with-a-passkey-pin-to-be-used-as-headset-for-iphone-816003/
Edit simple-agent, put it somewhere, make it executable, put the missing files in the same directory and run it. It must stay running for it to be active.
In my case, the missing file was bluezutils.py.
Run hciconfig hci0 sspmode 0 first
Pl use Bluz5.30.
Initially it was really difficult to bring up bluetooth using Bluez 5. It seems it was okay with Bluez 4.I have tried different versions of Bluez 5 on my LFS build. Even up to Bluez 5.28 it was not satisfactory. Now it is Bluz5.30, with this, LFS doc and lot of trail, I could manage. I feel Bluez is one of the most badly documented user unfriendly software. I also feel it is very buggy. It can hang machines forcing to hard boot the system. I have seen bluetooth forcing the Android phone also to reboot. So it is important to get the latest version of the software. But to make the bluetooth speaker work Pulseaudio was needed. It is better to get the latest version; here also LFS doc was fine.
So the process of connecting speaker was using bluetoothctl is as follows;
>> power on
>> scan on
>> pairable on
>> pair <device>
>> agent on
>> default-agent
Now the actual sound. Here pactl and pacmd are useful.
paplay -d can test the devices.
using pacmd with command 'list-sinks' can show the devices.
pacmd ->list-modules can show the modules loaded.
How to change automatically the audio output to bluetooth speaker when it is connected?
For me in one machine it was working fine, with an identical LFS in another machine it was not working. Finally it was identified as a
missing module module-device-manager with arg do_routing=1.
Once it was loaded everything was fine. This particular module was not shown in the pulse configurations. So I have to find that and load,
pacmd
load-module module-device-manager do_routing=1
One can add a line in the default configuration file available in /etc/pulse.or one can add it in the user configuration file also.Now to make the new bluetooth speaker being used to play sound. For that issue the command 'move-sink-input ' using pacmd. You can find the sink names my issuing the command 'list-sinks'.
If your speaker is not connecting, it may be that it is already connected elsewhere. If it is not so, remove-device; scan on; pair; and connect using bluetoothctl. I was worrying how to make file transfer using bluetooth (Bluez5). Actually very little information is available in LFS documention or in general in the NET. This very true and unfortunate about Bluez in general. They do not provide any real user doc or nothing is available in net. So the steps are as follows:
You need to install OBEX library. Then you build Bluez5 (if it not done already). It will install obexd. After installation you can find obexd in $PREFIX/libexec/bluetooth/obexd.This is where you find bluetoothd also. One generally makes a link for bluetoothd in /usr/sbin. A similar link can be made for obexd also. Once you start bluetoothd and obexd you can find object transfer profiles in bluetoothctl->show.If you need a phone to push objects to the computer, you need to run obexd with options '-a' and '-r '. if '-a' is not given phone will fail to send the file. Now how to push a file from Computer to Phone. For this you need obexctl, I do not think it is a finished tool, and it will not be installed while we build Bluez 5. I have seen it in the source tree and copied to /usr/bin/. It should be used to connect the Phone and when the connection is established one can 'send ' and you have to accept the request in the phone.
Starting obexd as a deamon was a problem. When obexd was tried on a text terminal (init 3) it was not possible to start since it needs a dbus session which in turn needs X display. It means one need to login an X seession before you start obexd. If you dissable X while building DBUS (--without-x) then Window Managers will not work. But there is solution with 'dus-run-session < command> [args]'. That means you can start a service obexd (like bluetoothd) in the system start-up. So just by switching on the Computer ( if pairing, trusting etc... was done earlier) one can push files from Phone to computer.
>> connect <device>
Second time onwards just connection is fine. Probably you can trust the device.
>> trust <device>

how to automate adb events

I have used various adb shell commands to automate the loading of a URL to a handset via adb. It loads up the page but I need to then select an image on the screen. I have tried adb shell input keyevents but this is sometimes missing the image so I need to use the send event and mimic the touching of the screen.
Can someone please help. How do I find out the co-ordinates of the picture?
Thanks
You can use monkeyrunner to get screenshot
import sys
import os
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
device = MonkeyRunner.waitForConnection(10 , os.getenv('ANDROID_SERIAL'));
image = device.takeSnapshot();
image.writeToFile("/folder/test.png","png");
Don't forget to SET on windows and EXPORT on Linux ANDROID_SERIAL
ANDROID_SERIAL - it's your device number (can be obtain by using adb devices)
Then open image in Paint or any other, and get the coordinates of picture.
Enable Show pointer location from developer options. It will show coordinates of the point where you touch. using the coordinates you can touch on required points using monkeyrunner or
adb shell input tap <x><y>
.

Resources