new NfcManager()
NfcManager is responsible for NFC support.
NfcManager is responsible for NFC support. It controls NFC hardware state, detects NFC tags and triggers appropriate activities, detects NFC peers and takes part in NFC P2P sharing process (with ShrinkingUI), detects NFC Handover requests and passes them to NfcHandoverManager for handling.
- Source:
Requires:
- module:BaseModule
- module:ScreenManager
- module:MozActivity
- module:NDEF
- module:NfcUtils
Requires
- module:BaseModule
- module:ScreenManager
- module:MozActivity
- module:NDEF
- module:NfcUtils
Members
_hwState :String
Current NFC Hardware state
.Current NFC Hardware state
Type:
- String
- Source:
Methods
_checkP2PRegistration()
Step 1 of system app fallback P2P sharing.
Step 1 of system app fallback P2P sharing. Queries Gecko (via NFC dom) if currently visible app has registered onpeerready handler. If the result is true, shrinking-start event is dispatched to ShrinkingUI, which will trigger UI change asking the user to confirm sharing.
- Source:
_cleanP2PUI()
P2P UI clean up helper, notifies ShrinkingUI to stop shrinking animation and removes 'shrinking-sent' listener.
P2P UI clean up helper, notifies ShrinkingUI to stop shrinking animation and removes 'shrinking-sent' listener.
- Source:
_createNDEFActivityOptions(payload) → {Object}
Basing on decoded payload from first record of NDEF message prepares activity options object which will be used to launch MozActivity
.Basing on decoded payload from first record of NDEF message prepares activity options object which will be used to launch MozActivity
Parameters:
Name | Type | Description |
---|---|---|
payload |
Object | decoded payload of first record from NDEF msg |
- Source:
Returns:
options - object used to construct MozActivity
- Type
- Object
_dispatchP2PUserResponse()
Step 2 of system app fallback P2P sharing.
Step 2 of system app fallback P2P sharing. Notifies Gecko to fire onpeerready handler of the currently visible app.
- Source:
_doNfcStateTransition(evt)
Performs NFC state transition.
Performs NFC state transition. Checks in NFC HW State Table if NFC HW Event (argument) triggers a transition from current HW state to a different one. If transition exists, _hwState is changed to new state and state entry function is called.
Parameters:
Name | Type | Description |
---|---|---|
evt |
string | NFC HW Event |
- Source:
_fireNDEFDiscovered(records)
Fires NDEF related activities to launch other apps to perform further actions with NDEF Message contents.
Fires NDEF related activities to launch other apps to perform further actions with NDEF Message contents. If the first NDEF record contains a well know type additional parsing will be done in helper methods. In general the name of activity will be 'nfc-ndef-discovered', in some case other names may be used (e.g. 'dial' in case of tel uri)
Parameters:
Name | Type | Description |
---|---|---|
records |
Array | NDEF Message |
- Source:
_getSmartPoster(records) → {Object}
Retrieves Smart Poster record from NDEF records array following the rule outlined in NFCForum-SmartPoster_RTD_1.0, 3.4: "If an NDEF message contains one or multiple URI [URI] records in addition to the Smart Poster record at the top level (i.e., not nested), the Smart Poster record overrides them.
Retrieves Smart Poster record from NDEF records array following the rule outlined in NFCForum-SmartPoster_RTD_1.0, 3.4: "If an NDEF message contains one or multiple URI [URI] records in addition to the Smart Poster record at the top level (i.e., not nested), the Smart Poster record overrides them. The NDEF application MUST use only the Smart Poster record."
Parameters:
Name | Type | Description |
---|---|---|
records |
Array | array of NDEF records |
- Source:
Returns:
record - SmartPostr record or null
- Type
- Object
_handleTechDiscovered(msg)
Handler for nfc-manager-tech-discovered messages which originate from gecko.
Handler for nfc-manager-tech-discovered messages which originate from gecko. Basing on the first NDEF record tnf and type this method can use NfcHandoverManager to handle handover scenarios. Basing on the techList array it can either trigger P2P sharing scenario or create MozActivities for other apps to act upon.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
msg |
Object | gecko originated message Properties
|
- Source:
_handleTechLost(msg)
Handler for nfc-manager-tech-lost messages
.Handler for nfc-manager-tech-lost messages
Parameters:
Name | Type | Description |
---|---|---|
msg |
Object | tech lost message |
- Source:
_initP2PUI()
Notifies ShrinkingUI to start shrinking animation and starts listening for 'shrinking-sent' event.
Notifies ShrinkingUI to start shrinking animation and starts listening for 'shrinking-sent' event.
- Source:
_processNfcStateChange()
State entry function.
State entry function. Called after transitioning to new NFC HW state. Depending on _hwState it can trigger a new HW change request, change 'nfc.status' setting or update NFC icon.
- Source:
_start()
Initializes NfcManager, sets up listeners and handlers
.Initializes NfcManager, sets up listeners and handlers
- Source:
_stop()
Removes all listeners and handlers
.Removes all listeners and handlers
- Source: