Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

定制 b2g.sh 脚本

在手机上,  b2g 应用程序 (它提供了 Firefox OS API 以及其他的东西)是通过 /system/bin/b2g.sh 脚本启动的。你可以对这个脚本进行定制,以修改 Firefox OS 的行为,本文则是介绍了这些内容。

设定环境变量

如果你仅仅是想要对单个运行的 B2G 设定环境变量,可以执行下面命令:

adb shell stop b2g
adb shell "export ENV_VAR=value && /system/bin/b2g.sh"

如果你想要在任何时候都使用相同的环境能够变量,可以向下节描述中对 b2g.sh 进行编辑。

编辑 b2g.sh

For debugging, you may want to set environment variables to get logging information or to otherwise affect how the b2g program runs. You can do this by editing the b2g.sh script. There aren't any tools included on the phone to edit the file in place, so you'll need to copy it to your computer first.

  1. Connect the phone to your computer, open a terminal window, and execute the following command to edit the script:
    adb pull /system/bin/b2g.sh
  2. Edit the script to make the changes you want. For example, suppose you'd like to see some logging output (which requires a debug build), then you might add something like:
    export NSPR_LOG_FILE=/data/local/tmp/mylog.txt
    export NSPR_LOG_MODULES=Layers:5
    
  3. Run the following commands to save your updated b2g.sh script to the phone and restart b2g:
    adb shell stop b2g
    adb remount
    adb push b2g.sh /system/bin
    adb shell chmod 0755 /system/bin/b2g.sh
    adb shell start b2g
    

Note: /data/local/tmp is the only place on the filesystem which is writable by content processes.

参考

 

文档标签和贡献者

 此页面的贡献者: chrisdavidmills, ReyCG_sub
 最后编辑者: chrisdavidmills,