Closed Bug 1008056 Opened 11 years ago Closed 10 years ago

[NFC] The receiver should turn bluetooth off after NFC handover fail if user deactivated it in the settings

Categories

(Firefox OS Graveyard :: NFC, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(tracking-b2g:backlog, b2g-v2.0 affected)

RESOLVED WORKSFORME
tracking-b2g backlog
Tracking Status
b2g-v2.0 --- affected

People

(Reporter: ashiue, Assigned: arno)

References

Details

(Whiteboard: [2.0-flame-test-run-1], [2.0-flame-test-run-2])

Attachments

(2 files)

Attached image S__712708.jpg (deleted) —
Gaia      4f352142a54f7f7ae2c460aad9049eda4b0edb14
Gecko     https://hg.mozilla.org/mozilla-central/rev/9ac3e2dd0898
BuildID   20140508160203
Version   32.0a1
Device    Flame

Two phone with NFC

STR:
1. Enable NFC on both phones
2. Turn off BT on both phones
3. Open an image in device A
4. Tap 2 phones, and swipe device A's shrinking UI to share image
5. When device A fail to share, check device B's BT status


Expected result:
Receiver should turn off BT

Actual result:
Do not turn off BT on Receiver 

* Manually cancel transfer on device A would not occur this case. The easiest way to reproduce this case is sharing files via Flame, because Flame could not share file via NFC currently.
Arno, it is a error handler and needs your help for this.
Assignee: nobody → arno
When a file transfer completes (either successfully or unsuccessfully), bluetooth_transfer.js tells the NFCHandoverManager:
https://github.com/mozilla-b2g/gaia/blob/master/apps/system/js/bluetooth_transfer.js#L421
There the BT state is restored to its original state:
https://github.com/mozilla-b2g/gaia/blob/master/apps/system/js/nfc_handover_manager.js#L367

I need to turn on BT to prepare for the file transfer, but if the problem occurs even before the receiver gets any indication of the failed attempt, then there is little I can do. I rely on transferComplete() being called.

@Ian: can you tell from ashiue's test at which level in the BT stack the transfer failed? Is there another hook I might use to detect a failed transfer at the receiver?
Flags: needinfo?(iliu)
(In reply to ashiue from comment #0)
> * Manually cancel transfer on device A would not occur this case. The
> easiest way to reproduce this case is sharing files via Flame, because Flame
> could not share file via NFC currently.

Hi Ashiue, do you mean let Flame to be device B? I don't understand the symptom to make the issue happened. If one of the device is not supported NFC protocol, it should not trigger file sending via NFC. I will have a face on face discussion with you in detail.
Attached file nfc_debug.log (deleted) —
Hi, this is the debug log from receiver. Please refer it,  thanks!
I flash gaia with debugging mode for Gaia::BluetoothTransfer, Gaia::NfcHandoverManager.

********** Device Flame A **********
Gaia      6e660601486acc6aafaaac2e23b5f72af3922cb3
Gecko     https://hg.mozilla.org/mozilla-central/rev/9d8d16695f6a
BuildID   20140520160203
Version   32.0a1
ro.build.version.incremental=76
ro.build.date=Mon Apr 14 14:02:50 CST 2014

========== Sender log with grep bluetooth ==========

I/qcom-bluetooth( 2617): /system/etc/init.qcom.bt.sh: init.qcom.bt.sh config =  
I/bluedroid( 1587): Starting bluetoothd deamon
I/qcom-bluetooth( 2630): /system/etc/init.qcom.bt.sh: Transport : smd 
I/qcom-bluetooth( 2631): /system/etc/init.qcom.bt.sh: ** Bluez stack ** 
I/qcom-bluetooth( 2632): /system/etc/init.qcom.bt.sh: Power Class: Ignored. Default(1) used (1-CLASS1/2-CLASS2/3-CUSTOM) 
I/qcom-bluetooth( 2633): /system/etc/init.qcom.bt.sh: Power Class: To override, Before turning BT ON; setprop qcom.bt.dev_power_class <1 or 2 or 3> 
I/qcom-bluetooth( 2634): /system/etc/init.qcom.bt.sh: LE Power Class: Ignored. Default(2) used (1-CLASS1/2-CLASS2/3-CUSTOM) 
I/qcom-bluetooth( 2635): /system/etc/init.qcom.bt.sh: LE Power Class: To override, Before turning BT ON; setprop qcom.bt.le_dev_pwr_class <1 or 2 or 3> 
I/GeckoDump( 1587): [DEBUG] SYSTEM NFC-HANDOVER: bluetooth-adapter-added
E/GeckoConsole( 1587): Content JS LOG at app://system.gaiamobile.org/js/bluetooth_transfer.js:92 in bt_debug: [System Bluetooth Transfer]: push sending files request in queue, queued length = 1
E/GeckoConsole( 1587): Content JS LOG at app://system.gaiamobile.org/js/bluetooth_transfer.js:308 in bt_onUpdateProgress: --> onUpdateProgress(): mode = start
E/GeckoConsole( 1587): Content JS LOG at app://system.gaiamobile.org/js/bluetooth_transfer.js:423 in bt_onTransferComplete: --> onTransferComplete(): 
E/GeckoConsole( 1587): Content JS LOG at app://system.gaiamobile.org/js/bluetooth_transfer.js:92 in bt_debug: [System Bluetooth Transfer]: remove the finished sending task from queue, queue length = 0
I/bluedroid( 1587): Stopping bluetoothd deamon

========== Sender log with grep nfc ==========

I/GeckoDump( 1587): [DEBUG] SYSTEM NFC-HANDOVER: In New event nfc-manager-send-file{"requestId":"aWR7ZmQzYjI3MjMtN2ZlYy00NDY2LWEzODEtMDIyOWRmNWQ3YjFlfQ==","sessionToken":"{a6d31c2e-5439-49b2-83dc-1ed87efb9926}","blob":{},"sessionId":9}
...
D/nfcd    (  310):  112 of bytes to be sent... data=0xb7910e2c ret=0
D/nfcd    (  310): void NfcIpcSocket::writeToIncomingQueue(uint8_t*, size_t) enter, data=0xb7910e2c, dataLen=112
D/nfcd    (  310): void MessageHandler::processRequest(const uint8_t*, size_t) enter data=0xb7910e2c, dataLen=112
D/nfcd    (  310): void* NfcService::eventLoop(): NFCService msg=10
D/nfcd    (  310): void P2pLinkManager::push(NdefMessage&): send Handover Request by handover client
D/nfcd    (  310): bool HandoverClient::put(NdefMessage&): enter
D/nfcd    (  310): bool HandoverClient::put(NdefMessage&): exit
...
D/nfcd    (  310): NdefMessage* HandoverClient::receive(): get a complete NDEF message
D/nfcd    (  310): processNotificaton notification=2001
D/nfcd    (  310): numRecords=2
D/nfcd    (  310): tnf=1
D/nfcd    (  310): typeLength=2
D/nfcd    (  310): idLength=0
D/nfcd    (  310): payloadLength=10
D/nfcd    (  310): mPayload 0 = 18
D/nfcd    (  310): mPayload 1 = 209
D/nfcd    (  310): mPayload 2 = 2
D/nfcd    (  310): mPayload 3 = 4
D/nfcd    (  310): mPayload 4 = 97
D/nfcd    (  310): mPayload 5 = 99
D/nfcd    (  310): mPayload 6 = 1
D/nfcd    (  310): mPayload 7 = 1
D/nfcd    (  310): mPayload 8 = 48
D/nfcd    (  310): mPayload 9 = 0
D/nfcd    (  310): tnf=2
D/nfcd    (  310): typeLength=32
D/nfcd    (  310): idLength=1
D/nfcd    (  310): payloadLength=8
D/nfcd    (  310): mPayload 0 = 8
D/nfcd    (  310): mPayload 1 = 0
D/nfcd    (  310): mPayload 2 = 60
D/nfcd    (  310): mPayload 3 = 149
D/nfcd    (  310): mPayload 4 = 48
D/nfcd    (  310): mPayload 5 = 198
D/nfcd    (  310): mPayload 6 = 160
D/nfcd    (  310): mPayload 7 = 0
D/nfcd    (  310): void NfcIpcSocket::writeToOutgoingQueue(uint8_t*, size_t) enter, data=0xb7923ba0, dataLen=116
D/nfcd    (  310): Writing 116 bytes to gecko 
D/nfcd    (  310): void MessageHandler::processResponse(NfcResponseType, NfcErrorCode, void*) enter response=1000
D/nfcd    (  310): void NfcIpcSocket::writeToOutgoingQueue(uint8_t*, size_t) enter, data=0xb79238f0, dataLen=12
D/nfcd    (  310): Writing 12 bytes to gecko 
...
E/GeckoConsole( 1587): Content JS LOG at app://system.gaiamobile.org/js/nfc_handover_manager.js:361 in isHandoverInProgress: --> isHandoverInProgress(): this.sendFileRequest = [object Object]
E/GeckoConsole( 1587): Content JS LOG at app://system.gaiamobile.org/js/nfc_handover_manager.js:362 in isHandoverInProgress: --> isHandoverInProgress(): this.incomingFileTransferInProgress = false




********** Device Flame B **********
Gaia      6e660601486acc6aafaaac2e23b5f72af3922cb3
Gecko     https://hg.mozilla.org/mozilla-central/rev/9d8d16695f6a
BuildID   20140520160203
Version   32.0a1
ro.build.version.incremental=76
ro.build.date=Mon Apr 14 14:02:50 CST 2014

========== Receiver log with grep bluetooth ==========
I/qcom-bluetooth( 3278): /system/etc/init.qcom.bt.sh: init.qcom.bt.sh config =  
I/bluedroid( 1587): Starting bluetoothd deamon
I/qcom-bluetooth( 3290): /system/etc/init.qcom.bt.sh: Transport : smd 
I/qcom-bluetooth( 3291): /system/etc/init.qcom.bt.sh: ** Bluez stack ** 
I/qcom-bluetooth( 3293): /system/etc/init.qcom.bt.sh: Power Class: Ignored. Default(1) used (1-CLASS1/2-CLASS2/3-CUSTOM) 
I/qcom-bluetooth( 3295): /system/etc/init.qcom.bt.sh: Power Class: To override, Before turning BT ON; setprop qcom.bt.dev_power_class <1 or 2 or 3> 
I/qcom-bluetooth( 3297): /system/etc/init.qcom.bt.sh: LE Power Class: Ignored. Default(2) used (1-CLASS1/2-CLASS2/3-CUSTOM) 
I/qcom-bluetooth( 3298): /system/etc/init.qcom.bt.sh: LE Power Class: To override, Before turning BT ON; setprop qcom.bt.le_dev_pwr_class <1 or 2 or 3> 
I/GeckoDump( 1587): [DEBUG] SYSTEM NFC-HANDOVER: bluetooth-adapter-added
E/qcom-bluetooth( 3321): /system/etc/init.qcom.bt.sh: Bluetooth QSoC firmware download failed: exit code  

========== Receiver log with grep nfc ==========
I/BrcmNfcNfa(  310): nfc_set_state 4 (IDLE)->5 (OPEN)
I/BrcmNfcNfa(  310): nfc_ncif_proc_activate:47 36, mode:0x05
D/nfcd    (  310): static void NfcService::notifyLlcpLinkActivated(IP2pDevice*): enter
I/BrcmNfcNfa(  310): nfc_ncif_send_cmd.
D/nfcd    (  310): void* NfcService::eventLoop(): NFCService msg=1
D/nfcd    (  310): void NfcService::handleLlcpLinkActivation(NfcEvent*): enter
D/nfcd    (  310): void NfcService::handleLlcpLinkActivation(NfcEvent*): Target Activate LLCP OK
I/BrcmNfcNfa(  310): nfc_ncif_send_data :0, num_buff:1 qc:0
I/BrcmNfcNfa(  310): nfa_dm_nfc_response_cback () NFC_SET_CONFIG_REVT(0x5002)
I/BrcmNfcNfa(  310): nfc_ncif_send_data :0, num_buff:1 qc:0
I/BrcmNfcNfa(  310): nfc_ncif_proc_data 0x000002
I/BrcmNfcNfa(  310): nfc_ncif_proc_data len:2
E/nfcd    (  310): notifyLlcpLinkFirstPacketReceived: not implement
I/BrcmNfcNfa(  310): nfc_ncif_send_data :0, num_buff:1 qc:0
D/nfcd    (  310): void* SnepConnectionThreadFunc(void*): connection thread enter
D/nfcd    (  310): SnepMessage* SnepMessenger::getMessage(): enter
I/BrcmNfcNfa(  310): nfc_ncif_send_data :0, num_buff:1 qc:0
I/BrcmNfcNfa(  310): nfc_ncif_proc_data 0x000006
I/BrcmNfcNfa(  310): nfc_ncif_proc_data len:6
D/nfcd    (  310): bool HandoverClient::connect(): enter
D/BroadcomNfc(  310): doConnectBy: enter; sn = urn:nfc:sn:handover
D/BroadcomNfc(  310): PeerToPeer::connectConnOriented: enter; h: 37  service name=urn:nfc:sn:handover
I/BrcmNfcNfa(  310): NFA_P2pConnectByName (): client_handle:0x521, SN:<urn:nfc:sn:handover>, MIU:128, RW:1
I/BrcmNfcNfa(  310): nfc_ncif_send_data :0, num_buff:1 qc:0
I/BrcmNfcNfa(  310): nfc_ncif_send_data :0, num_buff:1 qc:0
I/BrcmNfcNfa(  310): nfc_ncif_proc_data 0x000017
I/BrcmNfcNfa(  310): nfc_ncif_proc_data len:23
I/BrcmNfcNfa(  310): llcp_util_parse_connect (): LLCP_SN_TYPE:<urn:nfc:sn:handover>
I/BrcmNfcNfa(  310): nfc_ncif_send_data :0, num_buff:1 qc:0
I/BrcmNfcNfa(  310): nfc_ncif_send_data :0, num_buff:1 qc:0
D/nfcd    (  310): void* HandoverConnectionThreadFunc(void*): connection thread enter
I/BrcmNfcNfa(  310): nfc_ncif_proc_data 0x000002
I/BrcmNfcNfa(  310): nfc_ncif_proc_data len:2
D/nfcd    (  310): bool HandoverClient::connect(): exit
D/nfcd    (  310): processNotificaton notification=2001
D/nfcd    (  310): void NfcIpcSocket::writeToOutgoingQueue(uint8_t*, size_t) enter, data=0xb7923f48, dataLen=20
D/nfcd    (  310): Writing 20 bytes to gecko 
D/nfcd    (  310): void NfcService::handleLlcpLinkActivation(NfcEvent*): exit
....
D/nfcd    (  310): void* HandoverConnectionThreadFunc(void*): get a complete NDEF message
D/nfcd    (  310): processNotificaton notification=2001
D/nfcd    (  310): numRecords=2
D/nfcd    (  310): tnf=1
D/nfcd    (  310): typeLength=2
D/nfcd    (  310): idLength=0
D/nfcd    (  310): payloadLength=17
D/nfcd    (  310): mPayload 0 = 18
D/nfcd    (  310): mPayload 1 = 145
D/nfcd    (  310): mPayload 2 = 2
D/nfcd    (  310): mPayload 3 = 2
D/nfcd    (  310): mPayload 4 = 99
D/nfcd    (  310): mPayload 5 = 114
D/nfcd    (  310): mPayload 6 = 104
D/nfcd    (  310): mPayload 7 = 0
D/nfcd    (  310): mPayload 8 = 81
D/nfcd    (  310): mPayload 9 = 2
D/nfcd    (  310): mPayload 10 = 4
D/nfcd    (  310): mPayload 11 = 97
D/nfcd    (  310): mPayload 12 = 99
D/nfcd    (  310): mPayload 13 = 1
D/nfcd    (  310): mPayload 14 = 1
D/nfcd    (  310): mPayload 15 = 48
D/nfcd    (  310): mPayload 16 = 0
D/nfcd    (  310): tnf=2
D/nfcd    (  310): typeLength=32
D/nfcd    (  310): idLength=1
D/nfcd    (  310): payloadLength=8
D/nfcd    (  310): mPayload 0 = 8
D/nfcd    (  310): mPayload 1 = 0
D/nfcd    (  310): mPayload 2 = 60
D/nfcd    (  310): mPayload 3 = 149
D/nfcd    (  310): mPayload 4 = 48
D/nfcd    (  310): mPayload 5 = 198
D/nfcd    (  310): mPayload 6 = 160
D/nfcd    (  310): mPayload 7 = 0
D/nfcd    (  310): void NfcIpcSocket::writeToOutgoingQueue(uint8_t*, size_t) enter, data=0xb79237c8, dataLen=124
D/nfcd    (  310): Writing 124 bytes to gecko 
I/BrcmNfcNfa(  310): nfc_ncif_send_data :0, num_buff:1 qc:0


I'm not familiar with NFC module, especially Gecko side. So I grep what I see via the keyword 'nfc'. For Gaia::BluetoothTransfer, it did not receive any incoming file event after NFC handover. I would like to suggest Gecko(Bluetooth/NFC?) devs for investigation the issue for following up work.
Flags: needinfo?(iliu)
Ken, could you please help to pass the investigation for right person? Thanks.
Flags: needinfo?(kchang)
Hi Eric, currently, NFC can not trigger a file sharing via BT because of Bug 1002391. In this case, is it possible that gaia app get any error event from BT? We need this error event to turn BT off. What is your suggestion? Thanks.
Flags: needinfo?(kchang) → needinfo?(echou)
blocking-b2g: --- → backlog
When bluetooth is off on both devices and the DUT shares an image to the other device, Bluetooth remains on for both the sending and receiving Flame 2.0 devices after the transfer has been completed. This issue occurs regardless if the transfer is successful or not.

Actual Result: Bluetooth remains on for the sending and receiving Flame 2.0 devices after the transfer has completed. 
Expected result: Bluetooth is turned off on both devices after the transfer has been completed.   

Flame 2.0
Build ID: 20140606040202
Gecko: https://hg.mozilla.org/mozilla-central/rev/c8288d0c7a15
Gaia: 857129928b6e56a809cee9d5445effb8fa9f1c2c
Platform Version: 32.0a1
Firmware Version: V10g-2
User Agent: Mozilla/5.0 (Mobile; rv:32.0) Gecko/32.0 Firefox/32.0

I'm only commenting this issue because I feel like these two issues are the most likely the same even though this specific issue states it only happens when the file transfer fails.
Whiteboard: [2.0-flame-test-run-1]
(In reply to Ken Chang[:ken] from comment #7)
> Hi Eric, currently, NFC can not trigger a file sharing via BT because of Bug
> 1002391. In this case, is it possible that gaia app get any error event from
> BT? We need this error event to turn BT off. What is your suggestion? Thanks.

Sorry for the late reply.

Bug 1002391 was fixed last Friday. I just flashed the latest Gecko/Gaia and NFC file sharing works as expected. Please give it a try.
Flags: needinfo?(echou)
I found that there may be another bug:

1. Make sure Bluetooth is off
2. Launch Gallery app, choose a photo
3. Tap with another NFC device once 
(Please be sure you only tap once. If you do "tap, leave and tap again" then file transferring would start)

Expected result: Bluetooth would be turned on and file sharing should begin

Actual result: Bluetooth would be turned on but file sharing does not begin

It's more like a gaia issue. Can anyone take a look?
Per comment 10, looks like another issue. But there is no any shrinking UI for me while I put the two flames back-to-back.

Gaia      6a778cb4c41415e389db5f73441db3dea374a601
Gecko     https://hg.mozilla.org/mozilla-central/rev/8bd92dc9ef59
BuildID   20140608160201
Version   32.0a1
ro.build.version.incremental=eng.cltbld.20140608.192224
ro.build.date=Sun Jun  8 19:22:36 EDT 2014
Whiteboard: [2.0-flame-test-run-1] → [2.0-flame-test-run-1], [2.0-flame-test-run-2]
Hi Alison
Does this problem still exist?
If it does, can you turn on the NFC debug from Settings-> Developer-> NFC output in ADB and attach the log?
Flags: needinfo?(ashiue)
Set as worksforme since could not reproduce this issue with the latest build.
Status: NEW → RESOLVED
Closed: 10 years ago
Flags: needinfo?(ashiue)
Resolution: --- → WORKSFORME
blocking-b2g: backlog → ---
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: