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

Commit 028765e6 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 4677756 from 6da53af9c55ba2231cd2f47c7dffb150f2c22a89 to pi-release

Change-Id: I97ad116a96610d781a8652edd3535863294657f5
parents a7417c8f babe7f95
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -680,10 +680,6 @@ public final class BluetoothAdapter {
        if (!getLeAccess()) {
            return null;
        }
        if (!isMultipleAdvertisementSupported()) {
            Log.e(TAG, "Bluetooth LE advertising not supported");
            return null;
        }
        synchronized (mLock) {
            if (sBluetoothLeAdvertiser == null) {
                sBluetoothLeAdvertiser = new BluetoothLeAdvertiser(mManagerService);
+71 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.bluetooth;

import android.Manifest;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
@@ -378,6 +379,76 @@ public final class BluetoothHearingAid implements BluetoothProfile {
        }
    }

    /**
     * Select a connected device as active.
     *
     * The active device selection is per profile. An active device's
     * purpose is profile-specific. For example, Hearing Aid audio
     * streaming is to the active Hearing Aid device. If a remote device
     * is not connected, it cannot be selected as active.
     *
     * <p> This API returns false in scenarios like the profile on the
     * device is not connected or Bluetooth is not turned on.
     * When this API returns true, it is guaranteed that the
     * {@link #ACTION_ACTIVE_DEVICE_CHANGED} intent will be broadcasted
     * with the active device.
     *
     * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}
     * permission.
     *
     * @param device the remote Bluetooth device. Could be null to clear
     * the active device and stop streaming audio to a Bluetooth device.
     * @return false on immediate error, true otherwise
     * @hide
     */
    public boolean setActiveDevice(@Nullable BluetoothDevice device) {
        if (DBG) log("setActiveDevice(" + device + ")");
        try {
            mServiceLock.readLock().lock();
            if (mService != null && isEnabled()
                    && ((device == null) || isValidDevice(device))) {
                mService.setActiveDevice(device);
                return true;
            }
            if (mService == null) Log.w(TAG, "Proxy not attached to service");
            return false;
        } catch (RemoteException e) {
            Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
            return false;
        } finally {
            mServiceLock.readLock().unlock();
        }
    }

    /**
     * Check whether the device is active.
     *
     * <p>Requires {@link android.Manifest.permission#BLUETOOTH}
     * permission.
     *
     * @return the connected device that is active or null if no device
     * is active
     * @hide
     */
    @RequiresPermission(Manifest.permission.BLUETOOTH)
    public boolean isActiveDevice(@Nullable BluetoothDevice device) {
        if (VDBG) log("isActiveDevice()");
        try {
            mServiceLock.readLock().lock();
            if (mService != null && isEnabled()
                    && ((device == null) || isValidDevice(device))) {
                return mService.isActiveDevice(device);
            }
            if (mService == null) Log.w(TAG, "Proxy not attached to service");
            return false;
        } catch (RemoteException e) {
            Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
            return false;
        } finally {
            mServiceLock.readLock().unlock();
        }
    }

    /**
     * Set priority of the profile
     *
+281 −77

File changed.

Preview size limit exceeded, changes collapsed.

+55 −133
Original line number Diff line number Diff line
@@ -29,12 +29,12 @@ import android.os.Parcelable;
 */
public final class BluetoothHidDeviceAppQosSettings implements Parcelable {

    public final int serviceType;
    public final int tokenRate;
    public final int tokenBucketSize;
    public final int peakBandwidth;
    public final int latency;
    public final int delayVariation;
    private final int mServiceType;
    private final int mTokenRate;
    private final int mTokenBucketSize;
    private final int mPeakBandwidth;
    private final int mLatency;
    private final int mDelayVariation;

    public static final int SERVICE_NO_TRAFFIC = 0x00;
    public static final int SERVICE_BEST_EFFORT = 0x01;
@@ -44,38 +44,53 @@ public final class BluetoothHidDeviceAppQosSettings implements Parcelable {

    /**
     * Create a BluetoothHidDeviceAppQosSettings object for the Bluetooth L2CAP channel. The QoS
     * Settings is optional. Recommended to use BluetoothHidDeviceAppQosSettings.Builder.
     * Please refer to Bluetooth HID Specfication v1.1.1 Section 5.2 and Appendix D for parameters.
     * Settings is optional. Please refer to Bluetooth HID Specfication v1.1.1 Section 5.2 and
     * Appendix D for parameters.
     *
     * @param serviceType L2CAP service type
     * @param tokenRate L2CAP token rate
     * @param tokenBucketSize L2CAP token bucket size
     * @param peakBandwidth L2CAP peak bandwidth
     * @param latency L2CAP latency
     * @param delayVariation L2CAP delay variation
     * @param serviceType L2CAP service type, default = SERVICE_BEST_EFFORT
     * @param tokenRate L2CAP token rate, default = 0
     * @param tokenBucketSize L2CAP token bucket size, default = 0
     * @param peakBandwidth L2CAP peak bandwidth, default = 0
     * @param latency L2CAP latency, default = MAX
     * @param delayVariation L2CAP delay variation, default = MAX
     */
    public BluetoothHidDeviceAppQosSettings(int serviceType, int tokenRate, int tokenBucketSize,
            int peakBandwidth, int latency, int delayVariation) {
        this.serviceType = serviceType;
        this.tokenRate = tokenRate;
        this.tokenBucketSize = tokenBucketSize;
        this.peakBandwidth = peakBandwidth;
        this.latency = latency;
        this.delayVariation = delayVariation;
    public BluetoothHidDeviceAppQosSettings(
            int serviceType,
            int tokenRate,
            int tokenBucketSize,
            int peakBandwidth,
            int latency,
            int delayVariation) {
        mServiceType = serviceType;
        mTokenRate = tokenRate;
        mTokenBucketSize = tokenBucketSize;
        mPeakBandwidth = peakBandwidth;
        mLatency = latency;
        mDelayVariation = delayVariation;
    }

    @Override
    public boolean equals(Object o) {
        if (o instanceof BluetoothHidDeviceAppQosSettings) {
            BluetoothHidDeviceAppQosSettings qos = (BluetoothHidDeviceAppQosSettings) o;
            return this.serviceType == qos.serviceType
                    && this.tokenRate == qos.tokenRate
                    && this.tokenBucketSize == qos.tokenBucketSize
                    && this.peakBandwidth == qos.peakBandwidth
                    && this.latency == qos.latency
                    && this.delayVariation == qos.delayVariation;
    public int getServiceType() {
        return mServiceType;
    }

    public int getTokenRate() {
        return mTokenRate;
    }

    public int getTokenBucketSize() {
        return mTokenBucketSize;
    }

    public int getPeakBandwidth() {
        return mPeakBandwidth;
    }

    public int getLatency() {
        return mLatency;
    }
        return false;

    public int getDelayVariation() {
        return mDelayVariation;
    }

    @Override
@@ -106,104 +121,11 @@ public final class BluetoothHidDeviceAppQosSettings implements Parcelable {

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeInt(serviceType);
        out.writeInt(tokenRate);
        out.writeInt(tokenBucketSize);
        out.writeInt(peakBandwidth);
        out.writeInt(latency);
        out.writeInt(delayVariation);
    }

    /** @return an int array representation of this instance */
    public int[] toArray() {
        return new int[] {
            serviceType, tokenRate, tokenBucketSize, peakBandwidth, latency, delayVariation
        };
    }

    /** A helper to build the BluetoothHidDeviceAppQosSettings object. */
    public static class Builder {
        // Optional parameters - initialized to default values
        private int mServiceType = SERVICE_BEST_EFFORT;
        private int mTokenRate = 0;
        private int mTokenBucketSize = 0;
        private int mPeakBandwidth = 0;
        private int mLatency = MAX;
        private int mDelayVariation = MAX;

        /**
         * Set the service type.
         *
         * @param val service type. Should be one of {SERVICE_NO_TRAFFIC, SERVICE_BEST_EFFORT,
         *     SERVICE_GUARANTEED}, with SERVICE_BEST_EFFORT being the default one.
         * @return BluetoothHidDeviceAppQosSettings Builder with specified service type.
         */
        public Builder serviceType(int val) {
            mServiceType = val;
            return this;
        }
        /**
         * Set the token rate.
         *
         * @param val token rate
         * @return BluetoothHidDeviceAppQosSettings Builder with specified token rate.
         */
        public Builder tokenRate(int val) {
            mTokenRate = val;
            return this;
        }

        /**
         * Set the bucket size.
         *
         * @param val bucket size
         * @return BluetoothHidDeviceAppQosSettings Builder with specified bucket size.
         */
        public Builder tokenBucketSize(int val) {
            mTokenBucketSize = val;
            return this;
        }

        /**
         * Set the peak bandwidth.
         *
         * @param val peak bandwidth
         * @return BluetoothHidDeviceAppQosSettings Builder with specified peak bandwidth.
         */
        public Builder peakBandwidth(int val) {
            mPeakBandwidth = val;
            return this;
        }
        /**
         * Set the latency.
         *
         * @param val latency
         * @return BluetoothHidDeviceAppQosSettings Builder with specified latency.
         */
        public Builder latency(int val) {
            mLatency = val;
            return this;
        }

        /**
         * Set the delay variation.
         *
         * @param val delay variation
         * @return BluetoothHidDeviceAppQosSettings Builder with specified delay variation.
         */
        public Builder delayVariation(int val) {
            mDelayVariation = val;
            return this;
        }

        /**
         * Build the BluetoothHidDeviceAppQosSettings object.
         *
         * @return BluetoothHidDeviceAppQosSettings object with current settings.
         */
        public BluetoothHidDeviceAppQosSettings build() {
            return new BluetoothHidDeviceAppQosSettings(mServiceType, mTokenRate, mTokenBucketSize,
                    mPeakBandwidth, mLatency, mDelayVariation);
        }
        out.writeInt(mServiceType);
        out.writeInt(mTokenRate);
        out.writeInt(mTokenBucketSize);
        out.writeInt(mPeakBandwidth);
        out.writeInt(mLatency);
        out.writeInt(mDelayVariation);
    }
}
+33 −27
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package android.bluetooth;
import android.os.Parcel;
import android.os.Parcelable;

import java.util.Arrays;

/**
 * Represents the Service Discovery Protocol (SDP) settings for a Bluetooth HID Device application.
@@ -31,11 +30,11 @@ import java.util.Arrays;
 */
public final class BluetoothHidDeviceAppSdpSettings implements Parcelable {

    public final String name;
    public final String description;
    public final String provider;
    public final byte subclass;
    public final byte[] descriptors;
    private final String mName;
    private final String mDescription;
    private final String mProvider;
    private final byte mSubclass;
    private final byte[] mDescriptors;

    /**
     * Create a BluetoothHidDeviceAppSdpSettings object for the Bluetooth SDP record.
@@ -52,24 +51,31 @@ public final class BluetoothHidDeviceAppSdpSettings implements Parcelable {
     */
    public BluetoothHidDeviceAppSdpSettings(
            String name, String description, String provider, byte subclass, byte[] descriptors) {
        this.name = name;
        this.description = description;
        this.provider = provider;
        this.subclass = subclass;
        this.descriptors = descriptors.clone();
        mName = name;
        mDescription = description;
        mProvider = provider;
        mSubclass = subclass;
        mDescriptors = descriptors.clone();
    }

    @Override
    public boolean equals(Object o) {
        if (o instanceof BluetoothHidDeviceAppSdpSettings) {
            BluetoothHidDeviceAppSdpSettings sdp = (BluetoothHidDeviceAppSdpSettings) o;
            return this.name.equals(sdp.name)
                    && this.description.equals(sdp.description)
                    && this.provider.equals(sdp.provider)
                    && this.subclass == sdp.subclass
                    && Arrays.equals(this.descriptors, sdp.descriptors);
    public String getName() {
        return mName;
    }

    public String getDescription() {
        return mDescription;
    }

    public String getProvider() {
        return mProvider;
    }

    public byte getSubclass() {
        return mSubclass;
    }
        return false;

    public byte[] getDescriptors() {
        return mDescriptors;
    }

    @Override
@@ -99,10 +105,10 @@ public final class BluetoothHidDeviceAppSdpSettings implements Parcelable {

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeString(name);
        out.writeString(description);
        out.writeString(provider);
        out.writeByte(subclass);
        out.writeByteArray(descriptors);
        out.writeString(mName);
        out.writeString(mDescription);
        out.writeString(mProvider);
        out.writeByte(mSubclass);
        out.writeByteArray(mDescriptors);
    }
}
Loading