Loading android/app/Android.bp +0 −2 Original line number Diff line number Diff line Loading @@ -75,7 +75,6 @@ android_app { srcs: [ "src/**/*.java", ":statslog-bluetooth-java-gen", ":libbluetooth-binder-aidl", ], platform_apis: true, certificate: "platform", Loading @@ -84,7 +83,6 @@ android_app { libs: [ "javax.obex", "services.net", "unsupportedappusage", ], static_libs: [ "com.android.vcard", Loading android/app/src/com/android/bluetooth/a2dpsink/A2dpSinkService.java +17 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import com.android.internal.annotations.VisibleForTesting; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; Loading Loading @@ -362,7 +363,11 @@ public class A2dpSinkService extends ProfileService { mDeviceStateMap.remove(stateMachine.getDevice()); } @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public List<BluetoothDevice> getConnectedDevices() { if (!Utils.checkConnectPermissionForPreflight(this)) { return Collections.emptyList(); } return getDevicesMatchingConnectionStates(new int[]{BluetoothAdapter.STATE_CONNECTED}); } Loading @@ -379,8 +384,12 @@ public class A2dpSinkService extends ProfileService { return existingStateMachine; } @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) { if (DBG) Log.d(TAG, "getDevicesMatchingConnectionStates" + Arrays.toString(states)); if (!Utils.checkConnectPermissionForPreflight(this)) { return Collections.emptyList(); } List<BluetoothDevice> deviceList = new ArrayList<>(); BluetoothDevice[] bondedDevices = mAdapterService.getBondedDevices(); int connectionState; Loading @@ -407,7 +416,11 @@ public class A2dpSinkService extends ProfileService { * {@link BluetoothProfile#STATE_CONNECTED} if this profile is connected, or * {@link BluetoothProfile#STATE_DISCONNECTING} if this profile is being disconnected */ @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public int getConnectionState(BluetoothDevice device) { if (!Utils.checkConnectPermissionForPreflight(this)) { return BluetoothProfile.STATE_DISCONNECTED; } A2dpSinkStateMachine stateMachine = mDeviceStateMap.get(device); return (stateMachine == null) ? BluetoothProfile.STATE_DISCONNECTED : stateMachine.getState(); Loading Loading @@ -479,7 +492,11 @@ public class A2dpSinkService extends ProfileService { } } @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) BluetoothAudioConfig getAudioConfig(BluetoothDevice device) { if (!Utils.checkConnectPermissionForPreflight(this)) { return null; } A2dpSinkStateMachine stateMachine = mDeviceStateMap.get(device); // a state machine instance doesn't exist. maybe it is already gone? if (stateMachine == null) { Loading android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerService.java +23 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.bluetooth.avrcpcontroller; import android.annotation.RequiresPermission; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAvrcpPlayerSettings; import android.bluetooth.BluetoothDevice; Loading @@ -33,6 +34,7 @@ import com.android.bluetooth.btservice.ProfileService; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; Loading Loading @@ -373,18 +375,27 @@ public class AvrcpControllerService extends ProfileService { @Override public void sendGroupNavigationCmd(BluetoothDevice device, int keyCode, int keyState) { Log.w(TAG, "sendGroupNavigationCmd not implemented"); if (!Utils.checkConnectPermissionForPreflight(getService())) { return; } return; } @Override public boolean setPlayerApplicationSetting(BluetoothAvrcpPlayerSettings settings) { Log.w(TAG, "setPlayerApplicationSetting not implemented"); if (!Utils.checkConnectPermissionForPreflight(getService())) { return false; } return false; } @Override public BluetoothAvrcpPlayerSettings getPlayerSettings(BluetoothDevice device) { Log.w(TAG, "getPlayerSettings not implemented"); if (!Utils.checkConnectPermissionForPreflight(getService())) { return null; } return null; } } Loading Loading @@ -812,7 +823,11 @@ public class AvrcpControllerService extends ProfileService { mDeviceStateMap.remove(stateMachine.getDevice()); } @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public List<BluetoothDevice> getConnectedDevices() { if (!Utils.checkConnectPermissionForPreflight(this)) { return Collections.emptyList(); } return getDevicesMatchingConnectionStates(new int[]{BluetoothAdapter.STATE_CONNECTED}); } Loading @@ -837,8 +852,12 @@ public class AvrcpControllerService extends ProfileService { return mCoverArtManager; } @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) { if (DBG) Log.d(TAG, "getDevicesMatchingConnectionStates" + Arrays.toString(states)); if (!Utils.checkConnectPermissionForPreflight(this)) { return Collections.emptyList(); } List<BluetoothDevice> deviceList = new ArrayList<>(); Set<BluetoothDevice> bondedDevices = mAdapter.getBondedDevices(); int connectionState; Loading @@ -856,7 +875,11 @@ public class AvrcpControllerService extends ProfileService { return deviceList; } @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) synchronized int getConnectionState(BluetoothDevice device) { if (!Utils.checkConnectPermissionForPreflight(this)) { return BluetoothProfile.STATE_DISCONNECTED; } AvrcpControllerStateMachine stateMachine = mDeviceStateMap.get(device); return (stateMachine == null) ? BluetoothProfile.STATE_DISCONNECTED : stateMachine.getState(); Loading android/app/src/com/android/bluetooth/hearingaid/HearingAidService.java +8 −0 Original line number Diff line number Diff line Loading @@ -546,7 +546,11 @@ public class HearingAidService extends ProfileService { .getProfileConnectionPolicy(device, BluetoothProfile.HEARING_AID); } @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) void setVolume(int volume) { if (!Utils.checkConnectPermissionForPreflight(this)) { return; } mHearingAidNativeInterface.setVolume(volume); } Loading @@ -560,7 +564,11 @@ public class HearingAidService extends ProfileService { return mDeviceHiSyncIdMap.getOrDefault(device, BluetoothHearingAid.HI_SYNC_ID_INVALID); } @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) int getCapabilities(BluetoothDevice device) { if (!Utils.checkConnectPermissionForPreflight(this)) { return -1; } return mDeviceCapabilitiesMap.getOrDefault(device, -1); } Loading android/app/src/com/android/bluetooth/hfpclient/HeadsetClientService.java +14 −0 Original line number Diff line number Diff line Loading @@ -340,11 +340,17 @@ public class HeadsetClientService extends ProfileService { @Override public void setAudioRouteAllowed(BluetoothDevice device, boolean allowed) { Log.e(TAG, "setAudioRouteAllowed API not supported"); if (!Utils.checkConnectPermissionForPreflight(getService())) { return; } } @Override public boolean getAudioRouteAllowed(BluetoothDevice device) { Log.e(TAG, "getAudioRouteAllowed API not supported"); if (!Utils.checkConnectPermissionForPreflight(getService())) { return false; } return false; } Loading Loading @@ -705,7 +711,11 @@ public class HeadsetClientService extends ProfileService { return true; } @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) int getAudioState(BluetoothDevice device) { if (!Utils.checkConnectPermissionForPreflight(this)) { return -1; } HeadsetClientStateMachine sm = getStateMachine(device); if (sm == null) { Log.e(TAG, "Cannot allocate SM for device " + device); Loading Loading @@ -933,7 +943,11 @@ public class HeadsetClientService extends ProfileService { return true; } @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean getLastVoiceTagNumber(BluetoothDevice device) { if (!Utils.checkConnectPermissionForPreflight(this)) { return false; } return false; } Loading Loading
android/app/Android.bp +0 −2 Original line number Diff line number Diff line Loading @@ -75,7 +75,6 @@ android_app { srcs: [ "src/**/*.java", ":statslog-bluetooth-java-gen", ":libbluetooth-binder-aidl", ], platform_apis: true, certificate: "platform", Loading @@ -84,7 +83,6 @@ android_app { libs: [ "javax.obex", "services.net", "unsupportedappusage", ], static_libs: [ "com.android.vcard", Loading
android/app/src/com/android/bluetooth/a2dpsink/A2dpSinkService.java +17 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import com.android.internal.annotations.VisibleForTesting; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; Loading Loading @@ -362,7 +363,11 @@ public class A2dpSinkService extends ProfileService { mDeviceStateMap.remove(stateMachine.getDevice()); } @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public List<BluetoothDevice> getConnectedDevices() { if (!Utils.checkConnectPermissionForPreflight(this)) { return Collections.emptyList(); } return getDevicesMatchingConnectionStates(new int[]{BluetoothAdapter.STATE_CONNECTED}); } Loading @@ -379,8 +384,12 @@ public class A2dpSinkService extends ProfileService { return existingStateMachine; } @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) { if (DBG) Log.d(TAG, "getDevicesMatchingConnectionStates" + Arrays.toString(states)); if (!Utils.checkConnectPermissionForPreflight(this)) { return Collections.emptyList(); } List<BluetoothDevice> deviceList = new ArrayList<>(); BluetoothDevice[] bondedDevices = mAdapterService.getBondedDevices(); int connectionState; Loading @@ -407,7 +416,11 @@ public class A2dpSinkService extends ProfileService { * {@link BluetoothProfile#STATE_CONNECTED} if this profile is connected, or * {@link BluetoothProfile#STATE_DISCONNECTING} if this profile is being disconnected */ @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public int getConnectionState(BluetoothDevice device) { if (!Utils.checkConnectPermissionForPreflight(this)) { return BluetoothProfile.STATE_DISCONNECTED; } A2dpSinkStateMachine stateMachine = mDeviceStateMap.get(device); return (stateMachine == null) ? BluetoothProfile.STATE_DISCONNECTED : stateMachine.getState(); Loading Loading @@ -479,7 +492,11 @@ public class A2dpSinkService extends ProfileService { } } @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) BluetoothAudioConfig getAudioConfig(BluetoothDevice device) { if (!Utils.checkConnectPermissionForPreflight(this)) { return null; } A2dpSinkStateMachine stateMachine = mDeviceStateMap.get(device); // a state machine instance doesn't exist. maybe it is already gone? if (stateMachine == null) { Loading
android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerService.java +23 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.bluetooth.avrcpcontroller; import android.annotation.RequiresPermission; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAvrcpPlayerSettings; import android.bluetooth.BluetoothDevice; Loading @@ -33,6 +34,7 @@ import com.android.bluetooth.btservice.ProfileService; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; Loading Loading @@ -373,18 +375,27 @@ public class AvrcpControllerService extends ProfileService { @Override public void sendGroupNavigationCmd(BluetoothDevice device, int keyCode, int keyState) { Log.w(TAG, "sendGroupNavigationCmd not implemented"); if (!Utils.checkConnectPermissionForPreflight(getService())) { return; } return; } @Override public boolean setPlayerApplicationSetting(BluetoothAvrcpPlayerSettings settings) { Log.w(TAG, "setPlayerApplicationSetting not implemented"); if (!Utils.checkConnectPermissionForPreflight(getService())) { return false; } return false; } @Override public BluetoothAvrcpPlayerSettings getPlayerSettings(BluetoothDevice device) { Log.w(TAG, "getPlayerSettings not implemented"); if (!Utils.checkConnectPermissionForPreflight(getService())) { return null; } return null; } } Loading Loading @@ -812,7 +823,11 @@ public class AvrcpControllerService extends ProfileService { mDeviceStateMap.remove(stateMachine.getDevice()); } @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public List<BluetoothDevice> getConnectedDevices() { if (!Utils.checkConnectPermissionForPreflight(this)) { return Collections.emptyList(); } return getDevicesMatchingConnectionStates(new int[]{BluetoothAdapter.STATE_CONNECTED}); } Loading @@ -837,8 +852,12 @@ public class AvrcpControllerService extends ProfileService { return mCoverArtManager; } @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) { if (DBG) Log.d(TAG, "getDevicesMatchingConnectionStates" + Arrays.toString(states)); if (!Utils.checkConnectPermissionForPreflight(this)) { return Collections.emptyList(); } List<BluetoothDevice> deviceList = new ArrayList<>(); Set<BluetoothDevice> bondedDevices = mAdapter.getBondedDevices(); int connectionState; Loading @@ -856,7 +875,11 @@ public class AvrcpControllerService extends ProfileService { return deviceList; } @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) synchronized int getConnectionState(BluetoothDevice device) { if (!Utils.checkConnectPermissionForPreflight(this)) { return BluetoothProfile.STATE_DISCONNECTED; } AvrcpControllerStateMachine stateMachine = mDeviceStateMap.get(device); return (stateMachine == null) ? BluetoothProfile.STATE_DISCONNECTED : stateMachine.getState(); Loading
android/app/src/com/android/bluetooth/hearingaid/HearingAidService.java +8 −0 Original line number Diff line number Diff line Loading @@ -546,7 +546,11 @@ public class HearingAidService extends ProfileService { .getProfileConnectionPolicy(device, BluetoothProfile.HEARING_AID); } @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) void setVolume(int volume) { if (!Utils.checkConnectPermissionForPreflight(this)) { return; } mHearingAidNativeInterface.setVolume(volume); } Loading @@ -560,7 +564,11 @@ public class HearingAidService extends ProfileService { return mDeviceHiSyncIdMap.getOrDefault(device, BluetoothHearingAid.HI_SYNC_ID_INVALID); } @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) int getCapabilities(BluetoothDevice device) { if (!Utils.checkConnectPermissionForPreflight(this)) { return -1; } return mDeviceCapabilitiesMap.getOrDefault(device, -1); } Loading
android/app/src/com/android/bluetooth/hfpclient/HeadsetClientService.java +14 −0 Original line number Diff line number Diff line Loading @@ -340,11 +340,17 @@ public class HeadsetClientService extends ProfileService { @Override public void setAudioRouteAllowed(BluetoothDevice device, boolean allowed) { Log.e(TAG, "setAudioRouteAllowed API not supported"); if (!Utils.checkConnectPermissionForPreflight(getService())) { return; } } @Override public boolean getAudioRouteAllowed(BluetoothDevice device) { Log.e(TAG, "getAudioRouteAllowed API not supported"); if (!Utils.checkConnectPermissionForPreflight(getService())) { return false; } return false; } Loading Loading @@ -705,7 +711,11 @@ public class HeadsetClientService extends ProfileService { return true; } @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) int getAudioState(BluetoothDevice device) { if (!Utils.checkConnectPermissionForPreflight(this)) { return -1; } HeadsetClientStateMachine sm = getStateMachine(device); if (sm == null) { Log.e(TAG, "Cannot allocate SM for device " + device); Loading Loading @@ -933,7 +943,11 @@ public class HeadsetClientService extends ProfileService { return true; } @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean getLastVoiceTagNumber(BluetoothDevice device) { if (!Utils.checkConnectPermissionForPreflight(this)) { return false; } return false; } Loading