1 /*
2  * Copyright (C) 2022 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.hdmi;
18 
19 import android.hardware.hdmi.HdmiDeviceInfo;
20 import android.util.IndentingPrintWriter;
21 
22 import com.android.internal.annotations.GuardedBy;
23 
24 /**
25  * Class that models a local eARC device hosted in this system.
26  * The class contains methods that are common between eARC TX and eARC RX devices.
27  */
28 abstract class HdmiEarcLocalDevice extends HdmiLocalDevice {
29     private static final String TAG = "HdmiEarcLocalDevice";
30 
31     // The current status of the eARC connection, as reported by the HAL
32     @GuardedBy("mLock")
33     @Constants.EarcStatus
34     protected int mEarcStatus;
35 
HdmiEarcLocalDevice(HdmiControlService service, int deviceType)36     protected HdmiEarcLocalDevice(HdmiControlService service, int deviceType) {
37         super(service, deviceType);
38     }
39 
40     // Factory method that returns HdmiCecLocalDevice of corresponding type.
create(HdmiControlService service, int deviceType)41     static HdmiEarcLocalDevice create(HdmiControlService service, int deviceType) {
42         switch (deviceType) {
43             case HdmiDeviceInfo.DEVICE_TV:
44                 return new HdmiEarcLocalDeviceTx(service);
45             default:
46                 return null;
47         }
48     }
49 
handleEarcStateChange(@onstants.EarcStatus int status)50     protected abstract void handleEarcStateChange(@Constants.EarcStatus int status);
51 
handleEarcCapabilitiesReported(byte[] rawCapabilities)52     protected abstract void handleEarcCapabilitiesReported(byte[] rawCapabilities);
53 
disableDevice()54     protected void disableDevice() {
55     }
56 
57     /** Dump internal status of HdmiEarcLocalDevice object */
dump(final IndentingPrintWriter pw)58     protected void dump(final IndentingPrintWriter pw) {
59         // Should be overridden in the more specific classes
60     }
61 }
62