[nearby] Sync discoveryTimestamp field name am: 64e14583cc am: 704ca5c767
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2871219 Change-Id: I75d8f9c9aad7f5feac6c90878c0d5545519a8460 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -20,6 +20,9 @@ import static android.nearby.ScanRequest.SCAN_TYPE_NEARBY_PRESENCE;
|
|||||||
|
|
||||||
import static com.android.server.nearby.NearbyService.TAG;
|
import static com.android.server.nearby.NearbyService.TAG;
|
||||||
|
|
||||||
|
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||||
|
import static java.util.concurrent.TimeUnit.NANOSECONDS;
|
||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -350,9 +353,10 @@ public class ChreDiscoveryProvider extends AbstractDiscoveryProvider {
|
|||||||
DataElement.DataType.ACTION,
|
DataElement.DataType.ACTION,
|
||||||
new byte[]{(byte) filterResult.getIntent()}));
|
new byte[]{(byte) filterResult.getIntent()}));
|
||||||
}
|
}
|
||||||
if (filterResult.hasDiscoveryTimestamp()) {
|
if (filterResult.hasTimestampNs()) {
|
||||||
presenceDeviceBuilder.setDiscoveryTimestampMillis(
|
presenceDeviceBuilder
|
||||||
filterResult.getDiscoveryTimestamp());
|
.setDiscoveryTimestampMillis(MILLISECONDS.convert(
|
||||||
|
filterResult.getTimestampNs(), NANOSECONDS));
|
||||||
}
|
}
|
||||||
PublicCredential publicCredential =
|
PublicCredential publicCredential =
|
||||||
new PublicCredential.Builder(
|
new PublicCredential.Builder(
|
||||||
|
|||||||
@@ -115,7 +115,9 @@ message BleFilterResult {
|
|||||||
repeated DataElement data_element = 7;
|
repeated DataElement data_element = 7;
|
||||||
optional bytes ble_service_data = 8;
|
optional bytes ble_service_data = 8;
|
||||||
optional ResultType result_type = 9;
|
optional ResultType result_type = 9;
|
||||||
optional uint64 discovery_timestamp = 10; // Timestamp when the device is discovered.
|
// Timestamp when the device is discovered, in nanoseconds,
|
||||||
|
// relative to Android SystemClock.elapsedRealtimeNanos().
|
||||||
|
optional uint64 timestamp_ns = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
message BleFilterResults {
|
message BleFilterResults {
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ public class ChreDiscoveryProviderTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SdkSuppress(minSdkVersion = 32, codeName = "T")
|
@SdkSuppress(minSdkVersion = 32, codeName = "T")
|
||||||
public void testOnNearbyDeviceDiscoveredWithDataElements() {
|
public void testOnNearbyDeviceDiscoveredWithDataElements_TIME() {
|
||||||
// Disables the setting of test app support
|
// Disables the setting of test app support
|
||||||
boolean isSupportedTestApp = getDeviceConfigBoolean(
|
boolean isSupportedTestApp = getDeviceConfigBoolean(
|
||||||
NEARBY_SUPPORT_TEST_APP, false /* defaultValue */);
|
NEARBY_SUPPORT_TEST_APP, false /* defaultValue */);
|
||||||
@@ -209,6 +209,7 @@ public class ChreDiscoveryProviderTest {
|
|||||||
// First byte is length of service data, padding zeros should be thrown away.
|
// First byte is length of service data, padding zeros should be thrown away.
|
||||||
final byte [] bleServiceData = new byte[] {5, 1, 2, 3, 4, 5, 0, 0, 0, 0};
|
final byte [] bleServiceData = new byte[] {5, 1, 2, 3, 4, 5, 0, 0, 0, 0};
|
||||||
final byte [] testData = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
final byte [] testData = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||||
|
final long timestampNs = 1697765417070000000L;
|
||||||
|
|
||||||
final List<DataElement> expectedExtendedProperties = new ArrayList<>();
|
final List<DataElement> expectedExtendedProperties = new ArrayList<>();
|
||||||
expectedExtendedProperties.add(new DataElement(DATA_TYPE_CONNECTION_STATUS_KEY,
|
expectedExtendedProperties.add(new DataElement(DATA_TYPE_CONNECTION_STATUS_KEY,
|
||||||
@@ -262,7 +263,7 @@ public class ChreDiscoveryProviderTest {
|
|||||||
.setValue(ByteString.copyFrom(testData))
|
.setValue(ByteString.copyFrom(testData))
|
||||||
.setValueLength(testData.length)
|
.setValueLength(testData.length)
|
||||||
)
|
)
|
||||||
.setDiscoveryTimestamp(1697765417070L)
|
.setTimestampNs(timestampNs)
|
||||||
.build();
|
.build();
|
||||||
Blefilter.BleFilterResults results =
|
Blefilter.BleFilterResults results =
|
||||||
Blefilter.BleFilterResults.newBuilder().addResult(result).build();
|
Blefilter.BleFilterResults.newBuilder().addResult(result).build();
|
||||||
@@ -286,6 +287,9 @@ public class ChreDiscoveryProviderTest {
|
|||||||
DeviceConfig.setProperty(NAMESPACE, NEARBY_SUPPORT_TEST_APP, "true", false);
|
DeviceConfig.setProperty(NAMESPACE, NEARBY_SUPPORT_TEST_APP, "true", false);
|
||||||
assertThat(new NearbyConfiguration().isTestAppSupported()).isTrue();
|
assertThat(new NearbyConfiguration().isTestAppSupported()).isTrue();
|
||||||
}
|
}
|
||||||
|
// Nanoseconds to Milliseconds
|
||||||
|
assertThat((mNearbyDevice.getValue().getPresenceDevice())
|
||||||
|
.getDiscoveryTimestampMillis()).isEqualTo(timestampNs / 1000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user