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

Commit 0b2a78a8 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Bluetooth 5 feature check implementation (3/3)

Wire the new feature check API to actual values received from the
controller.

Test: manual
Bug: 30622771
Change-Id: I0812ed3ed8e28b8be34090ffb09c27d7a6405b8b
parent d4e63485
Loading
Loading
Loading
Loading
+36 −0
Original line number Original line Diff line number Diff line
@@ -78,6 +78,10 @@ class AdapterProperties {
    private boolean mIsExtendedScanSupported;
    private boolean mIsExtendedScanSupported;
    private boolean mIsDebugLogSupported;
    private boolean mIsDebugLogSupported;
    private boolean mIsActivityAndEnergyReporting;
    private boolean mIsActivityAndEnergyReporting;
    private boolean mIsLe2MPhySupported;
    private boolean mIsLeCodedPhySupported;
    private boolean mIsLeExtendedAdvertisingSupported;
    private boolean mIsLePeriodicAdvertisingSupported;


    private BroadcastReceiver mReceiver = new BroadcastReceiver() {
    private BroadcastReceiver mReceiver = new BroadcastReceiver() {
        @Override
        @Override
@@ -280,6 +284,34 @@ class AdapterProperties {
        return mIsActivityAndEnergyReporting;
        return mIsActivityAndEnergyReporting;
    }
    }


    /**
     * @return the mIsLe2MPhySupported
     */
    boolean isLe2MPhySupported() {
        return mIsLe2MPhySupported;
    }

    /**
     * @return the mIsLeCodedPhySupported
     */
    boolean isLeCodedPhySupported() {
        return mIsLeCodedPhySupported;
    }

    /**
     * @return the mIsLeExtendedAdvertisingSupported
     */
    boolean isLeExtendedAdvertisingSupported() {
        return mIsLeExtendedAdvertisingSupported;
    }

    /**
     * @return the mIsLePeriodicAdvertisingSupported
     */
    boolean isLePeriodicAdvertisingSupported() {
        return mIsLePeriodicAdvertisingSupported;
    }

    /**
    /**
     * @return total number of trackable advertisements
     * @return total number of trackable advertisements
     */
     */
@@ -593,6 +625,10 @@ class AdapterProperties {
                            + (0xFF & ((int)val[10]));
                            + (0xFF & ((int)val[10]));
        mIsExtendedScanSupported = ((0xFF & ((int)val[12])) != 0);
        mIsExtendedScanSupported = ((0xFF & ((int)val[12])) != 0);
        mIsDebugLogSupported = ((0xFF & ((int)val[13])) != 0);
        mIsDebugLogSupported = ((0xFF & ((int)val[13])) != 0);
        mIsLe2MPhySupported = ((0xFF & ((int) val[14])) != 0);
        mIsLeCodedPhySupported = ((0xFF & ((int) val[15])) != 0);
        mIsLeExtendedAdvertisingSupported = ((0xFF & ((int) val[16])) != 0);
        mIsLePeriodicAdvertisingSupported = ((0xFF & ((int) val[17])) != 0);


        Log.d(TAG, "BT_PROPERTY_LOCAL_LE_FEATURES: update from BT controller"
        Log.d(TAG, "BT_PROPERTY_LOCAL_LE_FEATURES: update from BT controller"
                + " mNumOfAdvertisementInstancesSupported = "
                + " mNumOfAdvertisementInstancesSupported = "
+32 −4
Original line number Original line Diff line number Diff line
@@ -1333,19 +1333,27 @@ public class AdapterService extends Service {
         }
         }


         public boolean isLe2MPhySupported() {
         public boolean isLe2MPhySupported() {
             return false;
             AdapterService service = getService();
             if (service == null) return false;
             return service.isLe2MPhySupported();
         }
         }


         public boolean isLeCodedPhySupported() {
         public boolean isLeCodedPhySupported() {
             return false;
             AdapterService service = getService();
             if (service == null) return false;
             return service.isLeCodedPhySupported();
         }
         }


         public boolean isLeExtendedAdvertisingSupported() {
         public boolean isLeExtendedAdvertisingSupported() {
             return false;
             AdapterService service = getService();
             if (service == null) return false;
             return service.isLeExtendedAdvertisingSupported();
         }
         }


         public boolean isLePeriodicAdvertisingSupported() {
         public boolean isLePeriodicAdvertisingSupported() {
             return false;
             AdapterService service = getService();
             if (service == null) return false;
             return service.isLePeriodicAdvertisingSupported();
         }
         }


         public boolean isActivityAndEnergyReportingSupported() {
         public boolean isActivityAndEnergyReportingSupported() {
@@ -1895,6 +1903,26 @@ public class AdapterService extends Service {
        return mAdapterProperties.isActivityAndEnergyReportingSupported();
        return mAdapterProperties.isActivityAndEnergyReportingSupported();
    }
    }


    public boolean isLe2MPhySupported() {
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        return mAdapterProperties.isLe2MPhySupported();
    }

    public boolean isLeCodedPhySupported() {
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        return mAdapterProperties.isLeCodedPhySupported();
    }

    public boolean isLeExtendedAdvertisingSupported() {
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        return mAdapterProperties.isLeExtendedAdvertisingSupported();
    }

    public boolean isLePeriodicAdvertisingSupported() {
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        return mAdapterProperties.isLePeriodicAdvertisingSupported();
    }

    private BluetoothActivityEnergyInfo reportActivityInfo() {
    private BluetoothActivityEnergyInfo reportActivityInfo() {
        enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, "Need BLUETOOTH permission");
        enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, "Need BLUETOOTH permission");
        if (mAdapterProperties.getState() != BluetoothAdapter.STATE_ON ||
        if (mAdapterProperties.getState() != BluetoothAdapter.STATE_ON ||