The permissions
field in the app manifest controls the app's access to various sensitive APIs on the device (sometimes called WebAPIs). The permissions are described in the following tables.
Boot2gecko
The three levels of permission, in brief, are:
A version of Gecko for Project Tablet - a simple tablet dedicated to browsing the web 12 9 14 2 Updated on Jul 15, 2020 B2G. MIUI (pronunciation: Me You I) is a heavily modified Android ROM developed by Chinese electronics manufacturer Xiaomi.This is a fork of the Android OS. MIUI includes various features such as theme support. IPadOS is a mobile operating system developed by Apple Inc. For its iPad line of tablet computers.It is a rebranded variant of iOS, the operating system used by Apple's iPhones, renamed to reflect the diverging features of the two product lines, particularly the iPad's multitasking capabilities and support for keyboard use.
- Web apps: These only have a basic level of permissions, and don't have access to privileged or internal APIs.
- Privileged apps: These have all the permissions of web apps plus more. Hosted apps can't be privileged — they must be packaged apps.
- Internal (certified) apps: These have all the permissions of privileged and web apps plus more. Certified/internal apps can only be installed on a device by Mozilla or a device vendor; not 3rd party developers.
For more information on app types, see Types of packaged apps.
Note: If you use the App Manager/WebIDE to test your app, it will display an easy to read table of which permissions are allowed, denied, or require a prompt on the current device or simulator you are connected to.
Example
As an example, if your app wants to use getUserMedia()
to access audio and/or video from the user's microphone and camera, you need to specify one or both of the following fields inside your manifest file:
See permission: audio-capture and permission: video-capture for more information.
Manifest permission | API name | Description | Minimum app type required | access property | Default granted | Platform/version supported |
---|---|---|---|---|---|---|
alarms | Alarm | Schedule a notification, or schedule an application to be started. | hosted | none | Allow | FxOS 1.0.1 |
audio-capture | getUserMedia, Web Speech API | Obtain MediaStream from audio input devices, e.g. microphone. This is needed to allow audio capture in Firefox OS 1.2+. | hosted for getUserMedia, privileged for Web Speech API | none | Prompt for all installed App types for getUserMedia, Allow for Web Speech API. | FxOS 1.2 and Desktop Firefox 20+ for getUserMedia, FxOS 2.5 and Desktop Firefox 44 for Web Speech API. |
audio-channel-alarm | AudioChannels | Alarm clock, calendar alarms. | privileged | none | Allow | FxOS 1.0.1 |
audio-channel-content | AudioChannels | Music, video. | hosted | none | Allow | FxOS 1.0.1 |
audio-channel-normal | AudioChannels | UI sounds, Web content, music, radio. | hosted | none | Allow | FxOS 1.0.1 |
audio-channel-notification | AudioChannels | New email, incoming SMS. | privileged | none | Allow | FxOS 1.0.1 |
browser | Browser | Enables the app to implement a browser in an iframe . | privileged | none | Allow | FxOS 1.0.1 |
camera | Camera | Take photos, shoot video, record audio, and control the camera. Note: | privileged in Firefox OS 2.0+ internal/certified up to Firefox OS 1.4 | none | Prompt for all installed App types. | FxOS 1.0.1-1.4 certified FxOS 2.0+ privileged |
contacts | Contacts | Add, read, or modify contacts from the address book on the device and read contacts from the SIM. | privileged | readonly , readwrite , readcreate , or createonly | Prompt for all installed App types. | FxOS 1.1 Firefox Android 18 |
desktop-notification | mozNotification for Gecko <22, Notification for Gecko 22+ | Display a notification on the user's desktop. Note that this has changed, so for Gecko <22 (Firefox OS <1.2) you need to use mozNotification , while for Gecko 22+ (Firefox 1.2+) you need to use Notification . | hosted | none | Prompt for Web content. Allow for all installed App types. | FxOS 1.0.1, Android 4.0, Desktop 4.0 for prefixed version FxOS 1.2, Android 22, Desktop 22 for non-prefixed version |
device-storage:music | Device Storage | Add, read, or modify music files stored on the device. | privileged | readonly , readwrite , readcreate , or createonly | Prompt | FxOS 1.0.1 |
device-storage:pictures | Device Storage | Add, read, or modify picture files stored on the device. | privileged | readonly , readwrite , readcreate , or createonly | Prompt | FxOS 1.0.1 |
device-storage:sdcard | Device Storage | Add, read, or modify files stored on the device's SD card. | privileged | readonly , readwrite , readcreate , or createonly | Prompt | FxOS 1.0.1 |
device-storage:videos | Device Storage | Add, read, or modify video files stored on the device. | privileged | readonly , readwrite , readcreate , or createonly | Prompt | FxOS 1.0.1 |
fmradio | FM Radio | Control the FM radio. | hosted | none | Allow | FxOS 1.0.1 |
geolocation | Geolocation | Obtain the current location of the user. | hosted | none | Prompt (even for certified Apps) | FxOS 1.0.1, Desktop Firefox 3.5, Android 4.0 |
input | Keyboard | Allows the app to act as a virtual keyboard by listening to focus change events in other apps. All IME apps need this permission for sending input keys and updating the value of a input field. | privileged | none | Allow | FxOS 1.2 |
mobileid | Mobile identity | Allows an app to obtain a verified phone number (MSISDN) after the user selects the number to be shared and gives explicit permission for the app to obtain it. | privileged/ | none | Prompt | FxOS 2.0 |
mobilenetwork | Mobile Network | Obtain mobile network information (MCC, MNC, etc.). | privileged | none | Allow | FxOS 1.0.1 |
moz-firefox-accounts | Firefox Accounts | Allows the use of Firefox Accounts when using the navigator.mozId API. | privileged | none | Prompt for all installed App types. | FxOS 2.0 |
nfc | NFC API | NFC enables an app to transmit data to other devices via near field communication. This permission is required for reading and writing data. | Privileged | none | Allow | FxOS 2.2 |
nfc-share | NFC API | This permission is just required for sharing tags via NFC. | Privileged | none | Allow | FxOS 2.2 |
nfc-read , nfc-write | NFC API | These permissions were used to request reading and writing privileges in Firefox OS 2.0/2.1 | Was certified/internal at this stage in development. | none | Allow | FxOS 2.0 |
push | Simple Push | Enable an app to wake up to receive notification. | hosted | none | Allow | FxOS 1.1 |
speech-recognition | Web Speech API | Allows an app to use speech recognition. | privileged | none | Allow | FxOS 2.5 and Desktop Firefox 44. |
systemXHR | SystemXHR | Allows anonymous (no cookies) cross-origin XHR without the target site having CORS enabled. Similar to the TCP Socket API but restricted to XHR, not just raw sockets, so it is slightly less risky. See XMLHttpRequest. | privileged | none | Allow | FxOS 1.0.1 |
tcp-socket | TCP Socket | Create TCP sockets and communicate over them. | privileged | none | Allow | FxOS 1.0.1, Desktop (early versions) |
video-capture | GetUserMedia | Obtain MediaStream from video input devices, e.g. camera. This is needed to allow video capture in Firefox OS 1.4+. | hosted | none | Prompt for all installed App types. | FxOS 1.4 |
Note: To declare an app as privileged, you need to put 'type' : 'privileged'
into your app manifest. You don't need to include the type
field in your manifest for web apps, as web
is the default value.
Internal (Certified) app permissions
The following permissions require a internal app and are granted implicitly without prompting the user. Most app developers will not be able to use internal APIs, because they are intended for system-level apps and default apps created by Mozilla/operators/OEMs.
Manifest permission | API name | Description | Minimum app type required | access property | Platform |
---|---|---|---|---|---|
attention | Attention Screen | Allow content to open a window in front of all other content. Used by telephone and SMS. Note: Attention screens use the Firefox OS-specific | internal (certified) | none | FxOS 1.0.1 |
audio-channel-ringer | AudioChannels | Incoming phone calls. | internal (certified) | none | FxOS 1.0.1 |
audio-channel-telephony | AudioChannels | Phone calls, VoIP calls. | internal (certified) | none | FxOS 1.0.1 |
audio-channel-publicnotification | AudioChannels | Forced camera shutter sounds. | internal (certified) | none | FxOS 1.2 |
background-sensors | Background Sensor | Ability to listen to proximity sensor events in the background. (All apps recieve these events in the foreground.) | internal (certified) | none | FxOS 1.0.1 |
backgroundservice (Deprecated) | Background Services | Enable an app to run in the background and perform tasks like syncing or responding to incoming messages. | internal (certified) | none | FxOS 1.0.1 |
bluetooth | Low level access to Bluetooth hardware. | internal (certified) | none | FxOS 1.0.1 | |
browser:embedded-system-app | Browser | Enables an app opened in a browser <iframe> to call methods of the API on — and listen and respond to related events fired by — itself (usually the parent window of the iframe calls the Browser API.) See bug 1196654 for further information. | internal (certified) | none | FxOS 2.5 |
camera | Camera | Take photos, shoot video, record audio, and control the camera. Note: | internal (certified) up to Firefox OS 1.4, privileged in Firefox OS 2.0+ | none | FxOS 1.0.1-1.4 certified FxOS 2.0+ privileged |
cellbroadcast | Fires an event when a specific type of cell network message is received (an emergency network notification). | internal (certified) | none | FxOS 1.0.1 | |
No permission needed, but datastores-access /datastores-owned needs to be set in the manifest (see Data Store API Manifest fields.) | Data Store | A powerful, flexible storage mechanism for Firefox OS applications to use to store and share data. | internal (certified) | datastores-access /datastores-owned | FxOS 1.0.1 |
device-storage:apps | Device Storage | Add, read, or modify files stored in the apps location on the device. When this is used, the webapps-manage permission is also required alongside it (see below.) | internal (certified) | read | FxOS 1.0.1 |
embed-apps | Embed Apps | Ability to embed apps in mozApp frames. | internal (certified) | none | FxOS 1.0.1 |
idle | Idle | Notify the app if the user is idle. | internal (certified) | none | FxOS 1.0.1 |
mobileconnection | Mobile Connection | Obtain information about the current mobile voice and data connection. | internal (certified) | none | FxOS 1.0.1 |
network-events | Network Events | Monitor network uploads and downloads. | internal (certified) | none | FxOS 1.0.1 |
networkstats-manage | Network Stats | Obtain statistics of data usage per interface. | internal (certified) | none | FxOS 1.0.1 |
open-remote-window | Open out-of-process windows | Allows normal window.open calls, but the resulting window is opened in a new process. | internal (certified) | none | FxOS 1.0.1 |
permissions | Permissions (Firefox OS) | Allow an app to manage other permissions of other apps. | internal (certified) | none | FxOS 1.0.1 |
phonenumberservice | ?? | ?? | internal (certified) | none | ?? |
power | Power Management | Turn the screen on or off, control CPU, device power, and so on. Listen for and inspect resource lock events. | internal (certified) | none | FxOS 1.0.1 |
presentation-device-manage | Presentation | Obtain the list of available devices that can be used as external display and trigger device discovery. | internal (certified) | none | FxOS 3.0 |
settings | Settings | Configure or read device settings. | internal (certified) | readonly or readwrite | FxOS 1.0.1 |
sms | WebSMS | Send and receive SMS messages. | internal (certified) | none | FxOS 1.0.1, 1.1 for MMS |
telephony | Web Telephony | Access all telephony-related APIs to make and recieve phone calls. | internal (certified) | none | FxOS 1.0.1 |
time | TimeManager | Set current time. Time zone information is controlled by the Settings API. Formerly called systemclock . | internal (certified) | none | FxOS 1.0.1 |
voicemail | Voicemail | Access voicemail. | internal (certified) | none | FxOS 1.0.1 |
webapps-manage | Open Webapps | Obtain access to the navigator.mozApps.mgmt API to manage installed Open Web Apps.Required alongside the device-storage:apps permission (see above.) | internal (certified) | none | FxOS 1.0.1, Desktop, Android |
wifi-manage | WiFi Management | Enumerate available WiFi networks, get signal strength, connect to a network. | internal (certified) | none | FxOS 1.0.1 |
wappush | WAP Push | Receive WAP Push messages. | internal (certified) | none | FxOS 1.0.1 |
Note: The internal codename for internal apps is certified apps. To declare an app as internal, you need to put 'type' : 'certified'
into your app manifest.
See also
The permissions table is where Firefox OS API permissions are defined in the Firefox source code.
The B2G OS simulator lets you run Gaia and Web apps in a Gecko-based environment somewhat similar to an actual device. It doesn't emulate device hardware, so it's not adequate for testing device APIs, and isn't a replacement for testing on actual hardware. However, it does have several APIs enabled that aren't available on Firefox such as the Contacts and Settings APIs. It can therefore be useful during the development of your application, or while working on the Gaia user interface itself. This article covers downloading or building the Firefox OS simulator, as well as how to use it.
Note: The easiest way to use the Firefox OS desktop client is to use the Firefox OS Simulator add-on via WebIDE. It does not require you to build the simulator yourself.
Download nightly builds
Just like Firefox Nightlies, the B2G OS simulator desktop client (identified by b2g-) is automatically built every day from the latest source code. The latest build is available from the Mozilla FTP server. Be sure to pick the latest version and the right archive for your operating system. This lets you bypass having to build it yourself. In addition, you don't have to download Gaia on your own either.
Be sure to install the application in a writeable location; the application needs to be able to update the included Gaia profile.
You can now skip ahead to Running the simulator, unless you actually want to build it for yourself. This is necessary if you want to make and test changes to the codebase.
Building the simulator
The first thing you need to do is set up a standard Mozilla build environment. Once you have that, you can pull down the code you'll need and configure it to build the Firefox OS desktop client.
Downloading the code for the first time
In a directory where you'd like the source code to go, clone the mozilla-central
repository that contains all of Gecko:
Alternatively, you can download the same code from Github:
Updating the code
When you do subsequent builds, you should make sure to pull in the latest changes:
or
Create a mozconfig
Next, you need to create a file called .mozconfig
in the mozilla-central
directory to configure the build system to build the Boot to Gecko client instead of Firefox. This file should contain the following:
You also need to include the line ENABLE_MARIONETTE=1
in the file if you want to run Mochitests in the B2G desktop client (either mochitest-b2g-desktop
or mochitest-plain
) or if you want to run Gaia unit tests.
Building
Now you can build the desktop client with the following command (run this from inside the mozilla-central
directory):
The built client will be placed in the objdir/dist/bin
directory (based on the value you specify for MOZ_OBJDIR
in the mozconfig
file).
Business To Government
Note: If you have any trouble first check the dependencies.
Downloading Gaia
By default the simulator desktop client will show an empty screen because it doesn't know which web app to load initially as the system app. The collection of system apps and default apps that come with Firefox OS — Gaia — needs to be downloaded.
To download Gaia for the first time, clone the source code repository on GitHub:
To update an already existing clone of Gaia, you can pull in the latest changes from GitHub:
Creating a custom-settings.json
If you know what you're doing and you want to set various config options you can create the file gaia/build/config/custom-settings.json
and add them there, for example:
This example is useful for bypassing the lockscreen, which is otherwise impossible to bypass on desktop because it can't be unlocked using a mouse or trackpad.
Generating a profile
Next we need to set up Gaia's apps for the desktop simulator. This includes packaging the Gaia apps in the same way as they would be installed on the device, as well as setting up the permissions for the privileged system apps. We do this by generating a profile. The following command (run in the downloaded gaia
directory) will take care of that:
This should create a profile-debug
directory below the gaia
directory. The new profile contains a customized extension and other configuration details needed to make B2G run properly.
Note: There is currently a bug (bug 1180103) that causes Gaia debug profiles to render with an empty homescreen when run through the Firefox OS Simulator (through WebIDE, or whatever.) This can be worked around by building with DEBUG=1 DESKTOP=0 make
instead of DEBUG=1
.
Running the simulator
Once you've built the client (or downloaded and installed the nightly desktop application) and downloaded Gaia , you're ready to fire up the simulator.
Running on Linux
To run the simulator on Linux using the embedded Gaia profile, just run the b2g
executable. The binary is in the archive you downloaded earlier or in the objdir/dist/bin
directory if you built the client yourself.
You may experience annoying rendering problems. To avoid them, add the following line to your gaia/profile/user.js
file:
Running on Mac
If you downloaded the Nightly build, you can simply launch it from the Finder as usual. Any console output is visible by running the standard Console utility program included with your Mac.
If you want to specify a different Gaia profile (such as your separate download Gaia from above), you need to bypass the b2g
wrapper program and run the b2g
binary. The command line is slightly more complicated due to the location of the b2g
binary and the need for absolute paths when specifying the profile directory:
Running on Windows
Running the Nightly build on Windows is as simple as launching b2g.exe
. If you want to customize the execution, you can do so by running the b2g.exe
executable instead; this bypasses the wrapper program that automatically uses the bundled Gaia.
Command line options
There are a number of command line options you can use to adjust the runtime experience while using the desktop simulator. You can get a list by using the -help
option. This section covers some of the particularly interesting ones.
Specifying the screen size
You can specify the screen size of the device you want to simulate using the -screen
option:
Where <width>, <height>, and <dpi> are fairly self-explanatory parameters: the width and height of the device's screen in pixels and the device resolution in DPI. Here's some real examples:
Optionally, you can specify certain devices by name to simulate their screen size and resolution:
iphone
ipad
nexus_s
galaxy_nexus
galaxy_tab
wildfire
tattoo
salsa
chacha
These preset devices are defined in screen.js.
Mozilla Firefox Os
In order to select different screen you probably have to specify the profile path as follow:
./b2g-bin --profile ./gaia/profile/ --screen=galaxy_tab
Opening the JavaScript console
You can open the JavaScript console when launching the desktop simulator by launching it from the command line with the -jsconsole
flag. After building, just do:
If you've installed the Nightly build on a Mac, you can do the following:
Note: On production builds of Firefox OS, console logging (for example console.log()
) is disabled by default. In order to enable it, open the Developer settings and enable the Console Enabled preference.
Launching a specific application at startup
You can specify an application to be launched automatically when b2g starts up in the simulator. This is done as soon as the rest of the system is done loading up. To do this, just use the -runapp
option, which takes as a parameter the name of the application to run. For example:
Note: The specified name is normalized by converting it to all lower case and removing all dashes and spaces. This normalized name is then compared to similarly normalized names from the manifests of available apps' manifests. For example, the name of the email app is currently 'E-mail', but -runapp email
will work because of this normalization.
If you specify the -runapp
option without an argument, or with an empty argument, the simulator will output to your terminal a list of the known applications as well as a brief usage message.
Note: Using the -runapp
option disables the lock screen as a side effect and does not re-enable it. It's assumed that you won't use this command on a profile on which you will be testing the lock screen, or you will turn it back on manually using Settings > Screen Lock. Feel free to contribute a patch to change this behavior if it's a problem.
Usage tips
This section provides a few helpful tips to using the B2G desktop client.
- The Esc key performs the same function as the 'back' button.
- The Home key performs the same function as the 'home' button; if you're on a Mac, the Home key is available as Fn + ← (Fn + Left Arrow).
- The End key performs the same function as the 'power' button; if you're on a Mac, the End key is available as Fn + → (Fn + Right Arrow).
- the Page Up and Page Down keys perform the same functions as the 'Volume Up' and 'Volume Down' buttons respectively; if you're on a Mac, the Page Up key is available as Fn + ↑ (Fn + Up Arrow) and the Page Down key is available as Fn + ↓ (Fn + Down Arrow).
- A long press on the Home key opens the 'Card View'; if you're on Mac, Cmd + Fn + ← (Cmd + Fn + Left Arrow) opens the 'Card View'.
Troubleshooting: A blank screen when the simulator starts
When you start b2g using b2g -profile gaia/path/to/gaia/profile
a blank screen may show up along with an error 'Cannot reach app://system.gaiamobile.org'. To fix this there are a couple of things you can check:
- Rebuild the gaia profile using the
DEBUG=1 make
profile in the gaia directory. - Run b2g again.
- If this doesn't fix it, check if there is any other process listening on port 8080. The default profile of Gaia starts
httpd.js
, which listens on port 8080. When running a debug profile, B2G connects to localhost:8080. If some other process is running on port 8080, b2g will fail to display the home screen of gaia.- To find out if this is the case, you can enable logging on
httpd.js
. Thehttpd.js
in the profile resides in the locationgaia/profile/extensions/httpd/content/httpd.js
. Open this file for editing. - Change the line
var DEBUG=false;
tovar DEBUG=true;
- Save the file and restart B2G. On the console you will now be able to view the httpd's logs.
- To find out if this is the case, you can enable logging on
Next steps
Now that you have a simulated build of Boot to Gecko running, you can do testing, development, and other work in it: