Closed Bug 1086179 Opened 10 years ago Closed 10 years ago

Add a format API to MozNFCTag

Categories

(Firefox OS Graveyard :: NFC, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: allstars.chh, Assigned: jhao)

References

Details

Attachments

(2 files, 3 obsolete files)

In bug 1074611 we can know if the tag is formatable or not. We should add a API for 'formatting NDEF' on the tag, and if the tag is not formatable this method should throw.
Assignee: nobody → allstars.chh
Assignee: allstars.chh → nobody
Depends on: 1096821
Assignee: nobody → jhao
Attached patch Working-in-progress patch (obsolete) — Splinter Review
I have imitated the api "makeReadOnly" and fill corresponding code for format(). As I am not familiar with both WebIDL and NFC, I need Dimi to help me check if I'm on the right track.
Flags: needinfo?(dlee)
Comment on attachment 8522861 [details] [diff] [review] Working-in-progress patch Review of attachment 8522861 [details] [diff] [review]: ----------------------------------------------------------------- Hi Jonathan, Looks good, thanks! I will provide nfcd for you to test later. Once the test is complete, please find yoshi to review this patch. ::: dom/nfc/gonk/NfcGonkMessage.h @@ +23,5 @@ > enum NfcResponse { > GeneralRsp = 1000, > PowerRsp, > ReadNDEFRsp, > }; In this file, there is a define named NFCD_MINOR_VERSION, when the binary protocol is changed between b2g process and nfcd, we will update it. You could increase it to 16 in this patch. ::: dom/nfc/nsINfcContentHelper.idl @@ +77,5 @@ > > nsIDOMDOMRequest readNDEF(in DOMString sessionToken); > nsIDOMDOMRequest writeNDEF(in nsIVariant records, in DOMString sessionToken); > nsIDOMDOMRequest makeReadOnly(in DOMString sessionToken); > + nsIDOMDOMRequest format(in DOMString sessionToken); please also update the uuid
Attachment #8522861 - Flags: feedback+
Flags: needinfo?(dlee)
Attached file test nfcd
Attached patch Add format API (obsolete) — Splinter Review
I have tested with the following code in gaia/apps/system/js/nfc_handler.js > NfcHandler.prototype = { > start: function nh_start() { > if (window.navigator.mozNfc) { > window.navigator.mozNfc.onpeerready = this.handleEvent.bind(this); > window.navigator.mozNfc.ontagfound = function (evt) { > dump('ontagfound'); > var req = evt.tag.format(); > req.onsuccess = function () { dump('format successfully'); }; > req.onerror = function () { dump('format error'); }; > }; > } > }, and in the log we can see the format is successful. > I/GeckoDump(27614): format successfully
Attachment #8522861 - Attachment is obsolete: true
Attachment #8523797 - Flags: review?(allstars.chh)
Comment on attachment 8523797 [details] [diff] [review] Add format API Review of attachment 8523797 [details] [diff] [review]: ----------------------------------------------------------------- Please update the patch subject. Forward r? to smaug for WebIDL change in MozNFCTag.webidl.
Attachment #8523797 - Flags: review?(bugs)
Attachment #8523797 - Flags: review?(allstars.chh)
Attachment #8523797 - Flags: review+
Comment on attachment 8523797 [details] [diff] [review] Add format API Would it be useful to have a boolean attribute which tells whether the Tag is formattable?
Attachment #8523797 - Flags: review?(bugs) → review+
(In reply to Olli Pettay [:smaug] from comment #6) > Comment on attachment 8523797 [details] [diff] [review] > Add format API > > Would it be useful to have a boolean attribute which tells whether the Tag > is formattable? Hi Olli, I think what you proposed is already in MozNFCTag.webidl. http://dxr.mozilla.org/mozilla-central/source/dom/webidl/MozNFCTag.webidl?from=moznfctag.webidl#62
Attached patch Add format API (obsolete) — Splinter Review
Add patch subject.
Attachment #8523797 - Attachment is obsolete: true
Attached patch Add format APISplinter Review
Add "return true;" in the end of NfcMessageHandler::FormatRequest()
Attachment #8524211 - Attachment is obsolete: true
(In reply to Jonathan Hao [:jhao] from comment #7) > > Hi Olli, I think what you proposed is already in MozNFCTag.webidl. > http://dxr.mozilla.org/mozilla-central/source/dom/webidl/MozNFCTag. > webidl?from=moznfctag.webidl#62 So it is!
Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: