Bluetooth: Clening up BT service in error cases.

If the statemachine didnt get response from stack in
8secs for any reason during BT off time, state machine
restores the BT state to on, which is wrong.
Restoring the BT state by restarting the service.

CRs-fixed: 528656
Change-Id: Iac6b1b4ba8ea0b5bd34bae5d672450e4a93fe658
Bluetooth: Add Get/Set socket option to the Blueooth Socket

Add Get/Set socket option for the Bluetooth socket.These APIs
will be called from the frameworks.

CRs-Fixed: 557180
Change-Id: I5ceef23d49e382089f479e8d618eec1dbc6ed5fb
Conflicts:
jni/com_android_bluetooth_btservice_AdapterService.cpp
HID: Add support for Set Idle and Get Idle commands

This patch adds support for Get Idle and Set Idle command handling
in jni and HidService which will be used to provide interface for
sending thse commands to HID Remote device.

Change-Id: I066d47c022905a39c11d365a9d26d128f94fe2f6
CRs-Fixed: 522511
HID: Add support for sending priority to btif layer

This patch adds support for sending remote device priority to HID btif
layer. Now with every change in remote input device priority btif layer
would be informed.

Change-Id: I08935a9d733ccab29173ba41ddab795eccad3f7f
CRs-Fixed: 532234
PBAP: Add Bug fixes from kk

This patch is  squashed commit of the following:

commit d2bc733a1bc90e1173c34e75475f0f7840ea6b92
Author: Smriti Gupta <smritig@codeaurora.org>
Date:   Thu Dec 19 13:31:06 2013 +0530

    PBAP: Remove body header when it is not needed

    This change will remove the body header when
    the user is asking for the size and not the body.

    Change-Id: I8de1a9db0ac64dac3e0d0cf680814ef200fa11a0
    CRs-Fixed: 554222

commit c79e8c67d8c87346712cf714c90aa9ea95c2d627
Author: Smriti Gupta <smritig@codeaurora.org>
Date:   Thu Oct 10 12:57:23 2013 +0530

    PBAP: Remove BODY header from PSE's response to PB size request

    Modified the code so that PSE will not respond with a
    Body header when being asked for the size of Phonebook
    with max list count set to 0.

    Change-Id: Ib297bd5fe18179a390e3d2b223fb898a6c50ba57
    CRs-Fixed: 554222
    (cherry picked from commit e0599842a75517b7ef29e1517741760022a9e5ac)
    (cherry picked from commit 6763b280ad03a10428321cd5c176063b8fd2686a)
    (cherry picked from commit 34f1f17e1ff9bec5b7de93ecd16b91bf0cea2c5b)

Conflicts:
	src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java
	src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java

Change-Id: Id584ac29655d92da6a183a1fde63dbd3a48c1c72
GAP: Update Scan Mode state from NVM

During BT ON/OFF set Scan Mode state based on NVM Scan Mode state,
which have stored scan mode state. Otherwise, default Scan Mode
state is always set to SCAN_MODE_NONE and application will not
take the state from NVM.

When USER switch happen Scan Mode is set to NONE to avoid improper
scan mode state.

Change-Id: I87117e94cdd898991c720ad6ac72bfa3bb0366f5
CRs-Fixed: 519661, 691014
Conflicts:
src/com/android/bluetooth/btservice/AdapterProperties.java
Bluetooth: Fix resource leak in OPP (3/3)

- This patch handles closing of input stream if no device is selected
  by user when trying to send file via BT. Without this patch, input
  stream was never closed resulting in leak with each iteration and
  system crash after 1024 iterations.

- This change will remove hashmap share entry if user selected share
  via BT and press back or press cancel. Otherwise, hashmap will reach
  its limit for successive share via BT and cause BT app to crash.
  Change-Id: I6e145950975c3fe4cc5d1936c692e351779f242d

CRs-Fixed: 662147, 678607
Change-Id: I92aa0d8e81977fde0446f565f1de95e2d91e1e9c
OPP: Add BluetoothOppL2capListener.java file

Base reference for BluetoothOppL2capListener
is existing BluetoothOppRfcommListener.java.

Actual L2CAP socket implementation is added
from further gerrits.

CRs-Fixed: 639499
Change-Id: Ic2f9a4f5e91f55ee17333899a100c877f443c497
Bluetooth: Update the Bluetooth state in STOP_TIMEOUT case

Bluetooth adapter state is getting updated with turn off
but the same intent is not getting broad casted to the
application, so it hanged in turning off state.

Broadcasting the TRUN_OFF intent in STOP_TIMEOUT case.

CRs-fixed: 534372
Change-Id: I4f05a946e56a87ff62c6e505b6bfbfbfe7c8c951
Bluetooth: Query BluetoothPhoneService at BT ON.

This will allow the application to have
updated values of call states.

CRs-fixed: 506853
Change-Id: I0b1e9cdfd7ecac05062c82aa563849f49a5ae520
Bluetooth: Adding support to get remote DI record

Adding support to get remote DI record. The local
device can use the Device ID service record from
the remote device, In order to make best use of the
features on the device identified.

Change-Id: I36ff9708e1bb6ee2e159fb26c7daade66c3c0d45
CRs-Fixed: 692532
Bluetooth: Load jni library before calling classinitnative

Always load the Bluetooth jni library before calling the
classinitnative method to make sure all the  jni methods
are available for Bluetooth java space.

CRs-Fixed: 674145

Change-Id: I3911a531763fc3ba8fb429b3aa3c4206ed034c2a
Bluetooth: MAP: Do not set body header if maxlist count is 0

As per MAP profile spec when message listing or folder
listing is done with 0 as max list count, then the response
should not contain the body header. Hence add change for the
same

Change-Id: Idf50586ccf5616dec455cf36cb2d6edc24486e41
CRs-fixed: 590672
Bluetooth: Avoid Broadcasting ACTION_DISCOVERY_STARTED intent again

This change will avoid broadcasting ACTION_DISCOVERY_STARTED intent again
if mDiscovering is set. Otherwise some of the currently discovered devices
are removed from device list.

CRs-Fixed: 523374
Change-Id: I1166f59d48229213c554a53a10aca9078a5aa5cd
Fix to avoid the case when interface is already enabled.

Added BT_STATUS_DONE check in JNI interface loading.
Change-id: Iccfbe510a91bd94de258bcbe61b4fd6fa9044441
CRs-Fixed: 636497

Bluetooth :Fix to avoid the access of JNI gloabal reference object

This is a conrner case where bindandfinish gets called anytime
where adapter state!= STOPPED and calls cleanupNative. Further
while cleanup at lower layer will try to access JNI reference
which is already deleted.

Change-id: I579bc4015b61ad653f18a5f4a3d26a2508236ff5
CRs-Fixed: 642466

Bluetooth: Adapterservice Cleanup and unbind

AdapterService cleanup and unbind happens only when the
BT state is off.

CRs-fixed: 556716,562137
Change-id: Ida3b3c12a97604919fbab6d7f4f34b9daa93d85a

Bluetooth: GAP: Transition to stable state based on device

This patch adds check in BluetoothBondStateMachine to transition to
stable state on reception of BOND_STATE_NONE only for device that
are in pairing state and not for all devices. Without this patch it
was observed that state was transitioning to stable state for all
devices resulting in discarding of BOND_STATE_NONE from device that
was actually in pairing mode resulting in UI stuck in pairing forever.

Change-id: Ia860d26a5f036c13d649434246ba6dea7b9807f2
CRs-Fixed: 584102

Bluetooth: GAP: Update bondstatemachine to handle pairing scenarios

This patch updates BluetoothBondStateMachine to properly handle concurrency
scenarios of pairing while pairing is ongoing with some remote device.
Without this patch it was observed that DUT was getting stuck in pairing
when unpairing was done for some paired devices and pairing timed out with
device for which pairing was being initiated.

Change-id: I07d2bc323aebbeada9c930eb36c9855da59dd677
CRs-Fixed: 586935

Bluetooth: Null check added before accessing the Adapter service
Change-id: I22acb495f8aa76683dae4bc68376443a67f45b0a
Null check is being added before accesing the Adapter service's
APIs like createBondNative, cancelBondNative.

CRs-Fixed: 552616

Change-Id: Ib9014f653e829a5e4518a558ff39d5e89dafa0f3

Conflicts:
	src/com/android/bluetooth/btservice/BondStateMachine.java

Change-Id: I93c377d8a55b5a23ea9e12c453aaa145b2a71961
Bluetooth: Add trust device feature.

Add set trust feature where the remote device is marked
as a trusted device for subsequent connection.

Change-Id: Iee491db2e5b6090761a4f42467ac36ed53923fc4
CRs-fixed: 523135
BT: Send correct call state for Voip call at SLC.

When HS is connected while Virtual Call is ongoing, we send
correct call state in CIND update. But at SLC, phone state
query result updates CIEV 1,0 to remote. Remote treats it
as Voip call termination which is incorrect. Update correct
call state as call active at SLC so that SCO is opened.

Change-Id: Id267ba669b8a6237a62bdb040b5aede5373fb465
BluetoothGatt: Use ServerIf during registration

Use serverIf for active service declaration to fix
issues with certain Apps that don't wait on
onServiceAdded() before registering the next service

Change-Id: I6e329ddaf53611d81f56be1d98508564283dd377
CRs-Fixed: 632265
Bluetooth-OPP: Check for the pending batch to start next batch

During concurrent inbound and outbound transfer batches if one of
them is finished, then should check for the pending batch to start
next batch. Otherwise, next batch will not start until last
running batch is finished.

CRs-Fixed: 703671
Change-Id: I126c7cba117b379f932d7fb2a3d467e72cf494b1
Sends bond state change intent for unbonding a device

When remove bond API is called from the stack layer,
the bond state change intent is not sent in the
upper layers to unbond a device.

Change-Id: I515bfaf3f1a575106b10e2f688b1e9de58770b87
CRs-fixed: 605746