Sasken proposes to contribute following BT Device Discovery feature
enhancements to the android open source project.
The idea is to provide the user the option of enabling the BT
Discoverability feature in the Permanent mode.
This requirement essentially arises from an enhancement request #6348.
http://code.google.com/p/android/issues/detail?id=6348
The changes to the framework are described below. Before starting with
the design and implementation, we would like to have some feedback on
our proposal.
====================
ARCHITECTURAL IMPACT
====================
Current implementation is such that the Bluetooth Discoverability is
enabled only for a period of 120 secs (2 mins)
Following are the details of the current implementation:
There are two scan modes :
1. Connectable (BT Enabled with Discovery disabled)
2. Connectable & Discoverable (BT Enabled with Discovery enabled)
The Discoverability option is handled by the BluetoothDiscoveryEnabler
preference change listener class.
Whenever the Discovery option is selected by the user, the scan mode
is set to the Connectable-Discoverable timeout value and the timeout
value is set to 120 secs.
The countdown time is updated every 1 secs and on expiry of the
timeout value, the discoverbility is disabled by resetting the mode to
Connectable mode.
Thus in case there is a requirement for the device to always available
for discovery it is not possible without user intervention to set the
discoverable mode every 120 secs.
The proposed feature enhancement is to provide an option to the user
to enable the discoverability in the permanent mode
Further to enabling the Visibility option, the user will be provided
with the option to enable in permanant or temporary mode.
Bluetooth settings
|
|_ Visibility
|
|_ OFF
|_ ON Temporary visible
|_ ON Always visible
These changes however would be applicable only for the particular BT
session.
Changes are required only in the BT settings application in order to
achieve this.
---------------------
Change details
----------------------
BluetoothDiscoverableEnabler
--------------------------------------------
The class BluetoothDiscoverableEnabler is the preference change
listener which would handle the Visibility status preference change.
Currently the setEnabled function sets the endtimestamp using the 120
secs timeout and notifies the appropriate listener to enable the
option and start theb countdown timer which is refreshed by the
updateCountdownSummary every 1sec.
In order to support the visibility in a permanent mode, the setEnabled
value can be changed from a check box value to a list value of 0,1 and
2. This would require the onPreferenceChanged to handle a list value.
Handling of 0 (OFF) and 1 (On for 120 secs) in the setEnabled
function will stay as per the current implementation.
For a value of 2 (Always visible), a timeout of 0 will be set in the
BluetoothService which will enable it in the permanent mode.
Also the updateCountdownSummary will not be invoked in order to
suppress the countdown timer of 120 secs.
Another change would be in the handleModeChanged function which would
be called through Resume handler. Here too, it would be required to
check the timeout value using the
BluetoothAdapter.getDiscoverableTimer. If the timeout returned is a 0,
it implies that the mode is set to permanent and hence no
updateCountdownSummary needs to be invoked to continue the countdown
timer.