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

Commit 89b859a2 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6197114 from 0a5f568a6a75caca23b77b3bb251f85ec139bde3 to rvc-release

Change-Id: Ifa2e73c44f1507cc0c17fd3e2805324d774b6c1f
parents a8705fae 30372a3d
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
     */
    @SystemApi
    @SuppressLint("ActionValue")
    @RequiresPermission(Manifest.permission.BLUETOOTH)
    @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
    public static final String ACTION_CONNECTION_STATE_CHANGED =
            "android.bluetooth.a2dp-sink.profile.action.CONNECTION_STATE_CHANGED";

@@ -296,7 +296,7 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
     * @hide
     */
    @SystemApi
    @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
    @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
    public boolean setConnectionPolicy(@Nullable BluetoothDevice device,
            @ConnectionPolicy int connectionPolicy) {
        if (DBG) log("setConnectionPolicy(" + device + ", " + connectionPolicy + ")");
@@ -345,7 +345,7 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
     * @hide
     */
    @SystemApi
    @RequiresPermission(Manifest.permission.BLUETOOTH)
    @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
    public @ConnectionPolicy int getConnectionPolicy(@Nullable BluetoothDevice device) {
        if (VDBG) log("getConnectionPolicy(" + device + ")");
        final IBluetoothA2dpSink service = getService();
@@ -370,7 +370,7 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
     * @hide
     */
    @SystemApi
    @RequiresPermission(Manifest.permission.BLUETOOTH)
    @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
    public boolean isAudioPlaying(@Nullable BluetoothDevice device) {
        final IBluetoothA2dpSink service = getService();
        if (service != null && isEnabled() && isValidDevice(device)) {
+105 −46
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
import android.app.ActivityThread;
import android.app.PropertyInvalidatedCache;
import android.bluetooth.BluetoothProfile.ConnectionPolicy;
import android.bluetooth.le.BluetoothLeAdvertiser;
import android.bluetooth.le.BluetoothLeScanner;
@@ -994,6 +995,37 @@ public final class BluetoothAdapter {
        return false;
    }

    private static final String BLUETOOTH_GET_STATE_CACHE_PROPERTY = "cache_key.bluetooth.get_state";

    private final PropertyInvalidatedCache<Void, Integer> mBluetoothGetStateCache =
            new PropertyInvalidatedCache<Void, Integer>(
                8, BLUETOOTH_GET_STATE_CACHE_PROPERTY) {
                @Override
                protected Integer recompute(Void query) {
                    try {
                        mServiceLock.readLock().lock();
                        if (mService != null) {
                            return mService.getState();
                        }
                    } catch (RemoteException e) {
                        Log.e(TAG, "", e);
                    } finally {
                        mServiceLock.readLock().unlock();
                    }
                    return BluetoothAdapter.STATE_OFF;
                }
            };

    /** @hide */
    public void disableBluetoothGetStateCache() {
        mBluetoothGetStateCache.disableLocal();
    }

    /** @hide */
    public static void invalidateBluetoothGetStateCache() {
        PropertyInvalidatedCache.invalidateCache(BLUETOOTH_GET_STATE_CACHE_PROPERTY);
    }

    /**
     * Get the current state of the local Bluetooth adapter.
     * <p>Possible return values are
@@ -1007,18 +1039,7 @@ public final class BluetoothAdapter {
    @RequiresPermission(Manifest.permission.BLUETOOTH)
    @AdapterState
    public int getState() {
        int state = BluetoothAdapter.STATE_OFF;

        try {
            mServiceLock.readLock().lock();
            if (mService != null) {
                state = mService.getState();
            }
        } catch (RemoteException e) {
            Log.e(TAG, "", e);
        } finally {
            mServiceLock.readLock().unlock();
        }
        int state = mBluetoothGetStateCache.query(null);

        // Consider all internal states as OFF
        if (state == BluetoothAdapter.STATE_BLE_ON || state == BluetoothAdapter.STATE_BLE_TURNING_ON
@@ -1056,18 +1077,7 @@ public final class BluetoothAdapter {
    @UnsupportedAppUsage(publicAlternatives = "Use {@link #getState()} instead to determine "
            + "whether you can use BLE & BT classic.")
    public int getLeState() {
        int state = BluetoothAdapter.STATE_OFF;

        try {
            mServiceLock.readLock().lock();
            if (mService != null) {
                state = mService.getState();
            }
        } catch (RemoteException e) {
            Log.e(TAG, "", e);
        } finally {
            mServiceLock.readLock().unlock();
        }
        int state = mBluetoothGetStateCache.query(null);

        if (VDBG) {
            Log.d(TAG, "getLeState() returning " + BluetoothAdapter.nameForState(state));
@@ -1960,15 +1970,13 @@ public final class BluetoothAdapter {
        }
    }

    /**
     * Return true if offloaded filters are supported
     *
     * @return true if chipset supports on-chip filtering
     */
    public boolean isOffloadedFilteringSupported() {
        if (!getLeAccess()) {
            return false;
        }
    private static final String BLUETOOTH_FILTERING_CACHE_PROPERTY =
            "cache_key.bluetooth.is_offloaded_filtering_supported";
    private final PropertyInvalidatedCache<Void, Boolean> mBluetoothFilteringCache =
            new PropertyInvalidatedCache<Void, Boolean>(
                8, BLUETOOTH_FILTERING_CACHE_PROPERTY) {
                @Override
                protected Boolean recompute(Void query) {
                    try {
                        mServiceLock.readLock().lock();
                        if (mService != null) {
@@ -1980,6 +1988,30 @@ public final class BluetoothAdapter {
                        mServiceLock.readLock().unlock();
                    }
                    return false;

                }
            };

    /** @hide */
    public void disableIsOffloadedFilteringSupportedCache() {
        mBluetoothFilteringCache.disableLocal();
    }

    /** @hide */
    public static void invalidateIsOffloadedFilteringSupportedCache() {
        PropertyInvalidatedCache.invalidateCache(BLUETOOTH_FILTERING_CACHE_PROPERTY);
    }

    /**
     * Return true if offloaded filters are supported
     *
     * @return true if chipset supports on-chip filtering
     */
    public boolean isOffloadedFilteringSupported() {
        if (!getLeAccess()) {
            return false;
        }
        return mBluetoothFilteringCache.query(null);
    }

    /**
@@ -2351,6 +2383,43 @@ public final class BluetoothAdapter {
        return BluetoothAdapter.STATE_DISCONNECTED;
    }

    private static final String BLUETOOTH_PROFILE_CACHE_PROPERTY =
            "cache_key.bluetooth.get_profile_connection_state";
    private final PropertyInvalidatedCache<Integer, Integer>
            mGetProfileConnectionStateCache =
            new PropertyInvalidatedCache<Integer, Integer>(
                8, BLUETOOTH_PROFILE_CACHE_PROPERTY) {
                @Override
                protected Integer recompute(Integer query) {
                    try {
                        mServiceLock.readLock().lock();
                        if (mService != null) {
                            return mService.getProfileConnectionState(query);
                        }
                    } catch (RemoteException e) {
                        Log.e(TAG, "getProfileConnectionState:", e);
                    } finally {
                        mServiceLock.readLock().unlock();
                    }
                    return BluetoothProfile.STATE_DISCONNECTED;
                }
                @Override
                public String queryToString(Integer query) {
                    return String.format("getProfileConnectionState(profile=\"%d\")",
                                         query);
                }
            };

    /** @hide */
    public void disableGetProfileConnectionStateCache() {
        mGetProfileConnectionStateCache.disableLocal();
    }

    /** @hide */
    public static void invalidateGetProfileConnectionStateCache() {
        PropertyInvalidatedCache.invalidateCache(BLUETOOTH_PROFILE_CACHE_PROPERTY);
    }

    /**
     * Get the current connection state of a profile.
     * This function can be used to check whether the local Bluetooth adapter
@@ -2368,17 +2437,7 @@ public final class BluetoothAdapter {
        if (getState() != STATE_ON) {
            return BluetoothProfile.STATE_DISCONNECTED;
        }
        try {
            mServiceLock.readLock().lock();
            if (mService != null) {
                return mService.getProfileConnectionState(profile);
            }
        } catch (RemoteException e) {
            Log.e(TAG, "getProfileConnectionState:", e);
        } finally {
            mServiceLock.readLock().unlock();
        }
        return BluetoothProfile.STATE_DISCONNECTED;
        return mGetProfileConnectionStateCache.query(new Integer(profile));
    }

    /**
+9 −5
Original line number Diff line number Diff line
@@ -38,9 +38,6 @@ import java.util.Arrays;
import java.util.List;

/**
 * The Android Bluetooth API is not finalized, and *will* change. Use at your
 * own risk.
 *
 * Public API for controlling the Bluetooth Pbap Service. This includes
 * Bluetooth Phone book Access profile.
 * BluetoothPbap is a proxy object for controlling the Bluetooth Pbap
@@ -56,6 +53,11 @@ import java.util.List;
 * notification when it is bound, this is especially important if you wish to
 * immediately call methods on BluetoothPbap after construction.
 *
 * To get an instance of the BluetoothPbap class, you can call
 * {@link BluetoothAdapter#getProfileProxy(Context, ServiceListener, int)} with the final param
 * being {@link BluetoothProfile#PBAP}. The ServiceListener should be able to get the instance of
 * BluetoothPbap in {@link android.bluetooth.BluetoothProfile.ServiceListener#onServiceConnected}.
 *
 * Android only supports one connected Bluetooth Pce at a time.
 *
 * @hide
@@ -87,6 +89,7 @@ public class BluetoothPbap implements BluetoothProfile {
     */
    @SuppressLint("ActionValue")
    @SystemApi
    @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
    @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_CONNECTION_STATE_CHANGED =
            "android.bluetooth.pbap.profile.action.CONNECTION_STATE_CHANGED";
@@ -235,7 +238,8 @@ public class BluetoothPbap implements BluetoothProfile {
     */
    @SystemApi
    @Override
    public int getConnectionState(@Nullable BluetoothDevice device) {
    @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
    public @BtProfileState int getConnectionState(@Nullable BluetoothDevice device) {
        log("getConnectionState: device=" + device);
        try {
            final IBluetoothPbap service = mService;
@@ -287,7 +291,7 @@ public class BluetoothPbap implements BluetoothProfile {
     * @hide
     */
    @SystemApi
    @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
    @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
    public boolean setConnectionPolicy(@NonNull BluetoothDevice device,
            @ConnectionPolicy int connectionPolicy) {
        if (DBG) log("setConnectionPolicy(" + device + ", " + connectionPolicy + ")");