summaryrefslogtreecommitdiffstats
path: root/src/com/android/bluetooth/hid
diff options
context:
space:
mode:
authorGanesh Ganapathi Batta <ganeshg@broadcom.com>2012-07-31 16:22:32 -0700
committerMatthew Xie <mattx@google.com>2012-08-06 23:29:09 -0700
commit4f5430babbc5a8f870e5a578a4ea3452f41dd97a (patch)
tree2534082ebdb4124e5d8c151f97b0453cc5fad21b /src/com/android/bluetooth/hid
parent0322ae1f5e8ea55c391145e7925cb5962a97c11f (diff)
downloadandroid_packages_apps_Bluetooth-4f5430babbc5a8f870e5a578a4ea3452f41dd97a.tar.gz
android_packages_apps_Bluetooth-4f5430babbc5a8f870e5a578a4ea3452f41dd97a.tar.bz2
android_packages_apps_Bluetooth-4f5430babbc5a8f870e5a578a4ea3452f41dd97a.zip
Implement Profile Auto connection logic
Implement Profile Auto connection logic (moved from Settings App )in Bluetooth APK to avoid Auto connection not happening if the Settings App is not running As part of this implementation following features are implemented 1. Auto connection initiation during BT on OFF 2. Profile Auto connection priority management 3. Connecting Missing profile logic 4. Initialize Profile Priorities on Bond State Change Change-Id: I12b7c190e28f043b4b008c9b48ac7e13aaf178e6
Diffstat (limited to 'src/com/android/bluetooth/hid')
-rwxr-xr-xsrc/com/android/bluetooth/hid/HidService.java42
1 files changed, 40 insertions, 2 deletions
diff --git a/src/com/android/bluetooth/hid/HidService.java b/src/com/android/bluetooth/hid/HidService.java
index 2ed02b7eb..2f3c6de2e 100755
--- a/src/com/android/bluetooth/hid/HidService.java
+++ b/src/com/android/bluetooth/hid/HidService.java
@@ -38,6 +38,7 @@ public class HidService extends ProfileService {
private Map<BluetoothDevice, Integer> mInputDevices;
private boolean mNativeAvailable;
+ private static HidService sHidService;
private static final int MESSAGE_CONNECT = 1;
private static final int MESSAGE_DISCONNECT = 2;
@@ -68,6 +69,7 @@ public class HidService extends ProfileService {
mInputDevices = Collections.synchronizedMap(new HashMap<BluetoothDevice, Integer>());
initializeNative();
mNativeAvailable=true;
+ setHidService(this);
return true;
}
@@ -86,9 +88,45 @@ public class HidService extends ProfileService {
mInputDevices.clear();
mInputDevices = null;
}
+ clearHidService();
return true;
}
+ public static synchronized HidService getHidService(){
+ if (sHidService != null && sHidService.isAvailable()) {
+ if (DBG) Log.d(TAG, "getHidService(): returning " + sHidService);
+ return sHidService;
+ }
+ if (DBG) {
+ if (sHidService == null) {
+ Log.d(TAG, "getHidService(): service is NULL");
+ } else if (!(sHidService.isAvailable())) {
+ Log.d(TAG,"getHidService(): service is not available");
+ }
+ }
+ return null;
+ }
+
+ private static synchronized void setHidService(HidService instance) {
+ if (instance != null && instance.isAvailable()) {
+ if (DBG) Log.d(TAG, "setHidService(): set to: " + sHidService);
+ sHidService = instance;
+ } else {
+ if (DBG) {
+ if (sHidService == null) {
+ Log.d(TAG, "setHidService(): service not available");
+ } else if (!sHidService.isAvailable()) {
+ Log.d(TAG,"setHidService(): service is cleaning up");
+ }
+ }
+ }
+ }
+
+ private static synchronized void clearHidService() {
+ sHidService = null;
+ }
+
+
private final Handler mHandler = new Handler() {
@Override
@@ -359,7 +397,7 @@ public class HidService extends ProfileService {
return inputDevices;
}
- boolean setPriority(BluetoothDevice device, int priority) {
+ public boolean setPriority(BluetoothDevice device, int priority) {
enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
"Need BLUETOOTH_ADMIN permission");
Settings.Secure.putInt(getContentResolver(),
@@ -369,7 +407,7 @@ public class HidService extends ProfileService {
return true;
}
- int getPriority(BluetoothDevice device) {
+ public int getPriority(BluetoothDevice device) {
enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
"Need BLUETOOTH_ADMIN permission");
int priority = Settings.Secure.getInt(getContentResolver(),