Loading android/app/res/values/config.xml +2 −0 Original line number Diff line number Diff line Loading @@ -41,4 +41,6 @@ <integer name="gatt_high_priority_max_interval">12</integer> <integer name="gatt_low_power_min_interval">80</integer> <integer name="gatt_low_power_max_interval">100</integer> <bool name="headset_client_initial_audio_route_allowed">true</bool> </resources> android/app/src/com/android/bluetooth/hfpclient/HeadsetClientService.java +26 −0 Original line number Diff line number Diff line Loading @@ -252,6 +252,24 @@ public class HeadsetClientService extends ProfileService { return service.getAudioState(device); } @Override public void setAudioRouteAllowed(boolean allowed) { HeadsetClientService service = getService(); if (service != null) { service.setAudioRouteAllowed(allowed); } } @Override public boolean getAudioRouteAllowed() { HeadsetClientService service = getService(); if (service != null) { return service.getAudioRouteAllowed(); } return false; } @Override public boolean connectAudio() { HeadsetClientService service = getService(); Loading Loading @@ -543,6 +561,14 @@ public class HeadsetClientService extends ProfileService { return mStateMachine.getAudioState(device); } public void setAudioRouteAllowed(boolean allowed) { mStateMachine.setAudioRouteAllowed(allowed); } public boolean getAudioRouteAllowed() { return mStateMachine.getAudioRouteAllowed(); } boolean connectAudio() { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (!mStateMachine.isConnected()) { Loading android/app/src/com/android/bluetooth/hfpclient/HeadsetClientStateMachine.java +20 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,8 @@ import java.util.List; import java.util.Queue; import java.util.Set; import com.android.bluetooth.R; final class HeadsetClientStateMachine extends StateMachine { private static final String TAG = "HeadsetClientStateMachine"; private static final boolean DBG = false; Loading Loading @@ -142,6 +144,8 @@ final class HeadsetClientStateMachine extends StateMachine { private final AudioManager mAudioManager; private int mAudioState; // Indicates whether audio can be routed to the device. private boolean mAudioRouteAllowed; private boolean mAudioWbs; private final BluetoothAdapter mAdapter; private boolean mNativeAvailable; Loading Loading @@ -1210,6 +1214,9 @@ final class HeadsetClientStateMachine extends StateMachine { mAudioState = BluetoothHeadsetClient.STATE_AUDIO_DISCONNECTED; mAudioWbs = false; mAudioRouteAllowed = context.getResources().getBoolean( R.bool.headset_client_initial_audio_route_allowed); mIndicatorNetworkState = HeadsetClientHalConstants.NETWORK_STATE_NOT_AVAILABLE; mIndicatorNetworkType = HeadsetClientHalConstants.SERVICE_TYPE_HOME; mIndicatorNetworkSignal = 0; Loading Loading @@ -2016,6 +2023,11 @@ final class HeadsetClientStateMachine extends StateMachine { mAudioWbs = true; // fall through case HeadsetClientHalConstants.AUDIO_STATE_CONNECTED: if (!mAudioRouteAllowed) { sendMessage(HeadsetClientStateMachine.DISCONNECT_AUDIO); break; } mAudioState = BluetoothHeadsetClient.STATE_AUDIO_CONNECTED; // request audio focus for call int newAudioMode = AudioManager.MODE_IN_CALL; Loading Loading @@ -2365,6 +2377,14 @@ final class HeadsetClientStateMachine extends StateMachine { return (getCurrentState() == mAudioOn); } public void setAudioRouteAllowed(boolean allowed) { mAudioRouteAllowed = allowed; } public boolean getAudioRouteAllowed() { return mAudioRouteAllowed; } synchronized int getAudioState(BluetoothDevice device) { if (mCurrentDevice == null || !mCurrentDevice.equals(device)) { return BluetoothHeadsetClient.STATE_AUDIO_DISCONNECTED; Loading Loading
android/app/res/values/config.xml +2 −0 Original line number Diff line number Diff line Loading @@ -41,4 +41,6 @@ <integer name="gatt_high_priority_max_interval">12</integer> <integer name="gatt_low_power_min_interval">80</integer> <integer name="gatt_low_power_max_interval">100</integer> <bool name="headset_client_initial_audio_route_allowed">true</bool> </resources>
android/app/src/com/android/bluetooth/hfpclient/HeadsetClientService.java +26 −0 Original line number Diff line number Diff line Loading @@ -252,6 +252,24 @@ public class HeadsetClientService extends ProfileService { return service.getAudioState(device); } @Override public void setAudioRouteAllowed(boolean allowed) { HeadsetClientService service = getService(); if (service != null) { service.setAudioRouteAllowed(allowed); } } @Override public boolean getAudioRouteAllowed() { HeadsetClientService service = getService(); if (service != null) { return service.getAudioRouteAllowed(); } return false; } @Override public boolean connectAudio() { HeadsetClientService service = getService(); Loading Loading @@ -543,6 +561,14 @@ public class HeadsetClientService extends ProfileService { return mStateMachine.getAudioState(device); } public void setAudioRouteAllowed(boolean allowed) { mStateMachine.setAudioRouteAllowed(allowed); } public boolean getAudioRouteAllowed() { return mStateMachine.getAudioRouteAllowed(); } boolean connectAudio() { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (!mStateMachine.isConnected()) { Loading
android/app/src/com/android/bluetooth/hfpclient/HeadsetClientStateMachine.java +20 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,8 @@ import java.util.List; import java.util.Queue; import java.util.Set; import com.android.bluetooth.R; final class HeadsetClientStateMachine extends StateMachine { private static final String TAG = "HeadsetClientStateMachine"; private static final boolean DBG = false; Loading Loading @@ -142,6 +144,8 @@ final class HeadsetClientStateMachine extends StateMachine { private final AudioManager mAudioManager; private int mAudioState; // Indicates whether audio can be routed to the device. private boolean mAudioRouteAllowed; private boolean mAudioWbs; private final BluetoothAdapter mAdapter; private boolean mNativeAvailable; Loading Loading @@ -1210,6 +1214,9 @@ final class HeadsetClientStateMachine extends StateMachine { mAudioState = BluetoothHeadsetClient.STATE_AUDIO_DISCONNECTED; mAudioWbs = false; mAudioRouteAllowed = context.getResources().getBoolean( R.bool.headset_client_initial_audio_route_allowed); mIndicatorNetworkState = HeadsetClientHalConstants.NETWORK_STATE_NOT_AVAILABLE; mIndicatorNetworkType = HeadsetClientHalConstants.SERVICE_TYPE_HOME; mIndicatorNetworkSignal = 0; Loading Loading @@ -2016,6 +2023,11 @@ final class HeadsetClientStateMachine extends StateMachine { mAudioWbs = true; // fall through case HeadsetClientHalConstants.AUDIO_STATE_CONNECTED: if (!mAudioRouteAllowed) { sendMessage(HeadsetClientStateMachine.DISCONNECT_AUDIO); break; } mAudioState = BluetoothHeadsetClient.STATE_AUDIO_CONNECTED; // request audio focus for call int newAudioMode = AudioManager.MODE_IN_CALL; Loading Loading @@ -2365,6 +2377,14 @@ final class HeadsetClientStateMachine extends StateMachine { return (getCurrentState() == mAudioOn); } public void setAudioRouteAllowed(boolean allowed) { mAudioRouteAllowed = allowed; } public boolean getAudioRouteAllowed() { return mAudioRouteAllowed; } synchronized int getAudioState(BluetoothDevice device) { if (mCurrentDevice == null || !mCurrentDevice.equals(device)) { return BluetoothHeadsetClient.STATE_AUDIO_DISCONNECTED; Loading