Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 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 | |
| 17 | package com.android.server.hdmi; |
| 18 | |
Jinsuk Kim | 0340bbc | 2014-06-05 11:07:47 +0900 | [diff] [blame] | 19 | import android.hardware.hdmi.HdmiPortInfo; |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 20 | import android.os.Handler; |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 21 | import android.os.Looper; |
Jungshik Jang | 4085d0e | 2014-05-27 19:52:39 +0900 | [diff] [blame] | 22 | import android.os.MessageQueue; |
Yuncheol Heo | ece603b | 2014-05-23 20:10:19 +0900 | [diff] [blame] | 23 | import android.util.Slog; |
Jungshik Jang | 7d9a843 | 2014-04-29 15:12:43 +0900 | [diff] [blame] | 24 | import android.util.SparseArray; |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 25 | |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 26 | import com.android.internal.util.Predicate; |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 27 | import com.android.server.hdmi.HdmiAnnotations.IoThreadOnly; |
| 28 | import com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly; |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 29 | import com.android.server.hdmi.HdmiControlService.DevicePollingCallback; |
| 30 | |
Jungshik Jang | 3f74ab0 | 2014-04-30 14:31:02 +0900 | [diff] [blame] | 31 | import libcore.util.EmptyArray; |
| 32 | |
Jungshik Jang | 7d9a843 | 2014-04-29 15:12:43 +0900 | [diff] [blame] | 33 | import java.util.ArrayList; |
Jungshik Jang | 7d9a843 | 2014-04-29 15:12:43 +0900 | [diff] [blame] | 34 | import java.util.List; |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * Manages HDMI-CEC command and behaviors. It converts user's command into CEC command |
| 38 | * and pass it to CEC HAL so that it sends message to other device. For incoming |
| 39 | * message it translates the message and delegates it to proper module. |
| 40 | * |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 41 | * <p>It should be careful to access member variables on IO thread because |
| 42 | * it can be accessed from system thread as well. |
| 43 | * |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 44 | * <p>It can be created only by {@link HdmiCecController#create} |
| 45 | * |
| 46 | * <p>Declared as package-private, accessed by {@link HdmiControlService} only. |
| 47 | */ |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 48 | final class HdmiCecController { |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 49 | private static final String TAG = "HdmiCecController"; |
| 50 | |
Jungshik Jang | 3ee6572 | 2014-06-03 16:22:30 +0900 | [diff] [blame] | 51 | /** |
| 52 | * Interface to report allocated logical address. |
| 53 | */ |
| 54 | interface AllocateAddressCallback { |
| 55 | /** |
| 56 | * Called when a new logical address is allocated. |
| 57 | * |
| 58 | * @param deviceType requested device type to allocate logical address |
| 59 | * @param logicalAddress allocated logical address. If it is |
Jungshik Jang | 4223072 | 2014-07-07 17:40:25 +0900 | [diff] [blame] | 60 | * {@link Constants#ADDR_UNREGISTERED}, it means that |
Jungshik Jang | 3ee6572 | 2014-06-03 16:22:30 +0900 | [diff] [blame] | 61 | * it failed to allocate logical address for the given device type |
| 62 | */ |
| 63 | void onAllocated(int deviceType, int logicalAddress); |
| 64 | } |
| 65 | |
Jungshik Jang | 3f74ab0 | 2014-04-30 14:31:02 +0900 | [diff] [blame] | 66 | private static final byte[] EMPTY_BODY = EmptyArray.BYTE; |
| 67 | |
Jungshik Jang | 3f74ab0 | 2014-04-30 14:31:02 +0900 | [diff] [blame] | 68 | private static final int NUM_LOGICAL_ADDRESS = 16; |
| 69 | |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 70 | // Predicate for whether the given logical address is remote device's one or not. |
| 71 | private final Predicate<Integer> mRemoteDeviceAddressPredicate = new Predicate<Integer>() { |
| 72 | @Override |
| 73 | public boolean apply(Integer address) { |
| 74 | return !isAllocatedLocalDeviceAddress(address); |
| 75 | } |
| 76 | }; |
| 77 | |
| 78 | // Predicate whether the given logical address is system audio's one or not |
| 79 | private final Predicate<Integer> mSystemAudioAddressPredicate = new Predicate<Integer>() { |
| 80 | @Override |
| 81 | public boolean apply(Integer address) { |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 82 | return HdmiUtils.getTypeFromAddress(address) == Constants.ADDR_AUDIO_SYSTEM; |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 83 | } |
| 84 | }; |
| 85 | |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 86 | // Handler instance to process synchronous I/O (mainly send) message. |
| 87 | private Handler mIoHandler; |
| 88 | |
| 89 | // Handler instance to process various messages coming from other CEC |
| 90 | // device or issued by internal state change. |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 91 | private Handler mControlHandler; |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 92 | |
| 93 | // Stores the pointer to the native implementation of the service that |
| 94 | // interacts with HAL. |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 95 | private volatile long mNativePtr; |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 96 | |
Jungshik Jang | 7df5286 | 2014-08-11 14:35:27 +0900 | [diff] [blame^] | 97 | private final HdmiControlService mService; |
Jungshik Jang | a1fa91f | 2014-05-08 20:56:41 +0900 | [diff] [blame] | 98 | |
Jinsuk Kim | 7fe2ae0 | 2014-05-26 17:33:05 +0900 | [diff] [blame] | 99 | // Stores the local CEC devices in the system. Device type is used for key. |
| 100 | private final SparseArray<HdmiCecLocalDevice> mLocalDevices = new SparseArray<>(); |
Jungshik Jang | 7d9a843 | 2014-04-29 15:12:43 +0900 | [diff] [blame] | 101 | |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 102 | // Private constructor. Use HdmiCecController.create(). |
Jungshik Jang | 7df5286 | 2014-08-11 14:35:27 +0900 | [diff] [blame^] | 103 | private HdmiCecController(HdmiControlService service) { |
| 104 | mService = service; |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | /** |
| 108 | * A factory method to get {@link HdmiCecController}. If it fails to initialize |
| 109 | * inner device or has no device it will return {@code null}. |
| 110 | * |
| 111 | * <p>Declared as package-private, accessed by {@link HdmiControlService} only. |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 112 | * @param service {@link HdmiControlService} instance used to create internal handler |
| 113 | * and to pass callback for incoming message or event. |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 114 | * @return {@link HdmiCecController} if device is initialized successfully. Otherwise, |
| 115 | * returns {@code null}. |
| 116 | */ |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 117 | static HdmiCecController create(HdmiControlService service) { |
Jungshik Jang | 7df5286 | 2014-08-11 14:35:27 +0900 | [diff] [blame^] | 118 | HdmiCecController controller = new HdmiCecController(service); |
Jungshik Jang | 4085d0e | 2014-05-27 19:52:39 +0900 | [diff] [blame] | 119 | long nativePtr = nativeInit(controller, service.getServiceLooper().getQueue()); |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 120 | if (nativePtr == 0L) { |
Jinsuk Kim | 2918e9e | 2014-05-20 16:45:45 +0900 | [diff] [blame] | 121 | controller = null; |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 122 | return null; |
| 123 | } |
| 124 | |
Jungshik Jang | 7df5286 | 2014-08-11 14:35:27 +0900 | [diff] [blame^] | 125 | controller.init(nativePtr); |
Jinsuk Kim | 2918e9e | 2014-05-20 16:45:45 +0900 | [diff] [blame] | 126 | return controller; |
| 127 | } |
| 128 | |
Jungshik Jang | 7df5286 | 2014-08-11 14:35:27 +0900 | [diff] [blame^] | 129 | private void init(long nativePtr) { |
| 130 | mIoHandler = new Handler(mService.getServiceLooper()); |
| 131 | mControlHandler = new Handler(mService.getServiceLooper()); |
Jinsuk Kim | 2918e9e | 2014-05-20 16:45:45 +0900 | [diff] [blame] | 132 | mNativePtr = nativePtr; |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 133 | } |
| 134 | |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 135 | @ServiceThreadOnly |
Jungshik Jang | 3ee6572 | 2014-06-03 16:22:30 +0900 | [diff] [blame] | 136 | void addLocalDevice(int deviceType, HdmiCecLocalDevice device) { |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 137 | assertRunOnServiceThread(); |
Jungshik Jang | 3ee6572 | 2014-06-03 16:22:30 +0900 | [diff] [blame] | 138 | mLocalDevices.put(deviceType, device); |
Jungshik Jang | 3f74ab0 | 2014-04-30 14:31:02 +0900 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | /** |
| 142 | * Allocate a new logical address of the given device type. Allocated |
Jungshik Jang | 3ee6572 | 2014-06-03 16:22:30 +0900 | [diff] [blame] | 143 | * address will be reported through {@link AllocateAddressCallback}. |
Jungshik Jang | 3f74ab0 | 2014-04-30 14:31:02 +0900 | [diff] [blame] | 144 | * |
| 145 | * <p> Declared as package-private, accessed by {@link HdmiControlService} only. |
| 146 | * |
| 147 | * @param deviceType type of device to used to determine logical address |
| 148 | * @param preferredAddress a logical address preferred to be allocated. |
Jungshik Jang | 4223072 | 2014-07-07 17:40:25 +0900 | [diff] [blame] | 149 | * If sets {@link Constants#ADDR_UNREGISTERED}, scans |
Jungshik Jang | 3f74ab0 | 2014-04-30 14:31:02 +0900 | [diff] [blame] | 150 | * the smallest logical address matched with the given device type. |
| 151 | * Otherwise, scan address will start from {@code preferredAddress} |
| 152 | * @param callback callback interface to report allocated logical address to caller |
| 153 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 154 | @ServiceThreadOnly |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 155 | void allocateLogicalAddress(final int deviceType, final int preferredAddress, |
Jungshik Jang | 3ee6572 | 2014-06-03 16:22:30 +0900 | [diff] [blame] | 156 | final AllocateAddressCallback callback) { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 157 | assertRunOnServiceThread(); |
| 158 | |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 159 | runOnIoThread(new Runnable() { |
| 160 | @Override |
| 161 | public void run() { |
| 162 | handleAllocateLogicalAddress(deviceType, preferredAddress, callback); |
| 163 | } |
| 164 | }); |
| 165 | } |
| 166 | |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 167 | @IoThreadOnly |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 168 | private void handleAllocateLogicalAddress(final int deviceType, int preferredAddress, |
Jungshik Jang | 3ee6572 | 2014-06-03 16:22:30 +0900 | [diff] [blame] | 169 | final AllocateAddressCallback callback) { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 170 | assertRunOnIoThread(); |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 171 | int startAddress = preferredAddress; |
| 172 | // If preferred address is "unregistered", start address will be the smallest |
| 173 | // address matched with the given device type. |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 174 | if (preferredAddress == Constants.ADDR_UNREGISTERED) { |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 175 | for (int i = 0; i < NUM_LOGICAL_ADDRESS; ++i) { |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 176 | if (deviceType == HdmiUtils.getTypeFromAddress(i)) { |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 177 | startAddress = i; |
| 178 | break; |
| 179 | } |
| 180 | } |
| 181 | } |
| 182 | |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 183 | int logicalAddress = Constants.ADDR_UNREGISTERED; |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 184 | // Iterates all possible addresses which has the same device type. |
| 185 | for (int i = 0; i < NUM_LOGICAL_ADDRESS; ++i) { |
| 186 | int curAddress = (startAddress + i) % NUM_LOGICAL_ADDRESS; |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 187 | if (curAddress != Constants.ADDR_UNREGISTERED |
| 188 | && deviceType == HdmiUtils.getTypeFromAddress(curAddress)) { |
Jungshik Jang | 8e93c84 | 2014-08-06 15:48:33 +0900 | [diff] [blame] | 189 | int failedPollingCount = 0; |
| 190 | for (int j = 0; j < HdmiConfig.ADDRESS_ALLOCATION_RETRY; ++j) { |
| 191 | if (!sendPollMessage(curAddress, curAddress, 1)) { |
| 192 | failedPollingCount++; |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | // Pick logical address if failed ratio is more than a half of all retries. |
| 197 | if (failedPollingCount * 2 > HdmiConfig.ADDRESS_ALLOCATION_RETRY) { |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 198 | logicalAddress = curAddress; |
| 199 | break; |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | final int assignedAddress = logicalAddress; |
| 205 | if (callback != null) { |
| 206 | runOnServiceThread(new Runnable() { |
Jungshik Jang | 8e93c84 | 2014-08-06 15:48:33 +0900 | [diff] [blame] | 207 | @Override |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 208 | public void run() { |
| 209 | callback.onAllocated(deviceType, assignedAddress); |
| 210 | } |
| 211 | }); |
| 212 | } |
Jungshik Jang | 3f74ab0 | 2014-04-30 14:31:02 +0900 | [diff] [blame] | 213 | } |
| 214 | |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 215 | private static byte[] buildBody(int opcode, byte[] params) { |
| 216 | byte[] body = new byte[params.length + 1]; |
| 217 | body[0] = (byte) opcode; |
| 218 | System.arraycopy(params, 0, body, 1, params.length); |
| 219 | return body; |
| 220 | } |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 221 | |
Jungshik Jang | 7d9a843 | 2014-04-29 15:12:43 +0900 | [diff] [blame] | 222 | |
Jinsuk Kim | 0340bbc | 2014-06-05 11:07:47 +0900 | [diff] [blame] | 223 | HdmiPortInfo[] getPortInfos() { |
| 224 | return nativeGetPortInfos(mNativePtr); |
| 225 | } |
| 226 | |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 227 | /** |
Jinsuk Kim | 7fe2ae0 | 2014-05-26 17:33:05 +0900 | [diff] [blame] | 228 | * Return the locally hosted logical device of a given type. |
| 229 | * |
| 230 | * @param deviceType logical device type |
| 231 | * @return {@link HdmiCecLocalDevice} instance if the instance of the type is available; |
| 232 | * otherwise null. |
| 233 | */ |
| 234 | HdmiCecLocalDevice getLocalDevice(int deviceType) { |
| 235 | return mLocalDevices.get(deviceType); |
| 236 | } |
| 237 | |
| 238 | /** |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 239 | * Add a new logical address to the device. Device's HW should be notified |
| 240 | * when a new logical address is assigned to a device, so that it can accept |
| 241 | * a command having available destinations. |
| 242 | * |
| 243 | * <p>Declared as package-private. accessed by {@link HdmiControlService} only. |
| 244 | * |
| 245 | * @param newLogicalAddress a logical address to be added |
| 246 | * @return 0 on success. Otherwise, returns negative value |
| 247 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 248 | @ServiceThreadOnly |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 249 | int addLogicalAddress(int newLogicalAddress) { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 250 | assertRunOnServiceThread(); |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 251 | if (HdmiUtils.isValidAddress(newLogicalAddress)) { |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 252 | return nativeAddLogicalAddress(mNativePtr, newLogicalAddress); |
| 253 | } else { |
| 254 | return -1; |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | /** |
| 259 | * Clear all logical addresses registered in the device. |
| 260 | * |
| 261 | * <p>Declared as package-private. accessed by {@link HdmiControlService} only. |
| 262 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 263 | @ServiceThreadOnly |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 264 | void clearLogicalAddress() { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 265 | assertRunOnServiceThread(); |
Jinsuk Kim | 7fe2ae0 | 2014-05-26 17:33:05 +0900 | [diff] [blame] | 266 | for (int i = 0; i < mLocalDevices.size(); ++i) { |
| 267 | mLocalDevices.valueAt(i).clearAddress(); |
Jinsuk Kim | 2918e9e | 2014-05-20 16:45:45 +0900 | [diff] [blame] | 268 | } |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 269 | nativeClearLogicalAddress(mNativePtr); |
| 270 | } |
| 271 | |
Jungshik Jang | 4fc1d10 | 2014-07-09 19:24:50 +0900 | [diff] [blame] | 272 | @ServiceThreadOnly |
| 273 | void clearLocalDevices() { |
| 274 | assertRunOnServiceThread(); |
| 275 | mLocalDevices.clear(); |
| 276 | } |
| 277 | |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 278 | /** |
| 279 | * Return the physical address of the device. |
| 280 | * |
| 281 | * <p>Declared as package-private. accessed by {@link HdmiControlService} only. |
| 282 | * |
| 283 | * @return CEC physical address of the device. The range of success address |
| 284 | * is between 0x0000 and 0xFFFF. If failed it returns -1 |
| 285 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 286 | @ServiceThreadOnly |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 287 | int getPhysicalAddress() { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 288 | assertRunOnServiceThread(); |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 289 | return nativeGetPhysicalAddress(mNativePtr); |
| 290 | } |
| 291 | |
| 292 | /** |
| 293 | * Return CEC version of the device. |
| 294 | * |
| 295 | * <p>Declared as package-private. accessed by {@link HdmiControlService} only. |
| 296 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 297 | @ServiceThreadOnly |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 298 | int getVersion() { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 299 | assertRunOnServiceThread(); |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 300 | return nativeGetVersion(mNativePtr); |
| 301 | } |
| 302 | |
| 303 | /** |
| 304 | * Return vendor id of the device. |
| 305 | * |
| 306 | * <p>Declared as package-private. accessed by {@link HdmiControlService} only. |
| 307 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 308 | @ServiceThreadOnly |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 309 | int getVendorId() { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 310 | assertRunOnServiceThread(); |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 311 | return nativeGetVendorId(mNativePtr); |
| 312 | } |
| 313 | |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 314 | /** |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 315 | * Set an option to CEC HAL. |
Jungshik Jang | 092b445 | 2014-06-11 15:19:17 +0900 | [diff] [blame] | 316 | * |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 317 | * @param flag key of option |
| 318 | * @param value value of option |
Jungshik Jang | 092b445 | 2014-06-11 15:19:17 +0900 | [diff] [blame] | 319 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 320 | @ServiceThreadOnly |
Jungshik Jang | 092b445 | 2014-06-11 15:19:17 +0900 | [diff] [blame] | 321 | void setOption(int flag, int value) { |
| 322 | assertRunOnServiceThread(); |
| 323 | nativeSetOption(mNativePtr, flag, value); |
| 324 | } |
| 325 | |
| 326 | /** |
| 327 | * Configure ARC circuit in the hardware logic to start or stop the feature. |
| 328 | * |
| 329 | * @param enabled whether to enable/disable ARC |
| 330 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 331 | @ServiceThreadOnly |
Jungshik Jang | 092b445 | 2014-06-11 15:19:17 +0900 | [diff] [blame] | 332 | void setAudioReturnChannel(boolean enabled) { |
| 333 | assertRunOnServiceThread(); |
| 334 | nativeSetAudioReturnChannel(mNativePtr, enabled); |
| 335 | } |
| 336 | |
| 337 | /** |
| 338 | * Return the connection status of the specified port |
| 339 | * |
| 340 | * @param port port number to check connection status |
| 341 | * @return true if connected; otherwise, return false |
| 342 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 343 | @ServiceThreadOnly |
Jungshik Jang | 092b445 | 2014-06-11 15:19:17 +0900 | [diff] [blame] | 344 | boolean isConnected(int port) { |
| 345 | assertRunOnServiceThread(); |
| 346 | return nativeIsConnected(mNativePtr, port); |
| 347 | } |
| 348 | |
| 349 | /** |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 350 | * Poll all remote devices. It sends <Polling Message> to all remote |
| 351 | * devices. |
| 352 | * |
| 353 | * <p>Declared as package-private. accessed by {@link HdmiControlService} only. |
| 354 | * |
| 355 | * @param callback an interface used to get a list of all remote devices' address |
Jungshik Jang | 1de5142 | 2014-07-03 11:14:26 +0900 | [diff] [blame] | 356 | * @param sourceAddress a logical address of source device where sends polling message |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 357 | * @param pickStrategy strategy how to pick polling candidates |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 358 | * @param retryCount the number of retry used to send polling message to remote devices |
| 359 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 360 | @ServiceThreadOnly |
Jungshik Jang | 1de5142 | 2014-07-03 11:14:26 +0900 | [diff] [blame] | 361 | void pollDevices(DevicePollingCallback callback, int sourceAddress, int pickStrategy, |
| 362 | int retryCount) { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 363 | assertRunOnServiceThread(); |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 364 | |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 365 | // Extract polling candidates. No need to poll against local devices. |
| 366 | List<Integer> pollingCandidates = pickPollCandidates(pickStrategy); |
Jungshik Jang | 1de5142 | 2014-07-03 11:14:26 +0900 | [diff] [blame] | 367 | runDevicePolling(sourceAddress, pollingCandidates, retryCount, callback); |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 368 | } |
| 369 | |
Jungshik Jang | cc5ef8c | 2014-05-27 13:27:36 +0900 | [diff] [blame] | 370 | /** |
| 371 | * Return a list of all {@link HdmiCecLocalDevice}s. |
| 372 | * |
| 373 | * <p>Declared as package-private. accessed by {@link HdmiControlService} only. |
| 374 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 375 | @ServiceThreadOnly |
Jungshik Jang | cc5ef8c | 2014-05-27 13:27:36 +0900 | [diff] [blame] | 376 | List<HdmiCecLocalDevice> getLocalDeviceList() { |
| 377 | assertRunOnServiceThread(); |
Jungshik Jang | 79c58a4 | 2014-06-16 16:45:36 +0900 | [diff] [blame] | 378 | return HdmiUtils.sparseArrayToList(mLocalDevices); |
Jungshik Jang | cc5ef8c | 2014-05-27 13:27:36 +0900 | [diff] [blame] | 379 | } |
| 380 | |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 381 | private List<Integer> pickPollCandidates(int pickStrategy) { |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 382 | int strategy = pickStrategy & Constants.POLL_STRATEGY_MASK; |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 383 | Predicate<Integer> pickPredicate = null; |
| 384 | switch (strategy) { |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 385 | case Constants.POLL_STRATEGY_SYSTEM_AUDIO: |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 386 | pickPredicate = mSystemAudioAddressPredicate; |
| 387 | break; |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 388 | case Constants.POLL_STRATEGY_REMOTES_DEVICES: |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 389 | default: // The default is POLL_STRATEGY_REMOTES_DEVICES. |
| 390 | pickPredicate = mRemoteDeviceAddressPredicate; |
| 391 | break; |
| 392 | } |
| 393 | |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 394 | int iterationStrategy = pickStrategy & Constants.POLL_ITERATION_STRATEGY_MASK; |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 395 | ArrayList<Integer> pollingCandidates = new ArrayList<>(); |
| 396 | switch (iterationStrategy) { |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 397 | case Constants.POLL_ITERATION_IN_ORDER: |
| 398 | for (int i = Constants.ADDR_TV; i <= Constants.ADDR_SPECIFIC_USE; ++i) { |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 399 | if (pickPredicate.apply(i)) { |
| 400 | pollingCandidates.add(i); |
| 401 | } |
| 402 | } |
| 403 | break; |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 404 | case Constants.POLL_ITERATION_REVERSE_ORDER: |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 405 | default: // The default is reverse order. |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 406 | for (int i = Constants.ADDR_SPECIFIC_USE; i >= Constants.ADDR_TV; --i) { |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 407 | if (pickPredicate.apply(i)) { |
| 408 | pollingCandidates.add(i); |
| 409 | } |
| 410 | } |
| 411 | break; |
| 412 | } |
| 413 | return pollingCandidates; |
| 414 | } |
| 415 | |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 416 | @ServiceThreadOnly |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 417 | private boolean isAllocatedLocalDeviceAddress(int address) { |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 418 | assertRunOnServiceThread(); |
Jinsuk Kim | 7fe2ae0 | 2014-05-26 17:33:05 +0900 | [diff] [blame] | 419 | for (int i = 0; i < mLocalDevices.size(); ++i) { |
| 420 | if (mLocalDevices.valueAt(i).isAddressOf(address)) { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 421 | return true; |
| 422 | } |
| 423 | } |
| 424 | return false; |
| 425 | } |
| 426 | |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 427 | @ServiceThreadOnly |
Jungshik Jang | 1de5142 | 2014-07-03 11:14:26 +0900 | [diff] [blame] | 428 | private void runDevicePolling(final int sourceAddress, |
| 429 | final List<Integer> candidates, final int retryCount, |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 430 | final DevicePollingCallback callback) { |
| 431 | assertRunOnServiceThread(); |
| 432 | runOnIoThread(new Runnable() { |
| 433 | @Override |
| 434 | public void run() { |
| 435 | final ArrayList<Integer> allocated = new ArrayList<>(); |
| 436 | for (Integer address : candidates) { |
Jungshik Jang | 1de5142 | 2014-07-03 11:14:26 +0900 | [diff] [blame] | 437 | if (sendPollMessage(sourceAddress, address, retryCount)) { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 438 | allocated.add(address); |
| 439 | } |
| 440 | } |
| 441 | if (callback != null) { |
| 442 | runOnServiceThread(new Runnable() { |
| 443 | @Override |
| 444 | public void run() { |
| 445 | callback.onPollingFinished(allocated); |
| 446 | } |
| 447 | }); |
| 448 | } |
| 449 | } |
| 450 | }); |
| 451 | } |
| 452 | |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 453 | @IoThreadOnly |
Jungshik Jang | 1de5142 | 2014-07-03 11:14:26 +0900 | [diff] [blame] | 454 | private boolean sendPollMessage(int sourceAddress, int destinationAddress, int retryCount) { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 455 | assertRunOnIoThread(); |
| 456 | for (int i = 0; i < retryCount; ++i) { |
Jungshik Jang | 1de5142 | 2014-07-03 11:14:26 +0900 | [diff] [blame] | 457 | // <Polling Message> is a message which has empty body. |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 458 | // If sending <Polling Message> failed (NAK), it becomes |
| 459 | // new logical address for the device because no device uses |
| 460 | // it as logical address of the device. |
Jungshik Jang | 1de5142 | 2014-07-03 11:14:26 +0900 | [diff] [blame] | 461 | if (nativeSendCecCommand(mNativePtr, sourceAddress, destinationAddress, EMPTY_BODY) |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 462 | == Constants.SEND_RESULT_SUCCESS) { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 463 | return true; |
| 464 | } |
| 465 | } |
| 466 | return false; |
| 467 | } |
| 468 | |
| 469 | private void assertRunOnIoThread() { |
| 470 | if (Looper.myLooper() != mIoHandler.getLooper()) { |
| 471 | throw new IllegalStateException("Should run on io thread."); |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | private void assertRunOnServiceThread() { |
| 476 | if (Looper.myLooper() != mControlHandler.getLooper()) { |
| 477 | throw new IllegalStateException("Should run on service thread."); |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | // Run a Runnable on IO thread. |
| 482 | // It should be careful to access member variables on IO thread because |
| 483 | // it can be accessed from system thread as well. |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 484 | private void runOnIoThread(Runnable runnable) { |
| 485 | mIoHandler.post(runnable); |
| 486 | } |
| 487 | |
| 488 | private void runOnServiceThread(Runnable runnable) { |
| 489 | mControlHandler.post(runnable); |
| 490 | } |
| 491 | |
Jungshik Jang | a1fa91f | 2014-05-08 20:56:41 +0900 | [diff] [blame] | 492 | private boolean isAcceptableAddress(int address) { |
Jinsuk Kim | 2918e9e | 2014-05-20 16:45:45 +0900 | [diff] [blame] | 493 | // Can access command targeting devices available in local device or broadcast command. |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 494 | if (address == Constants.ADDR_BROADCAST) { |
Jinsuk Kim | 2918e9e | 2014-05-20 16:45:45 +0900 | [diff] [blame] | 495 | return true; |
| 496 | } |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 497 | return isAllocatedLocalDeviceAddress(address); |
Jungshik Jang | a1fa91f | 2014-05-08 20:56:41 +0900 | [diff] [blame] | 498 | } |
| 499 | |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 500 | @ServiceThreadOnly |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 501 | private void onReceiveCommand(HdmiCecMessage message) { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 502 | assertRunOnServiceThread(); |
Yuncheol Heo | 6aae652 | 2014-08-05 14:48:37 +0900 | [diff] [blame] | 503 | if (isAcceptableAddress(message.getDestination()) && mService.handleCecCommand(message)) { |
Jungshik Jang | a1fa91f | 2014-05-08 20:56:41 +0900 | [diff] [blame] | 504 | return; |
| 505 | } |
Yuncheol Heo | 6aae652 | 2014-08-05 14:48:37 +0900 | [diff] [blame] | 506 | // Not handled message, so we will reply it with <Feature Abort>. |
| 507 | maySendFeatureAbortCommand(message, Constants.ABORT_UNRECOGNIZED_OPCODE); |
| 508 | } |
Jungshik Jang | 1827fdc | 2014-07-17 13:58:14 +0900 | [diff] [blame] | 509 | |
Yuncheol Heo | 6aae652 | 2014-08-05 14:48:37 +0900 | [diff] [blame] | 510 | @ServiceThreadOnly |
| 511 | void maySendFeatureAbortCommand(HdmiCecMessage message, int reason) { |
| 512 | assertRunOnServiceThread(); |
| 513 | // Swap the source and the destination. |
| 514 | int src = message.getDestination(); |
| 515 | int dest = message.getSource(); |
| 516 | if (src == Constants.ADDR_BROADCAST || dest == Constants.ADDR_UNREGISTERED) { |
| 517 | // Don't reply <Feature Abort> from the unregistered devices or for the broadcasted |
| 518 | // messages. See CEC 12.2 Protocol General Rules for detail. |
| 519 | return; |
| 520 | } |
| 521 | int originalOpcode = message.getOpcode(); |
| 522 | if (originalOpcode == Constants.MESSAGE_FEATURE_ABORT) { |
| 523 | return; |
| 524 | } |
| 525 | sendCommand( |
| 526 | HdmiCecMessageBuilder.buildFeatureAbortCommand(src, dest, originalOpcode, reason)); |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 527 | } |
| 528 | |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 529 | @ServiceThreadOnly |
Jinsuk Kim | 2918e9e | 2014-05-20 16:45:45 +0900 | [diff] [blame] | 530 | void sendCommand(HdmiCecMessage cecMessage) { |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 531 | assertRunOnServiceThread(); |
Jinsuk Kim | 2918e9e | 2014-05-20 16:45:45 +0900 | [diff] [blame] | 532 | sendCommand(cecMessage, null); |
| 533 | } |
| 534 | |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 535 | @ServiceThreadOnly |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 536 | void sendCommand(final HdmiCecMessage cecMessage, |
| 537 | final HdmiControlService.SendMessageCallback callback) { |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 538 | assertRunOnServiceThread(); |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 539 | runOnIoThread(new Runnable() { |
| 540 | @Override |
| 541 | public void run() { |
| 542 | byte[] body = buildBody(cecMessage.getOpcode(), cecMessage.getParams()); |
Jungshik Jang | 8ed86c4 | 2014-07-11 11:56:46 +0900 | [diff] [blame] | 543 | int i = 0; |
| 544 | int errorCode = Constants.SEND_RESULT_SUCCESS; |
| 545 | do { |
| 546 | errorCode = nativeSendCecCommand(mNativePtr, cecMessage.getSource(), |
| 547 | cecMessage.getDestination(), body); |
| 548 | if (errorCode == Constants.SEND_RESULT_SUCCESS) { |
| 549 | break; |
| 550 | } |
| 551 | } while (i++ < HdmiConfig.RETRANSMISSION_COUNT); |
| 552 | |
| 553 | final int finalError = errorCode; |
| 554 | if (finalError != Constants.SEND_RESULT_SUCCESS) { |
Yuncheol Heo | ece603b | 2014-05-23 20:10:19 +0900 | [diff] [blame] | 555 | Slog.w(TAG, "Failed to send " + cecMessage); |
| 556 | } |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 557 | if (callback != null) { |
| 558 | runOnServiceThread(new Runnable() { |
| 559 | @Override |
| 560 | public void run() { |
Jungshik Jang | 8ed86c4 | 2014-07-11 11:56:46 +0900 | [diff] [blame] | 561 | callback.onSendCompleted(finalError); |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 562 | } |
| 563 | }); |
| 564 | } |
| 565 | } |
| 566 | }); |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 567 | } |
| 568 | |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 569 | /** |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 570 | * Called by native when incoming CEC message arrived. |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 571 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 572 | @ServiceThreadOnly |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 573 | private void handleIncomingCecCommand(int srcAddress, int dstAddress, byte[] body) { |
Jungshik Jang | 4085d0e | 2014-05-27 19:52:39 +0900 | [diff] [blame] | 574 | assertRunOnServiceThread(); |
| 575 | onReceiveCommand(HdmiCecMessageBuilder.of(srcAddress, dstAddress, body)); |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 576 | } |
| 577 | |
| 578 | /** |
| 579 | * Called by native when a hotplug event issues. |
| 580 | */ |
Jungshik Jang | 4223072 | 2014-07-07 17:40:25 +0900 | [diff] [blame] | 581 | @ServiceThreadOnly |
| 582 | private void handleHotplug(int port, boolean connected) { |
| 583 | assertRunOnServiceThread(); |
| 584 | mService.onHotplug(port, connected); |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 585 | } |
| 586 | |
Jungshik Jang | 4085d0e | 2014-05-27 19:52:39 +0900 | [diff] [blame] | 587 | private static native long nativeInit(HdmiCecController handler, MessageQueue messageQueue); |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 588 | private static native int nativeSendCecCommand(long controllerPtr, int srcAddress, |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 589 | int dstAddress, byte[] body); |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 590 | private static native int nativeAddLogicalAddress(long controllerPtr, int logicalAddress); |
| 591 | private static native void nativeClearLogicalAddress(long controllerPtr); |
| 592 | private static native int nativeGetPhysicalAddress(long controllerPtr); |
| 593 | private static native int nativeGetVersion(long controllerPtr); |
| 594 | private static native int nativeGetVendorId(long controllerPtr); |
Jinsuk Kim | 0340bbc | 2014-06-05 11:07:47 +0900 | [diff] [blame] | 595 | private static native HdmiPortInfo[] nativeGetPortInfos(long controllerPtr); |
Jungshik Jang | 092b445 | 2014-06-11 15:19:17 +0900 | [diff] [blame] | 596 | private static native void nativeSetOption(long controllerPtr, int flag, int value); |
| 597 | private static native void nativeSetAudioReturnChannel(long controllerPtr, boolean flag); |
| 598 | private static native boolean nativeIsConnected(long controllerPtr, int port); |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 599 | } |