B2g Os



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 permissionAPI nameDescriptionMinimum app type requiredaccess propertyDefault grantedPlatform/version supported
alarmsAlarmSchedule a notification, or schedule an application to be started.hostednoneAllowFxOS 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 APInonePrompt 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-alarmAudioChannelsAlarm clock, calendar alarms.privilegednoneAllowFxOS 1.0.1
audio-channel-contentAudioChannelsMusic, video.hostednoneAllowFxOS 1.0.1
audio-channel-normalAudioChannelsUI sounds, Web content, music, radio.hostednoneAllowFxOS 1.0.1
audio-channel-notificationAudioChannelsNew email, incoming SMS.privilegednoneAllowFxOS 1.0.1
browserBrowserEnables the app to implement a browser in an iframe.privilegednoneAllowFxOS 1.0.1
cameraCamera

Take photos, shoot video, record audio, and control the camera.

Note:camera was limited to certified apps initially because the app sandbox was preventing access to the camera hardware. Fixed from Firefox OS 2.0 onwards.

privileged in Firefox OS 2.0+ internal/certified up to Firefox OS 1.4

nonePrompt for all installed App types.FxOS 1.0.1-1.4 certified
FxOS 2.0+ privileged
contactsContactsAdd, read, or modify contacts from the address book on the device and read contacts from the SIM.privilegedreadonly, readwrite, readcreate, or createonlyPrompt for all installed App types.FxOS 1.1
Firefox Android 18
desktop-notificationmozNotification 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.hostednonePrompt 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:musicDevice StorageAdd, read, or modify music files stored on the device.privilegedreadonly, readwrite, readcreate, or createonlyPromptFxOS 1.0.1
device-storage:picturesDevice StorageAdd, read, or modify picture files stored on the device.privilegedreadonly, readwrite, readcreate, or createonlyPromptFxOS 1.0.1
device-storage:sdcardDevice StorageAdd, read, or modify files stored on the device's SD card.privilegedreadonly, readwrite, readcreate, or createonlyPromptFxOS 1.0.1
device-storage:videosDevice StorageAdd, read, or modify video files stored on the device.privilegedreadonly, readwrite, readcreate, or createonlyPromptFxOS 1.0.1
fmradioFM RadioControl the FM radio.hostednoneAllowFxOS 1.0.1
geolocationGeolocationObtain the current location of the user.hostednonePrompt (even for certified Apps)FxOS 1.0.1, Desktop Firefox 3.5, Android 4.0
inputKeyboardAllows 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.privilegednoneAllowFxOS 1.2
mobileidMobile identityAllows 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/nonePromptFxOS 2.0
mobilenetworkMobile NetworkObtain mobile network information (MCC, MNC, etc.).privilegednoneAllowFxOS 1.0.1
moz-firefox-accountsFirefox AccountsAllows the use of Firefox Accounts when using the navigator.mozId API.privilegednonePrompt for all installed App types.FxOS 2.0
nfcNFC APINFC enables an app to transmit data to other devices via near field communication. This permission is required for reading and writing data.PrivilegednoneAllowFxOS 2.2
nfc-shareNFC APIThis permission is just required for sharing tags via NFC.PrivilegednoneAllowFxOS 2.2
nfc-read, nfc-writeNFC APIThese permissions were used to request reading and writing privileges in Firefox OS 2.0/2.1Was certified/internal at this stage in development.noneAllowFxOS 2.0
pushSimple PushEnable an app to wake up to receive notification.hostednoneAllowFxOS 1.1
speech-recognitionWeb Speech APIAllows an app to use speech recognition.privilegednoneAllowFxOS 2.5 and Desktop Firefox 44.
systemXHRSystemXHRAllows 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.privilegednoneAllowFxOS 1.0.1
tcp-socketTCP SocketCreate TCP sockets and communicate over them.privilegednoneAllowFxOS 1.0.1,
Desktop (early versions)
video-captureGetUserMediaObtain MediaStream from video input devices, e.g. camera. This is needed to allow video capture in Firefox OS 1.4+.hostednonePrompt 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 permissionAPI nameDescriptionMinimum app type requiredaccess propertyPlatform
attentionAttention 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 attention feature name when calling window.open().

internal (certified)noneFxOS 1.0.1
audio-channel-ringerAudioChannelsIncoming phone calls.internal (certified)noneFxOS 1.0.1
audio-channel-telephonyAudioChannelsPhone calls, VoIP calls.internal (certified)noneFxOS 1.0.1
audio-channel-publicnotificationAudioChannelsForced camera shutter sounds.internal (certified)noneFxOS 1.2
background-sensorsBackground SensorAbility to listen to proximity sensor events in the background. (All apps recieve these events in the foreground.)internal (certified)noneFxOS 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)noneFxOS 1.0.1
bluetoothLow level access to Bluetooth hardware.internal (certified)noneFxOS 1.0.1
browser:embedded-system-appBrowserEnables 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)noneFxOS 2.5
cameraCamera

Take photos, shoot video, record audio, and control the camera.

Note:camera was limited to certified apps initially because the sandbox that apps run in was preventing access to the camera hardware. This has been fixed from Firefox OS 2.0 onwards.

internal (certified) up to Firefox OS 1.4, privileged in Firefox OS 2.0+noneFxOS 1.0.1-1.4 certified
FxOS 2.0+ privileged
cellbroadcastFires an event when a specific type of cell network message is received (an emergency network notification).internal (certified)noneFxOS 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 StoreA 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:appsDevice StorageAdd, 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)readFxOS 1.0.1
embed-appsEmbed AppsAbility to embed apps in mozApp frames.internal (certified)noneFxOS 1.0.1
idleIdleNotify the app if the user is idle.internal (certified)noneFxOS 1.0.1
mobileconnectionMobile ConnectionObtain information about the current mobile voice and data connection.internal (certified)noneFxOS 1.0.1
network-eventsNetwork EventsMonitor network uploads and downloads.internal (certified)noneFxOS 1.0.1
networkstats-manageNetwork StatsObtain statistics of data usage per interface.internal (certified)noneFxOS 1.0.1
open-remote-windowOpen out-of-process windowsAllows normal window.open calls, but the resulting window is opened in a new process.internal (certified)noneFxOS 1.0.1
permissionsPermissions (Firefox OS)Allow an app to manage other permissions of other apps.internal (certified)noneFxOS 1.0.1
phonenumberservice????internal (certified)none??
powerPower ManagementTurn the screen on or off, control CPU, device power, and so on. Listen for and inspect resource lock events.internal (certified)noneFxOS 1.0.1
presentation-device-managePresentationObtain the list of available devices that can be used as external display and trigger device discovery.internal (certified)noneFxOS 3.0
settingsSettingsConfigure or read device settings.internal (certified)readonly or readwriteFxOS 1.0.1
smsWebSMSSend and receive SMS messages.internal (certified)noneFxOS 1.0.1,
1.1 for MMS
telephonyWeb TelephonyAccess all telephony-related APIs to make and recieve phone calls.internal (certified)noneFxOS 1.0.1
timeTimeManagerSet current time. Time zone information is controlled by the Settings API. Formerly called systemclock.internal (certified)noneFxOS 1.0.1
voicemailVoicemailAccess voicemail.internal (certified)noneFxOS 1.0.1
webapps-manageOpen WebappsObtain access to the navigator.mozApps.mgmt API to manage installed Open Web Apps.
Required alongside the device-storage:apps permission (see above.)
internal (certified)noneFxOS 1.0.1, Desktop, Android
wifi-manageWiFi ManagementEnumerate available WiFi networks, get signal strength, connect to a network.internal (certified)noneFxOS 1.0.1
wappushWAP PushReceive WAP Push messages.internal (certified)noneFxOS 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.

B2g

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.

B2g Os

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:

Officer

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:

Firefox

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:

B2g Os
  • 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.
    1. To find out if this is the case, you can enable logging on httpd.js. The httpd.js in the profile resides in the location gaia/profile/extensions/httpd/content/httpd.js. Open this file for editing.
    2. Change the line var DEBUG=false; to var DEBUG=true;
    3. Save the file and restart B2G. On the console you will now be able to view the httpd's logs.

Next steps

Now that you have a simulated build of Boot to Gecko running, you can do testing, development, and other work in it: