1 /* 2 * Copyright (C) 2019 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 android.hdmicec.cts; 18 19 import java.util.HashMap; 20 import java.util.Map; 21 22 public enum LogicalAddress { 23 TV(0x0), 24 RECORDER_1(0x1), 25 RECORDER_2(0x2), 26 TUNER_1(0x3), 27 PLAYBACK_1(0x4), 28 AUDIO_SYSTEM(0x5), 29 TUNER_2(0x6), 30 TUNER_3(0x7), 31 PLAYBACK_2(0x8), 32 RECORDER_3(0x9), 33 TUNER_4(0xa), 34 PLAYBACK_3(0xb), 35 RESERVED_1(0xc), 36 RESERVED_2(0xd), 37 SPECIFIC_USE(0xe), 38 BROADCAST(0xf); 39 40 private final int address; 41 private static Map deviceMap = new HashMap<>(); 42 43 // CEC Device feature list 44 public static final String HDMI_CEC_FEATURE = "feature:android.hardware.hdmi.cec"; 45 public static final String LEANBACK_FEATURE = "feature:android.software.leanback"; 46 47 // CEC Device property list 48 public static final String HDMI_DEVICE_TYPE_PROPERTY = "ro.hdmi.device_type"; 49 50 @Override toString()51 public String toString() { 52 return Integer.toHexString(this.address); 53 } 54 55 static { 56 for (LogicalAddress device : LogicalAddress.values()) { deviceMap.put(device.address, device)57 deviceMap.put(device.address, device); 58 } 59 } 60 getDeviceType()61 public String getDeviceType() { 62 switch (this) { 63 case PLAYBACK_1: 64 case PLAYBACK_2: 65 case PLAYBACK_3: 66 return Integer.toString(HdmiCecConstants.CEC_DEVICE_TYPE_PLAYBACK_DEVICE); 67 case TV: 68 return Integer.toString(HdmiCecConstants.CEC_DEVICE_TYPE_TV); 69 case AUDIO_SYSTEM: 70 return Integer.toString(HdmiCecConstants.CEC_DEVICE_TYPE_AUDIO_SYSTEM); 71 case RECORDER_1: 72 case RECORDER_2: 73 case RECORDER_3: 74 return Integer.toString(HdmiCecConstants.CEC_DEVICE_TYPE_RECORDER); 75 case TUNER_1: 76 case TUNER_2: 77 case TUNER_3: 78 case TUNER_4: 79 return Integer.toString(HdmiCecConstants.CEC_DEVICE_TYPE_TUNER); 80 default: 81 return Integer.toString(HdmiCecConstants.CEC_DEVICE_TYPE_RESERVED); 82 } 83 } 84 getLogicalAddress(int address)85 public static LogicalAddress getLogicalAddress(int address) { 86 return (LogicalAddress) deviceMap.get(address); 87 } 88 LogicalAddress(int address)89 private LogicalAddress(int address) { 90 this.address = address; 91 } 92 } 93