B2G/QA/Tips And Tricks: Difference between revisions

From MozillaWiki
< B2G‎ | QA
Jump to navigation Jump to search
Line 3: Line 3:


== Helix internal storage ==
== Helix internal storage ==
If you have an SD card in the device, the internal storage will be at /mnt/sdcard2/screenshots
If you have an SD card in the device, the internal storage will be at /mnt/sdcard2/screenshots .
 
Or you can follow the steps below to find the internal/external storage mapping.
* Start a remote shell in your phone
  $ adb shell
* List detail information of /sdcard folder.
  root@android:/ # ls -l /sdcard                                                 
  lrwxrwxrwx root    root              1980-03-20 00:12 sdcard -> /mnt/sdcard
* Display the filesystems
  root@android:/ # df
  Filesystem            Size  Used  Free  Blksize
  ...
  /system                503M  186M  317M  4096
  /data                    1G    19M    1G  4096
  /cache                188M    4M  184M  4096
  ...
  /mnt/sdcard2            1G    93M    1G  4096
  /mnt/sdcard              3G  396M    3G  32768
  ...
  root@android:/ #
* The /mnt/sdcard mounted to /sdcard, which should be the external storage (SD card). And /mnt/sdcard2 should be the internal storage.


== Conversion tool to change file formats ==
== Conversion tool to change file formats ==

Revision as of 09:23, 21 October 2013

B2G Tips Tricks

A collection of QA's tips and tricks on how to test Firefox OS. See here for List of Terms

Helix internal storage

If you have an SD card in the device, the internal storage will be at /mnt/sdcard2/screenshots .

Or you can follow the steps below to find the internal/external storage mapping.

  • Start a remote shell in your phone
 $ adb shell
  • List detail information of /sdcard folder.
 root@android:/ # ls -l /sdcard                                                  
 lrwxrwxrwx root     root              1980-03-20 00:12 sdcard -> /mnt/sdcard
  • Display the filesystems
 root@android:/ # df
 Filesystem             Size   Used   Free   Blksize
 ...
 /system                503M   186M   317M   4096
 /data                    1G    19M     1G   4096
 /cache                 188M     4M   184M   4096
 ...
 /mnt/sdcard2             1G    93M     1G   4096
 /mnt/sdcard              3G   396M     3G   32768
 ...
 root@android:/ #
  • The /mnt/sdcard mounted to /sdcard, which should be the external storage (SD card). And /mnt/sdcard2 should be the internal storage.

Conversion tool to change file formats

Checking Hardware versus Software Graphics Rendering

  • Currently there is no implementation for a frame rate counter for hwc. This allows us to check software versus hardware rendering by turning on the frame rate counter.
    • to turn on the frame rate counter, go to settings -> device information -> more information -> developer -> show frames per sec...
    • to turn off the hwc :
adb root
adb pull /system/b2g/defaults/pref/user.js .
echo 'pref("layers.composer2d.enabled", false);' >> user.js 
adb remount
adb push user.js /system/b2g/defaults/pref
adb shell sync && adb reboot

Wifi Logging

  • turn on the wifi debug message in Settings/Device

information/More Information/Developer/Wi-Fi output in adb,

  • attach the debug message using "adb logcat". You need to turn off/on the wifi to

output the debug message.

Addon to Firefox web browser to see Firefox OS Simulator

https://addons.mozilla.org/en-us/firefox/addon/firefox-os-simulator/

Launching Desktop B2G on mac with profile

 $ git clone git://github.com/mozilla-b2g/gaia
 $ make -C gaia profile
 $ /path/to/b2g -profile gaia/profile
 (eg. Tonys-MacBook-Air:MacOS tchung$ ./b2g -profile /Users/tchung/Desktop/DailyB2G/07172012_desktop/gaia/profile)

Diagrams

of the RIL (Software Module Structure)

Gaia

Setting the system clock

 $ adb shell date -s 20120731.172200  (for 5:22pm)
  • In order to print the format the same on the mac:
  date -j "+%Y%m%d.%H%M%S"
  • Placing them together :
  adb shell date -s `date -j "+%Y%m%d.%H%M%S"`

Tricking b2g emulator to see network

 1) launch emulator ./run-emulator.sh
 2) adb shell setprop net.dns1 10.0.2.3

Sending class-0 message w/ emulator

 $ ./run-emulator.sh &
 $ telnet localhost 5554
 > sms pdu 00000191F10010001010000000000141
 OK

See https://mxr.mozilla.org/mozilla-central/source/dom/mobilemessage/tests/marionette/test_message_classes.js#57

Enabling A-GPS on device

This is for building B2G:

 $ cd b2g/app/b2g.js
 vi b2g.js
 add pref("geo.gps.supl_server", "supl.google.com");
 add pref("geo.gps.supl_port", 7276);

To get the Device IP

 $ adb shell netcfg

This will list of the devices with the ips on which it is running. If you are unable to check the device by name, then check by the mac address which is listed in the last column of the output

For changing the preference:

1. adb root
2. adb remount
3. adb pull /system/b2g/defaults/pref/user.js .
4. edit the file and change : 
     pref("geo.gps.supl_server", "test.supl.svc.ovi.com");
     pref("geo.gps.supl_port", 7276);
   to
     pref("geo.gps.supl_server", "supl.google.com");
     pref("geo.gps.supl_port", 7276);
5. adb push user.js /system/b2g/defaults/pref
6. adb reboot

Media Files Repository

Can be found here: http://hg.mozilla.org/mozilla-central/file/tip/content/media/test

Importing Contacts via Device (manually)

  • First, export your contacts in your old phone to the SIM card.
    • Some phones have this feature built-in, check your Contacts app or phone settings.
    • Android: To export Google contacts onto a SIM card (which Android does not do by default), install the free app Contact2Sim. Open the app, select the phone, and in the options menu choose "Copy missing to SIM".
    • iPhone: No easy solution. You could probably sync iPhone to Mac Address Book, and sync that to Google, and then find an Android phone to export those to your sim card.
  • Second, put the SIM card in your Firefox phone, open the Contacts app and click the "Import SIM contacts" button.

Changing preferences

Prefs.js:

 PREFS_JS=$(adb shell echo -n "/data/b2g/mozilla/*.default")/prefs.js
 adb pull $PREFS_JS
 edit prefs.js
 adb shell stop b2g
 adb push prefs.js $PREFS_JS
 adb shell start b2g
  • things to change :
    • For email debugging, setting this pref to set true : "browser.dom.window.dump.enabled"

User.js:

 adb pull /system/b2g/defaults/pref/user.js .
 < edit user.js and set "ril.debugging.enabled" to true >
 adb shell mount -o remount,rw /system
 adb push user.js /system/b2g/defaults/pref
 adb shell mount -o remount,ro /system
 adb shell sync && adb reboot
  • this turns ril debugging on
 adb root
 adb pull /system/b2g/defaults/pref/user.js .
 echo 'pref("network.dns.disablePrefetch", true);' >> user.js 
 adb remount
 adb push user.js /system/b2g/defaults/pref
 adb shell sync && adb reboot
 adb root
 adb pull /system/b2g/defaults/pref/user.js .
 echo 'pref("general.useragent.override", "Mozilla/5.0 (Android; Mobile; rv:22.0) Gecko/22.0 Firefox/22.0");' >> user.js 
 adb remount
 adb push user.js /system/b2g/defaults/pref
 adb shell sync && adb reboot


  • This adds the pref to disable dns prefetching : bug 856530


 adb forward tcp:9999 tcp:9999
 netcat localhost 9999
 navigator.mozSettings.createLock().set({'wifi.debugging.enabled': true})
  • to turn it back off, just set it to false:
 navigator.mozSettings.createLock().set({'wifi.debugging.enabled': false})

Source : bug 806611

  • to turn system system updates off; set gaia.system.checkForUpdates to false

Backing up the Profile and Restoring it after flash

 <go to a temp folder somewhere>
 adb pull /data/local local
 adb pull /data/b2g b2g
 <flash device>
 adb push local /data/local
 adb push b2g /data/b2g

Crashes

Getting crashes off the Device

  • adb shell ls -l /data/b2g/mozilla/Crash\ Reports/submitted/

if you have a long list of crashes and want them sorted by date, use this:

  • adb shell busybox ls -ltr /data/b2g/mozilla/Crash\ Reports/submitted/

How to Force a crash

how to run GDB script for b2g

  • Start the gallery app on the phone.
  • $ adb shell b2g-ps
 Note the pid of the gallery app
  • $ ./run-gdb.sh attach <pid>
  • Cause the crash
  • (gdb) bt

[Courtesy of jlebar]

BusyBox

File:Busybox-b2g.tar.gz

Install

Download and unzip the tarball, cd to busybox-b2g, and run install.sh

Usage

All of the busybox utilities get symlinks in /system/bin, so you can just run e.g. 'ping' directly

adb shell ping 8.8.8.8   => ping command 
adb shell ifconfig wlan0 => check tx/rx bytes  
adb shell cat /proc/net/route    => check the default route
adb shell iptables -t nat -nvL   => check if the packets are sent from application to IP layer, check Chain OUTPUT (policy ACCEPT 2 packets, 168 bytes)

DBus

Here is the way to provide more logs. dbus-log.txt Usage in ubuntu linux:

  1. Unzip File:Dbus-tool.zip
  2. adb root
  3. adb push dbus-monitor /system/bin
  4. adb shell chmod 777 /system/bin/dbus-monitor
  5. adb push dbus-uuidgen /system/bin
  6. adb shell chmod 777 /system/bin/dbus-uuidgen
  7. Before running dbus-monitor, you need to run "dbus-uuidgen --ensure" in unagi first.
  8. adb shell dbus-monitor --system "type='signal'" |tee dbus-log.txt
  9. Start to test. Now dbus log will be recorded.

Notes:

  1. . Why we use it : http://en.wikipedia.org/wiki/D-Bus
  2. . example and instructions from : bug 828860

Rooting a production device

Partner production builds often come with unrooted access. You can follow these steps if you have a special rooted boot image from the partner.

  • Pre-setup: receive a rooted boot.img from the partner. This usually means root=true.

Buri Device

start up in normal adb mode.
 $ adb reboot bootloader  //enter into fastboot. you should see a White splashscreen
 
 $ fastboot flash boot boot_rooted.img  //flash the boot_rooted.img onto the boot partition
   sending 'boot' (4506 KB)...
   OKAY [  0.410s]
   writing 'boot'...
   OKAY [  0.727s]
   finished. total time: 1.137s
 $ fastboot reboot   //reboot the image
 
 $ adb shell
   root@android:/ #    

cmd line prompt "root@android:/ #" means you're in rooted mode.

Scripts

Outdated scripts

Incomplete Script

Hardware Cheat codes

  • System Recovery Utilities:
    • Inari: reboot, power-on+ volume up
    • Hamachi/Buri : reboot, turn on, volume up
  • System Recovery Only UI:
    • Hamachi/Buri : reboot, power-on+volume-up
  • Fastboot mode: (mode that allows flashing on the device without setting remote debug on)
    • Inari : plug in, power on, hold volume up+down
    • Hamachi/Buri : plug in, power on, hold volume down
    • Unagi : plug in, power on, hold power + up
    • Leo: take out battery, hold down volume button, plug into computer
  • upload mode (visual screen change)
    • Leo: take out battery, hold up volume button, plug into computer


  • Calibrating the Proximity sensor
    • Inari
      1. load the image to the device
      2. start the Dialer app
      3. Input "*983*0#" and press "send". The device should start vendor engineering test app
      4. Press "Down" and Select "Sensor"
      5. Press "Calibrate" button to do prox sensor calibration
      6. The device will show "Calibrate OK", when the calibration is complete.
      7. Then you can test the sensor.
        1. block the sensor, the screen will show "Proximity:true"
        2. unblock the sensor, the screen will show "Proximity:false"
      8. Press "Back", "Quit" to quit this app, and check whether the sensor can work in voice call.

( Source : https://bugzilla.mozilla.org/show_bug.cgi?id=857484 )

  • Getting IMEI info:
    • dial *#06# in the phone app.


  • Getting Touchscreen Info:
 $ adb shell cat /proc/touchscreen/ts*


Devices that don't allow for adb root/adb remount

If you do a |adb shell getprop ro.secure| it should return 1. You basically have to repack which is complicated, or get a different boot.img.

The things that are blocking is the default.prop which has to be set to: ro.secure=0 ro.debuggable=1 persist.service.adb.enable=1

Unforuntately without mount/remount/root it's difficult.


ADB tricks

  • command to run and check the system directory:
  while true; do clear; adb shell mount | grep "system";sleep 1;done
  • a different log to check why mounting and other possible system issues:
 adb shell dmesg

Help I bricked my phone/Unagi

RIL

APN

   Name: T-Mobile
   APN: epc.tmobile.com or fast.tmobile.com (for LTE devices)
   Proxy: <Not set>
   Port: <Not set>
   Username: <Not set>
   Password: <Not set>
   Server: <Not set>
   MMSC: http://mms.msg.eng.t-mobile.com/mms/wapenc
   MMS proxy: <Not set>
   MMS port: <Not set>
   MMS protocol: WAP 2.0
   MCC: 310
   MNC: 260
   Authentication type: <Not set>
   APN type: <Not Set> OR Internet+MMS (depending on software version)
    • AT&T :
   Name: can be anything
   APN: wap.cingular
   Proxy: leave blank
   Port: leave blank
   Username:WAP@CINGULARGPRS.COM
   Password:CINGULAR1
   Server: leave blank
   MMSC: http://mmsc.cingular.com
   MMS Proxy: wireless.cingular.com
   MMS Port: 80
   MCC:310
   MNC:410
   APN Type: leave blank

MCC/MNC

  adb logcat | grep -E 'MCC|MNC'

COMRIL vs MOZRIL checking

Dealing with the Commercial RIL

If the bundles are in the distribution folder, then it will use that RIL:

  • adb shell ls /system/b2g/distribution/bundles/

To revert and use mozril, delete the bundles folder:

  • adb root
  • adb shell mount -o remount,rw /system
  • adb shell rm -r /system/b2g/distribution/bundles
  • adb shell mount -o remount,ro /system
  • adb shell sync && adb reboot

Locating the Firmware version on your Device

  • adb shell cat /proc/version
 Linux version 3.0.21-perf (jeremy.kim@LGEARND8B7) (gcc version 4.4.3 (GCC) ) #1 PREEMPT Mon May 13 14:20:36 KST 2013

Flashing only Gecko and Gaia bits over your base image

These are steps if you only want to apply gecko and gaia over your device Gonk or Commercial RIL.


  • Pre-setup:
  • Flash the base Leo build on the device, so you have the vendor binaries
  • download the Gaia.zip and b2g-18.0.en-US.android-arm.tar.gz from the Device directory's location. (Leo example)
  • Extract both into a temp directory
  $ adb root
  $ adb shell stop b2g
  $ adb remount
  //Updating gecko (make sure you push the b2g directory not the b2g app, 
  //ie be at the directory one level above the unzipped b2g-18 zip file instead of inside the b2g folder)
  $ adb push b2g /system/b2g
  //If gaia doesn't work the first time around, do the steps above and the following and then do the gaia update portion; 
  // otherwise skip this and go to the updating gaia portion:
  $ adb shell rm -r /cache/*
  $ adb shell rm -r /data/b2g/*
  $ adb shell rm -r /data/local/webapps
  $ adb shell rm -r /system/b2g/webapps
  //Updating gaia:
  $ adb push gaia/profile/webapps /system/b2g/webapps
  $ adb push gaia/profile/settings.json /system/b2g/defaults/
  $ adb push gaia/profile/user.js /system/b2g/defaults/pref/
  // restart
  $ adb shell sync
  $ adb shell reboot

Removing RIL + flashing Gecko + flashing Gaia and reseting profile

Instructions for updating currently:

  • Pre-setup:
  • Flash the base Leo build on the device, so you have the vendor binaries
  • download the Gaia.zip and b2g-18.0.en-US.android-arm.tar.gz from the Device directory's location. (Leo example)
  • Extract both into a temp directory
  $ adb root
  $ adb shell stop b2g
  $ adb remount
  // remove the RIL
  $ adb shell rm -r /system/b2g/distribution/bundles 


  //Updating gecko (make sure you push the b2g directory not the b2g app, 
  //ie be at the directory one level above the unzipped b2g-18 zip file instead of inside the b2g folder)
  $ adb push b2g /system/b2g
  //If gaia doesn't work the first time around, do the steps above and the following and then do the gaia update portion; 
  // otherwise skip this and go to the updating gaia portion:
  $ adb shell rm -r /cache/*
  $ adb shell rm -r /data/b2g/*
  $ adb shell rm -r /data/local/webapps
  $ adb shell rm -r /system/b2g/webapps
  //Updating gaia:
  $ adb push gaia/profile/webapps /system/b2g/webapps
  $ adb push gaia/profile/settings.json /system/b2g/defaults/
  $ adb push gaia/profile/user.js /system/b2g/defaults/pref/
  // restart
  $ adb shell sync
  $ adb shell reboot

Building Gecko/Gaia

B2G Compiling Gecko

  • Follow the instructions on : https://github.com/mozilla-b2g/B2G
  • if you have all the prereqs, you just need to clone the repo
  • use the config.sh to config what you're building, use the Branch variable to switch branches, use the device name to build for the specific devices
    • BRANCH=master ./config.sh peak
    • BRANCH=v1-train ./config.sh leo
  • build gecko
    • ./build.sh gecko

B2G Compiling Gaia

Importing contacts, dial data, sms, and media via USB

  • You can do this by just cloning the gaia repo and switching to master branch:
 git clone https://github.com/mozilla-b2g/gaia.git
 git checkout origin/master
 git checkout master

And then run the script to populate sqlite db

Note: the following steps below assumes that you have built your own gecko and gaia repo. If you havent done that first, you cannot run these steps. See Instructions on building your B2G Repo. Average time it takes to sync and build is around 5-8 hours

  • Start by syncing and updating your Gaia repo
 ./repo sync gaia
 Cd gaia
  • run the script that populates your sqlite db
 $ make reference-workload-x-heavy 
 Images:          250
 Songs:           250
 Videos:           50
 Contacts:       2000
 Sms Messages:   2000
 Dialer History:  500
 $ make reference-workload-medium
 Images:           50
 Songs:            50
 Videos:           10
 Contacts:        500
 Sms Messages:    500
 Dialer History:  100
 $ make reference-workload-light
 Images:           20
 Songs:            20
 Videos:            5
 Contacts:        200
 Sms Messages:    200
 Dialer History:   50

Reference : https://developer.mozilla.org/en-US/docs/Mozilla/Firefox_OS/Platform/Gaia/Hacking_Tips_And_FAQ

Hi DPI builds

  • Currently supported screens:
    • qHD: ~540×960, device pixel ratio = 1.6875
    • WVGA: ~480×800, device pixel ratio = 1.5

How to:

  • You need to set GAIA_DEV_PIXELS_PER_PX=1.5 when using any make command

Examples:

  • GAIA_DEV_PIXELS_PER_PX=1.5 make reset-gaia
  • GAIA_DEV_PIXELS_PER_PX=1.5 make install-gaia
  • GAIA_DEV_PIXELS_PER_PX=1.5 BUILD_APP_NAME=contacts make install-gaia

Other Gaia compilation commands

  • MOZILLA_OFFICIAL=1
    • to make branded; default 0
  • make production
    • production build versus engineering
  • DOGFOOD=1
    • dogfood is turned on
  • make profile
    • makes only the profile
  • make reset-gaia, keeps your old profile
    • resets gaia
  • make install-gaia
    • installs gaia, brand new
  • APP=<app name>
    • installs the specific application in the gaia directory
  • make clean
    • removes the generated profile; will be available when bug 874774 lands.

Example : if you want the production dogfood build that's branded: MOZILLA_OFFICIAL=1 DOGFOOD=1 make production

See : https://developer.mozilla.org/en-US/docs/Mozilla/Firefox_OS/Platform/Gaia/Build_System_Primer

Profiles

From kgrandon: bug 864751

We've recently landed a gaia patch which will use a different folder for DEBUG profiles compared to PRODUCTION profiles. 
By default, the new folder is now located in gaia/profile-debug. It's possible to override this by passing in your own 
folder name, e.g.: DEBUG=1 PROFILE_FOLDER=awesomeprofile make 

If you are using some aliases to start gaia in Firefox, you will likely need to update these. 
Here is what I have in my .bash_profile (on OSX) that works well for me:

alias gaiaff="/Applications/FirefoxNightly.app/Contents/MacOS/firefox -profile ~/workspace/gaia/profile-debug"

Customized UI

Customized UI allows people change their:

  • animation when boot and shutdown,
  • default ring tones,
  • wallpapers,
  • built-in bookmarks for browser,
  • built-in contacts,
  • default cost control setting,
  • home screen,
  • settings,
  • adding sms black list
  • and the working in support page.

For more detail, you can have a look on https://wiki.mozilla.org/B2G/MarketCustomizations

To setup a customized build, in the root Gaia directory, run:

MOZILLA_OFFICIAL=1 GAIA_DISTRIBUTION_DIR=sample_folder_path make production

Where sample_folder_path contains a customization. An example customization is here.

Building Profile

Building Gaia for l10n v1.1 for Geeksphone

After Compiling

  • to find the repo rev versions : look at: <compile dir>/out/target/product/leo/system/sources.xml

Generate Gaia/Gecko OTA Update Package

To generate complete Gaia/Gecko OTA update package and update.xml file, please follow the steps.

  • Prepare the B2G project, then config it.
  • Generate B2G build and update package.
 $ cd $b2g
 $ <ENV_VARS> ./build.sh 
 $ <ENV_VARS> ./build.sh gecko-update-full
  • Generate update.xml file for update package.
 $ ./tools/update-tools/build-update-xml.py -o out/update.xml -u <dest_url>/b2g-gecko-update.mar -v <app_ver> -V <platform_ver> \
   objdir-gecko/dist/b2g-update/b2g-gecko-update.mar
  • Copy update package to http server.
 $ cp objdir-gecko/dist/b2g-update/b2g-gecko-update.mar <dest>
 $ cp out/update.xml <dest>

For more detail, you can have a look on https://wiki.mozilla.org/B2G/Updating

Automation

Debugging OOM

  • https://wiki.mozilla.org/B2G/Debugging_OOMs
  • If you have b2g/gecko code on your computer, you should have a tools folder. Inside the tools folder you should see :
    • get_about_memory.py
      • in order to run this, you will want python installed and a build placed on a device attached to your machine
      • run |adb root|
      • run |python get_about_memory.py|
      • on your computer open the URL listed in a browser. ie : about:memory?file=/Volumes/Projects/Projects/b2g18-v1train-leo/tools/about-memory-0/memory-reports
        • Sample run:
   NH-MBP:tools nhirata$ python get_about_memory.py 
   Got 6/6 files.
   Pulled files into about-memory-1.
   To view this report, open Firefox on this machine and load the following URL:
     about:memory?file=/Volumes/Projects/Projects/b2g18-v1train-leo/tools/about-memory-1/memory-reports
   NH-MBP:tools nhirata$

Memoryreport.png

Data