FileDocCategorySizeDatePackage
HdmiControlManager.javaAPI DocAndroid 5.1 API20979Thu Mar 12 22:22:10 GMT 2015android.hardware.hdmi

HdmiControlManager

public final class HdmiControlManager extends Object
The {@link HdmiControlManager} class is used to send HDMI control messages to attached CEC devices.

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.

hide

Fields Summary
private static final String
TAG
private final IHdmiControlService
mService
public static final String
ACTION_OSD_MESSAGE
Broadcast Action: Display OSD message.

Send when the service has a message to display on screen for events that need user's attention such as ARC status change.

Always contains the extra fields {@link #EXTRA_MESSAGE_ID}.

Requires {@link android.Manifest.permission#HDMI_CEC} to receive.

public static final int
OSD_MESSAGE_ARC_CONNECTED_INVALID_PORT
Message that ARC enabled device is connected to invalid port (non-ARC port).
public static final int
OSD_MESSAGE_AVR_VOLUME_CHANGED
Message used by TV to receive volume status from Audio Receiver. It should check volume value that is retrieved from extra value with the key {@link #EXTRA_MESSAGE_EXTRA_PARAM1}. If the value is in range of [0,100], it is current volume of Audio Receiver. And there is another value, {@link #AVR_VOLUME_MUTED}, which is used to inform volume mute.
public static final String
EXTRA_MESSAGE_ID
Used as an extra field in the intent {@link #ACTION_OSD_MESSAGE}. Contains the ID of the message to display on screen.
public static final String
EXTRA_MESSAGE_EXTRA_PARAM1
Used as an extra field in the intent {@link #ACTION_OSD_MESSAGE}. Contains the extra value of the message.
public static final int
AVR_VOLUME_MUTED
Volume value for mute state.
public static final int
POWER_STATUS_UNKNOWN
public static final int
POWER_STATUS_ON
public static final int
POWER_STATUS_STANDBY
public static final int
POWER_STATUS_TRANSIENT_TO_ON
public static final int
POWER_STATUS_TRANSIENT_TO_STANDBY
public static final int
RESULT_SUCCESS
public static final int
RESULT_TIMEOUT
public static final int
RESULT_SOURCE_NOT_AVAILABLE
public static final int
RESULT_TARGET_NOT_AVAILABLE
public static final int
RESULT_ALREADY_IN_PROGRESS
public static final int
RESULT_EXCEPTION
public static final int
RESULT_INCORRECT_MODE
public static final int
RESULT_COMMUNICATION_FAILED
public static final int
DEVICE_EVENT_ADD_DEVICE
public static final int
DEVICE_EVENT_REMOVE_DEVICE
public static final int
DEVICE_EVENT_UPDATE_DEVICE
public static final int
ONE_TOUCH_RECORD_RECORDING_CURRENTLY_SELECTED_SOURCE
Recording currently selected source. Indicates the status of a recording.
public static final int
ONE_TOUCH_RECORD_RECORDING_DIGITAL_SERVICE
Recording Digital Service. Indicates the status of a recording.
public static final int
ONE_TOUCH_RECORD_RECORDING_ANALOGUE_SERVICE
Recording Analogue Service. Indicates the status of a recording.
public static final int
ONE_TOUCH_RECORD_RECORDING_EXTERNAL_INPUT
Recording External input. Indicates the status of a recording.
public static final int
ONE_TOUCH_RECORD_UNABLE_DIGITAL_SERVICE
No recording ⬠unable to record Digital Service. No suitable tuner.
public static final int
ONE_TOUCH_RECORD_UNABLE_ANALOGUE_SERVICE
No recording ⬠unable to record Analogue Service. No suitable tuner.
public static final int
ONE_TOUCH_RECORD_UNABLE_SELECTED_SERVICE
No recording ⬠unable to select required service. as suitable tuner, but the requested parameters are invalid or out of range for that tuner.
public static final int
ONE_TOUCH_RECORD_INVALID_EXTERNAL_PLUG_NUMBER
No recording ⬠invalid External plug number
public static final int
ONE_TOUCH_RECORD_INVALID_EXTERNAL_PHYSICAL_ADDRESS
No recording ⬠invalid External Physical Address
public static final int
ONE_TOUCH_RECORD_UNSUPPORTED_CA
No recording ⬠CA system not supported
public static final int
ONE_TOUCH_RECORD_NO_OR_INSUFFICIENT_CA_ENTITLEMENTS
No Recording ‚¨ No or Insufficient CA Entitlements‚¨ż
public static final int
ONE_TOUCH_RECORD_DISALLOW_TO_COPY
No recording ‚¨ Not allowed to copy source. Source is ‚¨Scopy never‚¨ż.
public static final int
ONE_TOUCH_RECORD_DISALLOW_TO_FUTHER_COPIES
No recording ⬠No further copies allowed
public static final int
ONE_TOUCH_RECORD_NO_MEDIA
No recording ⬠No media
public static final int
ONE_TOUCH_RECORD_PLAYING
No recording ⬠playing
public static final int
ONE_TOUCH_RECORD_ALREADY_RECORDING
No recording ⬠already recording
public static final int
ONE_TOUCH_RECORD_MEDIA_PROTECTED
No recording ⬠media protected
public static final int
ONE_TOUCH_RECORD_NO_SOURCE_SIGNAL
No recording ⬠no source signal
public static final int
ONE_TOUCH_RECORD_MEDIA_PROBLEM
No recording ⬠media problem
public static final int
ONE_TOUCH_RECORD_NOT_ENOUGH_SPACE
No recording ⬠not enough space available
public static final int
ONE_TOUCH_RECORD_PARENT_LOCK_ON
No recording ⬠Parental Lock On
public static final int
ONE_TOUCH_RECORD_RECORDING_TERMINATED_NORMALLY
Recording terminated normally
public static final int
ONE_TOUCH_RECORD_RECORDING_ALREADY_TERMINATED
Recording has already terminated
public static final int
ONE_TOUCH_RECORD_OTHER_REASON
No recording ⬠other reason
public static final int
ONE_TOUCH_RECORD_PREVIOUS_RECORDING_IN_PROGRESS
No recording. Previous recording request in progress.
public static final int
ONE_TOUCH_RECORD_CHECK_RECORDER_CONNECTION
No recording. Please check recorder and connection.
public static final int
ONE_TOUCH_RECORD_FAIL_TO_RECORD_DISPLAYED_SCREEN
Cannot record currently displayed source.
public static final int
ONE_TOUCH_RECORD_CEC_DISABLED
CEC is disabled.
public static final int
TIMER_RECORDING_TYPE_DIGITAL
Timer recording type for digital service source.
public static final int
TIMER_RECORDING_TYPE_ANALOGUE
Timer recording type for analogue service source.
public static final int
TIMER_RECORDING_TYPE_EXTERNAL
Timer recording type for external source.
public static final int
TIMER_STATUS_MEDIA_INFO_PRESENT_NOT_PROTECTED
[Timer Status Data/Media Info] - Media present and not protected.
public static final int
TIMER_STATUS_MEDIA_INFO_PRESENT_PROTECTED
[Timer Status Data/Media Info] - Media present, but protected.
public static final int
TIMER_STATUS_MEDIA_INFO_NOT_PRESENT
[Timer Status Data/Media Info] - Media not present.
public static final int
TIMER_STATUS_PROGRAMMED_INFO_ENOUGH_SPACE
[Timer Status Data/Programmed Info] - Enough space available for recording.
public static final int
TIMER_STATUS_PROGRAMMED_INFO_NOT_ENOUGH_SPACE
[Timer Status Data/Programmed Info] - Not enough space available for recording.
public static final int
TIMER_STATUS_PROGRAMMED_INFO_MIGHT_NOT_ENOUGH_SPACE
[Timer Status Data/Programmed Info] - Might not enough space available for recording.
public static final int
TIMER_STATUS_PROGRAMMED_INFO_NO_MEDIA_INFO
[Timer Status Data/Programmed Info] - No media info available.
public static final int
TIMER_STATUS_NOT_PROGRAMMED_NO_FREE_TIME
[Timer Status Data/Not Programmed Error Info] - No free timer available.
public static final int
TIMER_STATUS_NOT_PROGRAMMED_DATE_OUT_OF_RANGE
[Timer Status Data/Not Programmed Error Info] - Date out of range.
public static final int
TIMER_STATUS_NOT_PROGRAMMED_INVALID_SEQUENCE
[Timer Status Data/Not Programmed Error Info] - Recording Sequence error.
public static final int
TIMER_STATUS_NOT_PROGRAMMED_INVALID_EXTERNAL_PLUG_NUMBER
[Timer Status Data/Not Programmed Error Info] - Invalid External Plug Number.
public static final int
TIMER_STATUS_NOT_PROGRAMMED_INVALID_EXTERNAL_PHYSICAL_NUMBER
[Timer Status Data/Not Programmed Error Info] - Invalid External Physical Address.
public static final int
TIMER_STATUS_NOT_PROGRAMMED_CA_NOT_SUPPORTED
[Timer Status Data/Not Programmed Error Info] - CA system not supported.
public static final int
TIMER_STATUS_NOT_PROGRAMMED_NO_CA_ENTITLEMENTS
[Timer Status Data/Not Programmed Error Info] - No or insufficient CA Entitlements.
public static final int
TIMER_STATUS_NOT_PROGRAMMED_UNSUPPORTED_RESOLUTION
[Timer Status Data/Not Programmed Error Info] - Does not support resolution.
public static final int
TIMER_STATUS_NOT_PROGRAMMED_PARENTAL_LOCK_ON
[Timer Status Data/Not Programmed Error Info] - Parental Lock On.
public static final int
TIMER_STATUS_NOT_PROGRAMMED_CLOCK_FAILURE
[Timer Status Data/Not Programmed Error Info] - Clock Failure.
public static final int
TIMER_STATUS_NOT_PROGRAMMED_DUPLICATED
[Timer Status Data/Not Programmed Error Info] - Duplicate: already programmed.
public static final int
TIMER_RECORDING_RESULT_EXTRA_NO_ERROR
No extra error.
public static final int
TIMER_RECORDING_RESULT_EXTRA_CHECK_RECORDER_CONNECTION
No timer recording - check recorder and connection.
public static final int
TIMER_RECORDING_RESULT_EXTRA_FAIL_TO_RECORD_SELECTED_SOURCE
No timer recording - cannot record selected source.
public static final int
TIMER_RECORDING_RESULT_EXTRA_CEC_DISABLED
CEC is disabled.
public static final int
CLEAR_TIMER_STATUS_TIMER_NOT_CLEARED_RECORDING
Timer not cleared ⬠recording.
public static final int
CLEAR_TIMER_STATUS_TIMER_NOT_CLEARED_NO_MATCHING
Timer not cleared ⬠no matching.
public static final int
CLEAR_TIMER_STATUS_TIMER_NOT_CLEARED_NO_INFO_AVAILABLE
Timer not cleared ⬠no info available.
public static final int
CLEAR_TIMER_STATUS_TIMER_CLEARED
Timer cleared.
public static final int
CLEAR_TIMER_STATUS_CHECK_RECORDER_CONNECTION
Clear timer error - check recorder and connection.
public static final int
CLEAR_TIMER_STATUS_FAIL_TO_CLEAR_SELECTED_SOURCE
Clear timer error - cannot clear timer for selected source.
public static final int
CLEAR_TIMER_STATUS_CEC_DISABLE
Clear timer error - CEC is disabled.
public static final int
CONTROL_STATE_CHANGED_REASON_START
The HdmiControlService is started.
public static final int
CONTROL_STATE_CHANGED_REASON_SETTING
The state of HdmiControlService is changed by changing of settings.
public static final int
CONTROL_STATE_CHANGED_REASON_WAKEUP
The HdmiControlService is enabled to wake up.
public static final int
CONTROL_STATE_CHANGED_REASON_STANDBY
The HdmiControlService will be disabled to standby.
private final boolean
mHasPlaybackDevice
private final boolean
mHasTvDevice
private final android.util.ArrayMap
mHotplugEventListeners
Constructors Summary
public HdmiControlManager(IHdmiControlService service)
{@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.


                                           
       
        mService = service;
        int[] types = null;
        if (mService != null) {
            try {
                types = mService.getSupportedTypes();
            } catch (RemoteException e) {
                // Do nothing.
            }
        }
        mHasTvDevice = hasDeviceType(types, HdmiDeviceInfo.DEVICE_TV);
        mHasPlaybackDevice = hasDeviceType(types, HdmiDeviceInfo.DEVICE_PLAYBACK);
    
Methods Summary
public voidaddHotplugEventListener(android.hardware.hdmi.HdmiControlManager$HotplugEventListener listener)
Adds a listener to get informed of {@link HdmiHotplugEvent}.

To stop getting the notification, use {@link #removeHotplugEventListener(HotplugEventListener)}.

param
listener {@link HotplugEventListener} instance
see
HdmiControlManager#removeHotplugEventListener(HotplugEventListener)


               
       
                                                                  
                

                                                                                         
            
    

                                 
        
        if (mService == null) {
            Log.e(TAG, "HdmiControlService is not available");
            return;
        }
        if (mHotplugEventListeners.containsKey(listener)) {
            Log.e(TAG, "listener is already registered");
            return;
        }
        IHdmiHotplugEventListener wrappedListener = getHotplugEventListenerWrapper(listener);
        mHotplugEventListeners.put(listener, wrappedListener);
        try {
            mService.addHotplugEventListener(wrappedListener);
        } catch (RemoteException e) {
            Log.e(TAG, "failed to add hotplug event listener: ", e);
        }
    
public HdmiClientgetClient(int type)
Gets an object that represents an HDMI-CEC logical device of a specified type.

param
type CEC device type
return
{@link HdmiClient} instance. {@code null} on failure. See {@link HdmiDeviceInfo#DEVICE_PLAYBACK} See {@link HdmiDeviceInfo#DEVICE_TV}

        if (mService == null) {
            return null;
        }
        switch (type) {
            case HdmiDeviceInfo.DEVICE_TV:
                return mHasTvDevice ? new HdmiTvClient(mService) : null;
            case HdmiDeviceInfo.DEVICE_PLAYBACK:
                return mHasPlaybackDevice ? new HdmiPlaybackClient(mService) : null;
            default:
                return null;
        }
    
private IHdmiHotplugEventListenergetHotplugEventListenerWrapper(android.hardware.hdmi.HdmiControlManager$HotplugEventListener listener)

        return new IHdmiHotplugEventListener.Stub() {
            @Override
            public void onReceived(HdmiHotplugEvent event) {
                listener.onReceived(event);;
            }
        };
    
public HdmiPlaybackClientgetPlaybackClient()
Gets an object that represents an HDMI-CEC logical device of type playback on the system.

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.

        return (HdmiPlaybackClient) getClient(HdmiDeviceInfo.DEVICE_PLAYBACK);
    
public HdmiTvClientgetTvClient()
Gets an object that represents an HDMI-CEC logical device of type TV on the system.

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.

        return (HdmiTvClient) getClient(HdmiDeviceInfo.DEVICE_TV);
    
private static booleanhasDeviceType(int[] types, int type)

        if (types == null) {
            return false;
        }
        for (int t : types) {
            if (t == type) {
                return true;
            }
        }
        return false;
    
public voidremoveHotplugEventListener(android.hardware.hdmi.HdmiControlManager$HotplugEventListener listener)
Removes a listener to stop getting informed of {@link HdmiHotplugEvent}.

param
listener {@link HotplugEventListener} instance to be removed

        if (mService == null) {
            Log.e(TAG, "HdmiControlService is not available");
            return;
        }
        IHdmiHotplugEventListener wrappedListener = mHotplugEventListeners.remove(listener);
        if (wrappedListener == null) {
            Log.e(TAG, "tried to remove not-registered listener");
            return;
        }
        try {
            mService.removeHotplugEventListener(wrappedListener);
        } catch (RemoteException e) {
            Log.e(TAG, "failed to remove hotplug event listener: ", e);
        }