Merge "HdmiControlManager with HdmiPlaybackClient API definition"
diff --git a/Android.mk b/Android.mk
index edabdb4..19ee855 100644
--- a/Android.mk
+++ b/Android.mk
@@ -147,6 +147,8 @@
core/java/android/hardware/display/IDisplayManagerCallback.aidl \
core/java/android/hardware/hdmi/IHdmiCecListener.aidl \
core/java/android/hardware/hdmi/IHdmiCecService.aidl \
+ core/java/android/hardware/hdmi/IHdmiControlCallback.aidl \
+ core/java/android/hardware/hdmi/IHdmiControlService.aidl \
core/java/android/hardware/input/IInputManager.aidl \
core/java/android/hardware/input/IInputDevicesChangedListener.aidl \
core/java/android/hardware/location/IFusedLocationHardware.aidl \
diff --git a/api/current.txt b/api/current.txt
index 3b0702e..3e52b7e 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -6630,6 +6630,7 @@
field public static final java.lang.String DROPBOX_SERVICE = "dropbox";
field public static final java.lang.String FINGERPRINT_SERVICE = "fingerprint";
field public static final java.lang.String HDMI_CEC_SERVICE = "hdmi_cec";
+ field public static final java.lang.String HDMI_CONTROL_SERVICE = "hdmi_control";
field public static final java.lang.String INPUT_METHOD_SERVICE = "input_method";
field public static final java.lang.String INPUT_SERVICE = "input";
field public static final java.lang.String KEYGUARD_SERVICE = "keyguard";
@@ -12503,9 +12504,15 @@
field public static final int MESSAGE_VENDOR_REMOTE_BUTTON_UP = 139; // 0x8b
field public static final int POWER_STATUS_ON = 0; // 0x0
field public static final int POWER_STATUS_STANDBY = 1; // 0x1
+ field public static final int POWER_STATUS_TRANSIENT_TO_ON = 2; // 0x2
+ field public static final int POWER_STATUS_TRANSIENT_TO_STANDBY = 3; // 0x3
field public static final int POWER_STATUS_UNKNOWN = -1; // 0xffffffff
- field public static final int POWER_TRANSIENT_TO_ON = 2; // 0x2
- field public static final int POWER_TRANSIENT_TO_STANDBY = 3; // 0x3
+ field public static final int RESULT_ALREADY_IN_PROGRESS = 4; // 0x4
+ field public static final int RESULT_EXCEPTION = 5; // 0x5
+ field public static final int RESULT_SOURCE_NOT_AVAILABLE = 2; // 0x2
+ field public static final int RESULT_SUCCESS = 0; // 0x0
+ field public static final int RESULT_TARGET_NOT_AVAILABLE = 3; // 0x3
+ field public static final int RESULT_TIMEOUT = 1; // 0x1
field public static final int UNKNOWN_VENDOR_ID = 16777215; // 0xffffff
}
@@ -12551,6 +12558,27 @@
field public static final byte[] EMPTY_PARAM;
}
+ public final class HdmiControlManager {
+ method public android.hardware.hdmi.HdmiPlaybackClient getPlaybackClient();
+ method public android.hardware.hdmi.HdmiTvClient getTvClient();
+ }
+
+ public final class HdmiPlaybackClient {
+ method public void oneTouchPlay(android.hardware.hdmi.HdmiPlaybackClient.OneTouchPlayCallback);
+ method public void queryDisplayStatus(android.hardware.hdmi.HdmiPlaybackClient.DisplayStatusCallback);
+ }
+
+ public static abstract interface HdmiPlaybackClient.DisplayStatusCallback {
+ method public abstract void onComplete(int);
+ }
+
+ public static abstract interface HdmiPlaybackClient.OneTouchPlayCallback {
+ method public abstract void onComplete(int);
+ }
+
+ public final class HdmiTvClient {
+ }
+
}
package android.hardware.input {
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 74d2e9a..f7f51fe 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -2583,13 +2583,24 @@
/**
* Use with {@link #getSystemService} to retrieve a
- * {@link android.hardware.hdmi.HdmiCecManager for controlling and managing
+ * {@link android.hardware.hdmi.HdmiCecManager} for controlling and managing
* HDMI-CEC protocol.
*
* @see #getSystemService
* @see android.hardware.hdmi.HdmiCecManager
*/
- public static final String HDMI_CEC_SERVICE = "hdmi_cec";
+ // TODO: Remove this once HdmiControlService is ready.
+ public static final String HDMI_CEC_SERVICE = "hdmi_cec";
+
+ /**
+ * Use with {@link #getSystemService} to retrieve a
+ * {@link android.hardware.hdmi.HdmiControlManager} for controlling and managing
+ * HDMI-CEC protocol.
+ *
+ * @see #getSystemService
+ * @see android.hardware.hdmi.HdmiControlManager
+ */
+ public static final String HDMI_CONTROL_SERVICE = "hdmi_control";
/**
* Use with {@link #getSystemService} to retrieve a
diff --git a/core/java/android/hardware/hdmi/HdmiCec.java b/core/java/android/hardware/hdmi/HdmiCec.java
index 9193f89..a71a74d 100644
--- a/core/java/android/hardware/hdmi/HdmiCec.java
+++ b/core/java/android/hardware/hdmi/HdmiCec.java
@@ -171,8 +171,15 @@
public static final int POWER_STATUS_UNKNOWN = -1;
public static final int POWER_STATUS_ON = 0;
public static final int POWER_STATUS_STANDBY = 1;
- public static final int POWER_TRANSIENT_TO_ON = 2;
- public static final int POWER_TRANSIENT_TO_STANDBY = 3;
+ public static final int POWER_STATUS_TRANSIENT_TO_ON = 2;
+ public static final int POWER_STATUS_TRANSIENT_TO_STANDBY = 3;
+
+ public static final int RESULT_SUCCESS = 0;
+ public static final int RESULT_TIMEOUT = 1;
+ public static final int RESULT_SOURCE_NOT_AVAILABLE = 2;
+ public static final int RESULT_TARGET_NOT_AVAILABLE = 3;
+ public static final int RESULT_ALREADY_IN_PROGRESS = 4;
+ public static final int RESULT_EXCEPTION = 5;
private static final int[] ADDRESS_TO_TYPE = {
DEVICE_TV, // ADDR_TV
diff --git a/core/java/android/hardware/hdmi/HdmiControlManager.java b/core/java/android/hardware/hdmi/HdmiControlManager.java
new file mode 100644
index 0000000..a3f27b9
--- /dev/null
+++ b/core/java/android/hardware/hdmi/HdmiControlManager.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2014 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;
+
+import android.annotation.Nullable;
+/**
+ * The {@link HdmiControlManager} class is used to send HDMI control messages
+ * to attached CEC devices.
+ *
+ * <p>Provides various HDMI client instances that represent HDMI-CEC logical devices
+ * hosted in the system. {@link #getTvClient()}, for instance will return an
+ * {@link HdmiTvClient} object if the system is configured to host one. Android system
+ * can host more than one logical CEC devices. If multiple types are configured they
+ * all work as if they were independent logical devices running in the system.
+ */
+public final class HdmiControlManager {
+ @Nullable private final IHdmiControlService mService;
+
+ /**
+ * @hide - hide this constructor because it has a parameter of type
+ * IHdmiControlService, which is a system private class. The right way
+ * to create an instance of this class is using the factory
+ * Context.getSystemService.
+ */
+ public HdmiControlManager(IHdmiControlService service) {
+ mService = service;
+ }
+
+ /**
+ * Gets an object that represents a HDMI-CEC logical device of type playback on the system.
+ *
+ * <p>Used to send HDMI control messages to other devices like TV or audio amplifier 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 HdmiPlaybackClient} instance. {@code null} on failure.
+ */
+ @Nullable
+ public HdmiPlaybackClient getPlaybackClient() {
+ if (mService == null) {
+ return null;
+ }
+ return new HdmiPlaybackClient(mService);
+ }
+
+ /**
+ * Gets an object that represents a HDMI-CEC logical device of type TV on the system.
+ *
+ * <p>Used to send HDMI control messages to other devices and manage them 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 HdmiTvClient} instance. {@code null} on failure.
+ */
+ @Nullable
+ public HdmiTvClient getTvClient() {
+ if (mService == null) {
+ return null;
+ }
+ return new HdmiTvClient(mService);
+ }
+}
diff --git a/core/java/android/hardware/hdmi/HdmiPlaybackClient.java b/core/java/android/hardware/hdmi/HdmiPlaybackClient.java
new file mode 100644
index 0000000..83da29a
--- /dev/null
+++ b/core/java/android/hardware/hdmi/HdmiPlaybackClient.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2014 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;
+
+import android.os.RemoteException;
+
+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
+ * connected through HDMI bus.
+ */
+public final class HdmiPlaybackClient {
+ private static final String TAG = "HdmiPlaybackClient";
+
+ private final IHdmiControlService mService;
+
+ /**
+ * Listener used by the client to get the result of one touch play operation.
+ */
+ public interface OneTouchPlayCallback {
+ /**
+ * Called when the result of the feature one touch play is returned.
+ *
+ * @param result the result of the operation. {@link HdmiCec#RESULT_SUCCESS}
+ * if successful.
+ */
+ public void onComplete(int result);
+ }
+
+ /**
+ * Listener used by the client to get display device status.
+ */
+ public interface DisplayStatusCallback {
+ /**
+ * Called when display device status is reported.
+ *
+ * @param status display device status
+ * @see {@link HdmiCec#POWER_STATUS_ON}
+ * @see {@link HdmiCec#POWER_STATUS_STANDBY}
+ * @see {@link HdmiCec#POWER_STATUS_TRANSIENT_TO_ON}
+ * @see {@link HdmiCec#POWER_STATUS_TRANSIENT_TO_STANDBY}
+ * @see {@link HdmiCec#POWER_STATUS_UNKNOWN}
+ */
+ public void onComplete(int status);
+ }
+
+ HdmiPlaybackClient(IHdmiControlService service) {
+ mService = service;
+ }
+
+ /**
+ * Perform the feature 'one touch play' from playback device to turn on display
+ * and switch the input.
+ *
+ * @param callback {@link OneTouchPlayCallback} object to get informed
+ * of the result
+ */
+ public void oneTouchPlay(OneTouchPlayCallback callback) {
+ // TODO: Use PendingResult.
+ try {
+ mService.oneTouchPlay(getCallbackWrapper(callback));
+ } catch (RemoteException e) {
+ Log.e(TAG, "oneTouchPlay threw exception ", e);
+ }
+ }
+
+ /**
+ * Get the status of display device connected through HDMI bus.
+ *
+ * @param callback {@link DisplayStatusCallback} object to get informed
+ * of the result
+ */
+ public void queryDisplayStatus(DisplayStatusCallback callback) {
+ // TODO: PendingResult.
+ try {
+ mService.oneTouchPlay(getCallbackWrapper(callback));
+ } catch (RemoteException e) {
+ Log.e(TAG, "queryDisplayStatus threw exception ", e);
+ }
+ }
+
+ private IHdmiControlCallback getCallbackWrapper(final OneTouchPlayCallback callback) {
+ return new IHdmiControlCallback.Stub() {
+ @Override
+ public void onComplete(int result) {
+ callback.onComplete(result);
+ }
+ };
+ }
+
+ private IHdmiControlCallback getCallbackWrapper(final DisplayStatusCallback callback) {
+ return new IHdmiControlCallback.Stub() {
+ @Override
+ public void onComplete(int status) {
+ callback.onComplete(status);
+ }
+ };
+ }
+}
diff --git a/core/java/android/hardware/hdmi/HdmiTvClient.java b/core/java/android/hardware/hdmi/HdmiTvClient.java
new file mode 100644
index 0000000..73c72472
--- /dev/null
+++ b/core/java/android/hardware/hdmi/HdmiTvClient.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2014 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;
+
+/**
+ * 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.
+ */
+public final class HdmiTvClient {
+ private static final String TAG = "HdmiTvClient";
+
+ private final IHdmiControlService mService;
+
+ HdmiTvClient(IHdmiControlService service) {
+ mService = service;
+ }
+}
diff --git a/core/java/android/hardware/hdmi/IHdmiControlCallback.aidl b/core/java/android/hardware/hdmi/IHdmiControlCallback.aidl
new file mode 100644
index 0000000..ef3dd47
--- /dev/null
+++ b/core/java/android/hardware/hdmi/IHdmiControlCallback.aidl
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2014 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;
+
+/**
+ * Callback interface definition for HDMI client to get informed of
+ * the result of various API invocation.
+ *
+ * @hide
+ */
+oneway interface IHdmiControlCallback {
+ void onComplete(int result);
+}
diff --git a/core/java/android/hardware/hdmi/IHdmiControlService.aidl b/core/java/android/hardware/hdmi/IHdmiControlService.aidl
new file mode 100644
index 0000000..f790ed9
--- /dev/null
+++ b/core/java/android/hardware/hdmi/IHdmiControlService.aidl
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2014 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;
+
+import android.hardware.hdmi.HdmiCecMessage;
+import android.hardware.hdmi.IHdmiControlCallback;
+
+/**
+ * Binder interface that clients running in the application process
+ * will use to perform HDMI-CEC features by communicating with other devices
+ * on the bus.
+ *
+ * @hide
+ */
+interface IHdmiControlService {
+ int oneTouchPlay(IHdmiControlCallback callback);
+ int queryDisplayStatus(IHdmiControlCallback callback);
+}