HdmiMhlControllerStub.java revision 781041239f2931ca16c902fb371cd041b057c918
1/* 2 * Copyright (C) 2014 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 17package com.android.server.hdmi; 18 19import android.hardware.hdmi.HdmiPortInfo; 20import android.util.SparseArray; 21 22import com.android.server.hdmi.HdmiControlService.SendMessageCallback; 23 24/** 25 * A handler class for MHL control command. It converts user's command into MHL command and pass it 26 * to MHL HAL layer. 27 * <p> 28 * It can be created only by {@link HdmiMhlControllerStub#create}. 29 */ 30final class HdmiMhlControllerStub { 31 32 private static final SparseArray<HdmiMhlLocalDevice> mLocalDevices = new SparseArray<>(); 33 private static final HdmiPortInfo[] EMPTY_PORT_INFO = new HdmiPortInfo[0]; 34 private static final int INVALID_MHL_VERSION = 0; 35 private static final int NO_SUPPORTED_FEATURES = 0; 36 private static final int INVALID_DEVICE_ROLES = 0; 37 38 // Private constructor. Use HdmiMhlControllerStub.create(). 39 private HdmiMhlControllerStub(HdmiControlService service) { 40 } 41 42 // Returns true if MHL controller is initialized and ready to use. 43 boolean isReady() { 44 return false; 45 } 46 47 static HdmiMhlControllerStub create(HdmiControlService service) { 48 return new HdmiMhlControllerStub(service); 49 } 50 51 HdmiPortInfo[] getPortInfos() { 52 return EMPTY_PORT_INFO; 53 } 54 55 /** 56 * Return {@link HdmiMhlLocalDevice} matched with the given port id. 57 * 58 * @return null if has no matched port id 59 */ 60 HdmiMhlLocalDevice getLocalDevice(int portId) { 61 return null; 62 } 63 64 /** 65 * Return {@link HdmiMhlLocalDevice} matched with the given device id. 66 * 67 * @return null if has no matched id 68 */ 69 HdmiMhlLocalDevice getLocalDeviceById(int deviceId) { 70 return null; 71 } 72 73 SparseArray<HdmiMhlLocalDevice> getAllLocalDevices() { 74 return mLocalDevices; 75 } 76 77 /** 78 * Remove a {@link HdmiMhlLocalDevice} matched with the given port id. 79 * 80 * @return removed {@link HdmiMhlLocalDevice}. Return null if no matched port id. 81 */ 82 HdmiMhlLocalDevice removeLocalDevice(int portId) { 83 return null; 84 } 85 86 /** 87 * Add a new {@link HdmiMhlLocalDevice}. 88 * 89 * @return old {@link HdmiMhlLocalDevice} having same port id 90 */ 91 HdmiMhlLocalDevice addLocalDevice(HdmiMhlLocalDevice device) { 92 return null; 93 } 94 95 void clearAllLocalDevices() { 96 } 97 98 /** 99 * Send MHL MSC-Subcommand to the device connected to the given port. 100 */ 101 void sendSubcommand(int portId, HdmiMhlSubcommand command) { 102 } 103 104 void sendSubcommand(final int portId, final HdmiMhlSubcommand command, 105 SendMessageCallback callback) { 106 } 107 108 109 void sendScratchpadCommand(int portId, int offset, int length, byte[] data) { 110 } 111 112 void setOption(int flag, int value) { 113 } 114 115 /** 116 * Get the MHL version supported by underlying hardware port of the given {@code portId}. 117 * MHL specification version 2.0 returns 0x20, 3.0 will return 0x30 respectively. 118 * The return value is stored in 'version'. Return INVALID_VERSION if MHL hardware layer 119 * is not ready. 120 */ 121 int getMhlVersion(int portId) { 122 return INVALID_MHL_VERSION; 123 } 124 125 /** 126 * Get MHL version of a device which is connected to a port of the given {@code portId}. 127 * MHL specification version 2.0 returns 0x20, 3.0 will return 0x30 respectively. 128 * The return value is stored in 'version'. 129 */ 130 int getPeerMhlVersion(int portId) { 131 return INVALID_MHL_VERSION; 132 } 133 134 /** 135 * Get the bit flags describing the features supported by the system. Refer to feature support 136 * flag register info in MHL specification. 137 */ 138 int getSupportedFeatures(int portId) { 139 return NO_SUPPORTED_FEATURES; 140 } 141 142 /** 143 * Get the bit flags describing the roles which ECBUS device can play. Refer to the 144 * ECBUS_DEV_ROLES Register info MHL3.0 specification 145 */ 146 int getEcbusDeviceRoles(int portId) { 147 return INVALID_DEVICE_ROLES; 148 } 149} 150