Add proto for fast pair enum and nearby event codes.

Test: Skip tests. Will be covered by other tests.

Bug: 200231384
Change-Id: Icd0e431b2ae5b441ba17b35fb710140f044b145a
diff --git a/nearby/service/proto/Android.bp b/nearby/service/proto/Android.bp
new file mode 100644
index 0000000..a7e9292
--- /dev/null
+++ b/nearby/service/proto/Android.bp
@@ -0,0 +1,26 @@
+// 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"],
+}
\ 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
new file mode 100644
index 0000000..3b815ca
--- /dev/null
+++ b/nearby/service/proto/src/fast_pair_enums.proto
@@ -0,0 +1,106 @@
+//
+// 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
new file mode 100644
index 0000000..b6dcae8
--- /dev/null
+++ b/nearby/service/proto/src/nearby_event_codes.proto
@@ -0,0 +1,84 @@
+//
+// 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;
+  }
+}