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

Commit ac7fcfa3 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Bluetooth 5 periodc scan API (1/2)

Bug: 30622771
Test: manual
Change-Id: I61853bc71f6013e9406d1d151bb51ea4484bb92c
(cherry picked from commit a48e0374)
parent bed6fb3f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -131,6 +131,7 @@ LOCAL_SRC_FILES += \
	core/java/android/bluetooth/IBluetoothGattCallback.aidl \
	core/java/android/bluetooth/IBluetoothGattServerCallback.aidl \
	core/java/android/bluetooth/le/IAdvertiserCallback.aidl \
	core/java/android/bluetooth/le/IPeriodicAdvertisingCallback.aidl \
	core/java/android/bluetooth/le/IScannerCallback.aidl \
	core/java/android/content/IClipboard.aidl \
	core/java/android/content/IContentService.aidl \
+31 −0
Original line number Diff line number Diff line
@@ -6695,6 +6695,7 @@ package android.bluetooth {
    method public java.util.Set<android.bluetooth.BluetoothDevice> getBondedDevices();
    method public static synchronized android.bluetooth.BluetoothAdapter getDefaultAdapter();
    method public java.lang.String getName();
    method public android.bluetooth.le.PeriodicAdvertisingManager getPeriodicAdvertisingManager();
    method public int getProfileConnectionState(int);
    method public boolean getProfileProxy(android.content.Context, android.bluetooth.BluetoothProfile.ServiceListener, int);
    method public android.bluetooth.BluetoothDevice getRemoteDevice(java.lang.String);
@@ -7490,6 +7491,36 @@ package android.bluetooth.le {
    method public void stopScan(android.bluetooth.le.ScanCallback);
  }
  public abstract class PeriodicAdvertisingCallback {
    ctor public PeriodicAdvertisingCallback();
    method public void onPeriodicAdvertisingReport(android.bluetooth.le.PeriodicAdvertisingReport);
    method public void onSyncEstablished(int, android.bluetooth.BluetoothDevice, int, int, int, int);
    method public void onSyncLost(int);
    field public static final int SYNC_NO_RESOURCES = 2; // 0x2
    field public static final int SYNC_NO_RESPONSE = 1; // 0x1
  }
  public final class PeriodicAdvertisingManager {
    method public void registerSync(android.bluetooth.le.ScanResult, int, int, android.bluetooth.le.PeriodicAdvertisingCallback);
    method public void registerSync(android.bluetooth.le.ScanResult, int, int, android.bluetooth.le.PeriodicAdvertisingCallback, android.os.Handler);
    method public void unregisterSync(android.bluetooth.le.PeriodicAdvertisingCallback);
  }
  public final class PeriodicAdvertisingReport implements android.os.Parcelable {
    ctor public PeriodicAdvertisingReport(int, int, int, int, android.bluetooth.le.ScanRecord);
    method public int describeContents();
    method public android.bluetooth.le.ScanRecord getData();
    method public int getDataStatus();
    method public int getRssi();
    method public int getSyncHandle();
    method public long getTimestampNanos();
    method public int getTxPower();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.bluetooth.le.PeriodicAdvertisingReport> CREATOR;
    field public static final int DATA_COMPLETE = 0; // 0x0
    field public static final int DATA_INCOMPLETE_TRUNCATED = 2; // 0x2
  }
  public abstract class ScanCallback {
    ctor public ScanCallback();
    method public void onBatchScanResults(java.util.List<android.bluetooth.le.ScanResult>);
+31 −0
Original line number Diff line number Diff line
@@ -6993,6 +6993,7 @@ package android.bluetooth {
    method public java.util.Set<android.bluetooth.BluetoothDevice> getBondedDevices();
    method public static synchronized android.bluetooth.BluetoothAdapter getDefaultAdapter();
    method public java.lang.String getName();
    method public android.bluetooth.le.PeriodicAdvertisingManager getPeriodicAdvertisingManager();
    method public int getProfileConnectionState(int);
    method public boolean getProfileProxy(android.content.Context, android.bluetooth.BluetoothProfile.ServiceListener, int);
    method public android.bluetooth.BluetoothDevice getRemoteDevice(java.lang.String);
@@ -7797,6 +7798,36 @@ package android.bluetooth.le {
    method public void stopScan(android.bluetooth.le.ScanCallback);
  }
  public abstract class PeriodicAdvertisingCallback {
    ctor public PeriodicAdvertisingCallback();
    method public void onPeriodicAdvertisingReport(android.bluetooth.le.PeriodicAdvertisingReport);
    method public void onSyncEstablished(int, android.bluetooth.BluetoothDevice, int, int, int, int);
    method public void onSyncLost(int);
    field public static final int SYNC_NO_RESOURCES = 2; // 0x2
    field public static final int SYNC_NO_RESPONSE = 1; // 0x1
  }
  public final class PeriodicAdvertisingManager {
    method public void registerSync(android.bluetooth.le.ScanResult, int, int, android.bluetooth.le.PeriodicAdvertisingCallback);
    method public void registerSync(android.bluetooth.le.ScanResult, int, int, android.bluetooth.le.PeriodicAdvertisingCallback, android.os.Handler);
    method public void unregisterSync(android.bluetooth.le.PeriodicAdvertisingCallback);
  }
  public final class PeriodicAdvertisingReport implements android.os.Parcelable {
    ctor public PeriodicAdvertisingReport(int, int, int, int, android.bluetooth.le.ScanRecord);
    method public int describeContents();
    method public android.bluetooth.le.ScanRecord getData();
    method public int getDataStatus();
    method public int getRssi();
    method public int getSyncHandle();
    method public long getTimestampNanos();
    method public int getTxPower();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.bluetooth.le.PeriodicAdvertisingReport> CREATOR;
    field public static final int DATA_COMPLETE = 0; // 0x0
    field public static final int DATA_INCOMPLETE_TRUNCATED = 2; // 0x2
  }
  public final class ResultStorageDescriptor implements android.os.Parcelable {
    ctor public ResultStorageDescriptor(int, int, int);
    method public int describeContents();
+31 −0
Original line number Diff line number Diff line
@@ -6704,6 +6704,7 @@ package android.bluetooth {
    method public java.util.Set<android.bluetooth.BluetoothDevice> getBondedDevices();
    method public static synchronized android.bluetooth.BluetoothAdapter getDefaultAdapter();
    method public java.lang.String getName();
    method public android.bluetooth.le.PeriodicAdvertisingManager getPeriodicAdvertisingManager();
    method public int getProfileConnectionState(int);
    method public boolean getProfileProxy(android.content.Context, android.bluetooth.BluetoothProfile.ServiceListener, int);
    method public android.bluetooth.BluetoothDevice getRemoteDevice(java.lang.String);
@@ -7499,6 +7500,36 @@ package android.bluetooth.le {
    method public void stopScan(android.bluetooth.le.ScanCallback);
  }
  public abstract class PeriodicAdvertisingCallback {
    ctor public PeriodicAdvertisingCallback();
    method public void onPeriodicAdvertisingReport(android.bluetooth.le.PeriodicAdvertisingReport);
    method public void onSyncEstablished(int, android.bluetooth.BluetoothDevice, int, int, int, int);
    method public void onSyncLost(int);
    field public static final int SYNC_NO_RESOURCES = 2; // 0x2
    field public static final int SYNC_NO_RESPONSE = 1; // 0x1
  }
  public final class PeriodicAdvertisingManager {
    method public void registerSync(android.bluetooth.le.ScanResult, int, int, android.bluetooth.le.PeriodicAdvertisingCallback);
    method public void registerSync(android.bluetooth.le.ScanResult, int, int, android.bluetooth.le.PeriodicAdvertisingCallback, android.os.Handler);
    method public void unregisterSync(android.bluetooth.le.PeriodicAdvertisingCallback);
  }
  public final class PeriodicAdvertisingReport implements android.os.Parcelable {
    ctor public PeriodicAdvertisingReport(int, int, int, int, android.bluetooth.le.ScanRecord);
    method public int describeContents();
    method public android.bluetooth.le.ScanRecord getData();
    method public int getDataStatus();
    method public int getRssi();
    method public int getSyncHandle();
    method public long getTimestampNanos();
    method public int getTxPower();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.bluetooth.le.PeriodicAdvertisingReport> CREATOR;
    field public static final int DATA_COMPLETE = 0; // 0x0
    field public static final int DATA_INCOMPLETE_TRUNCATED = 2; // 0x2
  }
  public abstract class ScanCallback {
    ctor public ScanCallback();
    method public void onBatchScanResults(java.util.List<android.bluetooth.le.ScanResult>);
+26 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.annotation.SystemApi;
import android.app.ActivityThread;
import android.bluetooth.le.BluetoothLeAdvertiser;
import android.bluetooth.le.BluetoothLeScanner;
import android.bluetooth.le.PeriodicAdvertisingManager;
import android.bluetooth.le.ScanCallback;
import android.bluetooth.le.ScanFilter;
import android.bluetooth.le.ScanRecord;
@@ -525,6 +526,7 @@ public final class BluetoothAdapter {

    private static BluetoothLeScanner sBluetoothLeScanner;
    private static BluetoothLeAdvertiser sBluetoothLeAdvertiser;
    private static PeriodicAdvertisingManager sPeriodicAdvertisingManager;

    private final IBluetoothManager mManagerService;
    private IBluetooth mService;
@@ -629,6 +631,30 @@ public final class BluetoothAdapter {
        return sBluetoothLeAdvertiser;
    }

    /**
     * Returns a {@link PeriodicAdvertisingManager} object for Bluetooth LE Periodic Advertising
     * operations. Will return null if Bluetooth is turned off or if Bluetooth LE Periodic
     * Advertising is not supported on this device.
     * <p>
     * Use {@link #isLePeriodicAdvertisingSupported()} to check whether LE Periodic Advertising is
     * supported on this device before calling this method.
     */
    public PeriodicAdvertisingManager getPeriodicAdvertisingManager() {
      if (!getLeAccess())
        return null;

      if (!isLePeriodicAdvertisingSupported())
        return null;

      synchronized (mLock) {
        if (sPeriodicAdvertisingManager == null) {
          sPeriodicAdvertisingManager =
              new PeriodicAdvertisingManager(mManagerService);
        }
      }
      return sPeriodicAdvertisingManager;
    }

    /**
     * Returns a {@link BluetoothLeScanner} object for Bluetooth LE scan operations.
     */
Loading