Merge "Add missing Bluetooth API permission enforcement." into sc-dev
This commit is contained in:
@@ -187,6 +187,8 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@RequiresBluetoothConnectPermission
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
public List<BluetoothDevice> getConnectedDevices() {
|
public List<BluetoothDevice> getConnectedDevices() {
|
||||||
if (VDBG) log("getConnectedDevices()");
|
if (VDBG) log("getConnectedDevices()");
|
||||||
final IBluetoothA2dpSink service = getService();
|
final IBluetoothA2dpSink service = getService();
|
||||||
@@ -208,6 +210,8 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@RequiresBluetoothConnectPermission
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
|
public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
|
||||||
if (VDBG) log("getDevicesMatchingStates()");
|
if (VDBG) log("getDevicesMatchingStates()");
|
||||||
final IBluetoothA2dpSink service = getService();
|
final IBluetoothA2dpSink service = getService();
|
||||||
@@ -229,6 +233,8 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@RequiresBluetoothConnectPermission
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
public int getConnectionState(BluetoothDevice device) {
|
public int getConnectionState(BluetoothDevice device) {
|
||||||
if (VDBG) log("getState(" + device + ")");
|
if (VDBG) log("getState(" + device + ")");
|
||||||
final IBluetoothA2dpSink service = getService();
|
final IBluetoothA2dpSink service = getService();
|
||||||
@@ -256,6 +262,8 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@RequiresLegacyBluetoothPermission
|
@RequiresLegacyBluetoothPermission
|
||||||
|
@RequiresBluetoothConnectPermission
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
public BluetoothAudioConfig getAudioConfig(BluetoothDevice device) {
|
public BluetoothAudioConfig getAudioConfig(BluetoothDevice device) {
|
||||||
if (VDBG) log("getAudioConfig(" + device + ")");
|
if (VDBG) log("getAudioConfig(" + device + ")");
|
||||||
final IBluetoothA2dpSink service = getService();
|
final IBluetoothA2dpSink service = getService();
|
||||||
|
|||||||
@@ -117,6 +117,8 @@ public final class BluetoothAvrcpController implements BluetoothProfile {
|
|||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@RequiresBluetoothConnectPermission
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
public List<BluetoothDevice> getConnectedDevices() {
|
public List<BluetoothDevice> getConnectedDevices() {
|
||||||
if (VDBG) log("getConnectedDevices()");
|
if (VDBG) log("getConnectedDevices()");
|
||||||
final IBluetoothAvrcpController service =
|
final IBluetoothAvrcpController service =
|
||||||
@@ -137,6 +139,8 @@ public final class BluetoothAvrcpController implements BluetoothProfile {
|
|||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@RequiresBluetoothConnectPermission
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
|
public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
|
||||||
if (VDBG) log("getDevicesMatchingStates()");
|
if (VDBG) log("getDevicesMatchingStates()");
|
||||||
final IBluetoothAvrcpController service =
|
final IBluetoothAvrcpController service =
|
||||||
@@ -157,6 +161,8 @@ public final class BluetoothAvrcpController implements BluetoothProfile {
|
|||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@RequiresBluetoothConnectPermission
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
public int getConnectionState(BluetoothDevice device) {
|
public int getConnectionState(BluetoothDevice device) {
|
||||||
if (VDBG) log("getState(" + device + ")");
|
if (VDBG) log("getState(" + device + ")");
|
||||||
final IBluetoothAvrcpController service =
|
final IBluetoothAvrcpController service =
|
||||||
@@ -178,6 +184,8 @@ public final class BluetoothAvrcpController implements BluetoothProfile {
|
|||||||
*
|
*
|
||||||
* @return the {@link BluetoothAvrcpPlayerSettings} or {@link null} if there is an error.
|
* @return the {@link BluetoothAvrcpPlayerSettings} or {@link null} if there is an error.
|
||||||
*/
|
*/
|
||||||
|
@RequiresBluetoothConnectPermission
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
public BluetoothAvrcpPlayerSettings getPlayerSettings(BluetoothDevice device) {
|
public BluetoothAvrcpPlayerSettings getPlayerSettings(BluetoothDevice device) {
|
||||||
if (DBG) Log.d(TAG, "getPlayerSettings");
|
if (DBG) Log.d(TAG, "getPlayerSettings");
|
||||||
BluetoothAvrcpPlayerSettings settings = null;
|
BluetoothAvrcpPlayerSettings settings = null;
|
||||||
@@ -198,6 +206,8 @@ public final class BluetoothAvrcpController implements BluetoothProfile {
|
|||||||
* Sets the player app setting for current player.
|
* Sets the player app setting for current player.
|
||||||
* returns true in case setting is supported by remote, false otherwise
|
* returns true in case setting is supported by remote, false otherwise
|
||||||
*/
|
*/
|
||||||
|
@RequiresBluetoothConnectPermission
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
public boolean setPlayerApplicationSetting(BluetoothAvrcpPlayerSettings plAppSetting) {
|
public boolean setPlayerApplicationSetting(BluetoothAvrcpPlayerSettings plAppSetting) {
|
||||||
if (DBG) Log.d(TAG, "setPlayerApplicationSetting");
|
if (DBG) Log.d(TAG, "setPlayerApplicationSetting");
|
||||||
final IBluetoothAvrcpController service =
|
final IBluetoothAvrcpController service =
|
||||||
@@ -218,6 +228,8 @@ public final class BluetoothAvrcpController implements BluetoothProfile {
|
|||||||
* Send Group Navigation Command to Remote.
|
* Send Group Navigation Command to Remote.
|
||||||
* possible keycode values: next_grp, previous_grp defined above
|
* possible keycode values: next_grp, previous_grp defined above
|
||||||
*/
|
*/
|
||||||
|
@RequiresBluetoothConnectPermission
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
public void sendGroupNavigationCmd(BluetoothDevice device, int keyCode, int keyState) {
|
public void sendGroupNavigationCmd(BluetoothDevice device, int keyCode, int keyState) {
|
||||||
Log.d(TAG, "sendGroupNavigationCmd dev = " + device + " key " + keyCode + " State = "
|
Log.d(TAG, "sendGroupNavigationCmd dev = " + device + " key " + keyCode + " State = "
|
||||||
+ keyState);
|
+ keyState);
|
||||||
|
|||||||
@@ -1038,6 +1038,8 @@ public final class BluetoothHeadsetClient implements BluetoothProfile {
|
|||||||
* #EXTRA_AG_FEATURE_ATTACH_NUMBER_TO_VT}. This method invocation will fail silently when
|
* #EXTRA_AG_FEATURE_ATTACH_NUMBER_TO_VT}. This method invocation will fail silently when
|
||||||
* feature is not supported.</p>
|
* feature is not supported.</p>
|
||||||
*/
|
*/
|
||||||
|
@RequiresBluetoothConnectPermission
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
public boolean getLastVoiceTagNumber(BluetoothDevice device) {
|
public boolean getLastVoiceTagNumber(BluetoothDevice device) {
|
||||||
if (DBG) log("getLastVoiceTagNumber()");
|
if (DBG) log("getLastVoiceTagNumber()");
|
||||||
final IBluetoothHeadsetClient service =
|
final IBluetoothHeadsetClient service =
|
||||||
@@ -1059,6 +1061,8 @@ public final class BluetoothHeadsetClient implements BluetoothProfile {
|
|||||||
* Note: This is an internal function and shouldn't be exposed
|
* Note: This is an internal function and shouldn't be exposed
|
||||||
*/
|
*/
|
||||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
|
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
|
||||||
|
@RequiresBluetoothConnectPermission
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
public int getAudioState(BluetoothDevice device) {
|
public int getAudioState(BluetoothDevice device) {
|
||||||
if (VDBG) log("getAudioState");
|
if (VDBG) log("getAudioState");
|
||||||
final IBluetoothHeadsetClient service =
|
final IBluetoothHeadsetClient service =
|
||||||
@@ -1083,6 +1087,8 @@ public final class BluetoothHeadsetClient implements BluetoothProfile {
|
|||||||
* @param allowed if routing is allowed to the device Note: This is an internal function and
|
* @param allowed if routing is allowed to the device Note: This is an internal function and
|
||||||
* shouldn't be exposed
|
* shouldn't be exposed
|
||||||
*/
|
*/
|
||||||
|
@RequiresBluetoothConnectPermission
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
public void setAudioRouteAllowed(BluetoothDevice device, boolean allowed) {
|
public void setAudioRouteAllowed(BluetoothDevice device, boolean allowed) {
|
||||||
if (VDBG) log("setAudioRouteAllowed");
|
if (VDBG) log("setAudioRouteAllowed");
|
||||||
final IBluetoothHeadsetClient service =
|
final IBluetoothHeadsetClient service =
|
||||||
@@ -1106,6 +1112,8 @@ public final class BluetoothHeadsetClient implements BluetoothProfile {
|
|||||||
* @return whether the command succeeded Note: This is an internal function and shouldn't be
|
* @return whether the command succeeded Note: This is an internal function and shouldn't be
|
||||||
* exposed
|
* exposed
|
||||||
*/
|
*/
|
||||||
|
@RequiresBluetoothConnectPermission
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
public boolean getAudioRouteAllowed(BluetoothDevice device) {
|
public boolean getAudioRouteAllowed(BluetoothDevice device) {
|
||||||
if (VDBG) log("getAudioRouteAllowed");
|
if (VDBG) log("getAudioRouteAllowed");
|
||||||
final IBluetoothHeadsetClient service =
|
final IBluetoothHeadsetClient service =
|
||||||
|
|||||||
@@ -497,6 +497,8 @@ public final class BluetoothHearingAid implements BluetoothProfile {
|
|||||||
* @param volume Absolute volume to be set on remote
|
* @param volume Absolute volume to be set on remote
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
@RequiresBluetoothConnectPermission
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
public void setVolume(int volume) {
|
public void setVolume(int volume) {
|
||||||
if (DBG) Log.d(TAG, "setVolume(" + volume + ")");
|
if (DBG) Log.d(TAG, "setVolume(" + volume + ")");
|
||||||
|
|
||||||
@@ -556,6 +558,8 @@ public final class BluetoothHearingAid implements BluetoothProfile {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@RequiresLegacyBluetoothPermission
|
@RequiresLegacyBluetoothPermission
|
||||||
|
@RequiresBluetoothConnectPermission
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
public int getDeviceSide(BluetoothDevice device) {
|
public int getDeviceSide(BluetoothDevice device) {
|
||||||
if (VDBG) {
|
if (VDBG) {
|
||||||
log("getDeviceSide(" + device + ")");
|
log("getDeviceSide(" + device + ")");
|
||||||
@@ -582,6 +586,8 @@ public final class BluetoothHearingAid implements BluetoothProfile {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@RequiresLegacyBluetoothPermission
|
@RequiresLegacyBluetoothPermission
|
||||||
|
@RequiresBluetoothConnectPermission
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
public int getDeviceMode(BluetoothDevice device) {
|
public int getDeviceMode(BluetoothDevice device) {
|
||||||
if (VDBG) {
|
if (VDBG) {
|
||||||
log("getDeviceMode(" + device + ")");
|
log("getDeviceMode(" + device + ")");
|
||||||
|
|||||||
@@ -325,6 +325,8 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable {
|
|||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
@RequiresLegacyBluetoothPermission
|
@RequiresLegacyBluetoothPermission
|
||||||
|
@RequiresBluetoothConnectPermission
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
public List<BluetoothDevice> getActiveDevices() {
|
public List<BluetoothDevice> getActiveDevices() {
|
||||||
if (VDBG) log("getActiveDevices()");
|
if (VDBG) log("getActiveDevices()");
|
||||||
try {
|
try {
|
||||||
@@ -348,6 +350,8 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@RequiresLegacyBluetoothPermission
|
@RequiresLegacyBluetoothPermission
|
||||||
|
@RequiresBluetoothConnectPermission
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
public int getGroupId(@NonNull BluetoothDevice device) {
|
public int getGroupId(@NonNull BluetoothDevice device) {
|
||||||
if (VDBG) log("getGroupId()");
|
if (VDBG) log("getGroupId()");
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -442,6 +442,7 @@ public final class BluetoothLeScanner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_SCAN)
|
||||||
public void stopLeScan() {
|
public void stopLeScan() {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (mScannerId <= 0) {
|
if (mScannerId <= 0) {
|
||||||
@@ -458,6 +459,7 @@ public final class BluetoothLeScanner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_SCAN)
|
||||||
void flushPendingBatchResults() {
|
void flushPendingBatchResults() {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (mScannerId <= 0) {
|
if (mScannerId <= 0) {
|
||||||
@@ -588,6 +590,7 @@ public final class BluetoothLeScanner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("AndroidFrameworkBluetoothPermission")
|
||||||
private void postCallbackError(final ScanCallback callback, final int errorCode) {
|
private void postCallbackError(final ScanCallback callback, final int errorCode) {
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -714,9 +714,6 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
|||||||
Slog.w(TAG, "Callback is null in unregisterAdapter");
|
Slog.w(TAG, "Callback is null in unregisterAdapter");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!checkConnectPermissionForPreflight(mContext)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
synchronized (mCallbacks) {
|
synchronized (mCallbacks) {
|
||||||
mCallbacks.unregister(callback);
|
mCallbacks.unregister(callback);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user