[NearbyManager] Do not call back for null result

Test: -m
Fix: 260002423
Ignore-AOSP-First: nearby_not_in_aosp_yet
Change-Id: I195c17c54cff9cd7d31db0f4838175e3d861c2f8
This commit is contained in:
Xinyi Zhou 2022-11-22 16:40:46 -08:00
commit 7c97969baa

View file

@ -103,6 +103,7 @@ public class NearbyManager {
mService = service;
}
@Nullable
private static NearbyDevice toClientNearbyDevice(
NearbyDeviceParcelable nearbyDeviceParcelable,
@ScanRequest.ScanType int scanType) {
@ -328,9 +329,9 @@ public class NearbyManager {
public void onDiscovered(NearbyDeviceParcelable nearbyDeviceParcelable)
throws RemoteException {
mExecutor.execute(() -> {
if (mScanCallback != null) {
mScanCallback.onDiscovered(
toClientNearbyDevice(nearbyDeviceParcelable, mScanType));
NearbyDevice nearbyDevice = toClientNearbyDevice(nearbyDeviceParcelable, mScanType);
if (mScanCallback != null && nearbyDevice != null) {
mScanCallback.onDiscovered(nearbyDevice);
}
});
}
@ -339,7 +340,8 @@ public class NearbyManager {
public void onUpdated(NearbyDeviceParcelable nearbyDeviceParcelable)
throws RemoteException {
mExecutor.execute(() -> {
if (mScanCallback != null) {
NearbyDevice nearbyDevice = toClientNearbyDevice(nearbyDeviceParcelable, mScanType);
if (mScanCallback != null && nearbyDevice != null) {
mScanCallback.onUpdated(
toClientNearbyDevice(nearbyDeviceParcelable, mScanType));
}
@ -349,7 +351,8 @@ public class NearbyManager {
@Override
public void onLost(NearbyDeviceParcelable nearbyDeviceParcelable) throws RemoteException {
mExecutor.execute(() -> {
if (mScanCallback != null) {
NearbyDevice nearbyDevice = toClientNearbyDevice(nearbyDeviceParcelable, mScanType);
if (mScanCallback != null && nearbyDevice != null) {
mScanCallback.onLost(
toClientNearbyDevice(nearbyDeviceParcelable, mScanType));
}