Use mDatabaseManager when calling database functions

In some corner cases, when the Bluetooth is turning off,
setConnectionPolicy() in each profile could be invoked right after
mAdapterService is set to null.
This patch replaces mAdapterService.getDatabase() to mDatabaseManager
in order to avoid null pointer dereference. It also makes
setConnectionPolicy() to return the correct result.

Bug: 157973675
Test: atest BluetoothInstrumentationTests
Tag: #stability

Change-Id: I422571e63a9f01bc531e2ba21c0b303e92383efb
30 files changed