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

Commit 4ad0a983 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by android-build-merger
Browse files

Merge "Change how services are passed up to the stack" am: 2ebc12bb

am: d1ce469a

* commit 'd1ce469a':
  Change how services are passed up to the stack
parents 68f6150e d1ce469a
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -7101,9 +7101,10 @@ package android.bluetooth {
    method public void onServicesDiscovered(android.bluetooth.BluetoothGatt, int);
  }
  public class BluetoothGattCharacteristic {
  public class BluetoothGattCharacteristic implements android.os.Parcelable {
    ctor public BluetoothGattCharacteristic(java.util.UUID, int, int);
    method public boolean addDescriptor(android.bluetooth.BluetoothGattDescriptor);
    method public int describeContents();
    method public android.bluetooth.BluetoothGattDescriptor getDescriptor(java.util.UUID);
    method public java.util.List<android.bluetooth.BluetoothGattDescriptor> getDescriptors();
    method public java.lang.Float getFloatValue(int, int);
@@ -7121,6 +7122,8 @@ package android.bluetooth {
    method public boolean setValue(int, int, int, int);
    method public boolean setValue(java.lang.String);
    method public void setWriteType(int);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.bluetooth.BluetoothGattCharacteristic> CREATOR;
    field public static final int FORMAT_FLOAT = 52; // 0x34
    field public static final int FORMAT_SFLOAT = 50; // 0x32
    field public static final int FORMAT_SINT16 = 34; // 0x22
@@ -7151,13 +7154,16 @@ package android.bluetooth {
    field protected java.util.List<android.bluetooth.BluetoothGattDescriptor> mDescriptors;
  }
  public class BluetoothGattDescriptor {
  public class BluetoothGattDescriptor implements android.os.Parcelable {
    ctor public BluetoothGattDescriptor(java.util.UUID, int);
    method public int describeContents();
    method public android.bluetooth.BluetoothGattCharacteristic getCharacteristic();
    method public int getPermissions();
    method public java.util.UUID getUuid();
    method public byte[] getValue();
    method public boolean setValue(byte[]);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.bluetooth.BluetoothGattDescriptor> CREATOR;
    field public static final byte[] DISABLE_NOTIFICATION_VALUE;
    field public static final byte[] ENABLE_INDICATION_VALUE;
    field public static final byte[] ENABLE_NOTIFICATION_VALUE;
@@ -7200,16 +7206,19 @@ package android.bluetooth {
    method public void onServiceAdded(int, android.bluetooth.BluetoothGattService);
  }
  public class BluetoothGattService {
  public class BluetoothGattService implements android.os.Parcelable {
    ctor public BluetoothGattService(java.util.UUID, int);
    method public boolean addCharacteristic(android.bluetooth.BluetoothGattCharacteristic);
    method public boolean addService(android.bluetooth.BluetoothGattService);
    method public int describeContents();
    method public android.bluetooth.BluetoothGattCharacteristic getCharacteristic(java.util.UUID);
    method public java.util.List<android.bluetooth.BluetoothGattCharacteristic> getCharacteristics();
    method public java.util.List<android.bluetooth.BluetoothGattService> getIncludedServices();
    method public int getInstanceId();
    method public int getType();
    method public java.util.UUID getUuid();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.bluetooth.BluetoothGattService> CREATOR;
    field public static final int SERVICE_TYPE_PRIMARY = 0; // 0x0
    field public static final int SERVICE_TYPE_SECONDARY = 1; // 0x1
    field protected java.util.List<android.bluetooth.BluetoothGattCharacteristic> mCharacteristics;
+12 −3
Original line number Diff line number Diff line
@@ -7376,9 +7376,10 @@ package android.bluetooth {
    method public void onServicesDiscovered(android.bluetooth.BluetoothGatt, int);
  }
  public class BluetoothGattCharacteristic {
  public class BluetoothGattCharacteristic implements android.os.Parcelable {
    ctor public BluetoothGattCharacteristic(java.util.UUID, int, int);
    method public boolean addDescriptor(android.bluetooth.BluetoothGattDescriptor);
    method public int describeContents();
    method public android.bluetooth.BluetoothGattDescriptor getDescriptor(java.util.UUID);
    method public java.util.List<android.bluetooth.BluetoothGattDescriptor> getDescriptors();
    method public java.lang.Float getFloatValue(int, int);
@@ -7396,6 +7397,8 @@ package android.bluetooth {
    method public boolean setValue(int, int, int, int);
    method public boolean setValue(java.lang.String);
    method public void setWriteType(int);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.bluetooth.BluetoothGattCharacteristic> CREATOR;
    field public static final int FORMAT_FLOAT = 52; // 0x34
    field public static final int FORMAT_SFLOAT = 50; // 0x32
    field public static final int FORMAT_SINT16 = 34; // 0x22
@@ -7426,13 +7429,16 @@ package android.bluetooth {
    field protected java.util.List<android.bluetooth.BluetoothGattDescriptor> mDescriptors;
  }
  public class BluetoothGattDescriptor {
  public class BluetoothGattDescriptor implements android.os.Parcelable {
    ctor public BluetoothGattDescriptor(java.util.UUID, int);
    method public int describeContents();
    method public android.bluetooth.BluetoothGattCharacteristic getCharacteristic();
    method public int getPermissions();
    method public java.util.UUID getUuid();
    method public byte[] getValue();
    method public boolean setValue(byte[]);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.bluetooth.BluetoothGattDescriptor> CREATOR;
    field public static final byte[] DISABLE_NOTIFICATION_VALUE;
    field public static final byte[] ENABLE_INDICATION_VALUE;
    field public static final byte[] ENABLE_NOTIFICATION_VALUE;
@@ -7475,16 +7481,19 @@ package android.bluetooth {
    method public void onServiceAdded(int, android.bluetooth.BluetoothGattService);
  }
  public class BluetoothGattService {
  public class BluetoothGattService implements android.os.Parcelable {
    ctor public BluetoothGattService(java.util.UUID, int);
    method public boolean addCharacteristic(android.bluetooth.BluetoothGattCharacteristic);
    method public boolean addService(android.bluetooth.BluetoothGattService);
    method public int describeContents();
    method public android.bluetooth.BluetoothGattCharacteristic getCharacteristic(java.util.UUID);
    method public java.util.List<android.bluetooth.BluetoothGattCharacteristic> getCharacteristics();
    method public java.util.List<android.bluetooth.BluetoothGattService> getIncludedServices();
    method public int getInstanceId();
    method public int getType();
    method public java.util.UUID getUuid();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.bluetooth.BluetoothGattService> CREATOR;
    field public static final int SERVICE_TYPE_PRIMARY = 0; // 0x0
    field public static final int SERVICE_TYPE_SECONDARY = 1; // 0x1
    field protected java.util.List<android.bluetooth.BluetoothGattCharacteristic> mCharacteristics;
+27 −93
Original line number Diff line number Diff line
@@ -197,109 +197,43 @@ public final class BluetoothGatt implements BluetoothProfile {
            }

            /**
             * A new GATT service has been discovered.
             * The service is added to the internal list and the search
             * continues.
             * Remote search has been completed.
             * The internal object structure should now reflect the state
             * of the remote device database. Let the application know that
             * we are done at this point.
             * @hide
             */
            public void onGetService(String address, int srvcType,
                                     int srvcInstId, ParcelUuid srvcUuid) {
                if (VDBG) Log.d(TAG, "onGetService() - Device=" + address + " UUID=" + srvcUuid);
            public void onSearchComplete(String address, List<BluetoothGattService> services,
                                         int status) {
                if (DBG) Log.d(TAG, "onSearchComplete() = Device=" + address + " Status=" + status);
                if (!address.equals(mDevice.getAddress())) {
                    return;
                }
                mServices.add(new BluetoothGattService(mDevice, srvcUuid.getUuid(),
                                                       srvcInstId, srvcType));
            }

            /**
             * An included service has been found durig GATT discovery.
             * The included service is added to the respective parent.
             * @hide
             */
            public void onGetIncludedService(String address, int srvcType,
                                             int srvcInstId, ParcelUuid srvcUuid,
                                             int inclSrvcType, int inclSrvcInstId,
                                             ParcelUuid inclSrvcUuid) {
                if (VDBG) Log.d(TAG, "onGetIncludedService() - Device=" + address
                    + " UUID=" + srvcUuid + " Included=" + inclSrvcUuid);

                if (!address.equals(mDevice.getAddress())) {
                    return;
                for (BluetoothGattService s : services) {
                    //services we receive don't have device set properly.
                    s.setDevice(mDevice);
                }
                BluetoothGattService service = getService(mDevice,
                        srvcUuid.getUuid(), srvcInstId, srvcType);
                BluetoothGattService includedService = getService(mDevice,
                        inclSrvcUuid.getUuid(), inclSrvcInstId, inclSrvcType);

                if (service != null && includedService != null) {
                    service.addIncludedService(includedService);
                }
            }
                mServices.addAll(services);

            /**
             * A new GATT characteristic has been discovered.
             * Add the new characteristic to the relevant service and continue
             * the remote device inspection.
             * @hide
             */
            public void onGetCharacteristic(String address, int srvcType,
                             int srvcInstId, ParcelUuid srvcUuid,
                             int charInstId, ParcelUuid charUuid,
                             int charProps) {
                if (VDBG) Log.d(TAG, "onGetCharacteristic() - Device=" + address + " UUID=" +
                               charUuid);
                // Fix references to included services, as they doesn't point to right objects.
                for (BluetoothGattService fixedService : mServices) {
                    ArrayList<BluetoothGattService> includedServices =
                        new ArrayList(fixedService.getIncludedServices());
                    fixedService.getIncludedServices().clear();

                if (!address.equals(mDevice.getAddress())) {
                    return;
                    for(BluetoothGattService brokenRef : includedServices) {
                        BluetoothGattService includedService = getService(mDevice,
                            brokenRef.getUuid(), brokenRef.getInstanceId(), brokenRef.getType());
                        if (includedService != null) {
                            fixedService.addIncludedService(includedService);
                        } else {
                            Log.e(TAG, "Broken GATT database: can't find included service.");
                        }
                BluetoothGattService service = getService(mDevice, srvcUuid.getUuid(),
                                                          srvcInstId, srvcType);
                if (service != null) {
                    service.addCharacteristic(new BluetoothGattCharacteristic(
                           service, charUuid.getUuid(), charInstId, charProps, 0));
                    }
                }

            /**
             * A new GATT descriptor has been discovered.
             * Finally, add the descriptor to the related characteristic.
             * This should conclude the remote device update.
             * @hide
             */
            public void onGetDescriptor(String address, int srvcType,
                             int srvcInstId, ParcelUuid srvcUuid,
                             int charInstId, ParcelUuid charUuid,
                             int descrInstId, ParcelUuid descUuid) {
                if (VDBG) Log.d(TAG, "onGetDescriptor() - Device=" + address + " UUID=" + descUuid);

                if (!address.equals(mDevice.getAddress())) {
                    return;
                }
                BluetoothGattService service = getService(mDevice, srvcUuid.getUuid(),
                                                          srvcInstId, srvcType);
                if (service == null) return;

                BluetoothGattCharacteristic characteristic = service.getCharacteristic(
                    charUuid.getUuid(), charInstId);
                if (characteristic == null) return;

                characteristic.addDescriptor(new BluetoothGattDescriptor(
                    characteristic, descUuid.getUuid(), descrInstId, 0));
            }

            /**
             * Remote search has been completed.
             * The internal object structure should now reflect the state
             * of the remote device database. Let the application know that
             * we are done at this point.
             * @hide
             */
            public void onSearchComplete(String address, int status) {
                if (DBG) Log.d(TAG, "onSearchComplete() = Device=" + address + " Status=" + status);
                if (!address.equals(mDevice.getAddress())) {
                    return;
                }
                try {
                    mCallback.onServicesDiscovered(BluetoothGatt.this, status);
                } catch (Exception ex) {
+3 −24
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.bluetooth;

import android.bluetooth.le.AdvertiseSettings;
import android.bluetooth.le.ScanResult;
import android.bluetooth.BluetoothGattService;
import android.os.ParcelUuid;
import android.os.RemoteException;

@@ -48,30 +49,8 @@ public class BluetoothGattCallbackWrapper extends IBluetoothGattCallback.Stub {
    }

    @Override
    public void onGetService(String address, int srvcType, int srvcInstId, ParcelUuid srvcUuid)
            throws RemoteException {
    }

    @Override
    public void onGetIncludedService(String address, int srvcType, int srvcInstId,
            ParcelUuid srvcUuid, int inclSrvcType, int inclSrvcInstId, ParcelUuid inclSrvcUuid)
            throws RemoteException {
    }

    @Override
    public void onGetCharacteristic(String address, int srvcType, int srvcInstId,
            ParcelUuid srvcUuid, int charInstId, ParcelUuid charUuid, int charProps)
            throws RemoteException {
    }

    @Override
    public void onGetDescriptor(String address, int srvcType, int srvcInstId, ParcelUuid srvcUuid,
            int charInstId, ParcelUuid charUuid, int descrInstId, ParcelUuid descrUuid)
            throws RemoteException {
    }

    @Override
    public void onSearchComplete(String address, int status) throws RemoteException {
    public void onSearchComplete(String address, List<BluetoothGattService> services,
            int status) throws RemoteException {
    }

    @Override
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.bluetooth;

parcelable BluetoothGattCharacteristic;
Loading