OSDN Git Service

TIF: change input state based on the number of available streams
authorWonsik Kim <wonsik@google.com>
Tue, 21 Oct 2014 08:46:31 +0000 (17:46 +0900)
committerWonsik Kim <wonsik@google.com>
Tue, 21 Oct 2014 08:46:31 +0000 (17:46 +0900)
HAL implementation may indicate that the input port is disconnected
by exposing no available streams. Framework detects the change and
update input state accordingly.

Bug: 17648994
Change-Id: I15900288ff8eab6d2b7bd705f2b3c05263714152

services/core/java/com/android/server/tv/TvInputHardwareManager.java

index 44e4ad1..564f245 100644 (file)
@@ -188,6 +188,11 @@ class TvInputHardwareManager implements TvInputHal.Callback {
                 return;
             }
             connection.updateConfigsLocked(configs);
+            String inputId = mHardwareInputIdMap.get(deviceId);
+            if (inputId != null) {
+                mHandler.obtainMessage(ListenerHandler.STATE_CHANGED,
+                        convertConnectedToState(config.length > 0), 0, inputId).sendToTarget();
+            }
             try {
                 connection.getCallbackLocked().onStreamConfigChanged(configs);
             } catch (RemoteException e) {
@@ -257,6 +262,9 @@ class TvInputHardwareManager implements TvInputHal.Callback {
             mHardwareInputIdMap.put(deviceId, info.getId());
             mInputMap.put(info.getId(), info);
 
+            // Process pending state changes
+
+            // For logical HDMI devices, they have information from HDMI CEC signals.
             for (int i = 0; i < mHdmiStateMap.size(); ++i) {
                 TvInputHardwareInfo hardwareInfo =
                         findHardwareInfoForHdmiPortLocked(mHdmiStateMap.keyAt(i));
@@ -268,8 +276,17 @@ class TvInputHardwareManager implements TvInputHal.Callback {
                     mHandler.obtainMessage(ListenerHandler.STATE_CHANGED,
                             convertConnectedToState(mHdmiStateMap.valueAt(i)), 0,
                             inputId).sendToTarget();
+                    return;
                 }
             }
+            // For the rest of the devices, we can tell by the number of available streams.
+            Connection connection = mConnections.get(deviceId);
+            if (connection != null) {
+                mHandler.obtainMessage(ListenerHandler.STATE_CHANGED,
+                        convertConnectedToState(connection.getConfigsLocked().length > 0), 0,
+                        info.getId()).sendToTarget();
+                return;
+            }
         }
     }