summaryrefslogtreecommitdiff
authorTellen Yu <tellen.yu@amlogic.com>2017-11-06 07:13:11 (GMT)
committer Gerrit Code Review <gituser@scgit.amlogic.com>2017-11-06 07:13:11 (GMT)
commitc565959f8678df799a66e4d5891a09744b4817c3 (patch)
treed98b254e69439c9dc3ce5ff7f09e6a232d4c6806
parent852e44b279edcbf7e0aa14c28853172e47bceaeb (diff)
parentdd53f441c67e723e4187053383489942793af957 (diff)
downloadframeworks-c565959f8678df799a66e4d5891a09744b4817c3.zip
frameworks-c565959f8678df799a66e4d5891a09744b4817c3.tar.gz
frameworks-c565959f8678df799a66e4d5891a09744b4817c3.tar.bz2
Merge "BT: android o add remote audio[3/3]" into o-amlogic
Diffstat
-rw-r--r--core/res/src/com/droidlogic/BootComplete.java4
-rw-r--r--core/res/src/com/droidlogic/DialogBluetoothService.java11
2 files changed, 13 insertions, 2 deletions
diff --git a/core/res/src/com/droidlogic/BootComplete.java b/core/res/src/com/droidlogic/BootComplete.java
index fe5b9ea..0b69527 100644
--- a/core/res/src/com/droidlogic/BootComplete.java
+++ b/core/res/src/com/droidlogic/BootComplete.java
@@ -151,8 +151,8 @@ public class BootComplete extends BroadcastReceiver {
if (sm.getPropertyBoolean("ro.platform.has.tvuimode", false))
context.startService(new Intent(context, EsmService.class));
- //Intent gattServiceIntent = new Intent(context, DialogBluetoothService.class);
- //context.startService(gattServiceIntent);
+ Intent gattServiceIntent = new Intent(context, DialogBluetoothService.class);
+ context.startService(gattServiceIntent);
String rotProp = sm.getPropertyString("persist.sys.app.rotation", "");
ContentResolver res = context.getContentResolver();
diff --git a/core/res/src/com/droidlogic/DialogBluetoothService.java b/core/res/src/com/droidlogic/DialogBluetoothService.java
index 8817679..486d09a 100644
--- a/core/res/src/com/droidlogic/DialogBluetoothService.java
+++ b/core/res/src/com/droidlogic/DialogBluetoothService.java
@@ -57,6 +57,8 @@ import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentLinkedQueue;
+import android.media.AudioManager;
+
/**
* Service for managing connection and data communication with a GATT server hosted on a
@@ -130,6 +132,7 @@ public class DialogBluetoothService extends Service {
private BluetoothGattCharacteristic rep6Characteristic = null;
private BluetoothGattCharacteristic rep7Characteristic = null;
private int prevInstance = 0; // for checking audio data notifications sequence
+ private AudioManager mAudioManager;
/**
@@ -148,6 +151,9 @@ public class DialogBluetoothService extends Service {
final String action = intent.getAction();
final BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+ String macAddress = device.getAddress();
+ String deviceName = device.getName();
+ int connectedState;
if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)) {
Log.i(TAG, ">ACL LINK CONNECTED ["+device.getName()+"] - checking for supported devices after delay");
if (isRemoteAudioCapable(device)) {
@@ -156,6 +162,8 @@ public class DialogBluetoothService extends Service {
mHandler.postDelayed(mConnRunnable, CONNECTION_DELAY_MS);
// waiting some time to not overload BLE device with requests
}
+ connectedState = 1;
+ mAudioManager.setWiredDeviceConnectionState(AudioManager.DEVICE_IN_WIRED_HEADSET, connectedState, macAddress, deviceName);
}
else if (BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED.equals(action)) {
Log.i(TAG, ">ACL LINK DISCONNECT REQUEST ["+device.getName()+"]");
@@ -165,6 +173,8 @@ public class DialogBluetoothService extends Service {
pending.remove(device);
if (pending.isEmpty())
mHandler.removeCallbacks(mConnRunnable);
+ connectedState = 0;
+ mAudioManager.setWiredDeviceConnectionState(AudioManager.DEVICE_IN_WIRED_HEADSET, connectedState, macAddress, deviceName);
}
else if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) {
int bondStateNow = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_NONE);
@@ -261,6 +271,7 @@ public class DialogBluetoothService extends Service {
mHandler = new Handler();
initializeBTManager();
+ mAudioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
IntentFilter filter = new IntentFilter();
filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);