am 94294b1c: am 33813e73: am 2792be93: OnLost/OnFound integration - onfound match is done in framework, whereas hw signal is used to report onlost.

* commit '94294b1cbf1db48cc7ed24d6aa5c2274ce1cebc1':
  OnLost/OnFound integration - onfound match is done in framework, whereas hw signal is used to report onlost.
This commit is contained in:
Prerepa Viswanadham
2014-08-08 02:22:38 +00:00
committed by Android Git Automerger
3 changed files with 20 additions and 17 deletions

View File

@@ -124,8 +124,7 @@ public class BluetoothGattCallbackWrapper extends IBluetoothGattCallback.Stub {
}
@Override
public void onFoundOrLost(boolean onFound, String address, int rssi, byte[] advData)
throws RemoteException {
public void onFoundOrLost(boolean onFound, ScanResult scanResult) throws RemoteException {
}
}

View File

@@ -69,6 +69,5 @@ oneway interface IBluetoothGattCallback {
in AdvertiseSettings advertiseSettings);
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);
void onFoundOrLost(in boolean onFound, in ScanResult scanResult);
}

View File

@@ -322,22 +322,27 @@ public final class BluetoothLeScanner {
}
@Override
public void onFoundOrLost(boolean onFound, String address, int rssi,
byte[] advData) {
public void onFoundOrLost(final boolean onFound, final ScanResult scanResult) {
if (DBG) {
Log.d(TAG, "onFoundOrLost() - Device=" + address);
Log.d(TAG, "onFoundOrLost() - onFound = " + onFound +
" " + scanResult.toString());
}
// ToDo: Fix issue with underlying reporting from chipset
BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(
address);
long scanNanos = SystemClock.elapsedRealtimeNanos();
ScanResult result = new ScanResult(device, ScanRecord.parseFromBytes(advData), rssi,
scanNanos);
if (onFound) {
mScanCallback.onScanResult(ScanSettings.CALLBACK_TYPE_FIRST_MATCH, result);
} else {
mScanCallback.onScanResult(ScanSettings.CALLBACK_TYPE_MATCH_LOST, result);
// Check null in case the scan has been stopped
synchronized (this) {
if (mClientIf <= 0) return;
}
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
if (onFound) {
mScanCallback.onScanResult(ScanSettings.CALLBACK_TYPE_FIRST_MATCH, scanResult);
} else {
mScanCallback.onScanResult(ScanSettings.CALLBACK_TYPE_MATCH_LOST, scanResult);
}
}
});
}
}