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

Commit 5daedc1e authored by Prerepa Viswanadham's avatar Prerepa Viswanadham
Browse files

OnFound and Onlost callback integration

Change-Id: I23473b18484f041c4dd808c85bb92545a77e20c2
parent d1e941c7
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2132,5 +2132,11 @@ public final class BluetoothAdapter {
        public void onBatchScanResults(List<ScanResult> results) {
            // no op
        }

        @Override
        public void onFoundOrLost(boolean onFound, String address,int rssi,
                byte[] advData) {
            // no op
        }
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -631,6 +631,15 @@ public final class BluetoothGatt implements BluetoothProfile {
            public void onBatchScanResults(List<ScanResult> results) {
                // no op
            }

            /**
             * @hide
             */
            @Override
            public void onFoundOrLost(boolean onFound, String address, int rssi,
                    byte[] advData) {
                // no op.
            }
        };

    /*package*/ BluetoothGatt(Context context, IBluetoothGatt iGatt, BluetoothDevice device,
+2 −0
Original line number Diff line number Diff line
@@ -68,4 +68,6 @@ oneway interface IBluetoothGattCallback {
    void onMultiAdvertiseCallback(in int status);
    void onConfigureMTU(in String address, in int mtu, in int status);
    void onConnectionCongested(in String address, in boolean congested);
    void onFoundOrLost(in boolean onFound, in String address, in int rssi,
                             in byte[] advData);
}
+6 −0
Original line number Diff line number Diff line
@@ -386,6 +386,12 @@ public final class BluetoothLeAdvertiser {
        public void onBatchScanResults(List<ScanResult> results) {
            // no op
        }

        @Override
        public void onFoundOrLost(boolean onFound, String address, int rssi,
                byte[] advData) {
            // no op
        }
    }

    private void postCallbackFailure(final AdvertiseCallback callback, final int error) {
+19 −0
Original line number Diff line number Diff line
@@ -421,6 +421,25 @@ public final class BluetoothLeScanner {
        public void onConnectionCongested(String address, boolean congested) {
            // no op
        }

        @Override
        public void onFoundOrLost(boolean onFound, String address, int rssi,
                byte[] advData) {
            if (DBG) {
                Log.d(TAG, "onFoundOrLost() - Device=" + address);
            }
            // ToDo: Fix issue with underlying reporting from chipset
            BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(
                    address);
            long scanNanos = SystemClock.elapsedRealtimeNanos();
            ScanResult result = new ScanResult(device, advData, rssi,
                    scanNanos);
            if (onFound) {
                mScanCallback.onAdvertisementFound(result);
            } else {
                mScanCallback.onAdvertisementLost(result);
            }
        }
    }

    private void postCallbackError(final ScanCallback callback, final int errorCode) {
Loading