summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorJinsuk Kim <jinsukkim@google.com>2014-04-07 13:39:17 +0900
committerJinsuk Kim <jinsukkim@google.com>2014-04-11 18:35:01 +0900
commit61791075f4422cfef00fda325d6ae07293dd262f (patch)
tree2a2b3441329d2d4863c2bac97f5d24f9e562582d /services
parentbd6c5577ab0790415b99d24f41b7b3cdd823449d (diff)
downloadframeworks_base-61791075f4422cfef00fda325d6ae07293dd262f.zip
frameworks_base-61791075f4422cfef00fda325d6ae07293dd262f.tar.gz
frameworks_base-61791075f4422cfef00fda325d6ae07293dd262f.tar.bz2
Delegate HdmiCecService method impl to HdmiCecDevice subclass
Most of the methods in the interface IHdmiCecService should be implemented based on the device type. This CL makes a change such that the HdmiCecDevice just has stub methods that should be overriden by subclasses. Other changes: - Fixed a bug of <Inactive Source> not sending its physical address in its message body. Also the command should have been sent to TV only rather than broadcast. - Put back sendGiveDevicePowerStatus interface method. It allows the client to keep track of the other device(like TV) power status more closely. Devices goes through the status from standby -> transient to on -> on but the CEC spec doesn't require that they broacast it actively. The restored method can be used to let the playback device to get up-to-date power status of TV/display when it is booting up. This method should work the same across all the device types. So it was implemented in the service, not delegated to HdmiCecDevice. - Send <Report Physical Address> when a new logical device is registered, which is required by CEC spec: "it should report the association between its logical and physical address by broadcasting <Report Physical Address> Change-Id: Iac1d2cf5783d947f2dcd6965a54670fbdb8e6a63
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/hdmi/HdmiCecDevice.java40
-rw-r--r--services/core/java/com/android/server/hdmi/HdmiCecDevicePlayback.java37
-rw-r--r--services/core/java/com/android/server/hdmi/HdmiCecService.java28
-rw-r--r--services/core/jni/com_android_server_hdmi_HdmiCecService.cpp5
4 files changed, 91 insertions, 19 deletions
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecDevice.java b/services/core/java/com/android/server/hdmi/HdmiCecDevice.java
index 64b51c9..baae1d9 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecDevice.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecDevice.java
@@ -182,11 +182,49 @@ abstract class HdmiCecDevice {
}
/**
+ * Send &lt;Active Source&gt; command. The default implementation does nothing. Should be
+ * overriden by subclass.
+ */
+ public void sendActiveSource(int physicalAddress) {
+ logWarning("<Active Source> not valid for the device type: " + mType
+ + " address:" + physicalAddress);
+ }
+
+ /**
+ * Send &lt;Inactive Source&gt; command. The default implementation does nothing. Should be
+ * overriden by subclass.
+ */
+ public void sendInactiveSource(int physicalAddress) {
+ logWarning("<Inactive Source> not valid for the device type: " + mType
+ + " address:" + physicalAddress);
+ }
+
+ /**
+ * Send &lt;Image View On&gt; command. The default implementation does nothing. Should be
+ * overriden by subclass.
+ */
+ public void sendImageViewOn() {
+ logWarning("<Image View On> not valid for the device type: " + mType);
+ }
+
+ /**
+ * Send &lt;Text View On&gt; command. The default implementation does nothing. Should be
+ * overriden by subclass.
+ */
+ public void sendTextViewOn() {
+ logWarning("<Text View On> not valid for the device type: " + mType);
+ }
+
+ /**
* Check if the connected sink device is in powered-on state. The default implementation
* simply returns false. Should be overriden by subclass to report the correct state.
*/
public boolean isSinkDeviceOn() {
- Log.w(TAG, "Not valid for the device type: " + mType);
+ logWarning("isSinkDeviceOn() not valid for the device type: " + mType);
return false;
}
+
+ private void logWarning(String msg) {
+ Log.w(TAG, msg);
+ }
}
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecDevicePlayback.java b/services/core/java/com/android/server/hdmi/HdmiCecDevicePlayback.java
index 0310264..f8cf11d 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecDevicePlayback.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecDevicePlayback.java
@@ -66,14 +66,11 @@ final class HdmiCecDevicePlayback extends HdmiCecDevice {
// 1) Response for the queried power status request arrives. Update the status.
// 2) Broadcast or direct <Standby> command from TV, which is sent as TV itself is going
// into standby mode too.
- // 3) Broadcast <Report Physical Address> command from TV, which is sent while it boots up.
if (opcode == HdmiCec.MESSAGE_REPORT_POWER_STATUS) {
mSinkDevicePowerStatus = params[0];
} else if (srcAddress == HdmiCec.ADDR_TV) {
if (opcode == HdmiCec.MESSAGE_STANDBY) {
mSinkDevicePowerStatus = HdmiCec.POWER_STATUS_STANDBY;
- } else if (opcode == HdmiCec.MESSAGE_REPORT_PHYSICAL_ADDRESS) {
- mSinkDevicePowerStatus = HdmiCec.POWER_STATUS_ON;
}
}
super.handleMessage(srcAddress, dstAddress, opcode, params);
@@ -95,4 +92,38 @@ final class HdmiCecDevicePlayback extends HdmiCecDevice {
public boolean isSinkDeviceOn() {
return mSinkDevicePowerStatus == HdmiCec.POWER_STATUS_ON;
}
+
+ @Override
+ public void sendActiveSource(int physicalAddress) {
+ setIsActiveSource(true);
+ byte[] param = new byte[] {
+ (byte) ((physicalAddress >> 8) & 0xff),
+ (byte) (physicalAddress & 0xff)
+ };
+ getService().sendMessage(getType(), HdmiCec.ADDR_BROADCAST, HdmiCec.MESSAGE_ACTIVE_SOURCE,
+ param);
+ }
+
+ @Override
+ public void sendInactiveSource(int physicalAddress) {
+ setIsActiveSource(false);
+ byte[] param = new byte[] {
+ (byte) ((physicalAddress >> 8) & 0xff),
+ (byte) (physicalAddress & 0xff)
+ };
+ getService().sendMessage(getType(), HdmiCec.ADDR_TV, HdmiCec.MESSAGE_INACTIVE_SOURCE,
+ param);
+ }
+
+ @Override
+ public void sendImageViewOn() {
+ getService().sendMessage(getType(), HdmiCec.ADDR_TV, HdmiCec.MESSAGE_IMAGE_VIEW_ON,
+ HdmiCecService.EMPTY_PARAM);
+ }
+
+ @Override
+ public void sendTextViewOn() {
+ getService().sendMessage(getType(), HdmiCec.ADDR_TV, HdmiCec.MESSAGE_TEXT_VIEW_ON,
+ HdmiCecService.EMPTY_PARAM);
+ }
}
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecService.java b/services/core/java/com/android/server/hdmi/HdmiCecService.java
index aa496c5..0a4c719 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecService.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecService.java
@@ -277,14 +277,7 @@ public final class HdmiCecService extends SystemService {
enforceAccessPermission();
synchronized (mLock) {
HdmiCecDevice device = getLogicalDeviceLocked(b);
- device.setIsActiveSource(true);
- int physicalAddress = nativeGetPhysicalAddress(mNativePtr);
- byte[] param = new byte[] {
- (byte) ((physicalAddress >> 8) & 0xff),
- (byte) (physicalAddress & 0xff)
- };
- nativeSendMessage(mNativePtr, device.getType(), HdmiCec.ADDR_BROADCAST,
- HdmiCec.MESSAGE_ACTIVE_SOURCE, param);
+ device.sendActiveSource(nativeGetPhysicalAddress(mNativePtr));
}
}
@@ -293,9 +286,7 @@ public final class HdmiCecService extends SystemService {
enforceAccessPermission();
synchronized (mLock) {
HdmiCecDevice device = getLogicalDeviceLocked(b);
- device.setIsActiveSource(false);
- nativeSendMessage(mNativePtr, device.getType(), HdmiCec.ADDR_BROADCAST,
- HdmiCec.MESSAGE_INACTIVE_SOURCE, EMPTY_PARAM);
+ device.sendInactiveSource(nativeGetPhysicalAddress(mNativePtr));
}
}
@@ -304,8 +295,7 @@ public final class HdmiCecService extends SystemService {
enforceAccessPermission();
synchronized (mLock) {
HdmiCecDevice device = getLogicalDeviceLocked(b);
- nativeSendMessage(mNativePtr, device.getType(), HdmiCec.ADDR_TV,
- HdmiCec.MESSAGE_IMAGE_VIEW_ON, EMPTY_PARAM);
+ device.sendImageViewOn();
}
}
@@ -314,8 +304,16 @@ public final class HdmiCecService extends SystemService {
enforceAccessPermission();
synchronized (mLock) {
HdmiCecDevice device = getLogicalDeviceLocked(b);
- nativeSendMessage(mNativePtr, device.getType(), HdmiCec.ADDR_TV,
- HdmiCec.MESSAGE_TEXT_VIEW_ON, EMPTY_PARAM);
+ device.sendTextViewOn();
+ }
+ }
+
+ public void sendGiveDevicePowerStatus(IBinder b, int address) {
+ enforceAccessPermission();
+ synchronized (mLock) {
+ HdmiCecDevice device = getLogicalDeviceLocked(b);
+ nativeSendMessage(mNativePtr, device.getType(), address,
+ HdmiCec.MESSAGE_GIVE_DEVICE_POWER_STATUS, EMPTY_PARAM);
}
}
diff --git a/services/core/jni/com_android_server_hdmi_HdmiCecService.cpp b/services/core/jni/com_android_server_hdmi_HdmiCecService.cpp
index a00aaa8..54c9755 100644
--- a/services/core/jni/com_android_server_hdmi_HdmiCecService.cpp
+++ b/services/core/jni/com_android_server_hdmi_HdmiCecService.cpp
@@ -204,6 +204,11 @@ cec_logical_address_t HdmiCecHandler::initLogicalDevice(cec_device_type_t type)
} else {
ALOGV("Logical Address Allocation success: %d", addr);
mLogicalDevices.insert(std::pair<cec_device_type_t, cec_logical_address_t>(type, addr));
+
+ // Broadcast <Report Physical Address> when a new logical address was allocated to let
+ // other devices discover the new logical device and its logical - physical address
+ // association.
+ sendReportPhysicalAddress();
}
return addr;
}