Loading android/app/src/com/android/bluetooth/a2dpsink/A2dpSinkService.java +4 −2 Original line number Diff line number Diff line Loading @@ -523,7 +523,8 @@ public class A2dpSinkService extends ProfileService { public native void informAudioTrackGainNative(float gain); private void onConnectionStateChanged(byte[] address, int state) { StackEvent event = StackEvent.connectionStateChanged(getAnonymousDevice(address), state); StackEvent event = StackEvent.connectionStateChanged( BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address), state); A2dpSinkStateMachine stateMachine = getOrCreateStateMachine(event.mDevice); stateMachine.sendMessage(A2dpSinkStateMachine.STACK_EVENT, event); } Loading @@ -545,7 +546,8 @@ public class A2dpSinkService extends ProfileService { } private void onAudioConfigChanged(byte[] address, int sampleRate, int channelCount) { StackEvent event = StackEvent.audioConfigChanged(getAnonymousDevice(address), sampleRate, StackEvent event = StackEvent.audioConfigChanged( BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address), sampleRate, channelCount); A2dpSinkStateMachine stateMachine = getOrCreateStateMachine(event.mDevice); stateMachine.sendMessage(A2dpSinkStateMachine.STACK_EVENT, event); Loading android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerService.java +20 −20 Original line number Diff line number Diff line Loading @@ -445,7 +445,7 @@ public class AvrcpControllerService extends ProfileService { // Called by JNI when a device has connected or disconnected. private synchronized void onConnectionStateChanged(boolean remoteControlConnected, boolean browsingConnected, byte[] address) { BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); if (DBG) { Log.d(TAG, "onConnectionStateChanged " + remoteControlConnected + " " + browsingConnected + device); Loading Loading @@ -479,7 +479,7 @@ public class AvrcpControllerService extends ProfileService { // Called by JNI to notify Avrcp of a remote device's Cover Art PSM private void getRcPsm(byte[] address, int psm) { BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); if (DBG) Log.d(TAG, "getRcPsm(device=" + device + ", psm=" + psm + ")"); AvrcpControllerStateMachine stateMachine = getOrCreateStateMachine(device); if (stateMachine != null) { Loading @@ -498,7 +498,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "handleRegisterNotificationAbsVol"); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { stateMachine.sendMessage( Loading @@ -511,7 +511,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "handleSetAbsVolume "); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { stateMachine.sendMessage(AvrcpControllerStateMachine.MESSAGE_PROCESS_SET_ABS_VOL_CMD, Loading @@ -526,7 +526,7 @@ public class AvrcpControllerService extends ProfileService { Log.d(TAG, "onTrackChanged"); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { AvrcpItem.Builder aib = new AvrcpItem.Builder(); Loading @@ -552,7 +552,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "onPlayPositionChanged pos " + currSongPosition); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { stateMachine.sendMessage( Loading @@ -566,7 +566,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "onPlayStatusChanged " + playStatus); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { stateMachine.sendMessage( Loading @@ -581,7 +581,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "handlePlayerAppSetting rspLen = " + rspLen); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { PlayerApplicationSettings supportedSettings = Loading @@ -597,7 +597,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "onPlayerAppSettingChanged "); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { Loading @@ -613,7 +613,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG," onAvailablePlayerChanged"); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { Loading @@ -628,7 +628,7 @@ public class AvrcpControllerService extends ProfileService { + items.length + " items."); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); List<AvrcpItem> itemsList = new ArrayList<>(); for (AvrcpItem item : items) { if (VDBG) Log.d(TAG, item.toString()); Loading Loading @@ -659,7 +659,7 @@ public class AvrcpControllerService extends ProfileService { itemsList.add(item); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { stateMachine.sendMessage(AvrcpControllerStateMachine.MESSAGE_PROCESS_GET_PLAYER_ITEMS, Loading @@ -675,7 +675,7 @@ public class AvrcpControllerService extends ProfileService { + " attrids: " + attrIds + " attrVals: " + attrVals); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpItem.Builder aib = new AvrcpItem.Builder().fromAvrcpAttributeArray(attrIds, attrVals); aib.setDevice(device); aib.setItemType(AvrcpItem.TYPE_MEDIA); Loading @@ -694,7 +694,7 @@ public class AvrcpControllerService extends ProfileService { + name + " playable " + playable); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpItem.Builder aib = new AvrcpItem.Builder(); aib.setDevice(device); aib.setItemType(AvrcpItem.TYPE_FOLDER); Loading @@ -715,7 +715,7 @@ public class AvrcpControllerService extends ProfileService { + transportFlags + " play status " + playStatus + " player type " + playerType); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpPlayer.Builder apb = new AvrcpPlayer.Builder(); apb.setDevice(device); apb.setPlayerId(id); Loading @@ -730,7 +730,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "handleChangeFolderRsp count: " + count); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { stateMachine.sendMessage(AvrcpControllerStateMachine.MESSAGE_PROCESS_FOLDER_PATH, Loading @@ -742,7 +742,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "handleSetBrowsedPlayerRsp depth: " + depth); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { Loading @@ -755,7 +755,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "handleSetAddressedPlayerRsp status: " + status); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { Loading @@ -768,7 +768,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "handleAddressedPlayerChanged id: " + id); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { Loading @@ -781,7 +781,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "handleNowPlayingContentChanged"); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { Loading android/app/src/com/android/bluetooth/btservice/ProfileService.java +0 −27 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.annotation.SuppressLint; import android.app.ActivityManager; import android.app.Service; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading Loading @@ -336,30 +335,4 @@ public abstract class ProfileService extends Service { } stopSelf(); } /** * Returns a {@link BluetoothDevice} instance for the given address, but * with any {@link AttributionSource} details removed, making it "anonymous" * and not suitable for local use within this process. * <p> * The returned object is intended to be returned to a remote caller for * actual use, where {@link Attributable#setAttributionSource} will populate * it accurately. */ protected BluetoothDevice getAnonymousDevice(String address) { return BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); } /** * Returns a {@link BluetoothDevice} instance for the given address, but * with any {@link AttributionSource} details removed, making it "anonymous" * and not suitable for local use within this process. * <p> * The returned object is intended to be returned to a remote caller for * actual use, where {@link Attributable#setAttributionSource} will populate * it accurately. */ protected BluetoothDevice getAnonymousDevice(byte[] address) { return BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); } } android/app/src/com/android/bluetooth/gatt/GattService.java +6 −5 Original line number Diff line number Diff line Loading @@ -1175,7 +1175,7 @@ public class GattService extends ProfileService { continue; } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); ScanSettings settings = client.settings; byte[] scanRecordData; Loading Loading @@ -1971,7 +1971,7 @@ public class GattService extends ProfileService { extractBytes(batchRecord, i * TRUNCATED_RESULT_SIZE, TRUNCATED_RESULT_SIZE); byte[] address = extractBytes(record, 0, 6); reverse(address); BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); int rssi = record[8]; long timestampNanos = now - parseTimestampNanos(extractBytes(record, 9, 2)); results.add(new ScanResult(device, ScanRecord.parseFromBytes(new byte[0]), rssi, Loading @@ -1998,7 +1998,7 @@ public class GattService extends ProfileService { byte[] address = extractBytes(batchRecord, position, 6); // TODO: remove temp hack. reverse(address); BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); position += 6; // Skip address type. position++; Loading Loading @@ -2076,7 +2076,8 @@ public class GattService extends ProfileService { return; } BluetoothDevice device = getAnonymousDevice(trackingInfo.getAddress()); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter() .getRemoteDevice(trackingInfo.getAddress()); int advertiserState = trackingInfo.getAdvState(); ScanResult result = new ScanResult(device, ScanRecord.parseFromBytes(trackingInfo.getResult()), Loading Loading @@ -2208,7 +2209,7 @@ public class GattService extends ProfileService { connectedDevices.addAll(mServerMap.getConnectedDevices()); for (String address : connectedDevices) { BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); if (device != null) { deviceStates.put(device, BluetoothProfile.STATE_CONNECTED); } Loading android/app/src/com/android/bluetooth/hid/HidHostService.java +13 −6 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static android.Manifest.permission.BLUETOOTH_CONNECT; import static com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission; import android.annotation.RequiresPermission; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothHidHost; import android.bluetooth.BluetoothProfile; Loading Loading @@ -177,7 +178,8 @@ public class HidHostService extends ProfileService { } break; case MESSAGE_CONNECT_STATE_CHANGED: { BluetoothDevice device = getAnonymousDevice((byte[]) msg.obj); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter() .getRemoteDevice((byte[]) msg.obj); int halState = msg.arg1; Integer prevStateInteger = mInputDevices.get(device); int prevState = Loading Loading @@ -216,7 +218,8 @@ public class HidHostService extends ProfileService { break; case MESSAGE_ON_GET_PROTOCOL_MODE: { BluetoothDevice device = getAnonymousDevice((byte[]) msg.obj); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter() .getRemoteDevice((byte[]) msg.obj); int protocolMode = msg.arg1; broadcastProtocolMode(device, protocolMode); } Loading Loading @@ -250,7 +253,8 @@ public class HidHostService extends ProfileService { } break; case MESSAGE_ON_GET_REPORT: { BluetoothDevice device = getAnonymousDevice((byte[]) msg.obj); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter() .getRemoteDevice((byte[]) msg.obj); Bundle data = msg.getData(); byte[] report = data.getByteArray(BluetoothHidHost.EXTRA_REPORT); int bufferSize = data.getInt(BluetoothHidHost.EXTRA_REPORT_BUFFER_SIZE); Loading @@ -258,7 +262,8 @@ public class HidHostService extends ProfileService { } break; case MESSAGE_ON_HANDSHAKE: { BluetoothDevice device = getAnonymousDevice((byte[]) msg.obj); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter() .getRemoteDevice((byte[]) msg.obj); int status = msg.arg1; broadcastHandshake(device, status); } Loading @@ -274,7 +279,8 @@ public class HidHostService extends ProfileService { } break; case MESSAGE_ON_VIRTUAL_UNPLUG: { BluetoothDevice device = getAnonymousDevice((byte[]) msg.obj); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter() .getRemoteDevice((byte[]) msg.obj); int status = msg.arg1; broadcastVirtualUnplugStatus(device, status); } Loading @@ -287,7 +293,8 @@ public class HidHostService extends ProfileService { } break; case MESSAGE_ON_GET_IDLE_TIME: { BluetoothDevice device = getAnonymousDevice((byte[]) msg.obj); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter() .getRemoteDevice((byte[]) msg.obj); int idleTime = msg.arg1; broadcastIdleTime(device, idleTime); } Loading Loading
android/app/src/com/android/bluetooth/a2dpsink/A2dpSinkService.java +4 −2 Original line number Diff line number Diff line Loading @@ -523,7 +523,8 @@ public class A2dpSinkService extends ProfileService { public native void informAudioTrackGainNative(float gain); private void onConnectionStateChanged(byte[] address, int state) { StackEvent event = StackEvent.connectionStateChanged(getAnonymousDevice(address), state); StackEvent event = StackEvent.connectionStateChanged( BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address), state); A2dpSinkStateMachine stateMachine = getOrCreateStateMachine(event.mDevice); stateMachine.sendMessage(A2dpSinkStateMachine.STACK_EVENT, event); } Loading @@ -545,7 +546,8 @@ public class A2dpSinkService extends ProfileService { } private void onAudioConfigChanged(byte[] address, int sampleRate, int channelCount) { StackEvent event = StackEvent.audioConfigChanged(getAnonymousDevice(address), sampleRate, StackEvent event = StackEvent.audioConfigChanged( BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address), sampleRate, channelCount); A2dpSinkStateMachine stateMachine = getOrCreateStateMachine(event.mDevice); stateMachine.sendMessage(A2dpSinkStateMachine.STACK_EVENT, event); Loading
android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerService.java +20 −20 Original line number Diff line number Diff line Loading @@ -445,7 +445,7 @@ public class AvrcpControllerService extends ProfileService { // Called by JNI when a device has connected or disconnected. private synchronized void onConnectionStateChanged(boolean remoteControlConnected, boolean browsingConnected, byte[] address) { BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); if (DBG) { Log.d(TAG, "onConnectionStateChanged " + remoteControlConnected + " " + browsingConnected + device); Loading Loading @@ -479,7 +479,7 @@ public class AvrcpControllerService extends ProfileService { // Called by JNI to notify Avrcp of a remote device's Cover Art PSM private void getRcPsm(byte[] address, int psm) { BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); if (DBG) Log.d(TAG, "getRcPsm(device=" + device + ", psm=" + psm + ")"); AvrcpControllerStateMachine stateMachine = getOrCreateStateMachine(device); if (stateMachine != null) { Loading @@ -498,7 +498,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "handleRegisterNotificationAbsVol"); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { stateMachine.sendMessage( Loading @@ -511,7 +511,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "handleSetAbsVolume "); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { stateMachine.sendMessage(AvrcpControllerStateMachine.MESSAGE_PROCESS_SET_ABS_VOL_CMD, Loading @@ -526,7 +526,7 @@ public class AvrcpControllerService extends ProfileService { Log.d(TAG, "onTrackChanged"); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { AvrcpItem.Builder aib = new AvrcpItem.Builder(); Loading @@ -552,7 +552,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "onPlayPositionChanged pos " + currSongPosition); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { stateMachine.sendMessage( Loading @@ -566,7 +566,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "onPlayStatusChanged " + playStatus); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { stateMachine.sendMessage( Loading @@ -581,7 +581,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "handlePlayerAppSetting rspLen = " + rspLen); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { PlayerApplicationSettings supportedSettings = Loading @@ -597,7 +597,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "onPlayerAppSettingChanged "); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { Loading @@ -613,7 +613,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG," onAvailablePlayerChanged"); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { Loading @@ -628,7 +628,7 @@ public class AvrcpControllerService extends ProfileService { + items.length + " items."); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); List<AvrcpItem> itemsList = new ArrayList<>(); for (AvrcpItem item : items) { if (VDBG) Log.d(TAG, item.toString()); Loading Loading @@ -659,7 +659,7 @@ public class AvrcpControllerService extends ProfileService { itemsList.add(item); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { stateMachine.sendMessage(AvrcpControllerStateMachine.MESSAGE_PROCESS_GET_PLAYER_ITEMS, Loading @@ -675,7 +675,7 @@ public class AvrcpControllerService extends ProfileService { + " attrids: " + attrIds + " attrVals: " + attrVals); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpItem.Builder aib = new AvrcpItem.Builder().fromAvrcpAttributeArray(attrIds, attrVals); aib.setDevice(device); aib.setItemType(AvrcpItem.TYPE_MEDIA); Loading @@ -694,7 +694,7 @@ public class AvrcpControllerService extends ProfileService { + name + " playable " + playable); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpItem.Builder aib = new AvrcpItem.Builder(); aib.setDevice(device); aib.setItemType(AvrcpItem.TYPE_FOLDER); Loading @@ -715,7 +715,7 @@ public class AvrcpControllerService extends ProfileService { + transportFlags + " play status " + playStatus + " player type " + playerType); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpPlayer.Builder apb = new AvrcpPlayer.Builder(); apb.setDevice(device); apb.setPlayerId(id); Loading @@ -730,7 +730,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "handleChangeFolderRsp count: " + count); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { stateMachine.sendMessage(AvrcpControllerStateMachine.MESSAGE_PROCESS_FOLDER_PATH, Loading @@ -742,7 +742,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "handleSetBrowsedPlayerRsp depth: " + depth); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { Loading @@ -755,7 +755,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "handleSetAddressedPlayerRsp status: " + status); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { Loading @@ -768,7 +768,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "handleAddressedPlayerChanged id: " + id); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { Loading @@ -781,7 +781,7 @@ public class AvrcpControllerService extends ProfileService { if (DBG) { Log.d(TAG, "handleNowPlayingContentChanged"); } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); AvrcpControllerStateMachine stateMachine = getStateMachine(device); if (stateMachine != null) { Loading
android/app/src/com/android/bluetooth/btservice/ProfileService.java +0 −27 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.annotation.SuppressLint; import android.app.ActivityManager; import android.app.Service; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading Loading @@ -336,30 +335,4 @@ public abstract class ProfileService extends Service { } stopSelf(); } /** * Returns a {@link BluetoothDevice} instance for the given address, but * with any {@link AttributionSource} details removed, making it "anonymous" * and not suitable for local use within this process. * <p> * The returned object is intended to be returned to a remote caller for * actual use, where {@link Attributable#setAttributionSource} will populate * it accurately. */ protected BluetoothDevice getAnonymousDevice(String address) { return BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); } /** * Returns a {@link BluetoothDevice} instance for the given address, but * with any {@link AttributionSource} details removed, making it "anonymous" * and not suitable for local use within this process. * <p> * The returned object is intended to be returned to a remote caller for * actual use, where {@link Attributable#setAttributionSource} will populate * it accurately. */ protected BluetoothDevice getAnonymousDevice(byte[] address) { return BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); } }
android/app/src/com/android/bluetooth/gatt/GattService.java +6 −5 Original line number Diff line number Diff line Loading @@ -1175,7 +1175,7 @@ public class GattService extends ProfileService { continue; } BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); ScanSettings settings = client.settings; byte[] scanRecordData; Loading Loading @@ -1971,7 +1971,7 @@ public class GattService extends ProfileService { extractBytes(batchRecord, i * TRUNCATED_RESULT_SIZE, TRUNCATED_RESULT_SIZE); byte[] address = extractBytes(record, 0, 6); reverse(address); BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); int rssi = record[8]; long timestampNanos = now - parseTimestampNanos(extractBytes(record, 9, 2)); results.add(new ScanResult(device, ScanRecord.parseFromBytes(new byte[0]), rssi, Loading @@ -1998,7 +1998,7 @@ public class GattService extends ProfileService { byte[] address = extractBytes(batchRecord, position, 6); // TODO: remove temp hack. reverse(address); BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); position += 6; // Skip address type. position++; Loading Loading @@ -2076,7 +2076,8 @@ public class GattService extends ProfileService { return; } BluetoothDevice device = getAnonymousDevice(trackingInfo.getAddress()); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter() .getRemoteDevice(trackingInfo.getAddress()); int advertiserState = trackingInfo.getAdvState(); ScanResult result = new ScanResult(device, ScanRecord.parseFromBytes(trackingInfo.getResult()), Loading Loading @@ -2208,7 +2209,7 @@ public class GattService extends ProfileService { connectedDevices.addAll(mServerMap.getConnectedDevices()); for (String address : connectedDevices) { BluetoothDevice device = getAnonymousDevice(address); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); if (device != null) { deviceStates.put(device, BluetoothProfile.STATE_CONNECTED); } Loading
android/app/src/com/android/bluetooth/hid/HidHostService.java +13 −6 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static android.Manifest.permission.BLUETOOTH_CONNECT; import static com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission; import android.annotation.RequiresPermission; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothHidHost; import android.bluetooth.BluetoothProfile; Loading Loading @@ -177,7 +178,8 @@ public class HidHostService extends ProfileService { } break; case MESSAGE_CONNECT_STATE_CHANGED: { BluetoothDevice device = getAnonymousDevice((byte[]) msg.obj); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter() .getRemoteDevice((byte[]) msg.obj); int halState = msg.arg1; Integer prevStateInteger = mInputDevices.get(device); int prevState = Loading Loading @@ -216,7 +218,8 @@ public class HidHostService extends ProfileService { break; case MESSAGE_ON_GET_PROTOCOL_MODE: { BluetoothDevice device = getAnonymousDevice((byte[]) msg.obj); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter() .getRemoteDevice((byte[]) msg.obj); int protocolMode = msg.arg1; broadcastProtocolMode(device, protocolMode); } Loading Loading @@ -250,7 +253,8 @@ public class HidHostService extends ProfileService { } break; case MESSAGE_ON_GET_REPORT: { BluetoothDevice device = getAnonymousDevice((byte[]) msg.obj); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter() .getRemoteDevice((byte[]) msg.obj); Bundle data = msg.getData(); byte[] report = data.getByteArray(BluetoothHidHost.EXTRA_REPORT); int bufferSize = data.getInt(BluetoothHidHost.EXTRA_REPORT_BUFFER_SIZE); Loading @@ -258,7 +262,8 @@ public class HidHostService extends ProfileService { } break; case MESSAGE_ON_HANDSHAKE: { BluetoothDevice device = getAnonymousDevice((byte[]) msg.obj); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter() .getRemoteDevice((byte[]) msg.obj); int status = msg.arg1; broadcastHandshake(device, status); } Loading @@ -274,7 +279,8 @@ public class HidHostService extends ProfileService { } break; case MESSAGE_ON_VIRTUAL_UNPLUG: { BluetoothDevice device = getAnonymousDevice((byte[]) msg.obj); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter() .getRemoteDevice((byte[]) msg.obj); int status = msg.arg1; broadcastVirtualUnplugStatus(device, status); } Loading @@ -287,7 +293,8 @@ public class HidHostService extends ProfileService { } break; case MESSAGE_ON_GET_IDLE_TIME: { BluetoothDevice device = getAnonymousDevice((byte[]) msg.obj); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter() .getRemoteDevice((byte[]) msg.obj); int idleTime = msg.arg1; broadcastIdleTime(device, idleTime); } Loading