Closed Bug 1223806 Opened 9 years ago Closed 9 years ago

Move Bluetooth Core interface into separate class

Categories

(Firefox OS Graveyard :: Bluetooth, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(firefox45 fixed)

RESOLVED FIXED
2.6 S1 - 11/20
Tracking Status
firefox45 --- fixed

People

(Reporter: tzimmermann, Assigned: tzimmermann)

References

Details

Attachments

(5 files, 3 obsolete files)

10.76 KB, patch
ben.tian
: review+
brsun
: feedback+
Details | Diff | Splinter Review
15.35 KB, patch
ben.tian
: review+
brsun
: feedback+
Details | Diff | Splinter Review
11.99 KB, patch
ben.tian
: review+
brsun
: feedback+
Details | Diff | Splinter Review
48.53 KB, patch
tzimmermann
: review+
Details | Diff | Splinter Review
24.57 KB, patch
tzimmermann
: review+
Details | Diff | Splinter Review
The core Bluetooth backend interfaces are currently provided by |BluetoothInterface| and implemented by |BluetoothDaemonInterface|.

There shoudl be a separate interface |BluetoothCoreInterface| with implementation. |BluetoothInterface| will only be responsible for the connection to the Bluetooth daemon.
Assignee: nobody → tzimmermann
Status: NEW → ASSIGNED
Hi Thomas,

Sorry for the late reply.

Basically these patches look good to me. But since Ben has some concrete ideas on refining interfaces (see bug 1221477), I would suggest to let him discuss more on these changes with you. I am more than happy to input my comments if debate occurs.
Attachment #8686066 - Flags: review?(btian)
Attachment #8686066 - Flags: review?(brsun)
Attachment #8686066 - Flags: feedback+
Attachment #8686067 - Flags: review?(btian)
Attachment #8686067 - Flags: review?(brsun)
Attachment #8686067 - Flags: feedback+
Attachment #8686068 - Flags: review?(btian)
Attachment #8686068 - Flags: review?(brsun)
Attachment #8686068 - Flags: feedback+
Attachment #8686069 - Flags: review?(btian)
Attachment #8686069 - Flags: review?(brsun)
Attachment #8686069 - Flags: feedback+
Attachment #8686070 - Flags: review?(btian)
Attachment #8686070 - Flags: review?(brsun)
Attachment #8686070 - Flags: feedback+
Comment on attachment 8686069 [details] [diff] [review]
[04] Bug 1223806: Add |BluetoothDaemonCoreInterface|

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

LGTM
Attachment #8686069 - Flags: review?(btian) → review+
Comment on attachment 8686066 [details] [diff] [review]
[01] Bug 1223806: Add Bluetooth Core interface, notification and result handler

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

LGTM
Attachment #8686066 - Flags: review?(btian) → review+
Comment on attachment 8686067 [details] [diff] [review]
[02] Bug 1223806: Convert Bluetooth to |BluetoothCoreResultHandler|

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

LGTM
Attachment #8686067 - Flags: review?(btian) → review+
Comment on attachment 8686068 [details] [diff] [review]
[03] Bug 1223806: Convert Bluetooth to |BluetoothCoreNotificationHandler|

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

LGTM
Attachment #8686068 - Flags: review?(btian) → review+
Comment on attachment 8686070 [details] [diff] [review]
[05] Bug 1223806: Convert Bluetooth to |BluetoothCoreInterface|

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

::: dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
@@ +144,4 @@
>      BluetoothService* bs = BluetoothService::Get();
>      NS_ENSURE_TRUE_VOID(bs);
>  
> +    auto coreInterface = sBtInterface->GetBluetoothCoreInterface();

How about remember |sBtCoreInterface| to save these additional checks?

@@ +1152,5 @@
>  
> +  auto coreInterface = sBtInterface->GetBluetoothCoreInterface();
> +  if (!coreInterface) {
> +    DispatchReplyError(aRunnable, STATUS_FAIL);
> +    return NS_ERROR_FAILURE;

Why do some methods return NS_OK but some returns NS_ERROR_FAILURE?
Attachment #8686070 - Flags: review?(btian)
Changes since v1:

  - store core-interface pointer for service manager

This change should also resolve the comment about the return values.
Attachment #8686070 - Attachment is obsolete: true
Attachment #8687972 - Flags: review?(btian)
Comment on attachment 8687972 [details] [diff] [review]
[05] Bug 1223806: Convert Bluetooth to |BluetoothCoreInterface| (v2)

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

LGTM. Note macros in [1] should be revised as well. I'll open a followup bug for it.
Attachment #8687972 - Flags: review?(btian) → review+
Blocks: 1225340
Comment on attachment 8687972 [details] [diff] [review]
[05] Bug 1223806: Convert Bluetooth to |BluetoothCoreInterface| (v2)

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

One more place to revise.

::: dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
@@ +2246,3 @@
>      // Bluetooth scan mode is SCAN_MODE_CONNECTABLE by default, i.e., it should
>      // be connectable and non-discoverable.
>      NS_ENSURE_TRUE_VOID(sBtInterface);

Replace with |sBtCoreInterface|.
Thomas,

Two more questions after patch 5 is landed:
1) Does non-null |sBtCoreInterface| implies non-null |sBtInterface|?
2) Does "BluetoothService::IsEnabled() == true" implies non-null |sBtCoreInterface|?

(In reply to Ben Tian [:btian] from comment #14)
> Comment on attachment 8687972 [details] [diff] [review]
> [05] Bug 1223806: Convert Bluetooth to |BluetoothCoreInterface| (v2)
> 
> Review of attachment 8687972 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> One more place to revise.
> 
> ::: dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
> @@ +2246,3 @@
> >      // Bluetooth scan mode is SCAN_MODE_CONNECTABLE by default, i.e., it should
> >      // be connectable and non-discoverable.
> >      NS_ENSURE_TRUE_VOID(sBtInterface);
> 
> Replace with |sBtCoreInterface|.
Flags: needinfo?(tzimmermann)
Hi

Yes, both should be true.

(In reply to Ben Tian [:btian] from comment #15)
> Thomas,
> 
> Two more questions after patch 5 is landed:
> 1) Does non-null |sBtCoreInterface| implies non-null |sBtInterface|?

I don't think the current code is very strict about setting |sBtInterface| to nullptr, but the intend is that a valid address in |sBtCoreInterface| always implies a valid address in |sBtInterface|. The start and stop machinery in |BluetoothServiceBluedroid| should take care of this.

> 2) Does "BluetoothService::IsEnabled() == true" implies non-null
> |sBtCoreInterface|?

Yes, |sBtCoreInterface::Enable| is required to enable Bluetooth. There's no way to enable Bluetooth without calling it first.
Flags: needinfo?(tzimmermann)
Changes since v1:

  - rebased onto latest m-c
Attachment #8686067 - Attachment is obsolete: true
Attachment #8689466 - Flags: review+
Changes since v2:

  - rebased onto latest m-c
  - fixed test for |sBtCoreInterface|
Attachment #8687972 - Attachment is obsolete: true
Attachment #8689468 - Flags: review+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: