Loading android/app/src/com/android/bluetooth/mcp/McpService.java +30 −4 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.bluetooth.mcp; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothProfile; import android.bluetooth.IBluetoothMcpServiceManager; import android.content.AttributionSource; import android.os.Handler; Loading @@ -27,6 +28,7 @@ import android.util.Log; import com.android.bluetooth.Utils; import com.android.bluetooth.btservice.ProfileService; import com.android.bluetooth.le_audio.LeAudioService; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -199,10 +201,34 @@ public class McpService extends ProfileService { } public int getDeviceAuthorization(BluetoothDevice device) { // TODO: For now just reject authorization for other than LeAudio device already authorized // except for PTS. Consider intent based authorization mechanism for non-LeAudio devices. return mDeviceAuthorizations.getOrDefault(device, Utils.isPtsTestMode() ? BluetoothDevice.ACCESS_ALLOWED : BluetoothDevice.ACCESS_UNKNOWN); /* Media control is allowed for * 1. in PTS mode * 2. authorized devices * 3. Any LeAudio devices which are allowed to connect */ if (mDeviceAuthorizations.getOrDefault(device, Utils.isPtsTestMode() ? BluetoothDevice.ACCESS_ALLOWED : BluetoothDevice.ACCESS_UNKNOWN) == BluetoothDevice.ACCESS_ALLOWED) { return BluetoothDevice.ACCESS_ALLOWED; } LeAudioService leAudioService = LeAudioService.getLeAudioService(); if (leAudioService == null) { Log.e(TAG, "MCS access not permited. LeAudioService not available"); return BluetoothDevice.ACCESS_UNKNOWN; } if (leAudioService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN) { if (DBG) { Log.d(TAG, "MCS authorization allowed based on supported LeAudio service"); } setDeviceAuthorized(device, true); return BluetoothDevice.ACCESS_ALLOWED; } Log.e(TAG, "MCS access not permited"); return BluetoothDevice.ACCESS_UNKNOWN; } @GuardedBy("mLock") Loading Loading
android/app/src/com/android/bluetooth/mcp/McpService.java +30 −4 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.bluetooth.mcp; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothProfile; import android.bluetooth.IBluetoothMcpServiceManager; import android.content.AttributionSource; import android.os.Handler; Loading @@ -27,6 +28,7 @@ import android.util.Log; import com.android.bluetooth.Utils; import com.android.bluetooth.btservice.ProfileService; import com.android.bluetooth.le_audio.LeAudioService; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -199,10 +201,34 @@ public class McpService extends ProfileService { } public int getDeviceAuthorization(BluetoothDevice device) { // TODO: For now just reject authorization for other than LeAudio device already authorized // except for PTS. Consider intent based authorization mechanism for non-LeAudio devices. return mDeviceAuthorizations.getOrDefault(device, Utils.isPtsTestMode() ? BluetoothDevice.ACCESS_ALLOWED : BluetoothDevice.ACCESS_UNKNOWN); /* Media control is allowed for * 1. in PTS mode * 2. authorized devices * 3. Any LeAudio devices which are allowed to connect */ if (mDeviceAuthorizations.getOrDefault(device, Utils.isPtsTestMode() ? BluetoothDevice.ACCESS_ALLOWED : BluetoothDevice.ACCESS_UNKNOWN) == BluetoothDevice.ACCESS_ALLOWED) { return BluetoothDevice.ACCESS_ALLOWED; } LeAudioService leAudioService = LeAudioService.getLeAudioService(); if (leAudioService == null) { Log.e(TAG, "MCS access not permited. LeAudioService not available"); return BluetoothDevice.ACCESS_UNKNOWN; } if (leAudioService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN) { if (DBG) { Log.d(TAG, "MCS authorization allowed based on supported LeAudio service"); } setDeviceAuthorized(device, true); return BluetoothDevice.ACCESS_ALLOWED; } Log.e(TAG, "MCS access not permited"); return BluetoothDevice.ACCESS_UNKNOWN; } @GuardedBy("mLock") Loading