Closed Bug 978707 Opened 10 years ago Closed 10 years ago

B2G NFC: sessionToken can be used to get NFCPeer and NFCTag object

Categories

(Firefox OS Graveyard :: NFC, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(tracking-b2g:backlog)

RESOLVED FIXED
2.1 S8 (7Nov)
tracking-b2g backlog

People

(Reporter: allstars.chh, Assigned: allstars.chh)

References

Details

(Whiteboard: [p=1])

Attachments

(1 file, 1 obsolete file)

This bug is related to Bug 963533, maybe we could duplicate this bug to Bug 963533 in the future, right now I just filed it as a seperate bug.

Currently we can get sessionToken from nfc-manager-tech-discovered system message, inside this message has a property called 'sessionToken', and we could use this sessionToken to get NFCTag or NFCPeer object. (This also prevents the Structured Clone problem). And Gaia app will check if 'P2P' is contained in the techList property, if it is, the Gaia app should use mozNfc.getPeer(sessionToken), otherwise it should use mozNfc.getTag(sessionToken). However if the app doesn't do this correctly, 


// Supposed the sessionToken is from a NFC Tag.

var nfcTag = mozNfc.getTag(sessionToken); 
// doing tag functionalities.

var nfcTag = mozNfc.getPeer(sessionToken); // Should we allow app the get a NFCPeer here, ever the session is actually referring to a NFC Tag.

Or should we let app could do this freely?
Also related to Bug 963541. I believe we should enforce a close session before allowing switching with get{Technology}, or automatically close it. I prefer a throw just to make it clear to the programmer. 

Question then becomes, enforce this at external/nfcd, or in system/gonk?
Depends on: 963541
Blocks: b2g-NFC-2.0
No longer blocks: b2g-NFC-2.0
Assignee: nobody → psiddh
blocking-b2g: --- → backlog
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → DUPLICATE
Reopen for this should have some fix in Gecko Chrome process, Bug 963533 should focus on WebAPI level.
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
Assignee: psiddh → allstars.chh
Attached patch Patch (obsolete) — Splinter Review
Attachment #8516568 - Flags: review?(dlee)
Comment on attachment 8516568 [details] [diff] [review]
Patch

Review of attachment 8516568 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/nfc/gonk/Nfc.js
@@ +315,5 @@
> +          let sessionToken = message.data.sessionToken;
> +          let sessionId = SessionHelper.getId(sessionToken);
> +          if (!SessionHelper.isValidToken(sessionToken) ||
> +              message.data.isP2P !== SessionHelper.isP2PSession(sessionId)) {
> +            debug("Received invalid Session Token: " + sessionToken);

From the idea here it looks like a "valid" session token stands for session token exists, and its type(isP2P) should be also correct. If this is the case, maybe we could just use:
SessionHelper.isValidToken(sessionToken, type) to do the check.

But make the API simple is also ok for me, just propose another idea.
Attachment #8516568 - Flags: review?(dlee) → review+
Attached patch Patch v2.Splinter Review
merged into one function, r? to Dimi again.
Attachment #8516568 - Attachment is obsolete: true
Attachment #8517259 - Flags: review?(dlee)
Attachment #8517259 - Flags: review?(dlee) → review+
https://hg.mozilla.org/mozilla-central/rev/798710d73edc
Status: REOPENED → RESOLVED
Closed: 10 years ago10 years ago
Resolution: --- → FIXED
blocking-b2g: backlog → ---
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: