OSDN Git Service

Set source address for <Polling Message>
authorJungshik Jang <jayjang@google.com>
Thu, 3 Jul 2014 02:14:26 +0000 (11:14 +0900)
committerJungshik Jang <jayjang@google.com>
Thu, 3 Jul 2014 02:14:26 +0000 (11:14 +0900)
CEC spec mentions that logical address allocation uses
the same address for source and destination while <Polling Message>
uses device's source address.

Bug: 16045547
Change-Id: Id18f328755501c62a98a1040b287c180cb889c9b

services/core/java/com/android/server/hdmi/FeatureAction.java
services/core/java/com/android/server/hdmi/HdmiCecController.java
services/core/java/com/android/server/hdmi/HdmiControlService.java

index cf28f05..3595f79 100644 (file)
@@ -207,7 +207,7 @@ abstract class FeatureAction {
 
     protected final void pollDevices(DevicePollingCallback callback, int pickStrategy,
             int retryCount) {
-        mService.pollDevices(callback, pickStrategy, retryCount);
+        mService.pollDevices(callback, getSourceAddress(), pickStrategy, retryCount);
     }
 
     /**
index 49f2d6f..7dfea6a 100644 (file)
@@ -200,7 +200,8 @@ final class HdmiCecController {
             int curAddress = (startAddress + i) % NUM_LOGICAL_ADDRESS;
             if (curAddress != HdmiCec.ADDR_UNREGISTERED
                     && deviceType == HdmiCec.getTypeFromAddress(curAddress)) {
-                if (!sendPollMessage(curAddress, RETRY_COUNT_FOR_LOGICAL_ADDRESS_ALLOCATION)) {
+                if (!sendPollMessage(curAddress, curAddress,
+                        RETRY_COUNT_FOR_LOGICAL_ADDRESS_ALLOCATION)) {
                     logicalAddress = curAddress;
                     break;
                 }
@@ -358,16 +359,18 @@ final class HdmiCecController {
      * <p>Declared as package-private. accessed by {@link HdmiControlService} only.
      *
      * @param callback an interface used to get a list of all remote devices' address
+     * @param sourceAddress a logical address of source device where sends polling message
      * @param pickStrategy strategy how to pick polling candidates
      * @param retryCount the number of retry used to send polling message to remote devices
      */
     @ServiceThreadOnly
-    void pollDevices(DevicePollingCallback callback, int pickStrategy, int retryCount) {
+    void pollDevices(DevicePollingCallback callback, int sourceAddress, int pickStrategy,
+            int retryCount) {
         assertRunOnServiceThread();
 
         // Extract polling candidates. No need to poll against local devices.
         List<Integer> pollingCandidates = pickPollCandidates(pickStrategy);
-        runDevicePolling(pollingCandidates, retryCount, callback);
+        runDevicePolling(sourceAddress, pollingCandidates, retryCount, callback);
     }
 
     /**
@@ -428,7 +431,8 @@ final class HdmiCecController {
     }
 
     @ServiceThreadOnly
-    private void runDevicePolling(final List<Integer> candidates, final int retryCount,
+    private void runDevicePolling(final int sourceAddress,
+            final List<Integer> candidates, final int retryCount,
             final DevicePollingCallback callback) {
         assertRunOnServiceThread();
         runOnIoThread(new Runnable() {
@@ -436,7 +440,7 @@ final class HdmiCecController {
             public void run() {
                 final ArrayList<Integer> allocated = new ArrayList<>();
                 for (Integer address : candidates) {
-                    if (sendPollMessage(address, retryCount)) {
+                    if (sendPollMessage(sourceAddress, address, retryCount)) {
                         allocated.add(address);
                     }
                 }
@@ -453,15 +457,14 @@ final class HdmiCecController {
     }
 
     @IoThreadOnly
-    private boolean sendPollMessage(int address, int retryCount) {
+    private boolean sendPollMessage(int sourceAddress, int destinationAddress, int retryCount) {
         assertRunOnIoThread();
         for (int i = 0; i < retryCount; ++i) {
-            // <Polling Message> is a message which has empty body and
-            // uses same address for both source and destination address.
+            // <Polling Message> is a message which has empty body.
             // If sending <Polling Message> failed (NAK), it becomes
             // new logical address for the device because no device uses
             // it as logical address of the device.
-            if (nativeSendCecCommand(mNativePtr, address, address, EMPTY_BODY)
+            if (nativeSendCecCommand(mNativePtr, sourceAddress, destinationAddress, EMPTY_BODY)
                     == HdmiConstants.SEND_RESULT_SUCCESS) {
                 return true;
             }
index a2df852..63df9a2 100644 (file)
@@ -448,14 +448,17 @@ public final class HdmiControlService extends SystemService {
      * devices.
      *
      * @param callback an interface used to get a list of all remote devices' address
+     * @param sourceAddress a logical address of source device where sends polling message
      * @param pickStrategy strategy how to pick polling candidates
      * @param retryCount the number of retry used to send polling message to remote devices
      * @throw IllegalArgumentException if {@code pickStrategy} is invalid value
      */
     @ServiceThreadOnly
-    void pollDevices(DevicePollingCallback callback, int pickStrategy, int retryCount) {
+    void pollDevices(DevicePollingCallback callback, int sourceAddress, int pickStrategy,
+            int retryCount) {
         assertRunOnServiceThread();
-        mCecController.pollDevices(callback, checkPollStrategy(pickStrategy), retryCount);
+        mCecController.pollDevices(callback, sourceAddress, checkPollStrategy(pickStrategy),
+                retryCount);
     }
 
     private int checkPollStrategy(int pickStrategy) {