Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 91120c54 authored by Jinsuk Kim's avatar Jinsuk Kim
Browse files

HdmiControlManager with HdmiPlaybackClient API definition

This is a rewrite of HdmiCecManager that exposes API for CEC Playback
device control. HdmiCecManager will be removed together with
HdmiCecService once the migration is completed.

Replaced direct access to CEC commands with the following 2 API:
- oneTouchPlay
- queryDisplayStatus

Each method requires communication with other device on CEC bus,
hence might take some time to finish. The result at the end of
protocol exchange is reported through a callback provided as a
parameter to the method.

The callback is based on interface not abstract class since
it has only one method 'onComplete'.

Change-Id: I41e9d4571f890303282a79a803c86530d0b46974
parent 677a9f24
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -147,6 +147,8 @@ LOCAL_SRC_FILES += \
	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 \
+30 −2
Original line number Diff line number Diff line
@@ -6630,6 +6630,7 @@ package android.content {
    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 @@ package android.hardware.hdmi {
    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 @@ package android.hardware.hdmi {
    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 {
+13 −2
Original line number Diff line number Diff line
@@ -2583,14 +2583,25 @@ public abstract class Context {

    /**
     * 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
     */
    // 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
     * {@link android.hardware.input.InputManager} for interacting with input devices.
+9 −2
Original line number Diff line number Diff line
@@ -171,8 +171,15 @@ public final class HdmiCec {
    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
+76 −0
Original line number Diff line number Diff line
/*
 * 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);
    }
}
Loading