Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2051326 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

More Bluetooth API annotation updates.

This change adds a "BluetoothPermissionChecker" that ensures that
all Bluetooth permission annotations are consistent.  In addition, it
verifies that all Bluetooth public APIs have been audited to be
permission protected where relevant.

We've currently standardized on saying that APIs that return device
or Bluetooth state information (without sharing details about any
particular remote Bluetooth device) do not need to be permission
protected.

This change is only annotations and has no behavior changes.

Bug: 183626724
Test: ./build/soong/soong_ui.bash --make-mode Bluetooth RUN_ERROR_PRONE=true
Change-Id: I0f39d884a4379cf33b4e185eae38dc92818a6fdb
parent f70e5df9
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.os.ResultReceiver;
 */
interface IBluetooth
{
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    int getState();

    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
@@ -89,7 +90,9 @@ interface IBluetooth
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED)")
    long getDiscoveryEndMillis();

    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    int getAdapterConnectionState();
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    int getProfileConnectionState(int profile);

    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
@@ -105,6 +108,7 @@ interface IBluetooth
    int getBondState(in BluetoothDevice device);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
    boolean isBondingInitiatedLocally(in BluetoothDevice device);
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    long getSupportedProfiles();
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
    int getConnectionState(in BluetoothDevice device);
@@ -163,19 +167,29 @@ interface IBluetooth
    void unregisterCallback(in IBluetoothCallback callback);

    // For Socket
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    IBluetoothSocketManager getSocketManager();

    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED)")
    boolean factoryReset();

    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    boolean isMultiAdvertisementSupported();
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    boolean isOffloadedFilteringSupported();
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    boolean isOffloadedScanBatchingSupported();
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    boolean isActivityAndEnergyReportingSupported();
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    boolean isLe2MPhySupported();
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    boolean isLeCodedPhySupported();
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    boolean isLeExtendedAdvertisingSupported();
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    boolean isLePeriodicAdvertisingSupported();
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    int getLeMaximumAdvertisingDataLength();

    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED)")
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ interface IBluetoothA2dp {
    boolean setConnectionPolicy(in BluetoothDevice device, int connectionPolicy);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED)")
    int getConnectionPolicy(in BluetoothDevice device);
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    boolean isAvrcpAbsoluteVolumeSupported();
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
    oneway void setAvrcpAbsoluteVolume(int volume);
+6 −0
Original line number Diff line number Diff line
@@ -42,8 +42,10 @@ interface IBluetoothManager
    boolean enableNoAutoConnect(String packageName);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
    boolean disable(String packageName, boolean persist);
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    int getState();
    @UnsupportedAppUsage
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    IBluetoothGatt getBluetoothGatt();

    boolean bindBluetoothProfileService(int profile, IBluetoothProfileServiceConnection proxy);
@@ -57,13 +59,17 @@ interface IBluetoothManager
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED)")
    boolean onFactoryReset();

    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    boolean isBleScanAlwaysAvailable();
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
    boolean enableBle(String packageName, IBinder b);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
    boolean disableBle(String packageName, IBinder b);
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    boolean isBleAppPresent();
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    boolean isHearingAidProfileSupported();

    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    List<String> getSystemConfigEnabledProfilesForPackage(String packageName);
}
+1 −0
Original line number Diff line number Diff line
@@ -24,5 +24,6 @@ import android.bluetooth.BluetoothDevice;
 * @hide
 */
oneway interface IBluetoothMetadataListener {
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    void onMetadataChanged(in BluetoothDevice devices, in int key, in byte[] value);
}
+2 −0
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import android.os.IBinder;
 * {@hide}
 */
oneway interface IBluetoothProfileServiceConnection {
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    void onServiceConnected(in ComponentName comp, in IBinder service);
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    void onServiceDisconnected(in ComponentName comp);
}