Closed
Bug 1162902
Opened 11 years ago
Closed 11 years ago
Implement PBAP SetPhoneBook function
Categories
(Firefox OS Graveyard :: Bluetooth, defect)
Tracking
(feature-b2g:2.2r+, firefox41 fixed, b2g-v2.2r fixed, b2g-master fixed)
People
(Reporter: ben.tian, Assigned: ben.tian)
References
Details
Attachments
(1 file, 2 obsolete files)
|
6.54 KB,
patch
|
shawnjohnjr
:
review+
|
Details | Diff | Splinter Review |
Implement SetPhoneBook function per Section 5.2, PBAP 1.2.
| Assignee | ||
Comment 1•11 years ago
|
||
Assignee: nobody → btian
| Assignee | ||
Comment 2•11 years ago
|
||
Attachment #8603266 -
Attachment is obsolete: true
Attachment #8603990 -
Flags: review?(shuang)
Comment on attachment 8603990 [details] [diff] [review]
Patch 1 (v1): Implement PBAP SetPhoneBook function
Review of attachment 8603990 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/bluetooth/bluedroid/BluetoothPbapManager.cpp
@@ +289,5 @@
> + const ObexHeaderSet& aHeader)
> +{
> + nsString newPath = mCurrentPath;
> +
> + // Section 5.2 "SetPhoneBook Function", PBAP 1.2
Please change comment style to multiline comment.
@@ +290,5 @@
> +{
> + nsString newPath = mCurrentPath;
> +
> + // Section 5.2 "SetPhoneBook Function", PBAP 1.2
> + //
Here the comments seems to be strange, maybe I misunderstood the spec.
@@ +292,5 @@
> +
> + // Section 5.2 "SetPhoneBook Function", PBAP 1.2
> + //
> + // Three cases:
> + // 1) Go up 1 level - flags bit 0 is 1
I checked PBAP 1.2 Section 5.2, Go up 1 level: both bit 0 and bit 1 are 1, and the name header is optional.
@@ +293,5 @@
> + // Section 5.2 "SetPhoneBook Function", PBAP 1.2
> + //
> + // Three cases:
> + // 1) Go up 1 level - flags bit 0 is 1
> + // 2) Go back to root - flags bit 0 is 0 AND name header is empty
Go back to root: bit 0 is 0, bit 1 is 1 AND name header is empty.
@@ +294,5 @@
> + //
> + // Three cases:
> + // 1) Go up 1 level - flags bit 0 is 1
> + // 2) Go back to root - flags bit 0 is 0 AND name header is empty
> + // 3) Go down 1 level - flags bit 0 is 0 AND name header is not empty,
bit 0 is 0, bit 1 is 1 and name header is not empty
@@ +299,5 @@
> + // where name header is the name of child folder
> + if (flags & 1) {
> + // Go up 1 level
> + if (!newPath.IsEmpty()) {
> + newPath = StringHead(newPath, newPath.RFindChar('/'));
I don't understand why do you set root path but the comment said 'Go up 1 level'?
@@ +319,5 @@
> +
> + // Ensure the new path is legal
> + if (!IsLegalPath(newPath)) {
> + BT_LOGR("Illegal phone book path [%s]",
> + NS_ConvertUTF16toUTF8(newPath).get());
If the SetPhoneBookPath is not legal, we shall reply Obex error code "NOT FOUND" response code "0xC4".
@@ +324,5 @@
> + return false;
> + }
> +
> + mCurrentPath = newPath;
> + BT_LOGR("[%s]", NS_ConvertUTF16toUTF8(mCurrentPath).get());
Please remove this line or print something more descriptive?
Attachment #8603990 -
Flags: review?(shuang)
| Assignee | ||
Comment 4•11 years ago
|
||
(In reply to Shawn Huang [:shawnjohnjr] from comment #3)
> @@ +293,5 @@
> > + // Section 5.2 "SetPhoneBook Function", PBAP 1.2
> > + //
> > + // Three cases:
> > + // 1) Go up 1 level - flags bit 0 is 1
> > + // 2) Go back to root - flags bit 0 is 0 AND name header is empty
>
> Go back to root: bit 0 is 0, bit 1 is 1 AND name header is empty.
All three cases has bit 2 is 1 so I omit it. Do you suggest to add following check before?
if ((flags >> 1) != 1) {
// bit 1: 1, bit 2~7: 0
return ObexResponseCode::BadRequest;
}
> @@ +299,5 @@
> > + // where name header is the name of child folder
> > + if (flags & 1) {
> > + // Go up 1 level
> > + if (!newPath.IsEmpty()) {
> > + newPath = StringHead(newPath, newPath.RFindChar('/'));
>
> I don't understand why do you set root path but the comment said 'Go up 1
> level'?
This is NOT root path but substring to the last "/". |RFindChar| gets the last index of "/" and |StringHead| returns the substring in |newPath| (start index=0, length=the last index of "/") as the 1-level up folder.
An example in HFP manager for reference.
https://dxr.mozilla.org/mozilla-central/source/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp#1510
> @@ +319,5 @@
> > +
> > + // Ensure the new path is legal
> > + if (!IsLegalPath(newPath)) {
> > + BT_LOGR("Illegal phone book path [%s]",
> > + NS_ConvertUTF16toUTF8(newPath).get());
>
> If the SetPhoneBookPath is not legal, we shall reply Obex error code "NOT
> FOUND" response code "0xC4".
OK. I'll make this function return ObexResponseCode for reply.
> @@ +324,5 @@
> > + return false;
> > + }
> > +
> > + mCurrentPath = newPath;
> > + BT_LOGR("[%s]", NS_ConvertUTF16toUTF8(mCurrentPath).get());
>
> Please remove this line or print something more descriptive?
Any suggestion on description? I think the following logs is descriptive enough since BT_LOGR shows function name.
05-18 23:02:43.366 206 206 I GeckoBluetooth: SetPhoneBookPath: [/telecom]
05-18 23:02:43.426 206 206 I GeckoBluetooth: SetPhoneBookPath: [/telecom/och]
Flags: needinfo?(shuang)
(In reply to Ben Tian [:btian][PTO: 5/25~6/5] from comment #4)
> (In reply to Shawn Huang [:shawnjohnjr] from comment #3)
> > @@ +293,5 @@
> > > + // Section 5.2 "SetPhoneBook Function", PBAP 1.2
> > > + //
> > > + // Three cases:
> > > + // 1) Go up 1 level - flags bit 0 is 1
> > > + // 2) Go back to root - flags bit 0 is 0 AND name header is empty
> >
> > Go back to root: bit 0 is 0, bit 1 is 1 AND name header is empty.
>
> All three cases has bit 2 is 1 so I omit it. Do you suggest to add following
> check before?
You mean bit 1 is 1 so you omit it?
I just thought it will be clear to have specification compliance comments.
>
> if ((flags >> 1) != 1) {
> // bit 1: 1, bit 2~7: 0
> return ObexResponseCode::BadRequest;
> }
>
Yes, that looks good to me.
> > @@ +299,5 @@
> > > + // where name header is the name of child folder
> > > + if (flags & 1) {
> > > + // Go up 1 level
> > > + if (!newPath.IsEmpty()) {
> > > + newPath = StringHead(newPath, newPath.RFindChar('/'));
> >
> > I don't understand why do you set root path but the comment said 'Go up 1
> > level'?
>
> This is NOT root path but substring to the last "/". |RFindChar| gets the
> last index of "/" and |StringHead| returns the substring in |newPath| (start
> index=0, length=the last index of "/") as the 1-level up folder.
>
> An example in HFP manager for reference.
> https://dxr.mozilla.org/mozilla-central/source/dom/bluetooth/bluedroid/hfp/
> BluetoothHfpManager.cpp#1510
>
Oh! My bad! I misunderstood the code.
> > @@ +319,5 @@
> > > +
> > > + // Ensure the new path is legal
> > > + if (!IsLegalPath(newPath)) {
> > > + BT_LOGR("Illegal phone book path [%s]",
> > > + NS_ConvertUTF16toUTF8(newPath).get());
> >
> > If the SetPhoneBookPath is not legal, we shall reply Obex error code "NOT
> > FOUND" response code "0xC4".
>
> OK. I'll make this function return ObexResponseCode for reply.
>
> > @@ +324,5 @@
> > > + return false;
> > > + }
> > > +
> > > + mCurrentPath = newPath;
> > > + BT_LOGR("[%s]", NS_ConvertUTF16toUTF8(mCurrentPath).get());
> >
> > Please remove this line or print something more descriptive?
>
> Any suggestion on description? I think the following logs is descriptive
> enough since BT_LOGR shows function name.
>
> 05-18 23:02:43.366 206 206 I GeckoBluetooth: SetPhoneBookPath: [/telecom]
> 05-18 23:02:43.426 206 206 I GeckoBluetooth: SetPhoneBookPath:
> [/telecom/och]
How about this?
BT_LOGR("Current path: [%s]", NS_ConvertUTF16toUTF8(mCurrentPath).get());
Flags: needinfo?(shuang)
| Assignee | ||
Comment 6•11 years ago
|
||
Revise based on reviewer's comment.
Attachment #8603990 -
Attachment is obsolete: true
Attachment #8607348 -
Flags: review?(shuang)
Comment on attachment 8607348 [details] [diff] [review]
Patch 1 (v2): Implement PBAP SetPhoneBook function
Review of attachment 8607348 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/bluetooth/bluedroid/BluetoothPbapManager.cpp
@@ +220,5 @@
>
> ReplyToDisconnectOrAbort();
> AfterPbapDisconnected();
> break;
> + case ObexRequestCode::SetPath: {
We probably should check receivedLength less than maximum total length here (MAX_PACKET_LENGTH) in the beginning of |ReceiveSocketData| .
@@ +223,5 @@
> break;
> + case ObexRequestCode::SetPath: {
> + // Section 3.3.6 "SetPath", IrOBEX 1.2
> + // [opcode:1][length:2][flags:1][contants:1][Headers:var]
> + if (!ParseHeaders(&data[5], receivedLength - 5, &pktHeaders)) {
If the remote device sends illegal OBEX format, i'm afraid directly access data[5] is a bit dangerous--it's possible to hit SIGSEGV. It all depends on the behavior that remote sends the correct format obex packets. We shall check the |receivedLength| first before accessing data[5].
Attachment #8607348 -
Flags: review?(shuang)
| Assignee | ||
Comment 8•11 years ago
|
||
Comment on attachment 8607348 [details] [diff] [review]
Patch 1 (v2): Implement PBAP SetPhoneBook function
I prefer to open another bug to fix comment 7 problems as they involve overall structural change (including OPP manager) rather than SetPhonebook only.
Set r? again.
Attachment #8607348 -
Flags: review?(shuang)
Attachment #8607348 -
Flags: review?(shuang) → review+
| Assignee | ||
Comment 9•11 years ago
|
||
Comment 11•11 years ago
|
||
| Assignee | ||
Comment 12•10 years ago
|
||
Wesley, please help mark this bug feature-b2g:2.2r since BT feature PBAP depends on this bug.
Flags: needinfo?(whuang)
Updated•10 years ago
|
Updated•10 years ago
|
status-b2g-master:
--- → fixed
Target Milestone: --- → 2.2 S13 (29may)
Comment 13•10 years ago
|
||
You need to log in
before you can comment on or make changes to this bug.
Description
•