1 /* 2 * Copyright 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.server.nearby.intdefs; 18 19 import androidx.annotation.IntDef; 20 21 import java.lang.annotation.Retention; 22 import java.lang.annotation.RetentionPolicy; 23 24 /** Holds integer definitions for FastPair. */ 25 public class FastPairEventIntDefs { 26 27 /** Fast Pair Bond State. */ 28 @Retention(RetentionPolicy.SOURCE) 29 @IntDef( 30 value = { 31 BondState.UNKNOWN_BOND_STATE, 32 BondState.NONE, 33 BondState.BONDING, 34 BondState.BONDED, 35 }) 36 public @interface BondState { 37 int UNKNOWN_BOND_STATE = 0; 38 int NONE = 10; 39 int BONDING = 11; 40 int BONDED = 12; 41 } 42 43 /** Fast Pair error code. */ 44 @Retention(RetentionPolicy.SOURCE) 45 @IntDef( 46 value = { 47 ErrorCode.UNKNOWN_ERROR_CODE, 48 ErrorCode.OTHER_ERROR, 49 ErrorCode.TIMEOUT, 50 ErrorCode.INTERRUPTED, 51 ErrorCode.REFLECTIVE_OPERATION_EXCEPTION, 52 ErrorCode.EXECUTION_EXCEPTION, 53 ErrorCode.PARSE_EXCEPTION, 54 ErrorCode.MDH_REMOTE_EXCEPTION, 55 ErrorCode.SUCCESS_RETRY_GATT_ERROR, 56 ErrorCode.SUCCESS_RETRY_GATT_TIMEOUT, 57 ErrorCode.SUCCESS_RETRY_SECRET_HANDSHAKE_ERROR, 58 ErrorCode.SUCCESS_RETRY_SECRET_HANDSHAKE_TIMEOUT, 59 ErrorCode.SUCCESS_SECRET_HANDSHAKE_RECONNECT, 60 ErrorCode.SUCCESS_ADDRESS_ROTATE, 61 ErrorCode.SUCCESS_SIGNAL_LOST, 62 }) 63 public @interface ErrorCode { 64 int UNKNOWN_ERROR_CODE = 0; 65 66 // Check the other fields for a more specific error code. 67 int OTHER_ERROR = 1; 68 69 // The operation timed out. 70 int TIMEOUT = 2; 71 72 // The thread was interrupted. 73 int INTERRUPTED = 3; 74 75 // Some reflective call failed (should never happen). 76 int REFLECTIVE_OPERATION_EXCEPTION = 4; 77 78 // A Future threw an exception (should never happen). 79 int EXECUTION_EXCEPTION = 5; 80 81 // Parsing something (e.g. BR/EDR Handover data) failed. 82 int PARSE_EXCEPTION = 6; 83 84 // A failure at MDH. 85 int MDH_REMOTE_EXCEPTION = 7; 86 87 // For errors on GATT connection and retry success 88 int SUCCESS_RETRY_GATT_ERROR = 8; 89 90 // For timeout on GATT connection and retry success 91 int SUCCESS_RETRY_GATT_TIMEOUT = 9; 92 93 // For errors on secret handshake and retry success 94 int SUCCESS_RETRY_SECRET_HANDSHAKE_ERROR = 10; 95 96 // For timeout on secret handshake and retry success 97 int SUCCESS_RETRY_SECRET_HANDSHAKE_TIMEOUT = 11; 98 99 // For secret handshake fail and restart GATT connection success 100 int SUCCESS_SECRET_HANDSHAKE_RECONNECT = 12; 101 102 // For address rotate and retry with new address success 103 int SUCCESS_ADDRESS_ROTATE = 13; 104 105 // For signal lost and retry with old address still success 106 int SUCCESS_SIGNAL_LOST = 14; 107 } 108 109 /** Fast Pair BrEdrHandover Error Code. */ 110 @Retention(RetentionPolicy.SOURCE) 111 @IntDef( 112 value = { 113 BrEdrHandoverErrorCode.UNKNOWN_BR_EDR_HANDOVER_ERROR_CODE, 114 BrEdrHandoverErrorCode.CONTROL_POINT_RESULT_CODE_NOT_SUCCESS, 115 BrEdrHandoverErrorCode.BLUETOOTH_MAC_INVALID, 116 BrEdrHandoverErrorCode.TRANSPORT_BLOCK_INVALID, 117 }) 118 public @interface BrEdrHandoverErrorCode { 119 int UNKNOWN_BR_EDR_HANDOVER_ERROR_CODE = 0; 120 int CONTROL_POINT_RESULT_CODE_NOT_SUCCESS = 1; 121 int BLUETOOTH_MAC_INVALID = 2; 122 int TRANSPORT_BLOCK_INVALID = 3; 123 } 124 125 /** Fast Pair CreateBound Error Code. */ 126 @Retention(RetentionPolicy.SOURCE) 127 @IntDef( 128 value = { 129 CreateBondErrorCode.UNKNOWN_BOND_ERROR_CODE, 130 CreateBondErrorCode.BOND_BROKEN, 131 CreateBondErrorCode.POSSIBLE_MITM, 132 CreateBondErrorCode.NO_PERMISSION, 133 CreateBondErrorCode.INCORRECT_VARIANT, 134 CreateBondErrorCode.FAILED_BUT_ALREADY_RECEIVE_PASS_KEY, 135 }) 136 public @interface CreateBondErrorCode { 137 int UNKNOWN_BOND_ERROR_CODE = 0; 138 int BOND_BROKEN = 1; 139 int POSSIBLE_MITM = 2; 140 int NO_PERMISSION = 3; 141 int INCORRECT_VARIANT = 4; 142 int FAILED_BUT_ALREADY_RECEIVE_PASS_KEY = 5; 143 } 144 145 /** Fast Pair Connect Error Code. */ 146 @Retention(RetentionPolicy.SOURCE) 147 @IntDef( 148 value = { 149 ConnectErrorCode.UNKNOWN_CONNECT_ERROR_CODE, 150 ConnectErrorCode.UNSUPPORTED_PROFILE, 151 ConnectErrorCode.GET_PROFILE_PROXY_FAILED, 152 ConnectErrorCode.DISCONNECTED, 153 ConnectErrorCode.LINK_KEY_CLEARED, 154 ConnectErrorCode.FAIL_TO_DISCOVERY, 155 ConnectErrorCode.DISCOVERY_NOT_FINISHED, 156 }) 157 public @interface ConnectErrorCode { 158 int UNKNOWN_CONNECT_ERROR_CODE = 0; 159 int UNSUPPORTED_PROFILE = 1; 160 int GET_PROFILE_PROXY_FAILED = 2; 161 int DISCONNECTED = 3; 162 int LINK_KEY_CLEARED = 4; 163 int FAIL_TO_DISCOVERY = 5; 164 int DISCOVERY_NOT_FINISHED = 6; 165 } 166 FastPairEventIntDefs()167 private FastPairEventIntDefs() {} 168 } 169