Merge "Use the system property for the HdmiControlService configuration." into lmp-dev
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 169e515..8517ad5 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -470,19 +470,6 @@
          provide full support for multiple displays.  -->
     <integer name="config_undockedHdmiRotation">-1</integer>
 
-    <!-- HDMI-CEC logical device types allowed on the system. Logical device types
-         are defined in HDMI-CEC standard 1.4 as follows:
-           0 TV
-           1 Recording Device
-           2 Reserved
-           3 Tuner
-           4 Playback
-           5 Audio System
-           6 Pure CEC Switch
-           7 Video Processor    -->
-    <integer-array name="config_hdmiCecLogicalDeviceType">
-    </integer-array>
-
     <!-- Control the default UI mode type to use when there is no other type override
          happening.  One of the following values (See Configuration.java):
              1  UI_MODE_TYPE_NORMAL
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 78e237f..641d545 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1328,7 +1328,6 @@
   <java-symbol type="anim" name="voice_activity_open_exit" />
   <java-symbol type="anim" name="voice_activity_open_enter" />
 
-  <java-symbol type="array" name="config_hdmiCecLogicalDeviceType" />
   <java-symbol type="array" name="config_keyboardTapVibePattern" />
   <java-symbol type="array" name="config_longPressVibePattern" />
   <java-symbol type="array" name="config_safeModeDisabledVibePattern" />
diff --git a/services/core/java/com/android/server/hdmi/Constants.java b/services/core/java/com/android/server/hdmi/Constants.java
index b55cf62..591cf25 100644
--- a/services/core/java/com/android/server/hdmi/Constants.java
+++ b/services/core/java/com/android/server/hdmi/Constants.java
@@ -265,5 +265,10 @@
     static final int MHL_CBUS_MODE_ECBUS_S = 2;
     static final int MHL_CBUS_MODE_ECBUS_D = 3;
 
+    // Property name for the local device configurations.
+    // TODO(OEM): OEM should provide this property, and the value is the comma separated integer
+    //     values which denotes the device type in HDMI Spec 1.4.
+    static final String PROPERTY_DEVICE_TYPE = "ro.hdmi.device_type";
+
     private Constants() { /* cannot be instantiated */ }
 }
diff --git a/services/core/java/com/android/server/hdmi/HdmiControlService.java b/services/core/java/com/android/server/hdmi/HdmiControlService.java
index 6f33f75..0e57afd 100644
--- a/services/core/java/com/android/server/hdmi/HdmiControlService.java
+++ b/services/core/java/com/android/server/hdmi/HdmiControlService.java
@@ -18,7 +18,6 @@
 
 import static com.android.server.hdmi.Constants.DISABLED;
 import static com.android.server.hdmi.Constants.ENABLED;
-import static com.android.server.hdmi.Constants.OPTION_CEC_AUTO_DEVICE_OFF;
 import static com.android.server.hdmi.Constants.OPTION_CEC_AUTO_WAKEUP;
 import static com.android.server.hdmi.Constants.OPTION_CEC_ENABLE;
 import static com.android.server.hdmi.Constants.OPTION_CEC_SERVICE_CONTROL;
@@ -33,8 +32,8 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.database.ContentObserver;
-import android.hardware.hdmi.HdmiDeviceInfo;
 import android.hardware.hdmi.HdmiControlManager;
+import android.hardware.hdmi.HdmiDeviceInfo;
 import android.hardware.hdmi.HdmiHotplugEvent;
 import android.hardware.hdmi.HdmiPortInfo;
 import android.hardware.hdmi.IHdmiControlCallback;
@@ -55,8 +54,10 @@
 import android.os.PowerManager;
 import android.os.RemoteException;
 import android.os.SystemClock;
+import android.os.SystemProperties;
 import android.os.UserHandle;
 import android.provider.Settings.Global;
+import android.text.TextUtils;
 import android.util.ArraySet;
 import android.util.Slog;
 import android.util.SparseArray;
@@ -244,11 +245,24 @@
 
     public HdmiControlService(Context context) {
         super(context);
-        mLocalDevices = HdmiUtils.asImmutableList(getContext().getResources().getIntArray(
-                com.android.internal.R.array.config_hdmiCecLogicalDeviceType));
+        mLocalDevices = getIntList(SystemProperties.get(Constants.PROPERTY_DEVICE_TYPE));
         mSettingsObserver = new SettingsObserver(mHandler);
     }
 
+    private static List<Integer> getIntList(String string) {
+        ArrayList<Integer> list = new ArrayList<>();
+        TextUtils.SimpleStringSplitter splitter = new TextUtils.SimpleStringSplitter(',');
+        splitter.setString(string);
+        for (String item : splitter) {
+            try {
+                list.add(Integer.parseInt(item));
+            } catch (NumberFormatException e) {
+                Slog.w(TAG, "Can't parseInt: " + item);
+            }
+        }
+        return Collections.unmodifiableList(list);
+    }
+
     @Override
     public void onStart() {
         mIoThread.start();