1 /* 2 * Copyright 2024 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.ranging.oob; 18 19 /** Enum representing a message type of the OOB message. */ 20 public enum MessageType { 21 CAPABILITY_REQUEST(0), 22 CAPABILITY_RESPONSE(1), 23 SET_CONFIGURATION(2), 24 SET_CONFIGURATION_RESPONSE(3), 25 START_RANGING(4), 26 START_RANGING_RESPONSE(5), 27 STOP_RANGING(6), 28 STOP_RANGING_RESPONSE(7), 29 UNKNOWN(8); 30 31 private final int mValue; 32 MessageType(int value)33 MessageType(int value) { 34 this.mValue = value; 35 } 36 getValue()37 public int getValue() { 38 return mValue; 39 } 40 toByte()41 public byte toByte() { 42 return (byte) mValue; 43 } 44 parseByte(byte messageId)45 public static MessageType parseByte(byte messageId) { 46 if (messageId > 8) { 47 return UNKNOWN; 48 } 49 return MessageType.values()[messageId]; 50 } 51 } 52