User Services/Try FMD

From MozillaWiki
Jump to: navigation, search

Get Find My Device Working

FxOS 2.0 Aurora and 2.1 Master

Requirement: build flashed after 15:36 PST - 7/10/2014

  1. On FxOS, goto Settings > Find My Device
  2. sign in with existing Firefox Account or create a new one, then enable FMD
  3. goto https://find.firefox.com
  4. sign in with the same user as step #2
  5. It should locate your device

End-2-End Test

FindMyDevice end-to-end test with options!

  • launches desktopB2G and uses marionette.js to sign into FXA and enable FMD, leaves window open
  • launches webdriver to sign into FMD web site with the same FXA acct
  • tells you if your phone was located withing 60 sec (can be changed)
  • kicks off Ringer on each test
  • specify options: repeat test, FXA server, FMD server, test timeout

Installation

Pre-requisites:

  • virtualenv recommended
  • gaia profile generated (if you need to, run make test-integration, then kill when tests begin)
$ mkvirtualenv fmdtest
$ pip install selenium fxa-python-client psutil gaiatest
  • Clone my repo/branch, create a new directory if you already have gaia
$ git clone https://github.com/rpappalax/gaia.git
$ cd gaia
$ git checkout fmd-e2e-plus

Note

  • if you run into a compiler flag not found error on OSX, you may need to export this env var
$ export ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future"

Run Test(s)

To see all options:

$ python fmd_locate.py -h

Example: run a test 3x:

$ python fmd_locate.py -r 3

optional arguments:

 -h, --help            show this help message and exit
 -x FXA_SERVER, --fxa-server FXA_SERVER
                       Enter path of Firefox Accounts server (default:https
                       ://api-accounts.stage.mozaws.net/
 -f FMD_SERVER, --fmd-server FMD_SERVER
                       Enter the URL of the FMD server
                       (default:https://find.stage.mozaws.net)
 -g GAIA_DIR, --gaia-dir GAIA_DIR
                       Enter path of gaia dir
                       (default:/Users/rpappalardo/git/B2G/gaia)
 -t TEST_TIMEOUT, --test-timeout TEST_TIMEOUT
                       Enter the test timeout in seconds (default:60)
 -r REPEAT, --repeat REPEAT
                       Enter the number of times to repeat test (default:1)
 -s SELENIUM_SERVER, --selenium-server SELENIUM_SERVER
                       Enter path of selenium jar file
                       (default:/Users/rpappalardo/git/B2G/gaia/selenium-
                       server-standalone-2.42.2.jar)

Reference

Source

QA Flash Steps

clone this:

git clone https://github.com/Mozilla-TWQA/B2G-flash-tool

run

./auto_flash_from_pvt.sh -w -g -G

choose gaia+gecko

Debugging

Client side on device:

User Build

Enable Developer Menu:

  • Check this box: Settings > Device Information > Developer Menu
  • Then check the boxes for:
    • Settings > Developer > Gaia debug traces
    • You may be able to set this via pref: user_pref('browser.dom.window.dump.enabled', true);
    • Settings > Developer > Geolocation output in ADB
    • Then run this:
adb logcat | grep -e GEO -e findmydevice
  • Enable adb access:
    • Settings > Debugging via USB - set to 'ADB' or 'ADB and DevTools'

install adb on desktop then run

adb logcat

Engineering Build

Enabled verbose logging by enabling this:

  • Settings > Developer > Gaia debug traces.

install adb then run

adb logcat

For the web app, open Tools > Web Developer > Web Console

Geolocation data will print to console.

Custom FMD Server

If you want to flash FMD app to use a specific server, follow these steps:

Note: i haven’t been able to figure out if this can be done at runtime editable file vs build then flash. I wasn’t able to find any files with the fmd endpoint URI

Set FMD and Gaia URLS

$ git clone https://github.com/mozilla-b2g/gaia.git
$ cd gaia
Edit 3 files defined here:

https://github.com/6a68/gaia/commit/00ec611f5d1dfc3f86bf1c139e460aae178f3d08

$ make reset-gaia

If you want to confirm the URLs are written correctly to your phone.

adb shell
adb pull /system/b2g/webapps/findmydevice.gaiamobile.org/application.zip

on desktop unzip and view

js/config.js

Set Firefox Account URL

1. set fxa to use stage servers download this: https://gist.github.com/edmoz/5596162

$ chmod +x modPref.sh
$ ./modPref.sh pull

edit prefs.js and add this to the bottom on it’s own line:

user_pref("identity.fxaccounts.auth.uri", "https://api-accounts.stage.mozaws.net/v1");

2. Run this

$ ./modPref.sh push prefs.js


3. on Flame, sign into Fxa, verify email if needed, the verify link should be to

https://accounts.stage.mozaws.net/v1/verify_email?…

Note: even if you have an existing account before, you may not have created one in the Stage Database. Just create it again.

4. sign into:

https://find.stage.mozaws.net

if you look in console i see and it correctly finds my location:

"device:updated" "2731a65040a15a6080c6b48d4231b4d9" Object { 
 hasPasscode: undefined, 
 latitude: 37.xx, 
 longitude: -122.xx, 
 altitude: 0,
 located: true, 
 time: Date 2014-06-20T21:48:46.000Z 
} "{"Latitude":37.xx,
 "Longitude":-122.23120187,
 "Altitude":0,
 "Time":1403300926000,
 "Cmd":{"t":{"la":37.xx,"lo":-122.xx,"ok":true,"ti":1.403300926e+12}}}" 
 device.js:50

ring, lost mode, erase all work as expected.

Set SimplePush URL

If you also need to use a staging or custom SimplePush server, follow same steps as for setting Firefox Account URL (see above) but add user_pref for "services.push.serverURL".

default setting is:

user_pref("services.push.serverURL", "wss://push.services.mozilla.com/");

Low Memory Throttling

All testing should be done with a memory limit on the Flame. Run these cmds:

adb reboot bootloader  
*Device will restart*
fastboot oem mem 273
fastboot reboot

To see what you have it set to:

adb reboot bootloader
fastboot getvar mem

Note: There has been debate about 512MB vs 273MB, 273MB has been confirmed by tchung as the shipping memory target.

Test Servers

FMD uses 2 different apps, Firefox Accounts Settings/FirstTimeUse gecko level code. Which is what you use when you sign into firefox accounts. You can modify this endpoint by pushing user_pref onto your b2g device.

Find My Device - Settings has two endpoints: fxa-oauth and fmd app server which is in the Gaia layer. You can modify this endpoint by flashing a locally modified findmydevice.json Gaia to your phone.

Current 2.1 master src of truth:

Flash Gaia URLS

To set the URLS in Gaia, edit these files, and run make reset-gaia

apps/findmydevice/build/build.js
apps/settings/build/build.js
customization/findmydevice.json 

Here's the last commit - https://github.com/mozilla-b2g/gaia/commit/c710decee223224687c27333fc0d7e12df400c1c

prod env

Default for 2.0 and 2.1 branches

stable env

dev env:

Must Flash Gaia URLS (see above)

stage env:

Must Flash Gaia URLS (see above)