Merge changes from topic "nearby_tethering_apex"
* changes:
Rename NearbyServiceImpl to NearbyService
Start NearbyService from connectivity initializer
Move nearby apex to tethering
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
-xYI3w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gxjNe1xdwVyRbKZLxJHTF
-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
-LmFuZHJvaWQubmVhcmJ5MCAXDTIxMDYwMTIzNTQwNVoYDzQ3NTkwNDI4MjM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nNiRq8XyQh0kFR5Hm6W18BZ6AIawUWDx0syCQlflFzsbQSSqkAxg
-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/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 43d0d21..56dc682 100644
--- a/nearby/tests/cts/fastpair/Android.bp
+++ b/nearby/tests/cts/fastpair/Android.bp
@@ -25,11 +25,11 @@
"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: [
diff --git a/nearby/tests/unit/Android.bp b/nearby/tests/unit/Android.bp
index 11bf84a..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",