summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothHeadset.java
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2021-04-23 14:13:57 -0600
committerJeff Sharkey <jsharkey@android.com>2021-04-24 08:31:43 -0600
commit43ee69eed974cd7ebc4784416a6e1e251464cc36 (patch)
tree8bea2d1eff66be08849c3ce5f147d3d99b749e80 /framework/java/android/bluetooth/BluetoothHeadset.java
parentf9e176c3dcafb82f251a123751578539e3484deb (diff)
Long-tail of AttributionSource plumbing.
Wires up AttributionSource across the remaining long-tail of Bluetooth AIDL interfaces, ensuring that developers can accurately make calls chained back to a specific Context. Moves "for data delivery" permission checks to happen in a single location on each interface to ensure they're performed consistently with the new AttributionSource arguments. Note that "for data delivery" isn't the best name; it's designed to represent that the requested action was performed and should result in the relevant appop being noted for the caller. This change has the positive side effect of ensuring that all interfaces are consistently enforcing the BLUETOOTH_CONNECT permission, even in the case where BLUETOOTH_PRIVILEGED is also required; this is what ensures that revoking the "Nearby devices" permission takes effect for all callers. Additionally, standardizing on enforcing permissions closer to the AIDL entry point reduces the need for @RequiresPermission annotations to be carried around inside the Bluetooth stack. Bug: 183626112 Test: atest BluetoothInstrumentationTests Change-Id: I8023dda654e325b8bfa2f0cdb994ad63a2b429d4
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothHeadset.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothHeadset.java62
1 files changed, 36 insertions, 26 deletions
diff --git a/framework/java/android/bluetooth/BluetoothHeadset.java b/framework/java/android/bluetooth/BluetoothHeadset.java
index 92f3f5427b..9dc2d8e953 100644
--- a/framework/java/android/bluetooth/BluetoothHeadset.java
+++ b/framework/java/android/bluetooth/BluetoothHeadset.java
@@ -545,7 +545,8 @@ public final class BluetoothHeadset implements BluetoothProfile {
if (service != null && isEnabled()) {
try {
return BluetoothDevice.setAttributionSource(
- service.getDevicesMatchingConnectionStates(states), mAttributionSource);
+ service.getDevicesMatchingConnectionStates(states, mAttributionSource),
+ mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
return new ArrayList<BluetoothDevice>();
@@ -608,7 +609,8 @@ public final class BluetoothHeadset implements BluetoothProfile {
}
try {
return service.setPriority(
- device, BluetoothAdapter.priorityToConnectionPolicy(priority));
+ device, BluetoothAdapter.priorityToConnectionPolicy(priority),
+ mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
return false;
@@ -647,7 +649,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
return false;
}
try {
- return service.setConnectionPolicy(device, connectionPolicy);
+ return service.setConnectionPolicy(device, connectionPolicy, mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
return false;
@@ -677,7 +679,8 @@ public final class BluetoothHeadset implements BluetoothProfile {
final IBluetoothHeadset service = mService;
if (service != null && isEnabled() && isValidDevice(device)) {
try {
- return BluetoothAdapter.connectionPolicyToPriority(service.getPriority(device));
+ return BluetoothAdapter.connectionPolicyToPriority(
+ service.getPriority(device, mAttributionSource));
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
return BluetoothProfile.PRIORITY_OFF;
@@ -699,13 +702,17 @@ public final class BluetoothHeadset implements BluetoothProfile {
* @hide
*/
@SystemApi
- @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
+ @RequiresBluetoothConnectPermission
+ @RequiresPermission(allOf = {
+ android.Manifest.permission.BLUETOOTH_CONNECT,
+ android.Manifest.permission.BLUETOOTH_PRIVILEGED,
+ })
public @ConnectionPolicy int getConnectionPolicy(@NonNull BluetoothDevice device) {
if (VDBG) log("getConnectionPolicy(" + device + ")");
final IBluetoothHeadset service = mService;
if (service != null && isEnabled() && isValidDevice(device)) {
try {
- return service.getConnectionPolicy(device);
+ return service.getConnectionPolicy(device, mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
@@ -729,7 +736,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
final IBluetoothHeadset service = mService;
if (service != null && isEnabled() && isValidDevice(device)) {
try {
- return service.isNoiseReductionSupported(device);
+ return service.isNoiseReductionSupported(device, mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
}
@@ -752,7 +759,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
final IBluetoothHeadset service = mService;
if (service != null && isEnabled() && isValidDevice(device)) {
try {
- return service.isVoiceRecognitionSupported(device);
+ return service.isVoiceRecognitionSupported(device, mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
}
@@ -791,7 +798,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
final IBluetoothHeadset service = mService;
if (service != null && isEnabled() && isValidDevice(device)) {
try {
- return service.startVoiceRecognition(device);
+ return service.startVoiceRecognition(device, mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
}
@@ -820,7 +827,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
final IBluetoothHeadset service = mService;
if (service != null && isEnabled() && isValidDevice(device)) {
try {
- return service.stopVoiceRecognition(device);
+ return service.stopVoiceRecognition(device, mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
}
@@ -843,7 +850,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
final IBluetoothHeadset service = mService;
if (service != null && isEnabled() && isValidDevice(device)) {
try {
- return service.isAudioConnected(device);
+ return service.isAudioConnected(device, mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
}
@@ -877,7 +884,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
final IBluetoothHeadset service = mService;
if (service != null && !isDisabled()) {
try {
- return service.getAudioState(device);
+ return service.getAudioState(device, mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
@@ -905,7 +912,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
final IBluetoothHeadset service = mService;
if (service != null && isEnabled()) {
try {
- service.setAudioRouteAllowed(allowed);
+ service.setAudioRouteAllowed(allowed, mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
@@ -928,7 +935,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
final IBluetoothHeadset service = mService;
if (service != null && isEnabled()) {
try {
- return service.getAudioRouteAllowed();
+ return service.getAudioRouteAllowed(mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
@@ -953,7 +960,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
final IBluetoothHeadset service = mService;
if (service != null && isEnabled()) {
try {
- service.setForceScoAudio(forced);
+ service.setForceScoAudio(forced, mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
@@ -978,7 +985,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
final IBluetoothHeadset service = mService;
if (service != null && isEnabled()) {
try {
- return service.isAudioOn();
+ return service.isAudioOn(mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
}
@@ -1013,7 +1020,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
final IBluetoothHeadset service = mService;
if (service != null && isEnabled()) {
try {
- return service.connectAudio();
+ return service.connectAudio(mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
@@ -1042,7 +1049,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
final IBluetoothHeadset service = mService;
if (service != null && isEnabled()) {
try {
- return service.disconnectAudio();
+ return service.disconnectAudio(mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
@@ -1086,7 +1093,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
final IBluetoothHeadset service = mService;
if (service != null && isEnabled()) {
try {
- return service.startScoUsingVirtualVoiceCall();
+ return service.startScoUsingVirtualVoiceCall(mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
@@ -1121,7 +1128,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
final IBluetoothHeadset service = mService;
if (service != null && isEnabled()) {
try {
- return service.stopScoUsingVirtualVoiceCall();
+ return service.stopScoUsingVirtualVoiceCall(mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
@@ -1151,7 +1158,8 @@ public final class BluetoothHeadset implements BluetoothProfile {
final IBluetoothHeadset service = mService;
if (service != null && isEnabled()) {
try {
- service.phoneStateChanged(numActive, numHeld, callState, number, type, name);
+ service.phoneStateChanged(numActive, numHeld, callState, number, type, name,
+ mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
@@ -1176,7 +1184,8 @@ public final class BluetoothHeadset implements BluetoothProfile {
final IBluetoothHeadset service = mService;
if (service != null && isEnabled()) {
try {
- service.clccResponse(index, direction, status, mode, mpty, number, type);
+ service.clccResponse(index, direction, status, mode, mpty, number, type,
+ mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
@@ -1216,7 +1225,8 @@ public final class BluetoothHeadset implements BluetoothProfile {
final IBluetoothHeadset service = mService;
if (service != null && isEnabled() && isValidDevice(device)) {
try {
- return service.sendVendorSpecificResultCode(device, command, arg);
+ return service.sendVendorSpecificResultCode(device, command, arg,
+ mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
}
@@ -1260,7 +1270,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
final IBluetoothHeadset service = mService;
if (service != null && isEnabled() && (device == null || isValidDevice(device))) {
try {
- return service.setActiveDevice(device);
+ return service.setActiveDevice(device, mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
}
@@ -1290,7 +1300,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
final IBluetoothHeadset service = mService;
if (service != null && isEnabled()) {
try {
- return service.getActiveDevice();
+ return service.getActiveDevice(mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
}
@@ -1318,7 +1328,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
final IBluetoothHeadset service = mService;
if (service != null && isEnabled()) {
try {
- return service.isInbandRingingEnabled();
+ return service.isInbandRingingEnabled(mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
}