diff --git a/services/core/java/com/android/server/hdmi/HdmiCecController.java b/services/core/java/com/android/server/hdmi/HdmiCecController.java index c87fc99807f50..b103a4dc29b48 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecController.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecController.java @@ -40,7 +40,7 @@ import java.util.List; * *
Declared as package-private, accessed by {@link HdmiControlService} only. */ -class HdmiCecController { +final class HdmiCecController { private static final String TAG = "HdmiCecController"; private static final byte[] EMPTY_BODY = EmptyArray.BYTE; @@ -313,6 +313,63 @@ class HdmiCecController { return mDeviceInfos.get(logicalAddress); } + /** + * Add a new logical address to the device. Device's HW should be notified + * when a new logical address is assigned to a device, so that it can accept + * a command having available destinations. + * + *
Declared as package-private. accessed by {@link HdmiControlService} only. + * + * @param newLogicalAddress a logical address to be added + * @return 0 on success. Otherwise, returns negative value + */ + int addLogicalAddress(int newLogicalAddress) { + if (HdmiCec.isValidAddress(newLogicalAddress)) { + return nativeAddLogicalAddress(mNativePtr, newLogicalAddress); + } else { + return -1; + } + } + + /** + * Clear all logical addresses registered in the device. + * + *
Declared as package-private. accessed by {@link HdmiControlService} only. + */ + void clearLogicalAddress() { + nativeClearLogicalAddress(mNativePtr); + } + + /** + * Return the physical address of the device. + * + *
Declared as package-private. accessed by {@link HdmiControlService} only. + * + * @return CEC physical address of the device. The range of success address + * is between 0x0000 and 0xFFFF. If failed it returns -1 + */ + int getPhysicalAddress() { + return nativeGetPhysicalAddress(mNativePtr); + } + + /** + * Return CEC version of the device. + * + *
Declared as package-private. accessed by {@link HdmiControlService} only. + */ + int getVersion() { + return nativeGetVersion(mNativePtr); + } + + /** + * Return vendor id of the device. + * + *
Declared as package-private. accessed by {@link HdmiControlService} only.
+ */
+ int getVendorId() {
+ return nativeGetVendorId(mNativePtr);
+ }
+
private void init(HdmiControlService service, long nativePtr) {
mIoHandler = new IoHandler(service.getServiceLooper());
mControlHandler = new ControlHandler(service.getServiceLooper());
@@ -364,6 +421,11 @@ class HdmiCecController {
}
private static native long nativeInit(HdmiCecController handler);
- private static native int nativeSendCecCommand(long contollerPtr, int srcAddress,
+ private static native int nativeSendCecCommand(long controllerPtr, int srcAddress,
int dstAddress, byte[] body);
+ private static native int nativeAddLogicalAddress(long controllerPtr, int logicalAddress);
+ private static native void nativeClearLogicalAddress(long controllerPtr);
+ private static native int nativeGetPhysicalAddress(long controllerPtr);
+ private static native int nativeGetVersion(long controllerPtr);
+ private static native int nativeGetVendorId(long controllerPtr);
}
diff --git a/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp b/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp
index 527216d8759c9..27c8876fdf9c0 100644
--- a/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp
+++ b/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp
@@ -43,6 +43,16 @@ public:
// Send message to other device. Note that it runs in IO thread.
int sendMessage(const cec_message_t& message);
+ // Add a logical address to device.
+ int addLogicalAddress(cec_logical_address_t address);
+ // Clear all logical address registered to the device.
+ void clearLogicaladdress();
+ // Get physical address of device.
+ int getPhysicalAddress();
+ // Get CEC version from driver.
+ int getVersion();
+ // Get vendor id used for vendor command.
+ uint32_t getVendorId();
private:
// Propagate the message up to Java layer.
@@ -94,6 +104,34 @@ int HdmiCecController::sendMessage(const cec_message_t& message) {
return mDevice->send_message(mDevice, &message);
}
+int HdmiCecController::addLogicalAddress(cec_logical_address_t address) {
+ return mDevice->add_logical_address(mDevice, address);
+}
+
+void HdmiCecController::clearLogicaladdress() {
+ mDevice->clear_logical_address(mDevice);
+}
+
+int HdmiCecController::getPhysicalAddress() {
+ uint16_t physicalAddress = 0xFFFF;
+ if (mDevice->get_physical_address(mDevice, &physicalAddress) == 0) {
+ return physicalAddress;
+ }
+ return -1;
+}
+
+int HdmiCecController::getVersion() {
+ int version = 0;
+ mDevice->get_version(mDevice, &version);
+ return version;
+}
+
+uint32_t HdmiCecController::getVendorId() {
+ uint32_t vendorId = 0;
+ mDevice->get_vendor_id(mDevice, &vendorId);
+ return vendorId;
+}
+
// static
void HdmiCecController::checkAndClearExceptionFromCallback(JNIEnv* env,
const char* methodName) {
@@ -180,12 +218,51 @@ static jint nativeSendCecCommand(JNIEnv* env, jclass clazz, jlong controllerPtr,
return controller->sendMessage(message);
}
+static jint nativeAddLogicalAddress(JNIEnv* env, jclass clazz,
+ jlong controllerPtr, jint logicalAddress) {
+ HdmiCecController* controller =
+ reinterpret_cast