author | Kuibao Zhang <kuibao.zhang@amlogic.com> | 2017-11-01 13:08:04 (GMT) |
---|---|---|
committer | Kuibao Zhang <kuibao.zhang@amlogic.com> | 2017-11-06 04:09:46 (GMT) |
commit | dd53f441c67e723e4187053383489942793af957 (patch) | |
tree | b7e841e7293726c4c5cb128f81e40900eaf5c8ed | |
parent | af58a906e0f479a81a798103aaf54a174a183936 (diff) | |
download | frameworks-dd53f441c67e723e4187053383489942793af957.zip frameworks-dd53f441c67e723e4187053383489942793af957.tar.gz frameworks-dd53f441c67e723e4187053383489942793af957.tar.bz2 |
BT: android o add remote audio[3/3]
PD#150889
1.set device connectstate
Change-Id: I5a0333fd6d0de20b45c0b9710f29ed11dda01e73
-rw-r--r-- | core/res/src/com/droidlogic/BootComplete.java | 4 | ||||
-rw-r--r-- | core/res/src/com/droidlogic/DialogBluetoothService.java | 11 |
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); |