Add Intdefs.
Remove proto enums at the same time.
Test: skip test for const.
Bug: 201673262
Change-Id: Icae8aa8aeb4ca07c1a243133cacd727ea9285dc5
diff --git a/nearby/service/Android.bp b/nearby/service/Android.bp
index 1ed318d..f1f7c44 100644
--- a/nearby/service/Android.bp
+++ b/nearby/service/Android.bp
@@ -42,7 +42,6 @@
"androidx.annotation_annotation",
"androidx.core_core",
"auto_value_annotations",
- "fast-pair-lite-protos",
"guava",
"libprotobuf-java-lite",
],
diff --git a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/BluetoothAudioPairer.java b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/BluetoothAudioPairer.java
index e05399c..acf64b9 100644
--- a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/BluetoothAudioPairer.java
+++ b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/BluetoothAudioPairer.java
@@ -52,9 +52,9 @@
import com.android.server.nearby.common.bluetooth.fastpair.TimingLogger.ScopedTiming;
import com.android.server.nearby.common.bluetooth.gatt.BluetoothGattConnection;
import com.android.server.nearby.common.bluetooth.gatt.BluetoothGattConnection.ChangeObserver;
-import com.android.server.nearby.proto.FastPairEnums.FastPairEvent.ConnectErrorCode;
-import com.android.server.nearby.proto.FastPairEnums.FastPairEvent.CreateBondErrorCode;
-import com.android.server.nearby.proto.NearbyEventCodes.NearbyEvent.EventCode;
+import com.android.server.nearby.intdefs.FastPairEventIntDefs.ConnectErrorCode;
+import com.android.server.nearby.intdefs.FastPairEventIntDefs.CreateBondErrorCode;
+import com.android.server.nearby.intdefs.NearbyEventIntDefs.EventCode;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.SettableFuture;
diff --git a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/ConnectException.java b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/ConnectException.java
index 9413723..9c8d292 100644
--- a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/ConnectException.java
+++ b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/ConnectException.java
@@ -16,19 +16,20 @@
package com.android.server.nearby.common.bluetooth.fastpair;
-import com.android.server.nearby.proto.FastPairEnums.FastPairEvent;
+import com.android.server.nearby.intdefs.FastPairEventIntDefs.ConnectErrorCode;
+
/** Thrown when connecting to a bluetooth device fails. */
public class ConnectException extends PairingException {
- final FastPairEvent.ConnectErrorCode mErrorCode;
+ final @ConnectErrorCode int mErrorCode;
- ConnectException(FastPairEvent.ConnectErrorCode errorCode, String format, Object... objects) {
+ ConnectException(@ConnectErrorCode int errorCode, String format, Object... objects) {
super(format, objects);
this.mErrorCode = errorCode;
}
/** Returns error code. */
- public FastPairEvent.ConnectErrorCode getErrorCode() {
+ public @ConnectErrorCode int getErrorCode() {
return mErrorCode;
}
}
diff --git a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/CreateBondException.java b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/CreateBondException.java
index cca2c7f..d6aa3b2 100644
--- a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/CreateBondException.java
+++ b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/CreateBondException.java
@@ -16,14 +16,14 @@
package com.android.server.nearby.common.bluetooth.fastpair;
-import com.android.server.nearby.proto.FastPairEnums.FastPairEvent;
+import com.android.server.nearby.intdefs.FastPairEventIntDefs.CreateBondErrorCode;
/** Thrown when binding (pairing) with a bluetooth device fails. */
public class CreateBondException extends PairingException {
- final FastPairEvent.CreateBondErrorCode mErrorCode;
+ final @CreateBondErrorCode int mErrorCode;
int mReason;
- CreateBondException(FastPairEvent.CreateBondErrorCode errorCode, int reason, String format,
+ CreateBondException(@CreateBondErrorCode int errorCode, int reason, String format,
Object... objects) {
super(format, objects);
this.mErrorCode = errorCode;
@@ -31,7 +31,7 @@
}
/** Returns error code. */
- public FastPairEvent.CreateBondErrorCode getErrorCode() {
+ public @CreateBondErrorCode int getErrorCode() {
return mErrorCode;
}
diff --git a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/Event.java b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/Event.java
index c867aaa..5b0ed53 100644
--- a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/Event.java
+++ b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/Event.java
@@ -20,7 +20,7 @@
import android.os.Parcel;
import android.os.Parcelable;
-import com.android.server.nearby.proto.NearbyEventCodes.NearbyEvent.EventCode;
+import com.android.server.nearby.intdefs.NearbyEventIntDefs.EventCode;
import com.google.auto.value.AutoValue;
@@ -36,7 +36,7 @@
/**
* Returns event code.
*/
- public abstract EventCode getEventCode();
+ public abstract @EventCode int getEventCode();
/**
* Returns timestamp.
@@ -98,7 +98,7 @@
/**
* Set event code.
*/
- public abstract Builder setEventCode(EventCode eventCode);
+ public abstract Builder setEventCode(@EventCode int eventCode);
/**
* Set timestamp.
@@ -128,7 +128,7 @@
@Override
public final void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(getEventCode().getNumber());
+ dest.writeInt(getEventCode());
dest.writeLong(getTimestamp());
dest.writeValue(getProfile());
dest.writeParcelable(getBluetoothDevice(), 0);
@@ -149,7 +149,7 @@
/** Creates Event from Parcel. */
public Event createFromParcel(Parcel in) {
return Event.builder()
- .setEventCode(EventCode.forNumber(in.readInt()))
+ .setEventCode(in.readInt())
.setTimestamp(in.readLong())
.setProfile((Short) in.readValue(Short.class.getClassLoader()))
.setBluetoothDevice(
diff --git a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/EventLoggerWrapper.java b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/EventLoggerWrapper.java
index 79da3c3..024bfde 100644
--- a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/EventLoggerWrapper.java
+++ b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/EventLoggerWrapper.java
@@ -20,7 +20,7 @@
import android.content.Context;
import com.android.server.nearby.common.bluetooth.fastpair.Preferences.ExtraLoggingInformation;
-import com.android.server.nearby.proto.NearbyEventCodes.NearbyEvent.EventCode;
+import com.android.server.nearby.intdefs.NearbyEventIntDefs.EventCode;
import javax.annotation.Nullable;
@@ -49,7 +49,7 @@
void unbind(Context context) {
}
- void setCurrentEvent(EventCode code) {
+ void setCurrentEvent(@EventCode int code) {
}
void setCurrentProfile(short profile) {
diff --git a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/FastPairConnection.java b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/FastPairConnection.java
index 0571737..fa93639 100644
--- a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/FastPairConnection.java
+++ b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/FastPairConnection.java
@@ -25,7 +25,6 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.nearby.common.bluetooth.BluetoothException;
-import com.android.server.nearby.proto.FastPairEnums.FastPairEvent;
import com.google.auto.value.AutoValue;
@@ -41,7 +40,7 @@
@Nullable protected OnGetBluetoothAddressCallback mOnGetBluetoothAddressCallback;
@Nullable protected PasskeyConfirmationHandler mPasskeyConfirmationHandler;
@Nullable protected FastPairSignalChecker mFastPairSignalChecker;
- @Nullable protected Consumer<FastPairEvent.ErrorCode> mRescueFromError;
+ @Nullable protected Consumer<Integer> mRescueFromError;
@Nullable protected Runnable mPrepareCreateBondCallback;
protected boolean mPasskeyIsGotten;
@@ -65,7 +64,7 @@
this.mFastPairSignalChecker = fastPairSignalChecker;
}
- public void setRescueFromError(Consumer<FastPairEvent.ErrorCode> rescueFromError) {
+ public void setRescueFromError(Consumer<Integer> rescueFromError) {
this.mRescueFromError = rescueFromError;
}
diff --git a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/FastPairDualConnection.java b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/FastPairDualConnection.java
index 13b1458..c3b3711 100644
--- a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/FastPairDualConnection.java
+++ b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/FastPairDualConnection.java
@@ -20,7 +20,7 @@
import androidx.annotation.Nullable;
-import com.android.server.nearby.proto.NearbyEventCodes.NearbyEvent.EventCode;
+import com.android.server.nearby.intdefs.NearbyEventIntDefs.EventCode;
import com.google.common.base.Ascii;
@@ -111,7 +111,7 @@
public abstract class FastPairDualConnection extends FastPairConnection {
static void logRetrySuccessEvent(
- EventCode eventCode,
+ @EventCode int eventCode,
@Nullable Exception recoverFromException,
EventLoggerWrapper eventLogger) {
if (recoverFromException == null) {
diff --git a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/GattConnectionManager.java b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/GattConnectionManager.java
index 88936c0..ff0efc7 100644
--- a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/GattConnectionManager.java
+++ b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/GattConnectionManager.java
@@ -39,8 +39,8 @@
import com.android.server.nearby.common.bluetooth.gatt.BluetoothGattHelper.ConnectionOptions;
import com.android.server.nearby.common.bluetooth.testability.android.bluetooth.BluetoothAdapter;
import com.android.server.nearby.common.bluetooth.util.BluetoothOperationExecutor.BluetoothOperationTimeoutException;
-import com.android.server.nearby.proto.FastPairEnums.FastPairEvent.ErrorCode;
-import com.android.server.nearby.proto.NearbyEventCodes.NearbyEvent.EventCode;
+import com.android.server.nearby.intdefs.FastPairEventIntDefs.ErrorCode;
+import com.android.server.nearby.intdefs.NearbyEventIntDefs.EventCode;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@@ -111,7 +111,7 @@
}
BluetoothGattConnection getConnectionWithSignalLostCheck(
- @Nullable Consumer<ErrorCode> rescueFromError)
+ @Nullable Consumer<Integer> rescueFromError)
throws InterruptedException, ExecutionException, TimeoutException, BluetoothException,
SignalLostException, SignalRotatedException {
if (mGattConnection == null) {
@@ -135,7 +135,7 @@
private BluetoothGattConnection connect(
String address, boolean checkSignalWhenFail,
- @Nullable Consumer<ErrorCode> rescueFromError)
+ @Nullable Consumer<Integer> rescueFromError)
throws InterruptedException, ExecutionException, TimeoutException, BluetoothException,
SignalLostException, SignalRotatedException {
int i = 1;
diff --git a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/HandshakeHandler.java b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/HandshakeHandler.java
index caeeb30..b1918b5 100644
--- a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/HandshakeHandler.java
+++ b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/HandshakeHandler.java
@@ -63,8 +63,8 @@
import com.android.server.nearby.common.bluetooth.gatt.BluetoothGattConnection;
import com.android.server.nearby.common.bluetooth.gatt.BluetoothGattConnection.ChangeObserver;
import com.android.server.nearby.common.bluetooth.util.BluetoothOperationExecutor.BluetoothOperationTimeoutException;
-import com.android.server.nearby.proto.FastPairEnums.FastPairEvent.ErrorCode;
-import com.android.server.nearby.proto.NearbyEventCodes.NearbyEvent.EventCode;
+import com.android.server.nearby.intdefs.FastPairEventIntDefs.ErrorCode;
+import com.android.server.nearby.intdefs.NearbyEventIntDefs.EventCode;
import java.security.GeneralSecurityException;
import java.security.SecureRandom;
@@ -144,7 +144,7 @@
* FastPair signal check if fails.
*/
public SharedSecret doHandshakeWithRetryAndSignalLostCheck(
- byte[] key, HandshakeMessage message, @Nullable Consumer<ErrorCode> rescueFromError)
+ byte[] key, HandshakeMessage message, @Nullable Consumer<Integer> rescueFromError)
throws GeneralSecurityException, InterruptedException, ExecutionException,
TimeoutException, BluetoothException, PairingException {
Keys keys = createKey(key);
diff --git a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/TdsException.java b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/TdsException.java
index 81dadbe..7382ff3 100644
--- a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/TdsException.java
+++ b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/TdsException.java
@@ -16,7 +16,7 @@
package com.android.server.nearby.common.bluetooth.fastpair;
-import com.android.server.nearby.proto.FastPairEnums.FastPairEvent.BrEdrHandoverErrorCode;
+import com.android.server.nearby.intdefs.FastPairEventIntDefs.BrEdrHandoverErrorCode;
import com.google.errorprone.annotations.FormatMethod;
@@ -25,16 +25,16 @@
*/
public class TdsException extends Exception {
- final BrEdrHandoverErrorCode mErrorCode;
+ final @BrEdrHandoverErrorCode int mErrorCode;
@FormatMethod
- TdsException(BrEdrHandoverErrorCode errorCode, String format, Object... objects) {
+ TdsException(@BrEdrHandoverErrorCode int errorCode, String format, Object... objects) {
super(String.format(format, objects));
this.mErrorCode = errorCode;
}
/** Returns error code. */
- public BrEdrHandoverErrorCode getErrorCode() {
+ public @BrEdrHandoverErrorCode int getErrorCode() {
return mErrorCode;
}
}
diff --git a/nearby/service/java/com/android/server/nearby/intdefs/FastPairEventIntDefs.java b/nearby/service/java/com/android/server/nearby/intdefs/FastPairEventIntDefs.java
new file mode 100644
index 0000000..8bb7980
--- /dev/null
+++ b/nearby/service/java/com/android/server/nearby/intdefs/FastPairEventIntDefs.java
@@ -0,0 +1,168 @@
+/*
+ * Copyright 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.intdefs;
+
+import androidx.annotation.IntDef;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/** Holds integer definitions for FastPair. */
+public class FastPairEventIntDefs {
+
+ /** Fast Pair Bond State. */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(
+ value = {
+ BondState.UNKNOWN_BOND_STATE,
+ BondState.NONE,
+ BondState.BONDING,
+ BondState.BONDED,
+ })
+ public @interface BondState {
+ int UNKNOWN_BOND_STATE = 0;
+ int NONE = 10;
+ int BONDING = 11;
+ int BONDED = 12;
+ }
+
+ /** Fast Pair error code. */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(
+ value = {
+ ErrorCode.UNKNOWN_ERROR_CODE,
+ ErrorCode.OTHER_ERROR,
+ ErrorCode.TIMEOUT,
+ ErrorCode.INTERRUPTED,
+ ErrorCode.REFLECTIVE_OPERATION_EXCEPTION,
+ ErrorCode.EXECUTION_EXCEPTION,
+ ErrorCode.PARSE_EXCEPTION,
+ ErrorCode.MDH_REMOTE_EXCEPTION,
+ ErrorCode.SUCCESS_RETRY_GATT_ERROR,
+ ErrorCode.SUCCESS_RETRY_GATT_TIMEOUT,
+ ErrorCode.SUCCESS_RETRY_SECRET_HANDSHAKE_ERROR,
+ ErrorCode.SUCCESS_RETRY_SECRET_HANDSHAKE_TIMEOUT,
+ ErrorCode.SUCCESS_SECRET_HANDSHAKE_RECONNECT,
+ ErrorCode.SUCCESS_ADDRESS_ROTATE,
+ ErrorCode.SUCCESS_SIGNAL_LOST,
+ })
+ public @interface ErrorCode {
+ int UNKNOWN_ERROR_CODE = 0;
+
+ // Check the other fields for a more specific error code.
+ int OTHER_ERROR = 1;
+
+ // The operation timed out.
+ int TIMEOUT = 2;
+
+ // The thread was interrupted.
+ int INTERRUPTED = 3;
+
+ // Some reflective call failed (should never happen).
+ int REFLECTIVE_OPERATION_EXCEPTION = 4;
+
+ // A Future threw an exception (should never happen).
+ int EXECUTION_EXCEPTION = 5;
+
+ // Parsing something (e.g. BR/EDR Handover data) failed.
+ int PARSE_EXCEPTION = 6;
+
+ // A failure at MDH.
+ int MDH_REMOTE_EXCEPTION = 7;
+
+ // For errors on GATT connection and retry success
+ int SUCCESS_RETRY_GATT_ERROR = 8;
+
+ // For timeout on GATT connection and retry success
+ int SUCCESS_RETRY_GATT_TIMEOUT = 9;
+
+ // For errors on secret handshake and retry success
+ int SUCCESS_RETRY_SECRET_HANDSHAKE_ERROR = 10;
+
+ // For timeout on secret handshake and retry success
+ int SUCCESS_RETRY_SECRET_HANDSHAKE_TIMEOUT = 11;
+
+ // For secret handshake fail and restart GATT connection success
+ int SUCCESS_SECRET_HANDSHAKE_RECONNECT = 12;
+
+ // For address rotate and retry with new address success
+ int SUCCESS_ADDRESS_ROTATE = 13;
+
+ // For signal lost and retry with old address still success
+ int SUCCESS_SIGNAL_LOST = 14;
+ }
+
+ /** Fast Pair BrEdrHandover Error Code. */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(
+ value = {
+ BrEdrHandoverErrorCode.UNKNOWN_BR_EDR_HANDOVER_ERROR_CODE,
+ BrEdrHandoverErrorCode.CONTROL_POINT_RESULT_CODE_NOT_SUCCESS,
+ BrEdrHandoverErrorCode.BLUETOOTH_MAC_INVALID,
+ BrEdrHandoverErrorCode.TRANSPORT_BLOCK_INVALID,
+ })
+ public @interface BrEdrHandoverErrorCode {
+ int UNKNOWN_BR_EDR_HANDOVER_ERROR_CODE = 0;
+ int CONTROL_POINT_RESULT_CODE_NOT_SUCCESS = 1;
+ int BLUETOOTH_MAC_INVALID = 2;
+ int TRANSPORT_BLOCK_INVALID = 3;
+ }
+
+ /** Fast Pair CreateBound Error Code. */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(
+ value = {
+ CreateBondErrorCode.UNKNOWN_BOND_ERROR_CODE,
+ CreateBondErrorCode.BOND_BROKEN,
+ CreateBondErrorCode.POSSIBLE_MITM,
+ CreateBondErrorCode.NO_PERMISSION,
+ CreateBondErrorCode.INCORRECT_VARIANT,
+ CreateBondErrorCode.FAILED_BUT_ALREADY_RECEIVE_PASS_KEY,
+ })
+ public @interface CreateBondErrorCode {
+ int UNKNOWN_BOND_ERROR_CODE = 0;
+ int BOND_BROKEN = 1;
+ int POSSIBLE_MITM = 2;
+ int NO_PERMISSION = 3;
+ int INCORRECT_VARIANT = 4;
+ int FAILED_BUT_ALREADY_RECEIVE_PASS_KEY = 5;
+ }
+
+ /** Fast Pair Connect Error Code. */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(
+ value = {
+ ConnectErrorCode.UNKNOWN_CONNECT_ERROR_CODE,
+ ConnectErrorCode.UNSUPPORTED_PROFILE,
+ ConnectErrorCode.GET_PROFILE_PROXY_FAILED,
+ ConnectErrorCode.DISCONNECTED,
+ ConnectErrorCode.LINK_KEY_CLEARED,
+ ConnectErrorCode.FAIL_TO_DISCOVERY,
+ ConnectErrorCode.DISCOVERY_NOT_FINISHED,
+ })
+ public @interface ConnectErrorCode {
+ int UNKNOWN_CONNECT_ERROR_CODE = 0;
+ int UNSUPPORTED_PROFILE = 1;
+ int GET_PROFILE_PROXY_FAILED = 2;
+ int DISCONNECTED = 3;
+ int LINK_KEY_CLEARED = 4;
+ int FAIL_TO_DISCOVERY = 5;
+ int DISCOVERY_NOT_FINISHED = 6;
+ }
+
+ private FastPairEventIntDefs() {}
+}
diff --git a/nearby/service/java/com/android/server/nearby/intdefs/NearbyEventIntDefs.java b/nearby/service/java/com/android/server/nearby/intdefs/NearbyEventIntDefs.java
new file mode 100644
index 0000000..91bf49a
--- /dev/null
+++ b/nearby/service/java/com/android/server/nearby/intdefs/NearbyEventIntDefs.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright 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.intdefs;
+
+import androidx.annotation.IntDef;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/** Holds integer definitions for NearbyEvent. */
+public class NearbyEventIntDefs {
+
+ /** NearbyEvent Code. */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(
+ value = {
+ EventCode.UNKNOWN_EVENT_TYPE,
+ EventCode.MAGIC_PAIR_START,
+ EventCode.WAIT_FOR_SCREEN_UNLOCK,
+ EventCode.GATT_CONNECT,
+ EventCode.BR_EDR_HANDOVER_WRITE_CONTROL_POINT_REQUEST,
+ EventCode.BR_EDR_HANDOVER_READ_BLUETOOTH_MAC,
+ EventCode.BR_EDR_HANDOVER_READ_TRANSPORT_BLOCK,
+ EventCode.GET_PROFILES_VIA_SDP,
+ EventCode.DISCOVER_DEVICE,
+ EventCode.CANCEL_DISCOVERY,
+ EventCode.REMOVE_BOND,
+ EventCode.CANCEL_BOND,
+ EventCode.CREATE_BOND,
+ EventCode.CONNECT_PROFILE,
+ EventCode.DISABLE_BLUETOOTH,
+ EventCode.ENABLE_BLUETOOTH,
+ EventCode.MAGIC_PAIR_END,
+ EventCode.SECRET_HANDSHAKE,
+ EventCode.WRITE_ACCOUNT_KEY,
+ EventCode.WRITE_TO_FOOTPRINTS,
+ EventCode.PASSKEY_EXCHANGE,
+ EventCode.DEVICE_RECOGNIZED,
+ EventCode.GET_LOCAL_PUBLIC_ADDRESS,
+ EventCode.DIRECTLY_CONNECTED_TO_PROFILE,
+ EventCode.DEVICE_ALIAS_CHANGED,
+ EventCode.WRITE_DEVICE_NAME,
+ EventCode.UPDATE_PROVIDER_NAME_START,
+ EventCode.UPDATE_PROVIDER_NAME_END,
+ EventCode.READ_FIRMWARE_VERSION,
+ EventCode.RETROACTIVE_PAIR_START,
+ EventCode.RETROACTIVE_PAIR_END,
+ EventCode.SUBSEQUENT_PAIR_START,
+ EventCode.SUBSEQUENT_PAIR_END,
+ EventCode.BISTO_PAIR_START,
+ EventCode.BISTO_PAIR_END,
+ EventCode.REMOTE_PAIR_START,
+ EventCode.REMOTE_PAIR_END,
+ EventCode.BEFORE_CREATE_BOND,
+ EventCode.BEFORE_CREATE_BOND_BONDING,
+ EventCode.BEFORE_CREATE_BOND_BONDED,
+ EventCode.BEFORE_CONNECT_PROFILE,
+ EventCode.HANDLE_PAIRING_REQUEST,
+ EventCode.SECRET_HANDSHAKE_GATT_COMMUNICATION,
+ EventCode.GATT_CONNECTION_AND_SECRET_HANDSHAKE,
+ EventCode.CHECK_SIGNAL_AFTER_HANDSHAKE,
+ EventCode.RECOVER_BY_RETRY_GATT,
+ EventCode.RECOVER_BY_RETRY_HANDSHAKE,
+ EventCode.RECOVER_BY_RETRY_HANDSHAKE_RECONNECT,
+ EventCode.GATT_HANDSHAKE_MANUAL_RETRY_ATTEMPTS,
+ EventCode.PAIR_WITH_CACHED_MODEL_ID,
+ EventCode.DIRECTLY_CONNECT_PROFILE_WITH_CACHED_ADDRESS,
+ EventCode.PAIR_WITH_NEW_MODEL,
+ })
+ public @interface EventCode {
+ int UNKNOWN_EVENT_TYPE = 0;
+
+ // Codes for Magic Pair.
+ // Starting at 1000 to not conflict with other existing codes (e.g.
+ // DiscoveryEvent) that may be migrated to become official Event Codes.
+ int MAGIC_PAIR_START = 1010;
+ int WAIT_FOR_SCREEN_UNLOCK = 1020;
+ int GATT_CONNECT = 1030;
+ int BR_EDR_HANDOVER_WRITE_CONTROL_POINT_REQUEST = 1040;
+ int BR_EDR_HANDOVER_READ_BLUETOOTH_MAC = 1050;
+ int BR_EDR_HANDOVER_READ_TRANSPORT_BLOCK = 1060;
+ int GET_PROFILES_VIA_SDP = 1070;
+ int DISCOVER_DEVICE = 1080;
+ int CANCEL_DISCOVERY = 1090;
+ int REMOVE_BOND = 1100;
+ int CANCEL_BOND = 1110;
+ int CREATE_BOND = 1120;
+ int CONNECT_PROFILE = 1130;
+ int DISABLE_BLUETOOTH = 1140;
+ int ENABLE_BLUETOOTH = 1150;
+ int MAGIC_PAIR_END = 1160;
+ int SECRET_HANDSHAKE = 1170;
+ int WRITE_ACCOUNT_KEY = 1180;
+ int WRITE_TO_FOOTPRINTS = 1190;
+ int PASSKEY_EXCHANGE = 1200;
+ int DEVICE_RECOGNIZED = 1210;
+ int GET_LOCAL_PUBLIC_ADDRESS = 1220;
+ int DIRECTLY_CONNECTED_TO_PROFILE = 1230;
+ int DEVICE_ALIAS_CHANGED = 1240;
+ int WRITE_DEVICE_NAME = 1250;
+ int UPDATE_PROVIDER_NAME_START = 1260;
+ int UPDATE_PROVIDER_NAME_END = 1270;
+ int READ_FIRMWARE_VERSION = 1280;
+ int RETROACTIVE_PAIR_START = 1290;
+ int RETROACTIVE_PAIR_END = 1300;
+ int SUBSEQUENT_PAIR_START = 1310;
+ int SUBSEQUENT_PAIR_END = 1320;
+ int BISTO_PAIR_START = 1330;
+ int BISTO_PAIR_END = 1340;
+ int REMOTE_PAIR_START = 1350;
+ int REMOTE_PAIR_END = 1360;
+ int BEFORE_CREATE_BOND = 1370;
+ int BEFORE_CREATE_BOND_BONDING = 1380;
+ int BEFORE_CREATE_BOND_BONDED = 1390;
+ int BEFORE_CONNECT_PROFILE = 1400;
+ int HANDLE_PAIRING_REQUEST = 1410;
+ int SECRET_HANDSHAKE_GATT_COMMUNICATION = 1420;
+ int GATT_CONNECTION_AND_SECRET_HANDSHAKE = 1430;
+ int CHECK_SIGNAL_AFTER_HANDSHAKE = 1440;
+ int RECOVER_BY_RETRY_GATT = 1450;
+ int RECOVER_BY_RETRY_HANDSHAKE = 1460;
+ int RECOVER_BY_RETRY_HANDSHAKE_RECONNECT = 1470;
+ int GATT_HANDSHAKE_MANUAL_RETRY_ATTEMPTS = 1480;
+ int PAIR_WITH_CACHED_MODEL_ID = 1490;
+ int DIRECTLY_CONNECT_PROFILE_WITH_CACHED_ADDRESS = 1500;
+ int PAIR_WITH_NEW_MODEL = 1510;
+ }
+
+ private NearbyEventIntDefs() {}
+}
diff --git a/nearby/service/proto/Android.bp b/nearby/service/proto/Android.bp
deleted file mode 100644
index fa4b04d..0000000
--- a/nearby/service/proto/Android.bp
+++ /dev/null
@@ -1,29 +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 {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-// TODO(b/201673262): Check proto imported correctly.
-java_library {
- name: "fast-pair-lite-protos",
- proto: {
- type: "lite",
- },
- sdk_version: "system_current",
- min_sdk_version: "30",
- srcs: ["src/fast_pair_enums.proto", "src/nearby_event_codes.proto"],
- apex_available: [
- "com.android.nearby",
- ],
-}
\ No newline at end of file
diff --git a/nearby/service/proto/src/fast_pair_enums.proto b/nearby/service/proto/src/fast_pair_enums.proto
deleted file mode 100644
index 3b815ca..0000000
--- a/nearby/service/proto/src/fast_pair_enums.proto
+++ /dev/null
@@ -1,106 +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.
-//
-
-syntax = "proto2";
-
-package com_android_server_nearby;
-
-option java_package = "com.android.server.nearby.proto";
-option java_outer_classname = "FastPairEnums";
-
-// Enums related to logged events. For event codes, see NearbyEventCodes.
-message FastPairEvent {
- // These numbers match BluetoothDevice on Android.
- enum BondState {
- UNKNOWN_BOND_STATE = 0;
- NONE = 10;
- BONDING = 11;
- BONDED = 12;
- }
-
- // Generally applicable error codes.
- enum ErrorCode {
- UNKNOWN_ERROR_CODE = 0;
-
- // Check the other fields for a more specific error code.
- OTHER_ERROR = 1;
-
- // The operation timed out.
- TIMEOUT = 2;
-
- // The thread was interrupted.
- INTERRUPTED = 3;
-
- // Some reflective call failed (should never happen).
- REFLECTIVE_OPERATION_EXCEPTION = 4;
-
- // A Future threw an exception (should never happen).
- EXECUTION_EXCEPTION = 5;
-
- // Parsing something (e.g. BR/EDR Handover data) failed.
- PARSE_EXCEPTION = 6;
-
- // A failure at MDH.
- MDH_REMOTE_EXCEPTION = 7;
-
- // For errors on GATT connection and retry success
- SUCCESS_RETRY_GATT_ERROR = 8;
-
- // For timeout on GATT connection and retry success
- SUCCESS_RETRY_GATT_TIMEOUT = 9;
-
- // For errors on secret handshake and retry success
- SUCCESS_RETRY_SECRET_HANDSHAKE_ERROR = 10;
-
- // For timeout on secret handshake and retry success
- SUCCESS_RETRY_SECRET_HANDSHAKE_TIMEOUT = 11;
-
- // For secret handshake fail and restart GATT connection success
- SUCCESS_SECRET_HANDSHAKE_RECONNECT = 12;
-
- // For address rotate and retry with new address success
- SUCCESS_ADDRESS_ROTATE = 13;
-
- // For signal lost and retry with old address still success
- SUCCESS_SIGNAL_LOST = 14;
- }
-
- enum BrEdrHandoverErrorCode {
- UNKNOWN_BR_EDR_HANDOVER_ERROR_CODE = 0;
- CONTROL_POINT_RESULT_CODE_NOT_SUCCESS = 1;
- BLUETOOTH_MAC_INVALID = 2;
- TRANSPORT_BLOCK_INVALID = 3;
- }
-
- enum CreateBondErrorCode {
- UNKNOWN_BOND_ERROR_CODE = 0;
- BOND_BROKEN = 1;
- POSSIBLE_MITM = 2;
- NO_PERMISSION = 3;
- INCORRECT_VARIANT = 4;
- FAILED_BUT_ALREADY_RECEIVE_PASS_KEY = 5;
- }
-
- enum ConnectErrorCode {
- UNKNOWN_CONNECT_ERROR_CODE = 0;
- UNSUPPORTED_PROFILE = 1;
- GET_PROFILE_PROXY_FAILED = 2;
- DISCONNECTED = 3;
- LINK_KEY_CLEARED = 4;
- FAIL_TO_DISCOVERY = 5;
- DISCOVERY_NOT_FINISHED = 6;
- }
-}
diff --git a/nearby/service/proto/src/nearby_event_codes.proto b/nearby/service/proto/src/nearby_event_codes.proto
deleted file mode 100644
index b6dcae8..0000000
--- a/nearby/service/proto/src/nearby_event_codes.proto
+++ /dev/null
@@ -1,84 +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.
-//
-
-syntax = "proto2";
-
-package com_android_server_nearby;
-
-option java_package = "com.android.server.nearby.proto";
-option java_outer_classname = "NearbyEventCodes";
-
-// Event codes for the NEARBY log source.
-message NearbyEvent {
- enum EventCode {
- UNKNOWN_EVENT_TYPE = 0;
-
- // Codes for Magic Pair.
- // Starting at 1000 to not conflict with other existing codes (e.g.
- // DiscoveryEvent) that may be migrated to become official Event Codes.
- MAGIC_PAIR_START = 1010;
- WAIT_FOR_SCREEN_UNLOCK = 1020;
- GATT_CONNECT = 1030;
- BR_EDR_HANDOVER_WRITE_CONTROL_POINT_REQUEST = 1040;
- BR_EDR_HANDOVER_READ_BLUETOOTH_MAC = 1050;
- BR_EDR_HANDOVER_READ_TRANSPORT_BLOCK = 1060;
- GET_PROFILES_VIA_SDP = 1070;
- DISCOVER_DEVICE = 1080;
- CANCEL_DISCOVERY = 1090;
- REMOVE_BOND = 1100;
- CANCEL_BOND = 1110;
- CREATE_BOND = 1120;
- CONNECT_PROFILE = 1130;
- DISABLE_BLUETOOTH = 1140;
- ENABLE_BLUETOOTH = 1150;
- MAGIC_PAIR_END = 1160;
- SECRET_HANDSHAKE = 1170;
- WRITE_ACCOUNT_KEY = 1180;
- WRITE_TO_FOOTPRINTS = 1190;
- PASSKEY_EXCHANGE = 1200;
- DEVICE_RECOGNIZED = 1210;
- GET_LOCAL_PUBLIC_ADDRESS = 1220;
- DIRECTLY_CONNECTED_TO_PROFILE = 1230;
- DEVICE_ALIAS_CHANGED = 1240;
- WRITE_DEVICE_NAME = 1250;
- UPDATE_PROVIDER_NAME_START = 1260;
- UPDATE_PROVIDER_NAME_END = 1270;
- READ_FIRMWARE_VERSION = 1280;
- RETROACTIVE_PAIR_START = 1290;
- RETROACTIVE_PAIR_END = 1300;
- SUBSEQUENT_PAIR_START = 1310;
- SUBSEQUENT_PAIR_END = 1320;
- BISTO_PAIR_START = 1330;
- BISTO_PAIR_END = 1340;
- REMOTE_PAIR_START = 1350;
- REMOTE_PAIR_END = 1360;
- BEFORE_CREATE_BOND = 1370;
- BEFORE_CREATE_BOND_BONDING = 1380;
- BEFORE_CREATE_BOND_BONDED = 1390;
- BEFORE_CONNECT_PROFILE = 1400;
- HANDLE_PAIRING_REQUEST = 1410;
- SECRET_HANDSHAKE_GATT_COMMUNICATION = 1420;
- GATT_CONNECTION_AND_SECRET_HANDSHAKE = 1430;
- CHECK_SIGNAL_AFTER_HANDSHAKE = 1440;
- RECOVER_BY_RETRY_GATT = 1450;
- RECOVER_BY_RETRY_HANDSHAKE = 1460;
- RECOVER_BY_RETRY_HANDSHAKE_RECONNECT = 1470;
- GATT_HANDSHAKE_MANUAL_RETRY_ATTEMPTS = 1480;
- PAIR_WITH_CACHED_MODEL_ID = 1490;
- DIRECTLY_CONNECT_PROFILE_WITH_CACHED_ADDRESS = 1500;
- PAIR_WITH_NEW_MODEL = 1510;
- }
-}
diff --git a/nearby/tests/Android.bp b/nearby/tests/Android.bp
index 8a07882..4007f7d 100644
--- a/nearby/tests/Android.bp
+++ b/nearby/tests/Android.bp
@@ -34,7 +34,6 @@
static_libs: [
"androidx.test.rules",
- "fast-pair-lite-protos",
"framework-nearby-pre-jarjar",
"guava",
"libprotobuf-java-lite",
diff --git a/nearby/tests/src/com/android/server/nearby/common/bluetooth/fastpair/EventTest.java b/nearby/tests/src/com/android/server/nearby/common/bluetooth/fastpair/EventTest.java
index d0c36ce..dc459f1 100644
--- a/nearby/tests/src/com/android/server/nearby/common/bluetooth/fastpair/EventTest.java
+++ b/nearby/tests/src/com/android/server/nearby/common/bluetooth/fastpair/EventTest.java
@@ -26,7 +26,7 @@
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
-import com.android.server.nearby.proto.NearbyEventCodes.NearbyEvent.EventCode;
+import com.android.server.nearby.intdefs.NearbyEventIntDefs.EventCode;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -41,7 +41,7 @@
private static final String EXCEPTION_MESSAGE = "Test exception";
private static final long TIMESTAMP = 1234L;
- private static final EventCode EVENT_CODE = EventCode.CREATE_BOND;
+ private static final @EventCode int EVENT_CODE = EventCode.CREATE_BOND;
private static final BluetoothDevice BLUETOOTH_DEVICE = BluetoothAdapter.getDefaultAdapter()
.getRemoteDevice("11:22:33:44:55:66");
private static final Short PROFILE = (short) 1;