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

Commit af74e66e authored by Wei Wang's avatar Wei Wang Committed by Andre Eisenbach
Browse files

Unhide Bluetooth batch APIs. Deprecate BluetoothAdpater scan APIs. (1/2)

Change-Id: Ib0c4ea6c8372a15473269660355fb5ccf4284457
parent 3c58775a
Loading
Loading
Loading
Loading
+50 −52
Original line number Diff line number Diff line
@@ -5718,9 +5718,9 @@ package android.bluetooth {
    method public android.bluetooth.BluetoothServerSocket listenUsingRfcommWithServiceRecord(java.lang.String, java.util.UUID) throws java.io.IOException;
    method public boolean setName(java.lang.String);
    method public boolean startDiscovery();
    method public boolean startLeScan(android.bluetooth.BluetoothAdapter.LeScanCallback);
    method public boolean startLeScan(java.util.UUID[], android.bluetooth.BluetoothAdapter.LeScanCallback);
    method public void stopLeScan(android.bluetooth.BluetoothAdapter.LeScanCallback);
    method public deprecated boolean startLeScan(android.bluetooth.BluetoothAdapter.LeScanCallback);
    method public deprecated boolean startLeScan(java.util.UUID[], android.bluetooth.BluetoothAdapter.LeScanCallback);
    method public deprecated void stopLeScan(android.bluetooth.BluetoothAdapter.LeScanCallback);
    field public static final java.lang.String ACTION_CONNECTION_STATE_CHANGED = "android.bluetooth.adapter.action.CONNECTION_STATE_CHANGED";
    field public static final java.lang.String ACTION_DISCOVERY_FINISHED = "android.bluetooth.adapter.action.DISCOVERY_FINISHED";
    field public static final java.lang.String ACTION_DISCOVERY_STARTED = "android.bluetooth.adapter.action.DISCOVERY_STARTED";
@@ -6402,21 +6402,42 @@ package android.bluetooth.le {
  public abstract class AdvertiseCallback {
    ctor public AdvertiseCallback();
    method public abstract void onFailure(int);
    method public abstract void onSuccess(android.bluetooth.le.AdvertiseSettings);
    method public void onStartFailure(int);
    method public void onStartSuccess(android.bluetooth.le.AdvertiseSettings);
    field public static final int ADVERTISE_FAILED_ALREADY_STARTED = 3; // 0x3
    field public static final int ADVERTISE_FAILED_CONTROLLER_FAILURE = 5; // 0x5
    field public static final int ADVERTISE_FAILED_FEATURE_UNSUPPORTED = 7; // 0x7
    field public static final int ADVERTISE_FAILED_NOT_STARTED = 4; // 0x4
    field public static final int ADVERTISE_FAILED_FEATURE_UNSUPPORTED = 5; // 0x5
    field public static final int ADVERTISE_FAILED_INTERNAL_ERROR = 4; // 0x4
    field public static final int ADVERTISE_FAILED_SERVICE_UNKNOWN = 1; // 0x1
    field public static final int ADVERTISE_FAILED_TOO_MANY_ADVERTISERS = 2; // 0x2
  }
  public final class AdvertiseData implements android.os.Parcelable {
    method public int describeContents();
    method public boolean getIncludeTxPowerLevel();
    method public int getManufacturerId();
    method public byte[] getManufacturerSpecificData();
    method public byte[] getServiceData();
    method public android.os.ParcelUuid getServiceDataUuid();
    method public java.util.List<android.os.ParcelUuid> getServiceUuids();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator CREATOR;
  }
  public static final class AdvertiseData.Builder {
    ctor public AdvertiseData.Builder();
    method public android.bluetooth.le.AdvertiseData build();
    method public android.bluetooth.le.AdvertiseData.Builder setIncludeTxPowerLevel(boolean);
    method public android.bluetooth.le.AdvertiseData.Builder setManufacturerData(int, byte[]);
    method public android.bluetooth.le.AdvertiseData.Builder setServiceData(android.os.ParcelUuid, byte[]);
    method public android.bluetooth.le.AdvertiseData.Builder setServiceUuids(java.util.List<android.os.ParcelUuid>);
  }
  public final class AdvertiseSettings implements android.os.Parcelable {
    method public int describeContents();
    method public boolean getIsConnectable();
    method public int getMode();
    method public int getTimeout();
    method public int getTxPowerLevel();
    method public int getType();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final int ADVERTISE_MODE_BALANCED = 1; // 0x1
    field public static final int ADVERTISE_MODE_LOW_LATENCY = 2; // 0x2
@@ -6425,9 +6446,6 @@ package android.bluetooth.le {
    field public static final int ADVERTISE_TX_POWER_LOW = 1; // 0x1
    field public static final int ADVERTISE_TX_POWER_MEDIUM = 2; // 0x2
    field public static final int ADVERTISE_TX_POWER_ULTRA_LOW = 0; // 0x0
    field public static final int ADVERTISE_TYPE_CONNECTABLE = 2; // 0x2
    field public static final int ADVERTISE_TYPE_NON_CONNECTABLE = 0; // 0x0
    field public static final int ADVERTISE_TYPE_SCANNABLE = 1; // 0x1
    field public static final android.os.Parcelable.Creator CREATOR;
  }
@@ -6435,59 +6453,39 @@ package android.bluetooth.le {
    ctor public AdvertiseSettings.Builder();
    method public android.bluetooth.le.AdvertiseSettings build();
    method public android.bluetooth.le.AdvertiseSettings.Builder setAdvertiseMode(int);
    method public android.bluetooth.le.AdvertiseSettings.Builder setIsConnectable(boolean);
    method public android.bluetooth.le.AdvertiseSettings.Builder setTimeout(int);
    method public android.bluetooth.le.AdvertiseSettings.Builder setTxPowerLevel(int);
    method public android.bluetooth.le.AdvertiseSettings.Builder setType(int);
  }
  public final class AdvertisementData implements android.os.Parcelable {
    method public int describeContents();
    method public boolean getIncludeTxPowerLevel();
    method public int getManufacturerId();
    method public byte[] getManufacturerSpecificData();
    method public byte[] getServiceData();
    method public android.os.ParcelUuid getServiceDataUuid();
    method public java.util.List<android.os.ParcelUuid> getServiceUuids();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator CREATOR;
  }
  public static final class AdvertisementData.Builder {
    ctor public AdvertisementData.Builder();
    method public android.bluetooth.le.AdvertisementData build();
    method public android.bluetooth.le.AdvertisementData.Builder setIncludeTxPowerLevel(boolean);
    method public android.bluetooth.le.AdvertisementData.Builder setManufacturerData(int, byte[]);
    method public android.bluetooth.le.AdvertisementData.Builder setServiceData(android.os.ParcelUuid, byte[]);
    method public android.bluetooth.le.AdvertisementData.Builder setServiceUuids(java.util.List<android.os.ParcelUuid>);
  }
  public final class BluetoothLeAdvertiser {
    method public void startAdvertising(android.bluetooth.le.AdvertiseSettings, android.bluetooth.le.AdvertisementData, android.bluetooth.le.AdvertiseCallback);
    method public void startAdvertising(android.bluetooth.le.AdvertiseSettings, android.bluetooth.le.AdvertisementData, android.bluetooth.le.AdvertisementData, android.bluetooth.le.AdvertiseCallback);
    method public void startAdvertising(android.bluetooth.le.AdvertiseSettings, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseCallback);
    method public void startAdvertising(android.bluetooth.le.AdvertiseSettings, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseCallback);
    method public void stopAdvertising(android.bluetooth.le.AdvertiseCallback);
  }
  public final class BluetoothLeScanner {
    method public void flushPendingScanResults(android.bluetooth.le.ScanCallback);
    method public void startScan(android.bluetooth.le.ScanCallback);
    method public void startScan(java.util.List<android.bluetooth.le.ScanFilter>, android.bluetooth.le.ScanSettings, android.bluetooth.le.ScanCallback);
    method public void stopScan(android.bluetooth.le.ScanCallback);
  }
  public abstract class ScanCallback {
    ctor public ScanCallback();
    method public abstract void onAdvertisementFound(android.bluetooth.le.ScanResult);
    method public abstract void onAdvertisementLost(android.bluetooth.le.ScanResult);
    method public abstract void onAdvertisementUpdate(android.bluetooth.le.ScanResult);
    method public abstract void onScanFailed(int);
    method public void onBatchScanResults(java.util.List<android.bluetooth.le.ScanResult>);
    method public void onScanFailed(int);
    method public void onScanResult(int, android.bluetooth.le.ScanResult);
    field public static final int SCAN_FAILED_ALREADY_STARTED = 1; // 0x1
    field public static final int SCAN_FAILED_APPLICATION_REGISTRATION_FAILED = 2; // 0x2
    field public static final int SCAN_FAILED_CONTROLLER_FAILURE = 4; // 0x4
    field public static final int SCAN_FAILED_FEATURE_UNSUPPORTED = 5; // 0x5
    field public static final int SCAN_FAILED_GATT_SERVICE_FAILURE = 3; // 0x3
    field public static final int SCAN_FAILED_FEATURE_UNSUPPORTED = 4; // 0x4
    field public static final int SCAN_FAILED_INTERNAL_ERROR = 3; // 0x3
  }
  public final class ScanFilter implements android.os.Parcelable {
    method public int describeContents();
    method public java.lang.String getDeviceAddress();
    method public java.lang.String getLocalName();
    method public java.lang.String getDeviceName();
    method public byte[] getManufacturerData();
    method public byte[] getManufacturerDataMask();
    method public int getManufacturerId();
@@ -6505,10 +6503,10 @@ package android.bluetooth.le {
  public static final class ScanFilter.Builder {
    ctor public ScanFilter.Builder();
    method public android.bluetooth.le.ScanFilter build();
    method public android.bluetooth.le.ScanFilter.Builder setMacAddress(java.lang.String);
    method public android.bluetooth.le.ScanFilter.Builder setDeviceAddress(java.lang.String);
    method public android.bluetooth.le.ScanFilter.Builder setDeviceName(java.lang.String);
    method public android.bluetooth.le.ScanFilter.Builder setManufacturerData(int, byte[]);
    method public android.bluetooth.le.ScanFilter.Builder setManufacturerData(int, byte[], byte[]);
    method public android.bluetooth.le.ScanFilter.Builder setName(java.lang.String);
    method public android.bluetooth.le.ScanFilter.Builder setRssiRange(int, int);
    method public android.bluetooth.le.ScanFilter.Builder setServiceData(byte[]);
    method public android.bluetooth.le.ScanFilter.Builder setServiceData(byte[], byte[]);
@@ -6518,7 +6516,7 @@ package android.bluetooth.le {
  public final class ScanRecord {
    method public int getAdvertiseFlags();
    method public java.lang.String getLocalName();
    method public java.lang.String getDeviceName();
    method public int getManufacturerId();
    method public byte[] getManufacturerSpecificData();
    method public byte[] getServiceData();
@@ -6541,13 +6539,13 @@ package android.bluetooth.le {
  public final class ScanSettings implements android.os.Parcelable {
    method public int describeContents();
    method public int getCallbackType();
    method public long getReportDelayNanos();
    method public long getReportDelaySeconds();
    method public int getScanMode();
    method public int getScanResultType();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final int CALLBACK_TYPE_ON_FOUND = 1; // 0x1
    field public static final int CALLBACK_TYPE_ON_LOST = 2; // 0x2
    field public static final int CALLBACK_TYPE_ON_UPDATE = 0; // 0x0
    field public static final int CALLBACK_TYPE_ALL_MATCHES = 1; // 0x1
    field public static final int CALLBACK_TYPE_FIRST_MATCH = 2; // 0x2
    field public static final int CALLBACK_TYPE_MATCH_LOST = 4; // 0x4
    field public static final android.os.Parcelable.Creator CREATOR;
    field public static final int SCAN_MODE_BALANCED = 1; // 0x1
    field public static final int SCAN_MODE_LOW_LATENCY = 2; // 0x2
@@ -6559,7 +6557,7 @@ package android.bluetooth.le {
    ctor public ScanSettings.Builder();
    method public android.bluetooth.le.ScanSettings build();
    method public android.bluetooth.le.ScanSettings.Builder setCallbackType(int);
    method public android.bluetooth.le.ScanSettings.Builder setReportDelayNanos(long);
    method public android.bluetooth.le.ScanSettings.Builder setReportDelaySeconds(long);
    method public android.bluetooth.le.ScanSettings.Builder setScanMode(int);
  }
+10 −0
Original line number Diff line number Diff line
@@ -20,7 +20,9 @@ import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.bluetooth.le.BluetoothLeAdvertiser;
import android.bluetooth.le.BluetoothLeScanner;
import android.bluetooth.le.ScanCallback;
import android.bluetooth.le.ScanResult;
import android.bluetooth.le.ScanSettings;
import android.content.Context;
import android.os.Handler;
import android.os.IBinder;
@@ -1734,7 +1736,10 @@ public final class BluetoothAdapter {
     *
     * @param callback the callback LE scan results are delivered
     * @return true, if the scan was started successfully
     * @deprecated use {@link BluetoothLeScanner#startScan(List, ScanSettings, ScanCallback)}
     *             instead.
     */
    @Deprecated
    public boolean startLeScan(LeScanCallback callback) {
        return startLeScan(null, callback);
    }
@@ -1751,7 +1756,10 @@ public final class BluetoothAdapter {
     * @param serviceUuids Array of services to look for
     * @param callback the callback LE scan results are delivered
     * @return true, if the scan was started successfully
     * @deprecated use {@link BluetoothLeScanner#startScan(List, ScanSettings, ScanCallback)}
     *             instead.
     */
    @Deprecated
    public boolean startLeScan(UUID[] serviceUuids, LeScanCallback callback) {
        if (DBG) Log.d(TAG, "startLeScan(): " + serviceUuids);

@@ -1794,7 +1802,9 @@ public final class BluetoothAdapter {
     *
     * @param callback used to identify which scan to stop
     *        must be the same handle used to start the scan
     * @deprecated Use {@link BluetoothLeScanner#stopScan(ScanCallback)} instead.
     */
    @Deprecated
    public void stopLeScan(LeScanCallback callback) {
        if (DBG) Log.d(TAG, "stopLeScan()");
        GattCallbackWrapper wrapper;
+3 −3
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ package android.bluetooth;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.le.AdvertiseSettings;
import android.bluetooth.le.AdvertisementData;
import android.bluetooth.le.AdvertiseData;
import android.bluetooth.le.ScanFilter;
import android.bluetooth.le.ScanSettings;
import android.os.ParcelUuid;
@@ -40,8 +40,8 @@ interface IBluetoothGatt {
    void stopScan(in int appIf, in boolean isServer);
    void flushPendingBatchResults(in int appIf, in boolean isServer);
    void startMultiAdvertising(in int appIf,
                               in AdvertisementData advertiseData,
                               in AdvertisementData scanResponse,
                               in AdvertiseData advertiseData,
                               in AdvertiseData scanResponse,
                               in AdvertiseSettings settings);
    void stopMultiAdvertising(in int appIf);
    void registerClient(in ParcelUuid appId, in IBluetoothGattCallback callback);
+22 −28
Original line number Diff line number Diff line
@@ -17,64 +17,58 @@
package android.bluetooth.le;

/**
 * Callback of Bluetooth LE advertising, which is used to deliver advertising operation status.
 * Bluetooth LE advertising callbacks, used to deliver advertising operation status.
 */
public abstract class AdvertiseCallback {

    /**
     * The operation is success.
     *
     * The requested operation was successful.
     * @hide
     */
    public static final int SUCCESS = 0;
    public static final int ADVERTISE_SUCCESS = 0;

    /**
     * Fails to start advertising as the advertisement data contains services that are not added to
     * the local bluetooth GATT server.
     * Failed to start advertising as the advertisement data contains services that are not
     * added to the local Bluetooth GATT server.
     */
    public static final int ADVERTISE_FAILED_SERVICE_UNKNOWN = 1;

    /**
     * Fails to start advertising as system runs out of quota for advertisers.
     * Failed to start advertising because no advertising instance is available.
     */
    public static final int ADVERTISE_FAILED_TOO_MANY_ADVERTISERS = 2;

    /**
     * Fails to start advertising as the advertising is already started.
     * Failed to start advertising as the advertising is already started.
     */
    public static final int ADVERTISE_FAILED_ALREADY_STARTED = 3;
    /**
     * Fails to stop advertising as the advertising is not started.
     */
    public static final int ADVERTISE_FAILED_NOT_STARTED = 4;

    /**
     * Operation fails due to bluetooth controller failure.
     * Operation failed due to an internal error.
     */
    public static final int ADVERTISE_FAILED_CONTROLLER_FAILURE = 5;
    public static final int ADVERTISE_FAILED_INTERNAL_ERROR = 4;

    /**
     * Operation fails due to GATT service failure.
     * @hide
     * This feature is not supported on this platform.
     */
    public static final int ADVERTISE_FAILED_GATT_SERVICE_FAILURE = 6;

    /**
     * Operation fails as this feature is not supported
     */
    public static final int ADVERTISE_FAILED_FEATURE_UNSUPPORTED = 7;
    public static final int ADVERTISE_FAILED_FEATURE_UNSUPPORTED = 5;


    /**
     * Callback when advertising operation succeeds.
     * Callback triggered in response to {@link BluetoothLeAdvertiser#startAdvertising} indicating
     * that the advertising has been started successfully.
     *
     * @param settingsInEffect The actual settings used for advertising, which may be different from
     *            what the app asks.
     *            what has been requested.
     */
    public abstract void onSuccess(AdvertiseSettings settingsInEffect);
    public void onStartSuccess(AdvertiseSettings settingsInEffect) {
    }

    /**
     * Callback when advertising operation fails.
     * Callback when advertising could not be started.
     *
     * @param errorCode Error code for failures.
     * @param errorCode Error code (see ADVERTISE_FAILED_* constants) for
     */
    public abstract void onFailure(int errorCode);
    public void onStartFailure(int errorCode) {
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -16,4 +16,4 @@

package android.bluetooth.le;

parcelable AdvertisementData;
 No newline at end of file
parcelable AdvertiseData;
Loading