summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorAndre Eisenbach <eisenbach@google.com>2016-02-24 18:47:16 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-02-24 18:47:16 +0000
commit9e6146ee2f94c0301d8cc19ca4655e197528829c (patch)
tree3605e1f5f8149afc9bc8381a19163ecca29fe5f6 /src/com
parent68d4713d8aa4bf743939b195e2658ae89703ffe7 (diff)
parente8363190528d0d95a35ab265ab91c591eb17a7c3 (diff)
downloadandroid_packages_apps_Bluetooth-9e6146ee2f94c0301d8cc19ca4655e197528829c.tar.gz
android_packages_apps_Bluetooth-9e6146ee2f94c0301d8cc19ca4655e197528829c.tar.bz2
android_packages_apps_Bluetooth-9e6146ee2f94c0301d8cc19ca4655e197528829c.zip
Merge "DO NOT MERGE Read Bluetooth interop database entries from settings (2/2)" into mnc-dr-dev
am: e836319052 * commit 'e8363190528d0d95a35ab265ab91c591eb17a7c3': DO NOT MERGE Read Bluetooth interop database entries from settings (2/2)
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/bluetooth/btservice/AdapterService.java58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/com/android/bluetooth/btservice/AdapterService.java b/src/com/android/bluetooth/btservice/AdapterService.java
index 5e60ee445..ac722829c 100644
--- a/src/com/android/bluetooth/btservice/AdapterService.java
+++ b/src/com/android/bluetooth/btservice/AdapterService.java
@@ -362,6 +362,8 @@ public class AdapterService extends Service {
mAdapterStateMachine.sendMessage(mAdapterStateMachine.obtainMessage(AdapterState.BREDR_STOPPED));
} else if (isTurningOn) {
+ updateInteropDatabase();
+
//Process start pending
//Check if all services are started if so, update state
synchronized (mProfileServicesState) {
@@ -387,6 +389,59 @@ public class AdapterService extends Service {
}
}
+ private void updateInteropDatabase() {
+ interopDatabaseClearNative();
+
+ String interop_string = Settings.Global.getString(getContentResolver(),
+ Settings.Global.BLUETOOTH_INTEROPERABILITY_LIST);
+ if (interop_string == null) return;
+ Log.d(TAG, "updateInteropDatabase: [" + interop_string + "]");
+
+ String[] entries = interop_string.split(";");
+ for (String entry : entries) {
+ String[] tokens = entry.split(",");
+ if (tokens.length != 2) continue;
+
+ // Get feature
+ int feature = 0;
+ try {
+ feature = Integer.parseInt(tokens[1]);
+ } catch (NumberFormatException e) {
+ Log.e(TAG, "updateInteropDatabase: Invalid feature '" + tokens[1] + "'");
+ continue;
+ }
+
+ // Get address bytes and length
+ int length = (tokens[0].length() + 1) / 3;
+ if (length < 1 || length > 6) {
+ Log.e(TAG, "updateInteropDatabase: Malformed address string '" + tokens[0] + "'");
+ continue;
+ }
+
+ byte[] addr = new byte[6];
+ int offset = 0;
+ for (int i = 0; i < tokens[0].length(); ) {
+ if (tokens[0].charAt(i) == ':') {
+ i += 1;
+ } else {
+ try {
+ addr[offset++] = (byte) Integer.parseInt(tokens[0].substring(i, i + 2), 16);
+ } catch (NumberFormatException e) {
+ offset = 0;
+ break;
+ }
+ i += 2;
+ }
+ }
+
+ // Check if address was parsed ok, otherwise, move on...
+ if (offset == 0) continue;
+
+ // Add entry
+ interopDatabaseAddNative(feature, addr, length);
+ }
+ }
+
@Override
public void onCreate() {
super.onCreate();
@@ -2147,6 +2202,9 @@ public class AdapterService extends Service {
private native void alarmFiredNative();
private native void dumpNative(FileDescriptor fd);
+ private native void interopDatabaseClearNative();
+ private native void interopDatabaseAddNative(int feature, byte[] address, int length);
+
protected void finalize() {
cleanup();
if (TRACE_REF) {