Merge "Add fast pair upload footprint entry"
diff --git a/nearby/README.md b/nearby/README.md
index 59d8082..da70819 100644
--- a/nearby/README.md
+++ b/nearby/README.md
@@ -33,7 +33,10 @@
## Build and Install
```sh
-$ source build/envsetup.sh && lunch <TARGE>
-$ mmm -j packages/modules/Nearby/
-$ adb install -r {ANDROID_PRODUCT_OUT}/system/apex/com.android.nearby.apex
+$ source build/envsetup.sh && lunch <TARGET>
+$ m com.android.tethering deapexer
+$ $ANDROID_BUILD_TOP/out/host/linux-x86/bin/deapexer decompress --input \
+ {ANDROID_PRODUCT_OUT}/system/apex/com.android.tethering.capex --output \
+ /tmp/tethering.apex
+$ adb install -r /tmp/tethering.apex
```
diff --git a/nearby/apex/Android.bp b/nearby/apex/Android.bp
index b277ac4..d7f063a 100644
--- a/nearby/apex/Android.bp
+++ b/nearby/apex/Android.bp
@@ -15,63 +15,7 @@
default_applicable_licenses: ["Android-Apache-2.0"],
}
-apex_key {
- name: "com.android.nearby.key",
- public_key: "com.android.nearby.avbpubkey",
- private_key: "com.android.nearby.pem",
-}
-
-android_app_certificate {
- name: "com.android.nearby.certificate",
- certificate: "com.android.nearby",
-}
-
-apex {
- name: "com.android.nearby",
- manifest: "manifest.json",
- // TODO(b/189890387): change the SDK version to "32" when T release is finalized.
- min_sdk_version: "current",
- updatable: true,
- file_contexts: ":apex.test-file_contexts", // Default, please edit, see go/android-apex-howto
- key: "com.android.nearby.key",
- certificate: ":com.android.nearby.certificate",
-
- bootclasspath_fragments: ["com.android.nearby-bootclasspath-fragment"],
- java_libs: [
- "service-nearby",
- ],
- apps: ["HalfSheetUX"],
-}
-
filegroup {
name: "nearby-jarjar-rules",
srcs: ["jarjar-rules.txt"],
}
-
-sdk {
- name: "nearby-module-sdk",
- java_sdk_libs: [
- "framework-nearby",
- ],
-}
-
-// Encapsulate the contributions made by the com.android.nearby to the bootclasspath.
-bootclasspath_fragment {
- name: "com.android.nearby-bootclasspath-fragment",
- contents: ["framework-nearby"],
- apex_available: ["com.android.nearby"],
-
- // The bootclasspath_fragments that provide APIs on which this depends.
- fragments: [
- {
- apex: "com.android.art",
- module: "art-bootclasspath-fragment",
- },
- ],
-
- // Additional stubs libraries that this fragment's contents use which are
- // not provided by another bootclasspath_fragment.
- additional_stubs: [
- "android-non-updatable",
- ],
-}
diff --git a/nearby/apex/com.android.nearby.avbpubkey b/nearby/apex/com.android.nearby.avbpubkey
deleted file mode 100644
index b6acf05..0000000
--- a/nearby/apex/com.android.nearby.avbpubkey
+++ /dev/null
Binary files differ
diff --git a/nearby/apex/com.android.nearby.pem b/nearby/apex/com.android.nearby.pem
deleted file mode 100644
index 2cc306c..0000000
--- a/nearby/apex/com.android.nearby.pem
+++ /dev/null
@@ -1,51 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIJKAIBAAKCAgEAtC8og8odwK2ZOudnFk/7J5z4gGVL1TTkw1Y/tKfpQPstBFqz
-HKVre+Xe439FLsFBxNreos7o8AeyRdn0LbsfPlXarSE7WyrWnXMf172PZ38KiEzv
-WaidlwJh8aUcz8aosY2IYK8WxGvGt97aOfq3BFxLhAYJQFcKq/hjbvR4lJ4K/1xH
-1xhlel6CHr/DR57ZC1H/cN8GfuBxxt/rHRelzam30D2j0FU6w63IS8fOf05qXfXx
-cCrN2DSSFe1IzsSjqxqizhTy9XiEP75jVq5lVBfvhs0XReZk+MPrzBAM1tmy4sm9
-t1uY+7FQ3wdBRtlBH7tZB21b4SsvSZSePTDCdEiq6rUQETMrw7Z84WKxnEOUIkl5
-v6B3t9Nn4r2u2OJw62/zCl3XsoLzWS7egiG1v1fZvFp8V7I/byY+wE3M8GzflU8L
-UmL6oi1UUCOLSp66yWFFC7GsmVOa9d9Pe4iCEgpTI81qzRGJR37Ds48N7FR3Ce4A
-MzysR85dB470jm5ZfnRr3wSMGyB8CribKa0nRYjYY5UamYOvIK+p71JfhI8IW9Xn
-xYI3wfaLotzQSVZqN7k1HnDHKiYNrDhluWhwy7muWfobiyuyw3s1rbY1kKX30g6b
-KkwPPTNQjiVVMaocz1RsLuKeG12ybiGMlghjqiDcHUg6Po+W9HyxDzfog0sCAwEA
-AQKCAgBu7OFKUPGEHttIchD6oX6C4pXxpWrL9OYogz5w3zYv9PG/zn6Z0hSbj+Zp
-s35JzFvK7ttE65BnxLUxX359cMdJPt2C3ASImZTKFYey71YLZyB6zLJFRhLOVn8p
-nnZgS3Kq6/DbZK7leVw68gzyyLBHFPLAcl7bpzpAqIe+VO6uv6URlCP9/Vzruqbs
-ey2jN91ypKZXPFXpYg9pWYyKunYuaJ9qqafhp7anpKK8VGOB6Cp/cduTLCbRRXvx
-18SM1m3T9m/n4um3yNvRykmpoW9sF9gz6qq7M51RsHvHgtIEqrz/9SbAbLl/qaeZ
-xgOftDvtZw7mDaMUudtAtye7j/sFRryGoaN/pBNUogC6k9KpIfVC9X6bUsGYrLNr
-w8B6vt89jeP1L6hLAgeW9YxZpOzfnmRz8bKW+gtQl3vSuN6Pzl+NHGXSXqKNviIR
-m69MHM5SIlNWzVmm1Jq+GfgsiL+fUpxa5GL1b3COMATm3WiNfdSJ2MnslY6oMoYT
-leruOBTnKaReMjhyJ2JgYqV7X8ajBCJXhXztwrD2QtGwOWi5ZubukT8RI0QbeTE8
-N3lbx8owXQus+O/R+AoB71X0c/x+x47Z1u192ENhKYjb0ur3+UbqMYdPH1LVqMPW
-FvCyPunEa8kb9T1Lu0lUtwqNps9pCyOO5gE4GLZ/VIKHnPK80QKCAQEA4ZgszIrt
-mxGj5mduAFQPIj4knFVfKv7AL5FwCMOIpaKxnMavFma1YnvgAOViixhhl52/B7pQ
-a+xoqAsGERHMF5z+ADYrV8d655IyiGwUmIbR/OtvzBcNsJ1XRCvStOWvH4qOMA+F
-8Ce8gy0iEro23PpEAOAPhyd0jOoWdkfkN1LsUSA0UTnqaE511t+G90qb1eJ7KfHi
-sqZxjSUbB20yp9XipX/DkIMD/sQAknvsXDyIeysJs516nBIm7+mc44iHGMfqQ1eo
-ISk8uS16Uxf3VkGbT9MEbquASh4z7mU4YCFM1+hhPKXMS3E8LJgAVIPhfbxZtuNc
-+285nr2Tm5OldwKCAQEAzHgqiR016+ozk2P2JA+tkAFAoAxs1f0ThL77G0brySjb
-VsYnwll7dL0cbqJdi/Bemxbuk4aFB+Yz3kB0WQWnmEgDVxaKV4aTmsi0Gdc++53Z
-AepO+hn0RBiLMrjrNA4+IG1bhtuTw6Ar6qcI3FUPnZ8Qb1QpJM3lqWSWo/WLRQ3P
-H6gNfXwqzo9suTBCN/ZOCFtx0RjHq+xQvw2cUmcDnpTgdgb2hVYUuQWq48uRNzS6
-BW2SggV2SBUQ9Lrg7R0KuQBQygu/Kt043AjAH4w9RIArZbmWjM6SG/x22f06QLSw
-lIPbD0c5Js5cer2OOCz99UOdFL73PctexIIRykfVzQKCAQAQcZAqZKIHIJUK0VUy
-Tu4/d7ohbxOdxa3qibZZ3S7Tq/U4UT8n6dqk0BS23AF/1AohDA2Fma4M/9FtFkid
-6+ctfXMCPvCP2Gl8AasPSJmDuKgLwHmIrdGAoydeP7d/GhLWwLm2hRslMzBJe3u1
-U792AgP88FgRaO3U66cxffIDmlbBXxCRLyCH89ghDm//DIApafXCS/BTR1CVkjPT
-KcF8fFml6JcvrG0ZH95OzxueaYclOzDc18i9IZGXATc/Wo9GXiQUPopxyFi1wrvc
-3K1ZqzSP7/itvHCAdo0gfl5Km4LHZhfYXNl0Uk+pjHbRsj84dAcyDoaTiTrw+C6P
-M4bnAoIBAQC7c0b7oQ34FCPocfIMKVti8+L9V6bHn1Yvkq6+2Qv8xTogmVWF9Wcb
-JOxV+QBt9JWm9SUPlnmLPl462ThRDMAS+aImSwHVMAlOE8YZEp4pKxLxkI+K9hRc
-AWxLuf/XH1+RdvA7+D3FUKgyXaPf6xN/233DspJtrV1pKFB6S/e7/ObwDK8hZZ4Q
-9KgmNrneeC4dt0fm/CLB2MpF/QJdARfuYGpPih6jKsGgxjNe1xdwVyRbKZLxJHTF
-rJp44oKmnsNfy4xFTvOZJmqkPll0Eqtwi1g90CDXQeHtSkzjmCW5gG2KGj/QB+m7
-S+C4neMuWQERw0TU6iXcPv/Ig74vhh/ZAoIBACWJjQSeO5bOhp1wbskooEykpDEw
-WlvF3GunFjBUOvXUnW11lHuS5sPiHtAYk6O+la1PbTayMvQp0mIIjpBBW2wXtn+o
-E6AspIwV9CVAhAs3icpmslYnr+dvfCOX7YDAgrgggSX64uepAVBZcMHeXBdXylqk
-/Dz9AXTDSjCesNL8LtMedmWmvr0NfDnYpN9XokEXjZMd/0wXEM+6ghKiGD4Bt53A
-C1g+rT68cEaz40KTHS3xN04EcwPAcTkyVNkva0qp65TFMQ5gXxbij2fzeow4KhVJ
-LqEBrNBaSWfe15oIGaW39I77CP2BbeB+wOjp2XJDjKIUJUQSzna451FiEpg=
------END RSA PRIVATE KEY-----
diff --git a/nearby/apex/com.android.nearby.pk8 b/nearby/apex/com.android.nearby.pk8
deleted file mode 100644
index 3ed4094..0000000
--- a/nearby/apex/com.android.nearby.pk8
+++ /dev/null
Binary files differ
diff --git a/nearby/apex/com.android.nearby.x509.pem b/nearby/apex/com.android.nearby.x509.pem
deleted file mode 100644
index 56388e7..0000000
--- a/nearby/apex/com.android.nearby.x509.pem
+++ /dev/null
@@ -1,33 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIFyTCCA7ECFEspssWJX+AMgDetCBZCRSwjPYlpMA0GCSqGSIb3DQEBCwUAMIGf
-MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91
-bnRhaW4gVmlldzEQMA4GA1UECgwHQW5kcm9pZDEQMA4GA1UECwwHQW5kcm9pZDEi
-MCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTEbMBkGA1UEAwwSY29t
-LmFuZHJvaWQubmVhcmJ5MCAXDTIxMDYwMTIzNTQwNVoYDzQ3NTkwNDI4MjM1NDA1
-WjCBnzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcM
-DU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB0FuZHJvaWQxEDAOBgNVBAsMB0FuZHJv
-aWQxIjAgBgkqhkiG9w0BCQEWE2FuZHJvaWRAYW5kcm9pZC5jb20xGzAZBgNVBAMM
-EmNvbS5hbmRyb2lkLm5lYXJieTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
-ggIBAMBBi6RNxCWMsRg56D4lZYGHNDW7pRFZG1Tya2pROBt3yta4EWuziXIv+MuX
-BBimIy1KKhx3eYOsxeS2YucrPn9HSTTya9jDxAzjJInGCgzp0XC1eNQlpMcMZAnG
-vTcwWbXariOLu5dcnPJvBl4N2SdhjfsSMptdLXe+wMxrKZfkLEW9GvK02vduahk0
-ttO92eY/dhaWxVPLnuEAWo7zMG0oF9AsichykOdS/QB6R5tmtmVOy3oC/FBodiOF
-ZTvW0WRPoFZlHruL2JnpFF6n4c8eGTFd4Ux7maM/K7qlzeUZLJdrahdPaOAOAmyR
-RZd22QlzMQ6DRKgzceQ2CknglFUZRE+b/nxO9anbDGQ1piiBzaqAUZi1JS79ujA5
-UugLVznM+Q2yaz2FElW5UrT1ZmSisN5KXv/Bx37UXmc8ATzwKSrl2uJB1UqBaSlT
-rThPonoUhaRQHxqA/O/aFTEFK+jSyCA+/K9gVZQIgWF14bQBs+ZMNXa3gvJzW/aI
-gBM+9yvr94VIN0/fE7dof3ggPUPkAccVvYm3vky5x4dpOF10JCCC9cyiJYZ9GUnI
-9hbncYbLrWJmW3V7j99x1bnwL6JsjKAIfXOjTPTw1Su+hDA0qixqLeGdFzIoGOnm
-DkX0ev/FM8tb4ZrFWxKoFOByJFSDD6X671HWt0D34SevujK/AgMBAAEwDQYJKoZI
-hvcNAQELBQADggIBAEWNKZ/PTc9eZ+hhOI9oCLIa4rbdGu9Sd6Iu2TESNoesOup6
-+sRZ1VqpvcPNnNiRq8XyQh0kFR5Hm6W18BZ6AIawUWDx0syCQlflFzsbQSSqkAxg
-O4EGcvZfGwISy+JGY5FbeZ6JmispV5OhK0X2Qp3svCXDJdIh7BIB/kLUvGSCiRJy
-9Ct6X0Ol5fPQo8CvyDz7eDquEIj04QBwqgTEJIk5qmtPvJTRA0mI7/irfjAoyQTh
-LF2LRGHnwOLfLblKrQ4eohQgWNleIF25dN14Lfir61gr/04fIJYANUUK3Wsb1p/T
-8TjWaxlYNy+VsY74LxUs/hGUEzJbr4iPJAXV1AzySkWxgLcJK453fJDSfAlkE0pr
-a2jYdETF382FM7j/XIZvWrb8ercALGTvA6FwRkqqJVVugl+Im27H/ohEIEW7Qv97
-yMu5Hh+K40PQsmp9DgmgEw/9OD5mTVSXeh/BbaPc8UZWZPCe6EbRC8QKRiPolj8Y
-AjLQBX1WNmVIObVlSuM9JvFgHzs4ddQn52uelJieNfG7GXZyHN/xiKsoPbin1H/y
-YrT8y4e1CvJ6Cm38QgteTdAnmvOFjobuf7/DFmw32ev268/GiDLQ4S8Shi4bPWwA
-oIf5w+Wbx90HpnAIxKx+SxwnRCbDSnnuEu72OPa2LLAlWJx5O1Bb3M0qQMba
------END CERTIFICATE-----
diff --git a/nearby/framework/Android.bp b/nearby/framework/Android.bp
index fd7f2c9..ec854df 100644
--- a/nearby/framework/Android.bp
+++ b/nearby/framework/Android.bp
@@ -16,6 +16,8 @@
default_applicable_licenses: ["Android-Apache-2.0"],
}
+// Sources included in the framework-connectivity-t jar
+// TODO: consider moving files to packages/modules/Connectivity
filegroup {
name: "framework-nearby-java-sources",
srcs: [
@@ -23,7 +25,9 @@
"java/**/*.aidl",
],
path: "java",
- visibility: ["//visibility:private"],
+ visibility: [
+ "//packages/modules/Connectivity/framework-t:__subpackages__",
+ ],
}
filegroup {
@@ -34,69 +38,18 @@
visibility: ["//frameworks/base"],
}
-// Defaults shared between `framework-nearby` & `framework-nearby-pre-jarjar`
-java_defaults {
- name: "framework-nearby-defaults",
- defaults: ["nearby-module-sdk-version-defaults"],
- srcs: [
- ":framework-nearby-java-sources",
- ],
- static_libs: [
- "modules-utils-preconditions",
- ],
-}
-
-// Defaults for SDK versions.
-java_defaults {
- name: "nearby-module-sdk-version-defaults",
- min_sdk_version: "current",
- target_sdk_version: "current",
-}
-
-// Nearby-service needs pre-jarjared version of framework-nearby so it can reference copied utility
-// classes before they are renamed.
+// Build of only framework-nearby (not as part of connectivity) for
+// unit tests
java_library {
- name: "framework-nearby-pre-jarjar",
- defaults: ["framework-nearby-defaults"],
+ name: "framework-nearby-static",
+ srcs: [":framework-nearby-java-sources"],
sdk_version: "module_current",
libs: [
"framework-annotations-lib",
"framework-bluetooth",
],
- // java_api_finder must accompany `srcs` (`srcs` defined in `framework-nearby-defaults`)
- plugins: ["java_api_finder"],
- installable: false,
- visibility: [
- "//packages/modules/Nearby/service",
- "//packages/modules/Nearby/halfsheet",
- "//packages/modules/Nearby/tests:__subpackages__",
+ static_libs: [
+ "modules-utils-preconditions",
],
-}
-
-// SDK library for nearby module API.
-java_sdk_library {
- name: "framework-nearby",
- defaults: [
- "framework-module-defaults", // the SDK needs to be usable in all processes
- "framework-nearby-defaults",
- ],
- libs: ["framework-bluetooth"],
-
- jarjar_rules: ":nearby-jarjar-rules",
- apex_available: [
- "com.android.nearby",
- ],
- installable: true,
- optimize: {
- enabled: false
- },
-
- // Restrict access to implementation library.
- impl_library_visibility: [
- "//packages/modules/Nearby/service:__subpackages__",
- ],
- permitted_packages: [
- "android.nearby",
- "com.android.nearby",
- ],
+ visibility: ["//packages/modules/Nearby/tests:__subpackages__"],
}
diff --git a/nearby/framework/api/current.txt b/nearby/framework/api/current.txt
deleted file mode 100644
index d802177..0000000
--- a/nearby/framework/api/current.txt
+++ /dev/null
@@ -1 +0,0 @@
-// Signature format: 2.0
diff --git a/nearby/framework/api/module-lib-current.txt b/nearby/framework/api/module-lib-current.txt
deleted file mode 100644
index d802177..0000000
--- a/nearby/framework/api/module-lib-current.txt
+++ /dev/null
@@ -1 +0,0 @@
-// Signature format: 2.0
diff --git a/nearby/framework/api/module-lib-removed.txt b/nearby/framework/api/module-lib-removed.txt
deleted file mode 100644
index d802177..0000000
--- a/nearby/framework/api/module-lib-removed.txt
+++ /dev/null
@@ -1 +0,0 @@
-// Signature format: 2.0
diff --git a/nearby/framework/api/removed.txt b/nearby/framework/api/removed.txt
deleted file mode 100644
index d802177..0000000
--- a/nearby/framework/api/removed.txt
+++ /dev/null
@@ -1 +0,0 @@
-// Signature format: 2.0
diff --git a/nearby/framework/api/system-current.txt b/nearby/framework/api/system-current.txt
deleted file mode 100644
index 6666c8d..0000000
--- a/nearby/framework/api/system-current.txt
+++ /dev/null
@@ -1,315 +0,0 @@
-// Signature format: 2.0
-package android.nearby {
-
- public class FastPairAccountKeyDeviceMetadata {
- method @Nullable public byte[] getAccountKey();
- method @Nullable public android.nearby.FastPairDeviceMetadata getFastPairDeviceMetadata();
- method @Nullable public android.nearby.FastPairDiscoveryItem getFastPairDiscoveryItem();
- method @Nullable public byte[] getSha256AccountKeyPublicAddress();
- }
-
- public static final class FastPairAccountKeyDeviceMetadata.Builder {
- ctor public FastPairAccountKeyDeviceMetadata.Builder();
- method @NonNull public android.nearby.FastPairAccountKeyDeviceMetadata build();
- method @NonNull public android.nearby.FastPairAccountKeyDeviceMetadata.Builder setAccountKey(@Nullable byte[]);
- method @NonNull public android.nearby.FastPairAccountKeyDeviceMetadata.Builder setFastPairDeviceMetadata(@Nullable android.nearby.FastPairDeviceMetadata);
- method @NonNull public android.nearby.FastPairAccountKeyDeviceMetadata.Builder setFastPairDiscoveryItem(@Nullable android.nearby.FastPairDiscoveryItem);
- method @NonNull public android.nearby.FastPairAccountKeyDeviceMetadata.Builder setSha256AccountKeyPublicAddress(@Nullable byte[]);
- }
-
- public class FastPairAntispoofkeyDeviceMetadata {
- }
-
- public static final class FastPairAntispoofkeyDeviceMetadata.Builder {
- ctor public FastPairAntispoofkeyDeviceMetadata.Builder();
- method @NonNull public android.nearby.FastPairAntispoofkeyDeviceMetadata build();
- method @NonNull public android.nearby.FastPairAntispoofkeyDeviceMetadata.Builder setAntiSpoofPublicKey(@Nullable byte[]);
- method @NonNull public android.nearby.FastPairAntispoofkeyDeviceMetadata.Builder setFastPairDeviceMetadata(@Nullable android.nearby.FastPairDeviceMetadata);
- }
-
- public abstract class FastPairDataProviderBase {
- ctor public FastPairDataProviderBase(@NonNull String);
- method @Nullable public final android.os.IBinder getBinder();
- method public abstract void onLoadFastPairAccountDevicesMetadata(@NonNull android.nearby.FastPairDataProviderBase.FastPairAccountDevicesMetadataRequest, @NonNull android.nearby.FastPairDataProviderBase.FastPairAccountDevicesMetadataCallback);
- method public abstract void onLoadFastPairAntispoofkeyDeviceMetadata(@NonNull android.nearby.FastPairDataProviderBase.FastPairAntispoofkeyDeviceMetadataRequest, @NonNull android.nearby.FastPairDataProviderBase.FastPairAntispoofkeyDeviceMetadataCallback);
- method public abstract void onLoadFastPairEligibleAccounts(@NonNull android.nearby.FastPairDataProviderBase.FastPairEligibleAccountsRequest, @NonNull android.nearby.FastPairDataProviderBase.FastPairEligibleAccountsCallback);
- method public abstract void onManageFastPairAccount(@NonNull android.nearby.FastPairDataProviderBase.FastPairManageAccountRequest, @NonNull android.nearby.FastPairDataProviderBase.FastPairManageActionCallback);
- method public abstract void onManageFastPairAccountDevice(@NonNull android.nearby.FastPairDataProviderBase.FastPairManageAccountDeviceRequest, @NonNull android.nearby.FastPairDataProviderBase.FastPairManageActionCallback);
- field public static final String ACTION_FAST_PAIR_DATA_PROVIDER = "android.nearby.action.FAST_PAIR_DATA_PROVIDER";
- field public static final int ERROR_CODE_BAD_REQUEST = 0; // 0x0
- field public static final int ERROR_CODE_INTERNAL_ERROR = 1; // 0x1
- field public static final int MANAGE_REQUEST_ADD = 0; // 0x0
- field public static final int MANAGE_REQUEST_REMOVE = 1; // 0x1
- }
-
- public static interface FastPairDataProviderBase.FastPairAccountDevicesMetadataCallback {
- method public void onError(int, @Nullable String);
- method public void onFastPairAccountDevicesMetadataReceived(@NonNull java.util.Collection<android.nearby.FastPairAccountKeyDeviceMetadata>);
- }
-
- public static class FastPairDataProviderBase.FastPairAccountDevicesMetadataRequest {
- method @NonNull public android.accounts.Account getAccount();
- }
-
- public static interface FastPairDataProviderBase.FastPairAntispoofkeyDeviceMetadataCallback {
- method public void onError(int, @Nullable String);
- method public void onFastPairAntispoofkeyDeviceMetadataReceived(@NonNull android.nearby.FastPairAntispoofkeyDeviceMetadata);
- }
-
- public static class FastPairDataProviderBase.FastPairAntispoofkeyDeviceMetadataRequest {
- method @NonNull public byte[] getModelId();
- }
-
- public static interface FastPairDataProviderBase.FastPairEligibleAccountsCallback {
- method public void onError(int, @Nullable String);
- method public void onFastPairEligibleAccountsReceived(@NonNull java.util.Collection<android.nearby.FastPairEligibleAccount>);
- }
-
- public static class FastPairDataProviderBase.FastPairEligibleAccountsRequest {
- }
-
- public static class FastPairDataProviderBase.FastPairManageAccountDeviceRequest {
- method @NonNull public android.accounts.Account getAccount();
- method @NonNull public android.nearby.FastPairAccountKeyDeviceMetadata getAccountKeyDeviceMetadata();
- method @Nullable public String getBleAddress();
- method public int getRequestType();
- }
-
- public static class FastPairDataProviderBase.FastPairManageAccountRequest {
- method @NonNull public android.accounts.Account getAccount();
- method public int getRequestType();
- }
-
- public static interface FastPairDataProviderBase.FastPairManageActionCallback {
- method public void onError(int, @Nullable String);
- method public void onSuccess();
- }
-
- public class FastPairDeviceMetadata {
- method @Nullable public String getAssistantSetupHalfSheet();
- method @Nullable public String getAssistantSetupNotification();
- method public int getBleTxPower();
- method @Nullable public String getConfirmPinDescription();
- method @Nullable public String getConfirmPinTitle();
- method @Nullable public String getConnectSuccessCompanionAppInstalled();
- method @Nullable public String getConnectSuccessCompanionAppNotInstalled();
- method public int getDeviceType();
- method @Nullable public String getDownloadCompanionAppDescription();
- method @Nullable public String getFailConnectGoToSettingsDescription();
- method @Nullable public String getFastPairTvConnectDeviceNoAccountDescription();
- method @Nullable public byte[] getImage();
- method @Nullable public String getImageUrl();
- method @Nullable public String getInitialNotificationDescription();
- method @Nullable public String getInitialNotificationDescriptionNoAccount();
- method @Nullable public String getInitialPairingDescription();
- method @Nullable public String getIntentUri();
- method @Nullable public String getLocale();
- method @Nullable public String getOpenCompanionAppDescription();
- method @Nullable public String getRetroactivePairingDescription();
- method @Nullable public String getSubsequentPairingDescription();
- method @Nullable public String getSyncContactsDescription();
- method @Nullable public String getSyncContactsTitle();
- method @Nullable public String getSyncSmsDescription();
- method @Nullable public String getSyncSmsTitle();
- method public float getTriggerDistance();
- method @Nullable public String getTrueWirelessImageUrlCase();
- method @Nullable public String getTrueWirelessImageUrlLeftBud();
- method @Nullable public String getTrueWirelessImageUrlRightBud();
- method @Nullable public String getUnableToConnectDescription();
- method @Nullable public String getUnableToConnectTitle();
- method @Nullable public String getUpdateCompanionAppDescription();
- method @Nullable public String getWaitLaunchCompanionAppDescription();
- }
-
- public static final class FastPairDeviceMetadata.Builder {
- ctor public FastPairDeviceMetadata.Builder();
- method @NonNull public android.nearby.FastPairDeviceMetadata build();
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setAssistantSetupHalfSheet(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setAssistantSetupNotification(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setBleTxPower(int);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setConfirmPinDescription(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setConfirmPinTitle(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setConnectSuccessCompanionAppInstalled(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setConnectSuccessCompanionAppNotInstalled(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setDeviceType(int);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setDownloadCompanionAppDescription(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setFailConnectGoToSettingsDescription(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setFastPairTvConnectDeviceNoAccountDescription(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setImage(@Nullable byte[]);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setImageUrl(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setInitialNotificationDescription(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setInitialNotificationDescriptionNoAccount(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setInitialPairingDescription(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setIntentUri(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setLocale(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setOpenCompanionAppDescription(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setRetroactivePairingDescription(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setSubsequentPairingDescription(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setSyncContactsDescription(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setSyncContactsTitle(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setSyncSmsDescription(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setSyncSmsTitle(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setTriggerDistance(float);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setTrueWirelessImageUrlCase(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setTrueWirelessImageUrlLeftBud(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setTrueWirelessImageUrlRightBud(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setUnableToConnectDescription(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setUnableToConnectTitle(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setUpdateCompanionAppDescription(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setWaitLaunchCompanionAppDescription(@Nullable String);
- }
-
- public class FastPairDiscoveryItem {
- method @Nullable public String getActionUrl();
- method public int getActionUrlType();
- method @Nullable public String getAppName();
- method public int getAttachmentType();
- method @Nullable public byte[] getAuthenticationPublicKeySecp256r1();
- method @Nullable public byte[] getBleRecordBytes();
- method public int getDebugCategory();
- method @Nullable public String getDebugMessage();
- method @Nullable public String getDescription();
- method @Nullable public String getDeviceName();
- method @Nullable public String getDisplayUrl();
- method @Nullable public String getEntityId();
- method @Nullable public String getFeatureGraphicUrl();
- method public long getFirstObservationTimestampMillis();
- method @Nullable public String getGroupId();
- method @Nullable public String getIconFfeUrl();
- method @Nullable public byte[] getIconPng();
- method @Nullable public String getId();
- method public long getLastObservationTimestampMillis();
- method public int getLastUserExperience();
- method public long getLostMillis();
- method @Nullable public String getMacAddress();
- method @Nullable public String getPackageName();
- method public long getPendingAppInstallTimestampMillis();
- method public int getRssi();
- method public int getState();
- method @Nullable public String getTitle();
- method @Nullable public String getTriggerId();
- method public int getTxPower();
- method public int getType();
- }
-
- public static final class FastPairDiscoveryItem.Builder {
- ctor public FastPairDiscoveryItem.Builder();
- method @NonNull public android.nearby.FastPairDiscoveryItem build();
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setActionUrl(@Nullable String);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setActionUrlType(int);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setAppName(@Nullable String);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setAttachmentType(int);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setAuthenticationPublicKeySecp256r1(@Nullable byte[]);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setBleRecordBytes(@Nullable byte[]);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setDebugCategory(int);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setDebugMessage(@Nullable String);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setDescription(@Nullable String);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setDeviceName(@Nullable String);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setDisplayUrl(@Nullable String);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setEntityId(@Nullable String);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setFeatureGraphicUrl(@Nullable String);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setFirstObservationTimestampMillis(long);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setGroupId(@Nullable String);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setIconFfeUrl(@Nullable String);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setIconPng(@Nullable byte[]);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setId(@Nullable String);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setLastObservationTimestampMillis(long);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setLastUserExperience(int);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setLostMillis(long);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setMacAddress(@Nullable String);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setPackageName(@Nullable String);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setPendingAppInstallTimestampMillis(long);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setRssi(int);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setState(int);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setTitle(@Nullable String);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setTriggerId(@Nullable String);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setTxPower(int);
- method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setType(int);
- }
-
- public class FastPairEligibleAccount {
- }
-
- public static final class FastPairEligibleAccount.Builder {
- ctor public FastPairEligibleAccount.Builder();
- method @NonNull public android.nearby.FastPairEligibleAccount build();
- method @NonNull public android.nearby.FastPairEligibleAccount.Builder setAccount(@Nullable android.accounts.Account);
- method @NonNull public android.nearby.FastPairEligibleAccount.Builder setOptIn(boolean);
- }
-
- public abstract class NearbyDevice {
- method public int getMedium();
- method @IntRange(from=0xffffff81, to=126) public int getRssi();
- method public static boolean isValidMedium(int);
- }
-
- public final class NearbyDeviceParcelable implements android.os.Parcelable {
- method public int describeContents();
- method @Nullable public String getBluetoothAddress();
- method @Nullable public byte[] getData();
- method @Nullable public String getFastPairModelId();
- method public int getMedium();
- method @Nullable public String getName();
- method @IntRange(from=0xffffff81, to=126) public int getRssi();
- method public void writeToParcel(@NonNull android.os.Parcel, int);
- field @NonNull public static final android.os.Parcelable.Creator<android.nearby.NearbyDeviceParcelable> CREATOR;
- }
-
- public static final class NearbyDeviceParcelable.Builder {
- ctor public NearbyDeviceParcelable.Builder();
- method @NonNull public android.nearby.NearbyDeviceParcelable build();
- method @NonNull public android.nearby.NearbyDeviceParcelable.Builder setBluetoothAddress(@Nullable String);
- method @NonNull public android.nearby.NearbyDeviceParcelable.Builder setData(@Nullable byte[]);
- method @NonNull public android.nearby.NearbyDeviceParcelable.Builder setFastPairModelId(@Nullable String);
- method @NonNull public android.nearby.NearbyDeviceParcelable.Builder setMedium(int);
- method @NonNull public android.nearby.NearbyDeviceParcelable.Builder setName(@Nullable String);
- method @NonNull public android.nearby.NearbyDeviceParcelable.Builder setRssi(int);
- }
-
- public final class NearbyFrameworkInitializer {
- method public static void registerServiceWrappers();
- }
-
- public class NearbyManager {
- method public void startScan(@NonNull android.nearby.ScanRequest, @NonNull java.util.concurrent.Executor, @NonNull android.nearby.ScanCallback);
- method public void stopScan(@NonNull android.nearby.ScanCallback);
- }
-
- public interface ScanCallback {
- method public void onDiscovered(@NonNull android.nearby.NearbyDevice);
- method public void onLost(@NonNull android.nearby.NearbyDevice);
- method public void onUpdated(@NonNull android.nearby.NearbyDevice);
- }
-
- public final class ScanRequest implements android.os.Parcelable {
- method public int describeContents();
- method public int getScanMode();
- method public int getScanType();
- method @NonNull public android.os.WorkSource getWorkSource();
- method public boolean isEnableBle();
- method public static boolean isValidScanMode(int);
- method public static boolean isValidScanType(int);
- method @NonNull public static String scanModeToString(int);
- method public void writeToParcel(@NonNull android.os.Parcel, int);
- field @NonNull public static final android.os.Parcelable.Creator<android.nearby.ScanRequest> CREATOR;
- field public static final int SCAN_MODE_BALANCED = 1; // 0x1
- field public static final int SCAN_MODE_LOW_LATENCY = 2; // 0x2
- field public static final int SCAN_MODE_LOW_POWER = 0; // 0x0
- field public static final int SCAN_MODE_NO_POWER = -1; // 0xffffffff
- field public static final int SCAN_TYPE_EXPOSURE_NOTIFICATION = 4; // 0x4
- field public static final int SCAN_TYPE_FAST_PAIR = 1; // 0x1
- field public static final int SCAN_TYPE_NEARBY_PRESENCE = 3; // 0x3
- field public static final int SCAN_TYPE_NEARBY_SHARE = 2; // 0x2
- }
-
- public static final class ScanRequest.Builder {
- ctor public ScanRequest.Builder();
- method @NonNull public android.nearby.ScanRequest build();
- method @NonNull public android.nearby.ScanRequest.Builder setEnableBle(boolean);
- method @NonNull public android.nearby.ScanRequest.Builder setScanMode(int);
- method @NonNull public android.nearby.ScanRequest.Builder setScanType(int);
- method @NonNull @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public android.nearby.ScanRequest.Builder setWorkSource(@Nullable android.os.WorkSource);
- }
-
-}
-
diff --git a/nearby/framework/api/system-removed.txt b/nearby/framework/api/system-removed.txt
deleted file mode 100644
index d802177..0000000
--- a/nearby/framework/api/system-removed.txt
+++ /dev/null
@@ -1 +0,0 @@
-// Signature format: 2.0
diff --git a/nearby/framework/api/test-current.txt b/nearby/framework/api/test-current.txt
deleted file mode 100644
index e69de29..0000000
--- a/nearby/framework/api/test-current.txt
+++ /dev/null
diff --git a/nearby/framework/api/test-removed.txt b/nearby/framework/api/test-removed.txt
deleted file mode 100644
index e69de29..0000000
--- a/nearby/framework/api/test-removed.txt
+++ /dev/null
diff --git a/nearby/framework/java/android/nearby/NearbyDeviceParcelable.java b/nearby/framework/java/android/nearby/NearbyDeviceParcelable.java
index ed3cb7b..0f85519 100644
--- a/nearby/framework/java/android/nearby/NearbyDeviceParcelable.java
+++ b/nearby/framework/java/android/nearby/NearbyDeviceParcelable.java
@@ -16,7 +16,6 @@
package android.nearby;
-
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -25,6 +24,9 @@
import android.os.Parcel;
import android.os.Parcelable;
+import java.util.Arrays;
+import java.util.Objects;
+
/**
* A data class representing scan result from Nearby Service. Scan result can come from multiple
* mediums like BLE, Wi-Fi Aware, and etc.
@@ -134,6 +136,43 @@
}
/**
+ * Returns a string representation of this ScanRequest.
+ */
+ @Override
+ public String toString() {
+ return "NearbyDeviceParcelable["
+ + "name=" + mName
+ + ", medium=" + NearbyDevice.mediumToString(mMedium)
+ + ", rssi=" + mRssi
+ + ", bluetoothAddress=" + mBluetoothAddress
+ + ", fastPairModelId=" + mFastPairModelId
+ + ", data=" + Arrays.toString(mData)
+ + "]";
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other instanceof NearbyDeviceParcelable) {
+ NearbyDeviceParcelable otherNearbyDeviceParcelable = (NearbyDeviceParcelable) other;
+ return Objects.equals(mName, otherNearbyDeviceParcelable.mName)
+ && (mMedium == otherNearbyDeviceParcelable.mMedium)
+ && (mRssi == otherNearbyDeviceParcelable.mRssi)
+ && (Objects.equals(
+ mBluetoothAddress, otherNearbyDeviceParcelable.mBluetoothAddress))
+ && (Objects.equals(
+ mFastPairModelId, otherNearbyDeviceParcelable.mFastPairModelId))
+ && (Arrays.equals(mData, otherNearbyDeviceParcelable.mData));
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ mName, mMedium, mRssi, mBluetoothAddress, mFastPairModelId, Arrays.hashCode(mData));
+ }
+
+ /**
* Gets the name of the NearbyDeviceParcelable. Returns {@code null} If there is no name.
*/
@Nullable
diff --git a/nearby/halfsheet/Android.bp b/nearby/halfsheet/Android.bp
index 82d0933..3f4f258 100644
--- a/nearby/halfsheet/Android.bp
+++ b/nearby/halfsheet/Android.bp
@@ -20,14 +20,15 @@
name: "HalfSheetDefaults",
srcs: ["src/**/*.java"],
sdk_version: "module_current",
- min_sdk_version: "current",
+ // This is included in tethering apex, which uses min SDK 30
+ min_sdk_version: "30",
target_sdk_version: "current",
manifest: "AndroidManifest.xml",
plugins: ["java_api_finder"],
jarjar_rules: ":nearby-jarjar-rules",
libs: [
"framework-bluetooth",
- "framework-nearby-pre-jarjar",
+ "framework-connectivity-tiramisu",
"nearby-service-string",
],
static_libs: [
@@ -49,7 +50,7 @@
static_libs: [
"com.google.android.material_material",
],
- apex_available: ["com.android.nearby",],
+ apex_available: ["com.android.tethering",],
}
android_app_certificate {
diff --git a/nearby/halfsheet/res/values/colors.xml b/nearby/halfsheet/res/values/colors.xml
index 2a2ed41..b066665 100644
--- a/nearby/halfsheet/res/values/colors.xml
+++ b/nearby/halfsheet/res/values/colors.xml
@@ -1,14 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<resources
- xmlns:android="http://schemas.android.com/apk/res/android">
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools">
<!-- Use original background color -->
<color name="fast_pair_notification_background">#00000000</color>
- <color name="fast_pair_half_sheet_button_color">@android:color/system_accent1_100</color>
- <color name="fast_pair_half_sheet_button_text">@android:color/system_neutral1_900</color>
- <color name="fast_pair_half_sheet_button_accent_text">@android:color/system_neutral1_900</color>
- <color name="fast_pair_progress_color">@android:color/system_accent1_600</color>
- <color name="fast_pair_half_sheet_subtitle_color">@android:color/system_neutral2_700</color>
- <color name="fast_pair_half_sheet_text_color">@android:color/system_neutral1_900</color>
+ <!-- Ignores NewApi as below system colors are available since API 31, and HalfSheet is always
+ running on T+ even though it has min_sdk 30 to match its containing APEX -->
+ <color name="fast_pair_half_sheet_button_color" tools:ignore="NewApi">@android:color/system_accent1_100</color>
+ <color name="fast_pair_half_sheet_button_text" tools:ignore="NewApi">@android:color/system_neutral1_900</color>
+ <color name="fast_pair_half_sheet_button_accent_text" tools:ignore="NewApi">@android:color/system_neutral1_900</color>
+ <color name="fast_pair_progress_color" tools:ignore="NewApi">@android:color/system_accent1_600</color>
+ <color name="fast_pair_half_sheet_subtitle_color" tools:ignore="NewApi">@android:color/system_neutral2_700</color>
+ <color name="fast_pair_half_sheet_text_color" tools:ignore="NewApi">@android:color/system_neutral1_900</color>
<!-- Nearby Discoverer -->
<color name="discovery_activity_accent">#4285F4</color>
diff --git a/nearby/service/Android.bp b/nearby/service/Android.bp
index 5b0028e..1e1af20 100644
--- a/nearby/service/Android.bp
+++ b/nearby/service/Android.bp
@@ -47,15 +47,12 @@
srcs: [":nearby-service-srcs"],
defaults: [
- "nearby-module-sdk-version-defaults",
"framework-system-server-module-defaults"
],
libs: [
- // pre-jarjar symbols are needed so that nearby-service can reference the original class
- // names at compile time
- "framework-nearby-pre-jarjar",
"framework-bluetooth.stubs.module_lib", // TODO(b/215722418): Change to framework-bluetooth once fixed
"error_prone_annotations",
+ "framework-connectivity-tiramisu.impl",
],
static_libs: [
"androidx.annotation_annotation",
@@ -70,13 +67,12 @@
"modules-utils-backgroundthread",
],
sdk_version: "system_server_current",
+ // This is included in service-connectivity which is 30+
+ // TODO: allow APEXes to have service jars with higher min_sdk than the APEX
+ // (service-connectivity is only used on 31+) and use 31 here
+ min_sdk_version: "30",
installable: true,
- optimize: {
- enabled: true,
- shrink: true,
- proguard_flags_files: ["proguard.flags"],
- },
dex_preopt: {
enabled: false,
app_image: false,
@@ -85,6 +81,6 @@
"//packages/modules/Nearby/apex",
],
apex_available: [
- "com.android.nearby",
+ "com.android.tethering",
],
}
diff --git a/nearby/service/java/com/android/server/nearby/NearbyService.java b/nearby/service/java/com/android/server/nearby/NearbyService.java
index b851c72..5326673 100644
--- a/nearby/service/java/com/android/server/nearby/NearbyService.java
+++ b/nearby/service/java/com/android/server/nearby/NearbyService.java
@@ -16,57 +16,117 @@
package com.android.server.nearby;
+import static com.android.server.SystemService.PHASE_BOOT_COMPLETED;
+import static com.android.server.SystemService.PHASE_THIRD_PARTY_APPS_CAN_START;
+
+import android.annotation.Nullable;
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothManager;
+import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.nearby.INearbyManager;
+import android.nearby.IScanListener;
+import android.nearby.ScanRequest;
import android.util.Log;
-import com.android.server.SystemService;
import com.android.server.nearby.common.locator.LocatorContextWrapper;
import com.android.server.nearby.fastpair.FastPairManager;
+import com.android.server.nearby.injector.Injector;
+import com.android.server.nearby.provider.DiscoveryProviderManager;
import com.android.server.nearby.provider.FastPairDataProvider;
/**
- * Service implementing nearby functionality. The actual implementation is delegated to
- * {@link NearbyServiceImpl}.
+ * Service implementing nearby functionality.
*/
-public class NearbyService extends SystemService {
-
+public class NearbyService extends INearbyManager.Stub {
public static final String TAG = "NearbyService";
- private static final boolean DBG = true;
private final Context mContext;
- private final NearbyServiceImpl mImpl;
+ private final SystemInjector mSystemInjector;
private final FastPairManager mFastPairManager;
- private LocatorContextWrapper mLocatorContextWrapper;
-
- public NearbyService(Context contextBase) {
- super(contextBase);
- mContext = contextBase;
- mImpl = new NearbyServiceImpl(contextBase);
- mLocatorContextWrapper = new LocatorContextWrapper(contextBase, null);
- mFastPairManager = new FastPairManager(mLocatorContextWrapper);
- }
-
- @Override
- public void onStart() {
- if (DBG) {
- Log.d(TAG, "Publishing NearbyService");
+ private final BroadcastReceiver mBluetoothReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ int state = intent
+ .getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
+ if (state == BluetoothAdapter.STATE_ON) {
+ if (mSystemInjector != null) {
+ // Have to do this logic in listener. Even during PHASE_BOOT_COMPLETED
+ // phase, BluetoothAdapter is not null, the BleScanner is null.
+ Log.v(TAG, "Initiating BluetoothAdapter when Bluetooth is turned on.");
+ mSystemInjector.initializeBluetoothAdapter();
+ }
+ }
}
- publishBinderService(Context.NEARBY_SERVICE, mImpl);
+ };
+ private DiscoveryProviderManager mProviderManager;
+
+ public NearbyService(Context context) {
+ mContext = context;
+ mSystemInjector = new SystemInjector(context);
+ mProviderManager = new DiscoveryProviderManager(context, mSystemInjector);
+ final LocatorContextWrapper lcw = new LocatorContextWrapper(context, null);
+ mFastPairManager = new FastPairManager(lcw);
}
@Override
+ public void registerScanListener(ScanRequest scanRequest, IScanListener listener) {
+ mProviderManager.registerScanListener(scanRequest, listener);
+ }
+
+ @Override
+ public void unregisterScanListener(IScanListener listener) {
+ mProviderManager.unregisterScanListener(listener);
+ }
+
+ /**
+ * Called by the service initializer.
+ *
+ * {@see com.android.server.SystemService#onBootPhase}.
+ */
public void onBootPhase(int phase) {
- if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) {
- onSystemThirdPartyAppsCanStart();
- } else if (phase == PHASE_BOOT_COMPLETED) {
- // the nearby service must be functioning after this boot phase.
- mImpl.onSystemReady();
- mFastPairManager.initiate();
+ switch (phase) {
+ case PHASE_THIRD_PARTY_APPS_CAN_START:
+ // Ensures that a fast pair data provider exists which will work in direct boot.
+ FastPairDataProvider.init(mContext);
+ break;
+ case PHASE_BOOT_COMPLETED:
+ // The nearby service must be functioning after this boot phase.
+ mSystemInjector.initializeBluetoothAdapter();
+ mContext.registerReceiver(mBluetoothReceiver,
+ new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED));
+ mFastPairManager.initiate();
+ break;
}
}
- private void onSystemThirdPartyAppsCanStart() {
- // Ensures that a fast pair data provider exists which will work in direct boot.
- FastPairDataProvider.init(mContext);
+ private static final class SystemInjector implements Injector {
+ private final Context mContext;
+ @Nullable
+ private BluetoothAdapter mBluetoothAdapter;
+
+ SystemInjector(Context context) {
+ mContext = context;
+ }
+
+ @Override
+ @Nullable
+ public BluetoothAdapter getBluetoothAdapter() {
+ return mBluetoothAdapter;
+ }
+
+ synchronized void initializeBluetoothAdapter() {
+ if (mBluetoothAdapter != null) {
+ return;
+ }
+ BluetoothManager manager = mContext.getSystemService(BluetoothManager.class);
+ if (manager == null) {
+ return;
+ }
+ mBluetoothAdapter = manager.getAdapter();
+ }
}
+
}
diff --git a/nearby/service/java/com/android/server/nearby/NearbyServiceImpl.java b/nearby/service/java/com/android/server/nearby/NearbyServiceImpl.java
deleted file mode 100644
index 04e73a5..0000000
--- a/nearby/service/java/com/android/server/nearby/NearbyServiceImpl.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.server.nearby;
-
-import static com.android.server.nearby.NearbyService.TAG;
-
-import android.annotation.Nullable;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothManager;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.nearby.INearbyManager;
-import android.nearby.IScanListener;
-import android.nearby.ScanRequest;
-import android.util.Log;
-
-import com.android.server.nearby.injector.Injector;
-import com.android.server.nearby.provider.DiscoveryProviderManager;
-
-/**
- * Implementation of {@link com.android.server.nearby.NearbyService}.
- */
-public class NearbyServiceImpl extends INearbyManager.Stub {
-
- private final Context mContext;
- private final SystemInjector mSystemInjector;
- private final BroadcastReceiver mBluetoothReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- int state = intent
- .getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
- if (state == BluetoothAdapter.STATE_ON) {
- if (mSystemInjector != null) {
- // Have to do this logic in listener. Even during PHASE_BOOT_COMPLETED
- // phase, BluetoothAdapter is not null, the BleScanner is null.
- Log.v(TAG, "Initiating BluetoothAdapter when Bluetooth is turned on.");
- mSystemInjector.initializeBluetoothAdapter();
- }
- }
- }
- };
- private DiscoveryProviderManager mProviderManager;
-
- public NearbyServiceImpl(Context context) {
- mContext = context;
- mSystemInjector = new SystemInjector(context);
- mProviderManager = new DiscoveryProviderManager(context, mSystemInjector);
- }
-
- @Override
- public void registerScanListener(ScanRequest scanRequest, IScanListener listener) {
- mProviderManager.registerScanListener(scanRequest, listener);
- }
-
- @Override
- public void unregisterScanListener(IScanListener listener) {
- mProviderManager.unregisterScanListener(listener);
- }
-
- void onSystemReady() {
- mSystemInjector.initializeBluetoothAdapter();
- mContext.registerReceiver(mBluetoothReceiver,
- new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED));
- }
-
- private static final class SystemInjector implements Injector {
- private final Context mContext;
- @Nullable
- private BluetoothAdapter mBluetoothAdapter;
-
- SystemInjector(Context context) {
- mContext = context;
- }
-
- @Override
- @Nullable
- public BluetoothAdapter getBluetoothAdapter() {
- return mBluetoothAdapter;
- }
-
- synchronized void initializeBluetoothAdapter() {
- if (mBluetoothAdapter != null) {
- return;
- }
- BluetoothManager manager = mContext.getSystemService(BluetoothManager.class);
- if (manager == null) {
- return;
- }
- mBluetoothAdapter = manager.getAdapter();
- }
- }
-
-}
diff --git a/nearby/service/proguard.flags b/nearby/service/proguard.flags
deleted file mode 100644
index 55c963f..0000000
--- a/nearby/service/proguard.flags
+++ /dev/null
@@ -1,5 +0,0 @@
-# Prevent proguard from stripping out any nearby-service.
-# TODO: This could be optimized in the future to only keep the critical
-# entry points and then let proguard strip out any unused code within
-# the service.
--keep class com.android.server.nearby.** { *; }
diff --git a/nearby/service/proto/Android.bp b/nearby/service/proto/Android.bp
index 9eca51d..d8c059e 100644
--- a/nearby/service/proto/Android.bp
+++ b/nearby/service/proto/Android.bp
@@ -25,7 +25,7 @@
min_sdk_version: "30",
srcs: ["src/*/*.proto"],
apex_available: [
- "com.android.nearby",
+ "com.android.tethering",
],
}
diff --git a/nearby/tests/cts/fastpair/Android.bp b/nearby/tests/cts/fastpair/Android.bp
index e28df1b..56dc682 100644
--- a/nearby/tests/cts/fastpair/Android.bp
+++ b/nearby/tests/cts/fastpair/Android.bp
@@ -25,16 +25,17 @@
"androidx.test.rules",
"compatibility-device-util-axt",
"ctstestrunner-axt",
- "framework-nearby-pre-jarjar",
"truth-prebuilt",
],
libs: [
"android.test.base",
+ "framework-connectivity-tiramisu.impl",
],
srcs: ["src/**/*.java"],
test_suites: [
"cts",
"general-tests",
+ "mts-tethering",
],
platform_apis: true,
sdk_version: "module_current",
diff --git a/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairDataProviderBaseTest.java b/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairDataProviderBaseTest.java
index bceca81..bfe71cd 100644
--- a/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairDataProviderBaseTest.java
+++ b/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairDataProviderBaseTest.java
@@ -20,21 +20,23 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.MockitoAnnotations.initMocks;
import android.accounts.Account;
+import android.nearby.FastPairAccountKeyDeviceMetadata;
import android.nearby.FastPairAntispoofkeyDeviceMetadata;
import android.nearby.FastPairDataProviderBase;
import android.nearby.FastPairDeviceMetadata;
+import android.nearby.FastPairDiscoveryItem;
import android.nearby.FastPairEligibleAccount;
import android.nearby.aidl.FastPairAccountDevicesMetadataRequestParcel;
import android.nearby.aidl.FastPairAccountKeyDeviceMetadataParcel;
import android.nearby.aidl.FastPairAntispoofkeyDeviceMetadataParcel;
import android.nearby.aidl.FastPairAntispoofkeyDeviceMetadataRequestParcel;
import android.nearby.aidl.FastPairDeviceMetadataParcel;
+import android.nearby.aidl.FastPairDiscoveryItemParcel;
import android.nearby.aidl.FastPairEligibleAccountParcel;
import android.nearby.aidl.FastPairEligibleAccountsRequestParcel;
import android.nearby.aidl.FastPairManageAccountDeviceRequestParcel;
@@ -76,18 +78,14 @@
private static final int DEVICE_TYPE = 7;
private static final String DOWNLOAD_COMPANION_APP_DESCRIPTION =
"DOWNLOAD_COMPANION_APP_DESCRIPTION";
- private static final int ELIGIBLE_ACCOUNTS_NUM = 2;
private static final Account ELIGIBLE_ACCOUNT_1 = new Account("abc@google.com", "type1");
private static final boolean ELIGIBLE_ACCOUNT_1_OPT_IN = true;
private static final Account ELIGIBLE_ACCOUNT_2 = new Account("def@gmail.com", "type2");
private static final boolean ELIGIBLE_ACCOUNT_2_OPT_IN = false;
private static final Account MANAGE_ACCOUNT = new Account("ghi@gmail.com", "type3");
- private static final ImmutableList<FastPairEligibleAccount> ELIGIBLE_ACCOUNTS =
- ImmutableList.of(
- genHappyPathFastPairEligibleAccount(ELIGIBLE_ACCOUNT_1,
- ELIGIBLE_ACCOUNT_1_OPT_IN),
- genHappyPathFastPairEligibleAccount(ELIGIBLE_ACCOUNT_2,
- ELIGIBLE_ACCOUNT_2_OPT_IN));
+ private static final Account ACCOUNTDEVICES_METADATA_ACCOUNT =
+ new Account("jk@gmail.com", "type4");
+
private static final int ERROR_CODE_BAD_REQUEST =
FastPairDataProviderBase.ERROR_CODE_BAD_REQUEST;
private static final int MANAGE_ACCOUNT_REQUEST_TYPE =
@@ -126,23 +124,79 @@
"UPDATE_COMPANION_APP_DESCRIPTION";
private static final String WAIT_LAUNCH_COMPANION_APP_DESCRIPTION =
"WAIT_LAUNCH_COMPANION_APP_DESCRIPTION";
+ private static final byte[] ACCOUNT_KEY = new byte[] {3};
+ private static final byte[] SHA256_ACCOUNT_KEY_PUBLIC_ADDRESS = new byte[] {2, 8};
private static final byte[] REQUEST_MODEL_ID = new byte[] {1, 2, 3};
private static final byte[] ANTI_SPOOFING_KEY = new byte[] {4, 5, 6};
+ private static final String ACTION_URL = "ACTION_URL";
+ private static final int ACTION_URL_TYPE = 5;
+ private static final String APP_NAME = "APP_NAME";
+ private static final int ATTACHMENT_TYPE = 8;
+ private static final byte[] AUTHENTICATION_PUBLIC_KEY_SEC_P256R1 = new byte[] {5, 7};
+ private static final byte[] BLE_RECORD_BYTES = new byte[]{2, 4};
+ private static final int DEBUG_CATEGORY = 9;
+ private static final String DEBUG_MESSAGE = "DEBUG_MESSAGE";
+ private static final String DESCRIPTION = "DESCRIPTION";
+ private static final String DEVICE_NAME = "DEVICE_NAME";
+ private static final String DISPLAY_URL = "DISPLAY_URL";
+ private static final String ENTITY_ID = "ENTITY_ID";
+ private static final String FEATURE_GRAPHIC_URL = "FEATURE_GRAPHIC_URL";
+ private static final long FIRST_OBSERVATION_TIMESTAMP_MILLIS = 8393L;
+ private static final String GROUP_ID = "GROUP_ID";
+ private static final String ICON_FIFE_URL = "ICON_FIFE_URL";
+ private static final byte[] ICON_PNG = new byte[]{2, 5};
+ private static final String ID = "ID";
+ private static final long LAST_OBSERVATION_TIMESTAMP_MILLIS = 934234L;
+ private static final int LAST_USER_EXPERIENCE = 93;
+ private static final long LOST_MILLIS = 393284L;
+ private static final String MAC_ADDRESS = "MAC_ADDRESS";
+ private static final String PACKAGE_NAME = "PACKAGE_NAME";
+ private static final long PENDING_APP_INSTALL_TIMESTAMP_MILLIS = 832393L;
+ private static final int RSSI = 9;
+ private static final int STATE = 63;
+ private static final String TITLE = "TITLE";
+ private static final String TRIGGER_ID = "TRIGGER_ID";
+ private static final int TX_POWER = 62;
+ private static final int TYPE = 73;
+ private static final String BLE_ADDRESS = "BLE_ADDRESS";
+
+ private static final int ELIGIBLE_ACCOUNTS_NUM = 2;
+ private static final ImmutableList<FastPairEligibleAccount> ELIGIBLE_ACCOUNTS =
+ ImmutableList.of(
+ genHappyPathFastPairEligibleAccount(ELIGIBLE_ACCOUNT_1,
+ ELIGIBLE_ACCOUNT_1_OPT_IN),
+ genHappyPathFastPairEligibleAccount(ELIGIBLE_ACCOUNT_2,
+ ELIGIBLE_ACCOUNT_2_OPT_IN));
+ private static final int ACCOUNTKEY_DEVICE_NUM = 2;
+ private static final ImmutableList<FastPairAccountKeyDeviceMetadata>
+ FAST_PAIR_ACCOUNT_DEVICES_METADATA =
+ ImmutableList.of(
+ genHappyPathFastPairAccountkeyDeviceMetadata(),
+ genHappyPathFastPairAccountkeyDeviceMetadata());
+
private static final FastPairAntispoofkeyDeviceMetadataRequestParcel
FAST_PAIR_ANTI_SPOOF_KEY_DEVICE_METADATA_REQUEST_PARCEL =
genFastPairAntispoofkeyDeviceMetadataRequestParcel();
+ private static final FastPairAccountDevicesMetadataRequestParcel
+ FAST_PAIR_ACCOUNT_DEVICES_METADATA_REQUEST_PARCEL =
+ genFastPairAccountDevicesMetadataRequestParcel();
private static final FastPairEligibleAccountsRequestParcel
FAST_PAIR_ELIGIBLE_ACCOUNTS_REQUEST_PARCEL =
genFastPairEligibleAccountsRequestParcel();
private static final FastPairManageAccountRequestParcel
FAST_PAIR_MANAGE_ACCOUNT_REQUEST_PARCEL =
genFastPairManageAccountRequestParcel();
+ private static final FastPairManageAccountDeviceRequestParcel
+ FAST_PAIR_MANAGE_ACCOUNT_DEVICE_REQUEST_PARCEL =
+ genFastPairManageAccountDeviceRequestParcel();
private static final FastPairAntispoofkeyDeviceMetadata
HAPPY_PATH_FAST_PAIR_ANTI_SPOOF_KEY_DEVICE_METADATA =
genHappyPathFastPairAntispoofkeyDeviceMetadata();
private @Captor ArgumentCaptor<FastPairEligibleAccountParcel[]>
mFastPairEligibleAccountParcelsArgumentCaptor;
+ private @Captor ArgumentCaptor<FastPairAccountKeyDeviceMetadataParcel[]>
+ mFastPairAccountKeyDeviceMetadataParcelsArgumentCaptor;
private @Mock FastPairDataProviderBase mMockFastPairDataProviderBase;
private @Mock IFastPairAntispoofkeyDeviceMetadataCallback.Stub
@@ -174,33 +228,45 @@
// OEM receives request and verifies that it is as expected.
final ArgumentCaptor<FastPairDataProviderBase.FastPairAntispoofkeyDeviceMetadataRequest>
- mFastPairAntispoofkeyDeviceMetadataRequestCaptor =
+ fastPairAntispoofkeyDeviceMetadataRequestCaptor =
ArgumentCaptor.forClass(
FastPairDataProviderBase.FastPairAntispoofkeyDeviceMetadataRequest.class);
verify(mMockFastPairDataProviderBase).onLoadFastPairAntispoofkeyDeviceMetadata(
- mFastPairAntispoofkeyDeviceMetadataRequestCaptor.capture(),
+ fastPairAntispoofkeyDeviceMetadataRequestCaptor.capture(),
any(FastPairDataProviderBase.FastPairAntispoofkeyDeviceMetadataCallback.class));
- ensureHappyPathAsExpected(mFastPairAntispoofkeyDeviceMetadataRequestCaptor.getValue());
+ ensureHappyPathAsExpected(fastPairAntispoofkeyDeviceMetadataRequestCaptor.getValue());
// AOSP receives responses and verifies that it is as expected.
final ArgumentCaptor<FastPairAntispoofkeyDeviceMetadataParcel>
- mFastPairAntispoofkeyDeviceMetadataParcelCaptor =
+ fastPairAntispoofkeyDeviceMetadataParcelCaptor =
ArgumentCaptor.forClass(FastPairAntispoofkeyDeviceMetadataParcel.class);
verify(mAntispoofkeyDeviceMetadataCallback).onFastPairAntispoofkeyDeviceMetadataReceived(
- mFastPairAntispoofkeyDeviceMetadataParcelCaptor.capture());
- ensureHappyPathAsExpected(mFastPairAntispoofkeyDeviceMetadataParcelCaptor.getValue());
+ fastPairAntispoofkeyDeviceMetadataParcelCaptor.capture());
+ ensureHappyPathAsExpected(fastPairAntispoofkeyDeviceMetadataParcelCaptor.getValue());
}
@Test
public void testHappyPathLoadFastPairAccountDevicesMetadata() throws Exception {
+ // AOSP sends calls to OEM via Parcelable.
mHappyPathFastPairDataProvider.asProvider().loadFastPairAccountDevicesMetadata(
- new FastPairAccountDevicesMetadataRequestParcel(),
+ FAST_PAIR_ACCOUNT_DEVICES_METADATA_REQUEST_PARCEL,
mAccountDevicesMetadataCallback);
+
+ // OEM receives request and verifies that it is as expected.
+ final ArgumentCaptor<FastPairDataProviderBase.FastPairAccountDevicesMetadataRequest>
+ fastPairAccountDevicesMetadataRequestCaptor =
+ ArgumentCaptor.forClass(
+ FastPairDataProviderBase.FastPairAccountDevicesMetadataRequest.class);
verify(mMockFastPairDataProviderBase).onLoadFastPairAccountDevicesMetadata(
- any(FastPairDataProviderBase.FastPairAccountDevicesMetadataRequest.class),
+ fastPairAccountDevicesMetadataRequestCaptor.capture(),
any(FastPairDataProviderBase.FastPairAccountDevicesMetadataCallback.class));
+ ensureHappyPathAsExpected(fastPairAccountDevicesMetadataRequestCaptor.getValue());
+
+ // AOSP receives responses and verifies that it is as expected.
verify(mAccountDevicesMetadataCallback).onFastPairAccountDevicesMetadataReceived(
- any(FastPairAccountKeyDeviceMetadataParcel[].class));
+ mFastPairAccountKeyDeviceMetadataParcelsArgumentCaptor.capture());
+ ensureHappyPathAsExpected(
+ mFastPairAccountKeyDeviceMetadataParcelsArgumentCaptor.getValue());
}
@Test
@@ -212,13 +278,13 @@
// OEM receives request and verifies that it is as expected.
final ArgumentCaptor<FastPairDataProviderBase.FastPairEligibleAccountsRequest>
- mFastPairEligibleAccountsRequestCaptor =
+ fastPairEligibleAccountsRequestCaptor =
ArgumentCaptor.forClass(
FastPairDataProviderBase.FastPairEligibleAccountsRequest.class);
verify(mMockFastPairDataProviderBase).onLoadFastPairEligibleAccounts(
- mFastPairEligibleAccountsRequestCaptor.capture(),
+ fastPairEligibleAccountsRequestCaptor.capture(),
any(FastPairDataProviderBase.FastPairEligibleAccountsCallback.class));
- ensureHappyPathAsExpected(mFastPairEligibleAccountsRequestCaptor.getValue());
+ ensureHappyPathAsExpected(fastPairEligibleAccountsRequestCaptor.getValue());
// AOSP receives responses and verifies that it is as expected.
verify(mEligibleAccountsCallback).onFastPairEligibleAccountsReceived(
@@ -235,13 +301,13 @@
// OEM receives request and verifies that it is as expected.
final ArgumentCaptor<FastPairDataProviderBase.FastPairManageAccountRequest>
- mFastPairManageAccountRequestCaptor =
+ fastPairManageAccountRequestCaptor =
ArgumentCaptor.forClass(
FastPairDataProviderBase.FastPairManageAccountRequest.class);
verify(mMockFastPairDataProviderBase).onManageFastPairAccount(
- mFastPairManageAccountRequestCaptor.capture(),
+ fastPairManageAccountRequestCaptor.capture(),
any(FastPairDataProviderBase.FastPairManageActionCallback.class));
- ensureHappyPathAsExpected(mFastPairManageAccountRequestCaptor.getValue());
+ ensureHappyPathAsExpected(fastPairManageAccountRequestCaptor.getValue());
// AOSP receives SUCCESS response.
verify(mManageAccountCallback).onSuccess();
@@ -249,12 +315,22 @@
@Test
public void testHappyPathManageFastPairAccountDevice() throws Exception {
+ // AOSP sends calls to OEM via Parcelable.
mHappyPathFastPairDataProvider.asProvider().manageFastPairAccountDevice(
- new FastPairManageAccountDeviceRequestParcel(),
+ FAST_PAIR_MANAGE_ACCOUNT_DEVICE_REQUEST_PARCEL,
mManageAccountDeviceCallback);
+
+ // OEM receives request and verifies that it is as expected.
+ final ArgumentCaptor<FastPairDataProviderBase.FastPairManageAccountDeviceRequest>
+ fastPairManageAccountDeviceRequestCaptor =
+ ArgumentCaptor.forClass(
+ FastPairDataProviderBase.FastPairManageAccountDeviceRequest.class);
verify(mMockFastPairDataProviderBase).onManageFastPairAccountDevice(
- any(FastPairDataProviderBase.FastPairManageAccountDeviceRequest.class),
+ fastPairManageAccountDeviceRequestCaptor.capture(),
any(FastPairDataProviderBase.FastPairManageActionCallback.class));
+ ensureHappyPathAsExpected(fastPairManageAccountDeviceRequestCaptor.getValue());
+
+ // AOSP receives SUCCESS response.
verify(mManageAccountDeviceCallback).onSuccess();
}
@@ -273,12 +349,13 @@
@Test
public void testErrorPathLoadFastPairAccountDevicesMetadata() throws Exception {
mErrorPathFastPairDataProvider.asProvider().loadFastPairAccountDevicesMetadata(
- new FastPairAccountDevicesMetadataRequestParcel(),
+ FAST_PAIR_ACCOUNT_DEVICES_METADATA_REQUEST_PARCEL,
mAccountDevicesMetadataCallback);
verify(mMockFastPairDataProviderBase).onLoadFastPairAccountDevicesMetadata(
any(FastPairDataProviderBase.FastPairAccountDevicesMetadataRequest.class),
any(FastPairDataProviderBase.FastPairAccountDevicesMetadataCallback.class));
- verify(mAccountDevicesMetadataCallback).onError(anyInt(), any());
+ verify(mAccountDevicesMetadataCallback).onError(
+ eq(ERROR_CODE_BAD_REQUEST), eq(ERROR_STRING));
}
@Test
@@ -307,12 +384,12 @@
@Test
public void testErrorPathManageFastPairAccountDevice() throws Exception {
mErrorPathFastPairDataProvider.asProvider().manageFastPairAccountDevice(
- new FastPairManageAccountDeviceRequestParcel(),
+ FAST_PAIR_MANAGE_ACCOUNT_DEVICE_REQUEST_PARCEL,
mManageAccountDeviceCallback);
verify(mMockFastPairDataProviderBase).onManageFastPairAccountDevice(
any(FastPairDataProviderBase.FastPairManageAccountDeviceRequest.class),
any(FastPairDataProviderBase.FastPairManageActionCallback.class));
- verify(mManageAccountDeviceCallback).onError(anyInt(), any());
+ verify(mManageAccountDeviceCallback).onError(eq(ERROR_CODE_BAD_REQUEST), eq(ERROR_STRING));
}
public static class MyHappyPathProvider extends FastPairDataProviderBase {
@@ -344,7 +421,7 @@
@NonNull FastPairAccountDevicesMetadataCallback callback) {
mMockFastPairDataProviderBase.onLoadFastPairAccountDevicesMetadata(
request, callback);
- callback.onFastPairAccountDevicesMetadataReceived(ImmutableList.of());
+ callback.onFastPairAccountDevicesMetadataReceived(FAST_PAIR_ACCOUNT_DEVICES_METADATA);
}
@Override
@@ -438,6 +515,17 @@
return requestParcel;
}
+ /* Generates AccountDevicesMetadataRequestParcel. */
+ private static FastPairAccountDevicesMetadataRequestParcel
+ genFastPairAccountDevicesMetadataRequestParcel() {
+ FastPairAccountDevicesMetadataRequestParcel requestParcel =
+ new FastPairAccountDevicesMetadataRequestParcel();
+
+ requestParcel.account = ACCOUNTDEVICES_METADATA_ACCOUNT;
+
+ return requestParcel;
+ }
+
/* Generates FastPairEligibleAccountsRequestParcel. */
private static FastPairEligibleAccountsRequestParcel
genFastPairEligibleAccountsRequestParcel() {
@@ -458,6 +546,20 @@
return requestParcel;
}
+ /* Generates FastPairManageAccountDeviceRequestParcel. */
+ private static FastPairManageAccountDeviceRequestParcel
+ genFastPairManageAccountDeviceRequestParcel() {
+ FastPairManageAccountDeviceRequestParcel requestParcel =
+ new FastPairManageAccountDeviceRequestParcel();
+ requestParcel.account = MANAGE_ACCOUNT;
+ requestParcel.requestType = MANAGE_ACCOUNT_REQUEST_TYPE;
+ requestParcel.bleAddress = BLE_ADDRESS;
+ requestParcel.accountKeyDeviceMetadata =
+ genHappyPathFastPairAccountkeyDeviceMetadataParcel();
+
+ return requestParcel;
+ }
+
/* Generates Happy Path AntispoofkeyDeviceMetadata. */
private static FastPairAntispoofkeyDeviceMetadata
genHappyPathFastPairAntispoofkeyDeviceMetadata() {
@@ -469,6 +571,108 @@
return builder.build();
}
+ /* Generates Happy Path FastPairAccountKeyDeviceMetadata. */
+ private static FastPairAccountKeyDeviceMetadata
+ genHappyPathFastPairAccountkeyDeviceMetadata() {
+ FastPairAccountKeyDeviceMetadata.Builder builder =
+ new FastPairAccountKeyDeviceMetadata.Builder();
+ builder.setAccountKey(ACCOUNT_KEY);
+ builder.setFastPairDeviceMetadata(genHappyPathFastPairDeviceMetadata());
+ builder.setSha256AccountKeyPublicAddress(SHA256_ACCOUNT_KEY_PUBLIC_ADDRESS);
+ builder.setFastPairDiscoveryItem(genHappyPathFastPairDiscoveryItem());
+
+ return builder.build();
+ }
+
+ /* Generates Happy Path FastPairAccountKeyDeviceMetadataParcel. */
+ private static FastPairAccountKeyDeviceMetadataParcel
+ genHappyPathFastPairAccountkeyDeviceMetadataParcel() {
+ FastPairAccountKeyDeviceMetadataParcel parcel =
+ new FastPairAccountKeyDeviceMetadataParcel();
+ parcel.accountKey = ACCOUNT_KEY;
+ parcel.metadata = genHappyPathFastPairDeviceMetadataParcel();
+ parcel.sha256AccountKeyPublicAddress = SHA256_ACCOUNT_KEY_PUBLIC_ADDRESS;
+ parcel.discoveryItem = genHappyPathFastPairDiscoveryItemParcel();
+
+ return parcel;
+ }
+
+ /* Generates Happy Path DiscoveryItem. */
+ private static FastPairDiscoveryItem genHappyPathFastPairDiscoveryItem() {
+ FastPairDiscoveryItem.Builder builder = new FastPairDiscoveryItem.Builder();
+
+ builder.setActionUrl(ACTION_URL);
+ builder.setActionUrlType(ACTION_URL_TYPE);
+ builder.setAppName(APP_NAME);
+ builder.setAttachmentType(ATTACHMENT_TYPE);
+ builder.setAuthenticationPublicKeySecp256r1(AUTHENTICATION_PUBLIC_KEY_SEC_P256R1);
+ builder.setBleRecordBytes(BLE_RECORD_BYTES);
+ builder.setDebugCategory(DEBUG_CATEGORY);
+ builder.setDebugMessage(DEBUG_MESSAGE);
+ builder.setDescription(DESCRIPTION);
+ builder.setDeviceName(DEVICE_NAME);
+ builder.setDisplayUrl(DISPLAY_URL);
+ builder.setEntityId(ENTITY_ID);
+ builder.setFeatureGraphicUrl(FEATURE_GRAPHIC_URL);
+ builder.setFirstObservationTimestampMillis(FIRST_OBSERVATION_TIMESTAMP_MILLIS);
+ builder.setGroupId(GROUP_ID);
+ builder.setIconFfeUrl(ICON_FIFE_URL);
+ builder.setIconPng(ICON_PNG);
+ builder.setId(ID);
+ builder.setLastObservationTimestampMillis(LAST_OBSERVATION_TIMESTAMP_MILLIS);
+ builder.setLastUserExperience(LAST_USER_EXPERIENCE);
+ builder.setLostMillis(LOST_MILLIS);
+ builder.setMacAddress(MAC_ADDRESS);
+ builder.setPackageName(PACKAGE_NAME);
+ builder.setPendingAppInstallTimestampMillis(PENDING_APP_INSTALL_TIMESTAMP_MILLIS);
+ builder.setRssi(RSSI);
+ builder.setState(STATE);
+ builder.setTitle(TITLE);
+ builder.setTriggerId(TRIGGER_ID);
+ builder.setTxPower(TX_POWER);
+ builder.setType(TYPE);
+
+ return builder.build();
+ }
+
+ /* Generates Happy Path DiscoveryItemParcel. */
+ private static FastPairDiscoveryItemParcel genHappyPathFastPairDiscoveryItemParcel() {
+ FastPairDiscoveryItemParcel parcel = new FastPairDiscoveryItemParcel();
+
+ parcel.actionUrl = ACTION_URL;
+ parcel.actionUrlType = ACTION_URL_TYPE;
+ parcel.appName = APP_NAME;
+ parcel.attachmentType = ATTACHMENT_TYPE;
+ parcel.authenticationPublicKeySecp256r1 = AUTHENTICATION_PUBLIC_KEY_SEC_P256R1;
+ parcel.bleRecordBytes = BLE_RECORD_BYTES;
+ parcel.debugCategory = DEBUG_CATEGORY;
+ parcel.debugMessage = DEBUG_MESSAGE;
+ parcel.description = DESCRIPTION;
+ parcel.deviceName = DEVICE_NAME;
+ parcel.displayUrl = DISPLAY_URL;
+ parcel.entityId = ENTITY_ID;
+ parcel.featureGraphicUrl = FEATURE_GRAPHIC_URL;
+ parcel.firstObservationTimestampMillis = FIRST_OBSERVATION_TIMESTAMP_MILLIS;
+ parcel.groupId = GROUP_ID;
+ parcel.iconFifeUrl = ICON_FIFE_URL;
+ parcel.iconPng = ICON_PNG;
+ parcel.id = ID;
+ parcel.lastObservationTimestampMillis = LAST_OBSERVATION_TIMESTAMP_MILLIS;
+ parcel.lastUserExperience = LAST_USER_EXPERIENCE;
+ parcel.lostMillis = LOST_MILLIS;
+ parcel.macAddress = MAC_ADDRESS;
+ parcel.packageName = PACKAGE_NAME;
+ parcel.pendingAppInstallTimestampMillis = PENDING_APP_INSTALL_TIMESTAMP_MILLIS;
+ parcel.rssi = RSSI;
+ parcel.state = STATE;
+ parcel.title = TITLE;
+ parcel.triggerId = TRIGGER_ID;
+ parcel.txPower = TX_POWER;
+ parcel.type = TYPE;
+
+ return parcel;
+ }
+
/* Generates Happy Path DeviceMetadata. */
private static FastPairDeviceMetadata genHappyPathFastPairDeviceMetadata() {
FastPairDeviceMetadata.Builder builder = new FastPairDeviceMetadata.Builder();
@@ -512,6 +716,50 @@
return builder.build();
}
+ /* Generates Happy Path DeviceMetadataParcel. */
+ private static FastPairDeviceMetadataParcel genHappyPathFastPairDeviceMetadataParcel() {
+ FastPairDeviceMetadataParcel parcel = new FastPairDeviceMetadataParcel();
+
+ parcel.assistantSetupHalfSheet = ASSISTANT_SETUP_HALFSHEET;
+ parcel.assistantSetupNotification = ASSISTANT_SETUP_NOTIFICATION;
+ parcel.bleTxPower = BLE_TX_POWER;
+ parcel.confirmPinDescription = CONFIRM_PIN_DESCRIPTION;
+ parcel.confirmPinTitle = CONFIRM_PIN_TITLE;
+ parcel.connectSuccessCompanionAppInstalled = CONNECT_SUCCESS_COMPANION_APP_INSTALLED;
+ parcel.connectSuccessCompanionAppNotInstalled =
+ CONNECT_SUCCESS_COMPANION_APP_NOT_INSTALLED;
+ parcel.deviceType = DEVICE_TYPE;
+ parcel.downloadCompanionAppDescription = DOWNLOAD_COMPANION_APP_DESCRIPTION;
+ parcel.failConnectGoToSettingsDescription = FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION;
+ parcel.fastPairTvConnectDeviceNoAccountDescription =
+ FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION;
+ parcel.image = IMAGE;
+ parcel.imageUrl = IMAGE_URL;
+ parcel.initialNotificationDescription = INITIAL_NOTIFICATION_DESCRIPTION;
+ parcel.initialNotificationDescriptionNoAccount =
+ INITIAL_NOTIFICATION_DESCRIPTION_NO_ACCOUNT;
+ parcel.initialPairingDescription = INITIAL_PAIRING_DESCRIPTION;
+ parcel.intentUri = INTENT_URI;
+ parcel.locale = LOCALE;
+ parcel.openCompanionAppDescription = OPEN_COMPANION_APP_DESCRIPTION;
+ parcel.retroactivePairingDescription = RETRO_ACTIVE_PAIRING_DESCRIPTION;
+ parcel.subsequentPairingDescription = SUBSEQUENT_PAIRING_DESCRIPTION;
+ parcel.syncContactsDescription = SYNC_CONTACT_DESCRPTION;
+ parcel.syncContactsTitle = SYNC_CONTACTS_TITLE;
+ parcel.syncSmsDescription = SYNC_SMS_DESCRIPTION;
+ parcel.syncSmsTitle = SYNC_SMS_TITLE;
+ parcel.triggerDistance = TRIGGER_DISTANCE;
+ parcel.trueWirelessImageUrlCase = TRUE_WIRELESS_IMAGE_URL_CASE;
+ parcel.trueWirelessImageUrlLeftBud = TRUE_WIRELESS_IMAGE_URL_LEFT_BUD;
+ parcel.trueWirelessImageUrlRightBud = TRUE_WIRELESS_IMAGE_URL_RIGHT_BUD;
+ parcel.unableToConnectDescription = UNABLE_TO_CONNECT_DESCRIPTION;
+ parcel.unableToConnectTitle = UNABLE_TO_CONNECT_TITLE;
+ parcel.updateCompanionAppDescription = UPDATE_COMPANION_APP_DESCRIPTION;
+ parcel.waitLaunchCompanionAppDescription = WAIT_LAUNCH_COMPANION_APP_DESCRIPTION;
+
+ return parcel;
+ }
+
/* Generates Happy Path FastPairEligibleAccount. */
private static FastPairEligibleAccount genHappyPathFastPairEligibleAccount(
Account account, boolean optIn) {
@@ -528,18 +776,35 @@
assertEquals(REQUEST_MODEL_ID, request.getModelId());
}
+ /* Verifies Happy Path AccountDevicesMetadataRequest. */
+ private static void ensureHappyPathAsExpected(
+ FastPairDataProviderBase.FastPairAccountDevicesMetadataRequest request) {
+ assertEquals(ACCOUNTDEVICES_METADATA_ACCOUNT, request.getAccount());
+ }
+
+ /* Verifies Happy Path FastPairEligibleAccountsRequest. */
@SuppressWarnings("UnusedVariable")
private static void ensureHappyPathAsExpected(
FastPairDataProviderBase.FastPairEligibleAccountsRequest request) {
// No fields since FastPairEligibleAccountsRequest is just a place holder now.
}
+ /* Verifies Happy Path FastPairManageAccountRequest. */
private static void ensureHappyPathAsExpected(
FastPairDataProviderBase.FastPairManageAccountRequest request) {
assertEquals(MANAGE_ACCOUNT, request.getAccount());
assertEquals(MANAGE_ACCOUNT_REQUEST_TYPE, request.getRequestType());
}
+ /* Verifies Happy Path FastPairManageAccountDeviceRequest. */
+ private static void ensureHappyPathAsExpected(
+ FastPairDataProviderBase.FastPairManageAccountDeviceRequest request) {
+ assertEquals(MANAGE_ACCOUNT, request.getAccount());
+ assertEquals(MANAGE_ACCOUNT_REQUEST_TYPE, request.getRequestType());
+ assertEquals(BLE_ADDRESS, request.getBleAddress());
+ ensureHappyPathAsExpected(request.getAccountKeyDeviceMetadata());
+ }
+
/* Verifies Happy Path AntispoofkeyDeviceMetadataParcel. */
private static void ensureHappyPathAsExpected(
FastPairAntispoofkeyDeviceMetadataParcel metadataParcel) {
@@ -548,6 +813,37 @@
ensureHappyPathAsExpected(metadataParcel.deviceMetadata);
}
+ /* Verifies Happy Path FastPairAccountKeyDeviceMetadataParcel[]. */
+ private static void ensureHappyPathAsExpected(
+ FastPairAccountKeyDeviceMetadataParcel[] metadataParcels) {
+ assertNotNull(metadataParcels);
+ assertEquals(ACCOUNTKEY_DEVICE_NUM, metadataParcels.length);
+ for (FastPairAccountKeyDeviceMetadataParcel parcel: metadataParcels) {
+ ensureHappyPathAsExpected(parcel);
+ }
+ }
+
+ /* Verifies Happy Path FastPairAccountKeyDeviceMetadataParcel. */
+ private static void ensureHappyPathAsExpected(
+ FastPairAccountKeyDeviceMetadataParcel metadataParcel) {
+ assertNotNull(metadataParcel);
+ assertEquals(ACCOUNT_KEY, metadataParcel.accountKey);
+ assertEquals(SHA256_ACCOUNT_KEY_PUBLIC_ADDRESS,
+ metadataParcel.sha256AccountKeyPublicAddress);
+ ensureHappyPathAsExpected(metadataParcel.metadata);
+ ensureHappyPathAsExpected(metadataParcel.discoveryItem);
+ }
+
+ /* Verifies Happy Path FastPairAccountKeyDeviceMetadata. */
+ private static void ensureHappyPathAsExpected(
+ FastPairAccountKeyDeviceMetadata metadata) {
+ assertEquals(ACCOUNT_KEY, metadata.getAccountKey());
+ assertEquals(SHA256_ACCOUNT_KEY_PUBLIC_ADDRESS,
+ metadata.getSha256AccountKeyPublicAddress());
+ ensureHappyPathAsExpected(metadata.getFastPairDeviceMetadata());
+ ensureHappyPathAsExpected(metadata.getFastPairDiscoveryItem());
+ }
+
/* Verifies Happy Path DeviceMetadataParcel. */
private static void ensureHappyPathAsExpected(FastPairDeviceMetadataParcel metadataParcel) {
assertNotNull(metadataParcel);
@@ -597,7 +893,129 @@
metadataParcel.waitLaunchCompanionAppDescription);
}
- /* Verifies Happy Path EligibleAccounts. */
+ /* Verifies Happy Path DeviceMetadata. */
+ private static void ensureHappyPathAsExpected(FastPairDeviceMetadata metadata) {
+ assertEquals(ASSISTANT_SETUP_HALFSHEET, metadata.getAssistantSetupHalfSheet());
+ assertEquals(ASSISTANT_SETUP_NOTIFICATION, metadata.getAssistantSetupNotification());
+ assertEquals(BLE_TX_POWER, metadata.getBleTxPower());
+ assertEquals(CONFIRM_PIN_DESCRIPTION, metadata.getConfirmPinDescription());
+ assertEquals(CONFIRM_PIN_TITLE, metadata.getConfirmPinTitle());
+ assertEquals(CONNECT_SUCCESS_COMPANION_APP_INSTALLED,
+ metadata.getConnectSuccessCompanionAppInstalled());
+ assertEquals(CONNECT_SUCCESS_COMPANION_APP_NOT_INSTALLED,
+ metadata.getConnectSuccessCompanionAppNotInstalled());
+ assertEquals(DEVICE_TYPE, metadata.getDeviceType());
+ assertEquals(DOWNLOAD_COMPANION_APP_DESCRIPTION,
+ metadata.getDownloadCompanionAppDescription());
+ assertEquals(FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION,
+ metadata.getFailConnectGoToSettingsDescription());
+ assertEquals(FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION,
+ metadata.getFastPairTvConnectDeviceNoAccountDescription());
+ assertArrayEquals(IMAGE, metadata.getImage());
+ assertEquals(IMAGE_URL, metadata.getImageUrl());
+ assertEquals(INITIAL_NOTIFICATION_DESCRIPTION,
+ metadata.getInitialNotificationDescription());
+ assertEquals(INITIAL_NOTIFICATION_DESCRIPTION_NO_ACCOUNT,
+ metadata.getInitialNotificationDescriptionNoAccount());
+ assertEquals(INITIAL_PAIRING_DESCRIPTION, metadata.getInitialPairingDescription());
+ assertEquals(INTENT_URI, metadata.getIntentUri());
+ assertEquals(LOCALE, metadata.getLocale());
+ assertEquals(OPEN_COMPANION_APP_DESCRIPTION, metadata.getOpenCompanionAppDescription());
+ assertEquals(RETRO_ACTIVE_PAIRING_DESCRIPTION,
+ metadata.getRetroactivePairingDescription());
+ assertEquals(SUBSEQUENT_PAIRING_DESCRIPTION, metadata.getSubsequentPairingDescription());
+ assertEquals(SYNC_CONTACT_DESCRPTION, metadata.getSyncContactsDescription());
+ assertEquals(SYNC_CONTACTS_TITLE, metadata.getSyncContactsTitle());
+ assertEquals(SYNC_SMS_DESCRIPTION, metadata.getSyncSmsDescription());
+ assertEquals(SYNC_SMS_TITLE, metadata.getSyncSmsTitle());
+ assertEquals(TRIGGER_DISTANCE, metadata.getTriggerDistance(), DELTA);
+ assertEquals(TRUE_WIRELESS_IMAGE_URL_CASE, metadata.getTrueWirelessImageUrlCase());
+ assertEquals(TRUE_WIRELESS_IMAGE_URL_LEFT_BUD, metadata.getTrueWirelessImageUrlLeftBud());
+ assertEquals(TRUE_WIRELESS_IMAGE_URL_RIGHT_BUD,
+ metadata.getTrueWirelessImageUrlRightBud());
+ assertEquals(UNABLE_TO_CONNECT_DESCRIPTION, metadata.getUnableToConnectDescription());
+ assertEquals(UNABLE_TO_CONNECT_TITLE, metadata.getUnableToConnectTitle());
+ assertEquals(UPDATE_COMPANION_APP_DESCRIPTION,
+ metadata.getUpdateCompanionAppDescription());
+ assertEquals(WAIT_LAUNCH_COMPANION_APP_DESCRIPTION,
+ metadata.getWaitLaunchCompanionAppDescription());
+ }
+
+ /* Verifies Happy Path FastPairDiscoveryItemParcel. */
+ private static void ensureHappyPathAsExpected(FastPairDiscoveryItemParcel itemParcel) {
+ assertEquals(ACTION_URL, itemParcel.actionUrl);
+ assertEquals(ACTION_URL_TYPE, itemParcel.actionUrlType);
+ assertEquals(APP_NAME, itemParcel.appName);
+ assertEquals(ATTACHMENT_TYPE, itemParcel.attachmentType);
+ assertArrayEquals(AUTHENTICATION_PUBLIC_KEY_SEC_P256R1,
+ itemParcel.authenticationPublicKeySecp256r1);
+ assertArrayEquals(BLE_RECORD_BYTES, itemParcel.bleRecordBytes);
+ assertEquals(DEBUG_CATEGORY, itemParcel.debugCategory);
+ assertEquals(DEBUG_MESSAGE, itemParcel.debugMessage);
+ assertEquals(DESCRIPTION, itemParcel.description);
+ assertEquals(DEVICE_NAME, itemParcel.deviceName);
+ assertEquals(DISPLAY_URL, itemParcel.displayUrl);
+ assertEquals(ENTITY_ID, itemParcel.entityId);
+ assertEquals(FEATURE_GRAPHIC_URL, itemParcel.featureGraphicUrl);
+ assertEquals(FIRST_OBSERVATION_TIMESTAMP_MILLIS,
+ itemParcel.firstObservationTimestampMillis);
+ assertEquals(GROUP_ID, itemParcel.groupId);
+ assertEquals(ICON_FIFE_URL, itemParcel.iconFifeUrl);
+ assertEquals(ICON_PNG, itemParcel.iconPng);
+ assertEquals(ID, itemParcel.id);
+ assertEquals(LAST_OBSERVATION_TIMESTAMP_MILLIS, itemParcel.lastObservationTimestampMillis);
+ assertEquals(LAST_USER_EXPERIENCE, itemParcel.lastUserExperience);
+ assertEquals(LOST_MILLIS, itemParcel.lostMillis);
+ assertEquals(MAC_ADDRESS, itemParcel.macAddress);
+ assertEquals(PACKAGE_NAME, itemParcel.packageName);
+ assertEquals(PENDING_APP_INSTALL_TIMESTAMP_MILLIS,
+ itemParcel.pendingAppInstallTimestampMillis);
+ assertEquals(RSSI, itemParcel.rssi);
+ assertEquals(STATE, itemParcel.state);
+ assertEquals(TITLE, itemParcel.title);
+ assertEquals(TRIGGER_ID, itemParcel.triggerId);
+ assertEquals(TX_POWER, itemParcel.txPower);
+ assertEquals(TYPE, itemParcel.type);
+ }
+
+ /* Verifies Happy Path FastPairDiscoveryItem. */
+ private static void ensureHappyPathAsExpected(FastPairDiscoveryItem item) {
+ assertEquals(ACTION_URL, item.getActionUrl());
+ assertEquals(ACTION_URL_TYPE, item.getActionUrlType());
+ assertEquals(APP_NAME, item.getAppName());
+ assertEquals(ATTACHMENT_TYPE, item.getAttachmentType());
+ assertArrayEquals(AUTHENTICATION_PUBLIC_KEY_SEC_P256R1,
+ item.getAuthenticationPublicKeySecp256r1());
+ assertArrayEquals(BLE_RECORD_BYTES, item.getBleRecordBytes());
+ assertEquals(DEBUG_CATEGORY, item.getDebugCategory());
+ assertEquals(DEBUG_MESSAGE, item.getDebugMessage());
+ assertEquals(DESCRIPTION, item.getDescription());
+ assertEquals(DEVICE_NAME, item.getDeviceName());
+ assertEquals(DISPLAY_URL, item.getDisplayUrl());
+ assertEquals(ENTITY_ID, item.getEntityId());
+ assertEquals(FEATURE_GRAPHIC_URL, item.getFeatureGraphicUrl());
+ assertEquals(FIRST_OBSERVATION_TIMESTAMP_MILLIS,
+ item.getFirstObservationTimestampMillis());
+ assertEquals(GROUP_ID, item.getGroupId());
+ assertEquals(ICON_FIFE_URL, item.getIconFfeUrl());
+ assertEquals(ICON_PNG, item.getIconPng());
+ assertEquals(ID, item.getId());
+ assertEquals(LAST_OBSERVATION_TIMESTAMP_MILLIS, item.getLastObservationTimestampMillis());
+ assertEquals(LAST_USER_EXPERIENCE, item.getLastUserExperience());
+ assertEquals(LOST_MILLIS, item.getLostMillis());
+ assertEquals(MAC_ADDRESS, item.getMacAddress());
+ assertEquals(PACKAGE_NAME, item.getPackageName());
+ assertEquals(PENDING_APP_INSTALL_TIMESTAMP_MILLIS,
+ item.getPendingAppInstallTimestampMillis());
+ assertEquals(RSSI, item.getRssi());
+ assertEquals(STATE, item.getState());
+ assertEquals(TITLE, item.getTitle());
+ assertEquals(TRIGGER_ID, item.getTriggerId());
+ assertEquals(TX_POWER, item.getTxPower());
+ assertEquals(TYPE, item.getType());
+ }
+
+ /* Verifies Happy Path EligibleAccountParcel[]. */
private static void ensureHappyPathAsExpected(FastPairEligibleAccountParcel[] accountsParcel) {
assertEquals(ELIGIBLE_ACCOUNTS_NUM, accountsParcel.length);
assertEquals(ELIGIBLE_ACCOUNT_1, accountsParcel[0].account);
diff --git a/nearby/tests/cts/fastpair/src/android/nearby/cts/NearbyDeviceParcelableTest.java b/nearby/tests/cts/fastpair/src/android/nearby/cts/NearbyDeviceParcelableTest.java
new file mode 100644
index 0000000..16cab99
--- /dev/null
+++ b/nearby/tests/cts/fastpair/src/android/nearby/cts/NearbyDeviceParcelableTest.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.nearby.cts;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.nearby.NearbyDevice;
+import android.nearby.NearbyDeviceParcelable;
+import android.os.Build;
+
+import androidx.annotation.RequiresApi;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+@RequiresApi(Build.VERSION_CODES.TIRAMISU)
+public class NearbyDeviceParcelableTest {
+
+ private static final String BLUETOOTH_ADDRESS = "00:11:22:33:FF:EE";
+
+ /** Verify toString returns expected string. */
+ @Test
+ public void testToString() {
+ NearbyDeviceParcelable nearbyDeviceParcelable = new NearbyDeviceParcelable.Builder()
+ .setName("testDevice")
+ .setMedium(NearbyDevice.Medium.BLE)
+ .setRssi(-60)
+ .setFastPairModelId(null)
+ .setBluetoothAddress(BLUETOOTH_ADDRESS)
+ .setData(null)
+ .build();
+
+ assertThat(nearbyDeviceParcelable.toString()).isEqualTo(
+ "NearbyDeviceParcelable[name=testDevice, medium=BLE, rssi=-60, "
+ + "bluetoothAddress="
+ + BLUETOOTH_ADDRESS + ", fastPairModelId=null, data=null]");
+ }
+
+ @Test
+ public void test_defaultNullFields() {
+ NearbyDeviceParcelable nearbyDeviceParcelable = new NearbyDeviceParcelable.Builder()
+ .setMedium(NearbyDevice.Medium.BLE)
+ .setRssi(-60)
+ .build();
+
+ assertThat(nearbyDeviceParcelable.getName()).isNull();
+ assertThat(nearbyDeviceParcelable.getFastPairModelId()).isNull();
+ assertThat(nearbyDeviceParcelable.getBluetoothAddress()).isNull();
+ assertThat(nearbyDeviceParcelable.getData()).isNull();
+
+ assertThat(nearbyDeviceParcelable.getMedium()).isEqualTo(NearbyDevice.Medium.BLE);
+ assertThat(nearbyDeviceParcelable.getRssi()).isEqualTo(-60);
+ }
+}
diff --git a/nearby/tests/cts/fastpair/src/android/nearby/cts/NearbyDeviceTest.java b/nearby/tests/cts/fastpair/src/android/nearby/cts/NearbyDeviceTest.java
new file mode 100644
index 0000000..b7a4690
--- /dev/null
+++ b/nearby/tests/cts/fastpair/src/android/nearby/cts/NearbyDeviceTest.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.nearby.cts;
+
+import android.annotation.TargetApi;
+import android.nearby.FastPairDevice;
+import android.nearby.NearbyDevice;
+import android.os.Build;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import androidx.annotation.RequiresApi;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+@RequiresApi(Build.VERSION_CODES.TIRAMISU)
+@TargetApi(Build.VERSION_CODES.TIRAMISU)
+public class NearbyDeviceTest {
+
+ @Test
+ public void test_isValidMedium() {
+ assertThat(NearbyDevice.isValidMedium(1)).isTrue();
+ assertThat(NearbyDevice.isValidMedium(2)).isTrue();
+
+ assertThat(NearbyDevice.isValidMedium(0)).isFalse();
+ assertThat(NearbyDevice.isValidMedium(3)).isFalse();
+ }
+
+ @Test
+ public void test_getMedium_fromChild() {
+ FastPairDevice fastPairDevice = new FastPairDevice.Builder()
+ .setMedium(NearbyDevice.Medium.BLE)
+ .setRssi(-60)
+ .build();
+
+ assertThat(fastPairDevice.getMedium()).isEqualTo(1);
+ assertThat(fastPairDevice.getRssi()).isEqualTo(-60);
+ }
+}
diff --git a/nearby/tests/cts/fastpair/src/android/nearby/cts/NearbyFrameworkInitializerTest.java b/nearby/tests/cts/fastpair/src/android/nearby/cts/NearbyFrameworkInitializerTest.java
new file mode 100644
index 0000000..c062e84
--- /dev/null
+++ b/nearby/tests/cts/fastpair/src/android/nearby/cts/NearbyFrameworkInitializerTest.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.nearby.cts;
+
+import android.annotation.TargetApi;
+import android.nearby.NearbyFrameworkInitializer;
+import android.os.Build;
+
+import androidx.annotation.RequiresApi;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+// NearbyFrameworkInitializer was added in T
+@RunWith(AndroidJUnit4.class)
+@RequiresApi(Build.VERSION_CODES.TIRAMISU)
+@TargetApi(Build.VERSION_CODES.TIRAMISU)
+public class NearbyFrameworkInitializerTest {
+
+// // TODO(b/215435710) This test cannot pass now because our test cannot access system API.
+// // run "adb root && adb shell setenforce permissive" and uncomment testServicesRegistered,
+// // test passes.
+// @Test
+// public void testServicesRegistered() {
+// Context ctx = InstrumentationRegistry.getInstrumentation().getContext();
+// assertNotNull( "NearbyManager not registered",
+// ctx.getSystemService(Context.NEARBY_SERVICE));
+// }
+
+ // registerServiceWrappers can only be called during initialization and should throw otherwise
+ @Test(expected = IllegalStateException.class)
+ public void testThrowsException() {
+ NearbyFrameworkInitializer.registerServiceWrappers();
+ }
+}
diff --git a/nearby/tests/cts/fastpair/src/android/nearby/cts/ScanRequestTest.java b/nearby/tests/cts/fastpair/src/android/nearby/cts/ScanRequestTest.java
new file mode 100644
index 0000000..a49444f
--- /dev/null
+++ b/nearby/tests/cts/fastpair/src/android/nearby/cts/ScanRequestTest.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.nearby.cts;
+
+import static android.nearby.ScanRequest.SCAN_MODE_BALANCED;
+import static android.nearby.ScanRequest.SCAN_MODE_LOW_LATENCY;
+import static android.nearby.ScanRequest.SCAN_MODE_LOW_POWER;
+import static android.nearby.ScanRequest.SCAN_MODE_NO_POWER;
+import static android.nearby.ScanRequest.SCAN_TYPE_EXPOSURE_NOTIFICATION;
+import static android.nearby.ScanRequest.SCAN_TYPE_FAST_PAIR;
+import static android.nearby.ScanRequest.SCAN_TYPE_NEARBY_PRESENCE;
+import static android.nearby.ScanRequest.SCAN_TYPE_NEARBY_SHARE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.annotation.TargetApi;
+import android.nearby.ScanRequest;
+import android.os.Build;
+import android.os.WorkSource;
+
+import androidx.annotation.RequiresApi;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+// NearbyFrameworkInitializer was added in T
+@RunWith(AndroidJUnit4.class)
+@RequiresApi(Build.VERSION_CODES.TIRAMISU)
+@TargetApi(Build.VERSION_CODES.TIRAMISU)
+public class ScanRequestTest {
+
+ private static final int UID = 1001;
+ private static final String APP_NAME = "android.nearby.tests";
+
+ // Valid scan type must be set to one of ScanRequest#SCAN_TYPE_
+ @Test(expected = IllegalStateException.class)
+ public void testScanType_notSet_throwsException() {
+ new ScanRequest.Builder().setScanMode(SCAN_MODE_BALANCED).build();
+ }
+
+ @Test
+ public void testScanMode_defaultLowPower() {
+ ScanRequest request = new ScanRequest.Builder()
+ .setScanType(SCAN_TYPE_FAST_PAIR)
+ .build();
+
+ assertThat(request.getScanMode()).isEqualTo(SCAN_MODE_LOW_POWER);
+ }
+
+ /** Verify setting work source with null value in the scan request is allowed*/
+ @Test
+ public void testSetWorkSource_nullValue() {
+ ScanRequest request = new ScanRequest.Builder()
+ .setScanType(SCAN_TYPE_EXPOSURE_NOTIFICATION)
+ .setWorkSource(null)
+ .build();
+
+ // Null work source is allowed.
+ assertThat(request.getWorkSource().isEmpty()).isTrue();
+ }
+
+ /** Verify toString returns expected string. */
+ @Test
+ public void testToString() {
+ WorkSource workSource = getWorkSource();
+ ScanRequest request = new ScanRequest.Builder()
+ .setScanType(SCAN_TYPE_NEARBY_SHARE)
+ .setScanMode(SCAN_MODE_BALANCED)
+ .setEnableBle(true)
+ .setWorkSource(workSource)
+ .build();
+
+ assertThat(request.toString()).isEqualTo(
+ "Request[scanType=2, scanMode=SCAN_MODE_BALANCED, "
+ + "enableBle=true, workSource=WorkSource{" + UID + " " + APP_NAME + "}]");
+ }
+
+ /** Verify toString works correctly with null WorkSource. */
+ @Test
+ public void testToString_nullWorkSource() {
+ ScanRequest request = new ScanRequest.Builder().setScanType(
+ SCAN_TYPE_FAST_PAIR).setWorkSource(null).build();
+
+ assertThat(request.toString()).isEqualTo("Request[scanType=1, "
+ + "scanMode=SCAN_MODE_LOW_POWER, enableBle=true, workSource=WorkSource{}]");
+ }
+
+ @Test
+ public void testisEnableBle_defaultTrue() {
+ ScanRequest request = new ScanRequest.Builder()
+ .setScanType(SCAN_TYPE_FAST_PAIR)
+ .build();
+
+ assertThat(request.isEnableBle()).isTrue();
+ }
+
+ @Test
+ public void test_isValidScanType() {
+ assertThat(ScanRequest.isValidScanType(SCAN_TYPE_FAST_PAIR)).isTrue();
+ assertThat(ScanRequest.isValidScanType(SCAN_TYPE_NEARBY_SHARE)).isTrue();
+ assertThat(ScanRequest.isValidScanType(SCAN_TYPE_NEARBY_PRESENCE)).isTrue();
+ assertThat(ScanRequest.isValidScanType(SCAN_TYPE_EXPOSURE_NOTIFICATION)).isTrue();
+
+ assertThat(ScanRequest.isValidScanType(0)).isFalse();
+ assertThat(ScanRequest.isValidScanType(5)).isFalse();
+ }
+
+ @Test
+ public void test_isValidScanMode() {
+ assertThat(ScanRequest.isValidScanMode(SCAN_MODE_LOW_LATENCY)).isTrue();
+ assertThat(ScanRequest.isValidScanMode(SCAN_MODE_BALANCED)).isTrue();
+ assertThat(ScanRequest.isValidScanMode(SCAN_MODE_LOW_POWER)).isTrue();
+ assertThat(ScanRequest.isValidScanMode(SCAN_MODE_NO_POWER)).isTrue();
+
+ assertThat(ScanRequest.isValidScanMode(3)).isFalse();
+ assertThat(ScanRequest.isValidScanMode(-2)).isFalse();
+ }
+
+ @Test
+ public void test_scanModeToString() {
+ assertThat(ScanRequest.scanModeToString(2)).isEqualTo("SCAN_MODE_LOW_LATENCY");
+ assertThat(ScanRequest.scanModeToString(1)).isEqualTo("SCAN_MODE_BALANCED");
+ assertThat(ScanRequest.scanModeToString(0)).isEqualTo("SCAN_MODE_LOW_POWER");
+ assertThat(ScanRequest.scanModeToString(-1)).isEqualTo("SCAN_MODE_NO_POWER");
+
+ assertThat(ScanRequest.scanModeToString(3)).isEqualTo("SCAN_MODE_INVALID");
+ assertThat(ScanRequest.scanModeToString(-2)).isEqualTo("SCAN_MODE_INVALID");
+ }
+
+ private static WorkSource getWorkSource() {
+ return new WorkSource(UID, APP_NAME);
+ }
+}
diff --git a/nearby/tests/robotests/src/com/android/server/nearby/common/bluetooth/fastpair/BluetoothClassicPairerTest.java b/nearby/tests/robotests/src/com/android/server/nearby/common/bluetooth/fastpair/BluetoothClassicPairerTest.java
index 5d12758..1ac2aaf 100644
--- a/nearby/tests/robotests/src/com/android/server/nearby/common/bluetooth/fastpair/BluetoothClassicPairerTest.java
+++ b/nearby/tests/robotests/src/com/android/server/nearby/common/bluetooth/fastpair/BluetoothClassicPairerTest.java
@@ -16,14 +16,10 @@
package com.android.server.nearby.common.bluetooth.fastpair;
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.junit.Assert.assertThrows;
import static org.robolectric.Shadows.shadowOf;
import android.Manifest.permission;
import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
import com.android.libraries.testing.deviceshadower.Bluelet.IoCapabilities;
import com.android.libraries.testing.deviceshadower.DeviceShadowEnvironment;
@@ -38,7 +34,6 @@
import org.robolectric.RobolectricTestRunner;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.atomic.AtomicReference;
/**
* Tests for {@link BluetoothClassicPairer}.
@@ -83,6 +78,8 @@
@Test
public void pair_setPairingConfirmationTrue_deviceBonded() throws Exception {
+ // TODO(b/217195327): replace deviceshadower with injector.
+ /*
AtomicReference<BluetoothDevice> targetRemoteDevice = new AtomicReference<>();
BluetoothClassicPairer bluetoothClassicPairer =
new BluetoothClassicPairer(
@@ -105,10 +102,13 @@
assertThat(targetRemoteDevice.get().getAddress()).isEqualTo(REMOTE_DEVICE_PUBLIC_ADDRESS);
assertThat(targetRemoteDevice.get().getBondState()).isEqualTo(BluetoothDevice.BOND_BONDED);
assertThat(bluetoothClassicPairer.isPaired()).isTrue();
+ */
}
@Test
public void pair_setPairingConfirmationFalse_throwsExceptionDeviceNotBonded() throws Exception {
+ // TODO(b/217195327): replace deviceshadower with injector.
+ /*
AtomicReference<BluetoothDevice> targetRemoteDevice = new AtomicReference<>();
BluetoothClassicPairer bluetoothClassicPairer =
new BluetoothClassicPairer(
@@ -132,11 +132,14 @@
assertThat(targetRemoteDevice.get().getBondState()).isNotEqualTo(
BluetoothDevice.BOND_BONDED);
assertThat(bluetoothClassicPairer.isPaired()).isFalse();
+ */
}
@Test
public void pair_setPairingConfirmationIgnored_throwsExceptionDeviceNotBonded()
throws Exception {
+ // TODO(b/217195327): replace deviceshadower with injector.
+ /*
AtomicReference<BluetoothDevice> targetRemoteDevice = new AtomicReference<>();
BluetoothClassicPairer bluetoothClassicPairer =
new BluetoothClassicPairer(
@@ -158,6 +161,7 @@
assertThat(targetRemoteDevice.get().getBondState()).isNotEqualTo(
BluetoothDevice.BOND_BONDED);
assertThat(bluetoothClassicPairer.isPaired()).isFalse();
+ */
}
private static void setPairingConfirmationAtRemoteDevice(boolean confirm) {
diff --git a/nearby/tests/unit/Android.bp b/nearby/tests/unit/Android.bp
index 64ef292..93ab20a 100644
--- a/nearby/tests/unit/Android.bp
+++ b/nearby/tests/unit/Android.bp
@@ -37,7 +37,7 @@
"androidx.test.ext.junit",
"androidx.test.rules",
"compatibility-device-util-axt",
- "framework-nearby-pre-jarjar",
+ "framework-nearby-static",
"guava",
"junit",
"libprotobuf-java-lite",
@@ -50,6 +50,6 @@
],
test_suites: [
"general-tests",
- "mts",
+ "mts-tethering",
],
}