OSDN Git Service

Add HdmiAudioSystemClient
authorShubang <shubang@google.com>
Sat, 9 Jun 2018 01:30:15 +0000 (18:30 -0700)
committerNick Chalko <nchalko@google.com>
Wed, 18 Jul 2018 18:50:16 +0000 (11:50 -0700)
Bug: 109949458
Test: make;
Change-Id: Id82f5e6d5fd607ec0ffe11317341a02f7357354e

core/java/android/hardware/hdmi/HdmiAudioSystemClient.java [new file with mode: 0644]
core/java/android/hardware/hdmi/HdmiControlManager.java
core/java/android/hardware/hdmi/HdmiPlaybackClient.java
core/java/android/hardware/hdmi/HdmiTvClient.java

diff --git a/core/java/android/hardware/hdmi/HdmiAudioSystemClient.java b/core/java/android/hardware/hdmi/HdmiAudioSystemClient.java
new file mode 100644 (file)
index 0000000..23eef48
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.hardware.hdmi;
+
+/**
+ * HdmiAudioSystemClient represents HDMI-CEC logical device of type Audio System
+ * in the Android system which acts as an audio system device such as sound bar.
+ *
+ * <p>HdmiAudioSystemClient provides methods that control, get information from TV/Display device
+ * connected through HDMI bus.
+ *
+ * @hide
+ */
+public final class HdmiAudioSystemClient extends HdmiClient {
+    private static final String TAG = "HdmiAudioSystemClient";
+
+    /* package */ HdmiAudioSystemClient(IHdmiControlService service) {
+        super(service);
+    }
+
+    /**
+     * TODO(b/110094868): unhide and add @SystemApi for Q
+     * @hide
+     */
+    @Override
+    public int getDeviceType() {
+        return HdmiDeviceInfo.DEVICE_AUDIO_SYSTEM;
+    }
+}
index e34423c..72a6ffe 100644 (file)
@@ -22,10 +22,10 @@ import android.annotation.RequiresPermission;
 import android.annotation.SdkConstant;
 import android.annotation.SdkConstant.SdkConstantType;
 import android.annotation.SuppressLint;
-import android.content.Context;
-import android.content.pm.PackageManager;
 import android.annotation.SystemApi;
 import android.annotation.SystemService;
+import android.content.Context;
+import android.content.pm.PackageManager;
 import android.os.RemoteException;
 import android.util.ArrayMap;
 import android.util.Log;
@@ -262,6 +262,8 @@ public final class HdmiControlManager {
     private final boolean mHasPlaybackDevice;
     // True if we have a logical device of type TV hosted in the system.
     private final boolean mHasTvDevice;
+    // True if we have a logical device of type audio system hosted in the system.
+    private final boolean mHasAudioSystemDevice;
 
     /**
      * {@hide} - hide this constructor because it has a parameter of type IHdmiControlService,
@@ -280,6 +282,7 @@ public final class HdmiControlManager {
         }
         mHasTvDevice = hasDeviceType(types, HdmiDeviceInfo.DEVICE_TV);
         mHasPlaybackDevice = hasDeviceType(types, HdmiDeviceInfo.DEVICE_PLAYBACK);
+        mHasAudioSystemDevice = hasDeviceType(types, HdmiDeviceInfo.DEVICE_AUDIO_SYSTEM);
     }
 
     private static boolean hasDeviceType(int[] types, int type) {
@@ -301,6 +304,7 @@ public final class HdmiControlManager {
      * @return {@link HdmiClient} instance. {@code null} on failure.
      * See {@link HdmiDeviceInfo#DEVICE_PLAYBACK}
      * See {@link HdmiDeviceInfo#DEVICE_TV}
+     * See {@link HdmiDeviceInfo#DEVICE_AUDIO_SYSTEM}
      */
     @Nullable
     @SuppressLint("Doclava125")
@@ -313,6 +317,8 @@ public final class HdmiControlManager {
                 return mHasTvDevice ? new HdmiTvClient(mService) : null;
             case HdmiDeviceInfo.DEVICE_PLAYBACK:
                 return mHasPlaybackDevice ? new HdmiPlaybackClient(mService) : null;
+            case HdmiDeviceInfo.DEVICE_AUDIO_SYSTEM:
+                return mHasAudioSystemDevice ? new HdmiAudioSystemClient(mService) : null;
             default:
                 return null;
         }
@@ -349,6 +355,24 @@ public final class HdmiControlManager {
     }
 
     /**
+     * Gets an object that represents an HDMI-CEC logical device of type audio system on the system.
+     *
+     * <p>Used to send HDMI control messages to other devices like TV through HDMI bus. It is also
+     * possible to communicate with other logical devices hosted in the same system if the system is
+     * configured to host more than one type of HDMI-CEC logical devices.
+     *
+     * @return {@link HdmiAudioSystemClient} instance. {@code null} on failure.
+     *
+     * TODO(b/110094868): unhide for Q
+     * @hide
+     */
+    @Nullable
+    @SuppressLint("Doclava125")
+    public HdmiAudioSystemClient getAudioSystemClient() {
+        return (HdmiAudioSystemClient) getClient(HdmiDeviceInfo.DEVICE_AUDIO_SYSTEM);
+    }
+
+    /**
      * Controls standby mode of the system. It will also try to turn on/off the connected devices if
      * necessary.
      *
index 874b0c6..df231e6 100644 (file)
@@ -23,7 +23,8 @@ import android.util.Log;
 /**
  * HdmiPlaybackClient represents HDMI-CEC logical device of type Playback
  * in the Android system which acts as a playback device such as set-top box.
- * It provides with methods that control, get information from TV/Display device
+ *
+ * <p>HdmiPlaybackClient provides methods that control, get information from TV/Display device
  * connected through HDMI bus.
  *
  * @hide
index a336e5c..f33a137 100644 (file)
@@ -29,8 +29,9 @@ import java.util.List;
 
 /**
  * HdmiTvClient represents HDMI-CEC logical device of type TV in the Android system
- * which acts as TV/Display. It provides with methods that manage, interact with other
- * devices on the CEC bus.
+ * which acts as TV/Display.
+ *
+ * <p>HdmiTvClient provides methods that manage, interact with other devices on the CEC bus.
  *
  * @hide
  */