Removed class HdmiCec
Most of the constants in HdmiCec are internal use only. Moved them to service, and dispersed the rest to other relevant classes. Also moved HdmiCecMessage class to service as it doesn't need to be open ouside the service. Change-Id: I7b2ce3bf465330aa4d7fcd05f9aefa1e6c8b056a
This commit is contained in:
@ -1,333 +0,0 @@
|
||||
/*
|
||||
* 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.SystemApi;
|
||||
|
||||
/**
|
||||
* Defines constants and utility methods related to HDMI-CEC protocol.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public final class HdmiCec {
|
||||
|
||||
/** TV device type. */
|
||||
public static final int DEVICE_TV = 0;
|
||||
|
||||
/** Recording device type. */
|
||||
public static final int DEVICE_RECORDER = 1;
|
||||
|
||||
/** Device type reserved for future usage. */
|
||||
public static final int DEVICE_RESERVED = 2;
|
||||
|
||||
/** Tuner device type. */
|
||||
public static final int DEVICE_TUNER = 3;
|
||||
|
||||
/** Playback device type. */
|
||||
public static final int DEVICE_PLAYBACK = 4;
|
||||
|
||||
/** Audio system device type. */
|
||||
public static final int DEVICE_AUDIO_SYSTEM = 5;
|
||||
|
||||
// Value indicating the device is not an active source.
|
||||
public static final int DEVICE_INACTIVE = -1;
|
||||
|
||||
/** Logical address for TV */
|
||||
public static final int ADDR_TV = 0;
|
||||
|
||||
/** Logical address for recorder 1 */
|
||||
public static final int ADDR_RECORDER_1 = 1;
|
||||
|
||||
/** Logical address for recorder 2 */
|
||||
public static final int ADDR_RECORDER_2 = 2;
|
||||
|
||||
/** Logical address for tuner 1 */
|
||||
public static final int ADDR_TUNER_1 = 3;
|
||||
|
||||
/** Logical address for playback 1 */
|
||||
public static final int ADDR_PLAYBACK_1 = 4;
|
||||
|
||||
/** Logical address for audio system */
|
||||
public static final int ADDR_AUDIO_SYSTEM = 5;
|
||||
|
||||
/** Logical address for tuner 2 */
|
||||
public static final int ADDR_TUNER_2 = 6;
|
||||
|
||||
/** Logical address for tuner 3 */
|
||||
public static final int ADDR_TUNER_3 = 7;
|
||||
|
||||
/** Logical address for playback 2 */
|
||||
public static final int ADDR_PLAYBACK_2 = 8;
|
||||
|
||||
/** Logical address for recorder 3 */
|
||||
public static final int ADDR_RECORDER_3 = 9;
|
||||
|
||||
/** Logical address for tuner 4 */
|
||||
public static final int ADDR_TUNER_4 = 10;
|
||||
|
||||
/** Logical address for playback 3 */
|
||||
public static final int ADDR_PLAYBACK_3 = 11;
|
||||
|
||||
/** Logical address reserved for future usage */
|
||||
public static final int ADDR_RESERVED_1 = 12;
|
||||
|
||||
/** Logical address reserved for future usage */
|
||||
public static final int ADDR_RESERVED_2 = 13;
|
||||
|
||||
/** Logical address for TV other than the one assigned with {@link #ADDR_TV} */
|
||||
public static final int ADDR_SPECIFIC_USE = 14;
|
||||
|
||||
/** Logical address for devices to which address cannot be allocated */
|
||||
public static final int ADDR_UNREGISTERED = 15;
|
||||
|
||||
/** Logical address used in the destination address field for broadcast messages */
|
||||
public static final int ADDR_BROADCAST = 15;
|
||||
|
||||
/** Logical address used to indicate it is not initialized or invalid. */
|
||||
public static final int ADDR_INVALID = -1;
|
||||
|
||||
/** Logical address used to indicate the source comes from internal device. */
|
||||
public static final int ADDR_INTERNAL = 0xFFFF;
|
||||
|
||||
public static final int MESSAGE_FEATURE_ABORT = 0x00;
|
||||
public static final int MESSAGE_IMAGE_VIEW_ON = 0x04;
|
||||
public static final int MESSAGE_TUNER_STEP_INCREMENT = 0x05;
|
||||
public static final int MESSAGE_TUNER_STEP_DECREMENT = 0x06;
|
||||
public static final int MESSAGE_TUNER_DEVICE_STATUS = 0x07;
|
||||
public static final int MESSAGE_GIVE_TUNER_DEVICE_STATUS = 0x08;
|
||||
public static final int MESSAGE_RECORD_ON = 0x09;
|
||||
public static final int MESSAGE_RECORD_STATUS = 0x0A;
|
||||
public static final int MESSAGE_RECORD_OFF = 0x0B;
|
||||
public static final int MESSAGE_TEXT_VIEW_ON = 0x0D;
|
||||
public static final int MESSAGE_RECORD_TV_SCREEN = 0x0F;
|
||||
public static final int MESSAGE_GIVE_DECK_STATUS = 0x1A;
|
||||
public static final int MESSAGE_DECK_STATUS = 0x1B;
|
||||
public static final int MESSAGE_SET_MENU_LANGUAGE = 0x32;
|
||||
public static final int MESSAGE_CLEAR_ANALOG_TIMER = 0x33;
|
||||
public static final int MESSAGE_SET_ANALOG_TIMER = 0x34;
|
||||
public static final int MESSAGE_TIMER_STATUS = 0x35;
|
||||
public static final int MESSAGE_STANDBY = 0x36;
|
||||
public static final int MESSAGE_PLAY = 0x41;
|
||||
public static final int MESSAGE_DECK_CONTROL = 0x42;
|
||||
public static final int MESSAGE_TIMER_CLEARED_STATUS = 0x043;
|
||||
public static final int MESSAGE_USER_CONTROL_PRESSED = 0x44;
|
||||
public static final int MESSAGE_USER_CONTROL_RELEASED = 0x45;
|
||||
public static final int MESSAGE_GIVE_OSD_NAME = 0x46;
|
||||
public static final int MESSAGE_SET_OSD_NAME = 0x47;
|
||||
public static final int MESSAGE_SET_OSD_STRING = 0x64;
|
||||
public static final int MESSAGE_SET_TIMER_PROGRAM_TITLE = 0x67;
|
||||
public static final int MESSAGE_SYSTEM_AUDIO_MODE_REQUEST = 0x70;
|
||||
public static final int MESSAGE_GIVE_AUDIO_STATUS = 0x71;
|
||||
public static final int MESSAGE_SET_SYSTEM_AUDIO_MODE = 0x72;
|
||||
public static final int MESSAGE_REPORT_AUDIO_STATUS = 0x7A;
|
||||
public static final int MESSAGE_GIVE_SYSTEM_AUDIO_MODE_STATUS = 0x7D;
|
||||
public static final int MESSAGE_SYSTEM_AUDIO_MODE_STATUS = 0x7E;
|
||||
public static final int MESSAGE_ROUTING_CHANGE = 0x80;
|
||||
public static final int MESSAGE_ROUTING_INFORMATION = 0x81;
|
||||
public static final int MESSAGE_ACTIVE_SOURCE = 0x82;
|
||||
public static final int MESSAGE_GIVE_PHYSICAL_ADDRESS = 0x83;
|
||||
public static final int MESSAGE_REPORT_PHYSICAL_ADDRESS = 0x84;
|
||||
public static final int MESSAGE_REQUEST_ACTIVE_SOURCE = 0x85;
|
||||
public static final int MESSAGE_SET_STREAM_PATH = 0x86;
|
||||
public static final int MESSAGE_DEVICE_VENDOR_ID = 0x87;
|
||||
public static final int MESSAGE_VENDOR_COMMAND = 0x89;
|
||||
public static final int MESSAGE_VENDOR_REMOTE_BUTTON_DOWN = 0x8A;
|
||||
public static final int MESSAGE_VENDOR_REMOTE_BUTTON_UP = 0x8B;
|
||||
public static final int MESSAGE_GIVE_DEVICE_VENDOR_ID = 0x8C;
|
||||
public static final int MESSAGE_MENU_REQUEST = 0x8D;
|
||||
public static final int MESSAGE_MENU_STATUS = 0x8E;
|
||||
public static final int MESSAGE_GIVE_DEVICE_POWER_STATUS = 0x8F;
|
||||
public static final int MESSAGE_REPORT_POWER_STATUS = 0x90;
|
||||
public static final int MESSAGE_GET_MENU_LANGUAGE = 0x91;
|
||||
public static final int MESSAGE_SELECT_ANALOG_SERVICE = 0x92;
|
||||
public static final int MESSAGE_SELECT_DIGITAL_SERVICE = 0x93;
|
||||
public static final int MESSAGE_SET_DIGITAL_TIMER = 0x97;
|
||||
public static final int MESSAGE_CLEAR_DIGITAL_TIMER = 0x99;
|
||||
public static final int MESSAGE_SET_AUDIO_RATE = 0x9A;
|
||||
public static final int MESSAGE_INACTIVE_SOURCE = 0x9D;
|
||||
public static final int MESSAGE_CEC_VERSION = 0x9E;
|
||||
public static final int MESSAGE_GET_CEC_VERSION = 0x9F;
|
||||
public static final int MESSAGE_VENDOR_COMMAND_WITH_ID = 0xA0;
|
||||
public static final int MESSAGE_CLEAR_EXTERNAL_TIMER = 0xA1;
|
||||
public static final int MESSAGE_SET_EXTERNAL_TIMER = 0xA2;
|
||||
public static final int MESSAGE_INITIATE_ARC = 0xC0;
|
||||
public static final int MESSAGE_REPORT_ARC_INITIATED = 0xC1;
|
||||
public static final int MESSAGE_REPORT_ARC_TERMINATED = 0xC2;
|
||||
public static final int MESSAGE_REQUEST_ARC_INITIATION = 0xC3;
|
||||
public static final int MESSAGE_REQUEST_ARC_TERMINATION = 0xC4;
|
||||
public static final int MESSAGE_TERMINATE_ARC = 0xC5;
|
||||
public static final int MESSAGE_ABORT = 0xFF;
|
||||
|
||||
public static final int UNKNOWN_VENDOR_ID = 0xFFFFFF;
|
||||
|
||||
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_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;
|
||||
public static final int RESULT_INCORRECT_MODE = 6;
|
||||
|
||||
// Definitions used for setOption(). These should be in sync with the definition
|
||||
// in hardware/libhardware/include/hardware/{hdmi_cec.h,mhl.h}.
|
||||
|
||||
/**
|
||||
* TV gets turned on by incoming <Text/Image View On>. {@code ENABLED} by default.
|
||||
* If set to {@code DISABLED}, TV won't turn on automatically.
|
||||
*/
|
||||
public static final int OPTION_CEC_AUTO_WAKEUP = 1;
|
||||
|
||||
/**
|
||||
* If set to {@code DISABLED}, all CEC commands are discarded.
|
||||
*
|
||||
* <p> This option is for internal use only, not supposed to be used by other components.
|
||||
* @hide
|
||||
*/
|
||||
public static final int OPTION_CEC_ENABLE = 2;
|
||||
|
||||
/**
|
||||
* If set to {@code DISABLED}, system service yields control of CEC to sub-microcontroller.
|
||||
* If {@code ENABLED}, it take the control back.
|
||||
*
|
||||
* <p> This option is for internal use only, not supposed to be used by other components.
|
||||
* @hide
|
||||
*/
|
||||
public static final int OPTION_CEC_SERVICE_CONTROL = 3;
|
||||
|
||||
/**
|
||||
* Put other devices to standby when TV goes to standby. {@code ENABLED} by default.
|
||||
* If set to {@code DISABLED}, TV doesn't send <Standby> to other devices.
|
||||
*/
|
||||
public static final int OPTION_CEC_AUTO_DEVICE_OFF = 4;
|
||||
|
||||
/** If set to {@code DISABLED}, TV does not switch ports when mobile device is connected. */
|
||||
public static final int OPTION_MHL_INPUT_SWITCHING = 101;
|
||||
|
||||
/** If set to {@code ENABLED}, TV disables power charging for mobile device. */
|
||||
public static final int OPTION_MHL_POWER_CHARGE = 102;
|
||||
|
||||
/**
|
||||
* If set to {@code DISABLED}, all MHL commands are discarded.
|
||||
*
|
||||
* <p> This option is for internal use only, not supposed to be used by other components.
|
||||
* @hide
|
||||
*/
|
||||
public static final int OPTION_MHL_ENABLE = 103;
|
||||
|
||||
public static final int DISABLED = 0;
|
||||
public static final int ENABLED = 1;
|
||||
|
||||
private static final int[] ADDRESS_TO_TYPE = {
|
||||
DEVICE_TV, // ADDR_TV
|
||||
DEVICE_RECORDER, // ADDR_RECORDER_1
|
||||
DEVICE_RECORDER, // ADDR_RECORDER_2
|
||||
DEVICE_TUNER, // ADDR_TUNER_1
|
||||
DEVICE_PLAYBACK, // ADDR_PLAYBACK_1
|
||||
DEVICE_AUDIO_SYSTEM, // ADDR_AUDIO_SYSTEM
|
||||
DEVICE_TUNER, // ADDR_TUNER_2
|
||||
DEVICE_TUNER, // ADDR_TUNER_3
|
||||
DEVICE_PLAYBACK, // ADDR_PLAYBACK_2
|
||||
DEVICE_RECORDER, // ADDR_RECORDER_3
|
||||
DEVICE_TUNER, // ADDR_TUNER_4
|
||||
DEVICE_PLAYBACK, // ADDR_PLAYBACK_3
|
||||
DEVICE_RESERVED,
|
||||
DEVICE_RESERVED,
|
||||
DEVICE_TV, // ADDR_SPECIFIC_USE
|
||||
};
|
||||
|
||||
private static final String[] DEFAULT_NAMES = {
|
||||
"TV",
|
||||
"Recorder_1",
|
||||
"Recorder_2",
|
||||
"Tuner_1",
|
||||
"Playback_1",
|
||||
"AudioSystem",
|
||||
"Tuner_2",
|
||||
"Tuner_3",
|
||||
"Playback_2",
|
||||
"Recorder_3",
|
||||
"Tuner_4",
|
||||
"Playback_3",
|
||||
"Reserved_1",
|
||||
"Reserved_2",
|
||||
"Secondary_TV",
|
||||
};
|
||||
|
||||
private HdmiCec() { } // Prevents instantiation.
|
||||
|
||||
/**
|
||||
* Check if the given type is valid. A valid type is one of the actual
|
||||
* logical device types defined in the standard ({@link #DEVICE_TV},
|
||||
* {@link #DEVICE_PLAYBACK}, {@link #DEVICE_TUNER}, {@link #DEVICE_RECORDER},
|
||||
* and {@link #DEVICE_AUDIO_SYSTEM}).
|
||||
*
|
||||
* @param type device type
|
||||
* @return true if the given type is valid
|
||||
*/
|
||||
public static boolean isValidType(int type) {
|
||||
return (DEVICE_TV <= type && type <= DEVICE_AUDIO_SYSTEM)
|
||||
&& type != DEVICE_RESERVED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given logical address is valid. A logical address is valid
|
||||
* if it is one allocated for an actual device which allows communication
|
||||
* with other logical devices.
|
||||
*
|
||||
* @param address logical address
|
||||
* @return true if the given address is valid
|
||||
*/
|
||||
public static boolean isValidAddress(int address) {
|
||||
return (ADDR_TV <= address && address <= ADDR_SPECIFIC_USE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the device type for the given logical address.
|
||||
*
|
||||
* @param address logical address
|
||||
* @return device type for the given logical address; DEVICE_INACTIVE
|
||||
* if the address is not valid.
|
||||
*/
|
||||
public static int getTypeFromAddress(int address) {
|
||||
if (isValidAddress(address)) {
|
||||
return ADDRESS_TO_TYPE[address];
|
||||
}
|
||||
return DEVICE_INACTIVE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default device name for a logical address. This is the name
|
||||
* by which the logical device is known to others until a name is
|
||||
* set explicitly using HdmiCecService.setOsdName.
|
||||
*
|
||||
* @param address logical address
|
||||
* @return default device name; empty string if the address is not valid
|
||||
*/
|
||||
public static String getDefaultDeviceName(int address) {
|
||||
if (isValidAddress(address)) {
|
||||
return DEFAULT_NAMES[address];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
@ -29,6 +29,28 @@ import android.os.Parcelable;
|
||||
*/
|
||||
@SystemApi
|
||||
public final class HdmiCecDeviceInfo implements Parcelable {
|
||||
|
||||
/** TV device type. */
|
||||
public static final int DEVICE_TV = 0;
|
||||
|
||||
/** Recording device type. */
|
||||
public static final int DEVICE_RECORDER = 1;
|
||||
|
||||
/** Device type reserved for future usage. */
|
||||
public static final int DEVICE_RESERVED = 2;
|
||||
|
||||
/** Tuner device type. */
|
||||
public static final int DEVICE_TUNER = 3;
|
||||
|
||||
/** Playback device type. */
|
||||
public static final int DEVICE_PLAYBACK = 4;
|
||||
|
||||
/** Audio system device type. */
|
||||
public static final int DEVICE_AUDIO_SYSTEM = 5;
|
||||
|
||||
// Value indicating the device is not an active source.
|
||||
public static final int DEVICE_INACTIVE = -1;
|
||||
|
||||
// Logical address, phsical address, device type, vendor id and display name
|
||||
// are immutable value.
|
||||
private final int mLogicalAddress;
|
||||
@ -37,7 +59,6 @@ public final class HdmiCecDeviceInfo implements Parcelable {
|
||||
private final int mVendorId;
|
||||
private final String mDisplayName;
|
||||
|
||||
|
||||
/**
|
||||
* A helper class to deserialize {@link HdmiCecDeviceInfo} for a parcel.
|
||||
*/
|
||||
@ -63,11 +84,10 @@ public final class HdmiCecDeviceInfo implements Parcelable {
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param logicalAddress logical address of HDMI-Cec device.
|
||||
* For more details, refer {@link HdmiCec}
|
||||
* @param physicalAddress physical address of HDMI-Cec device
|
||||
* @param deviceType type of device. For more details, refer {@link HdmiCec}
|
||||
* @param vendorId vendor id of device. It's used for vendor specific command
|
||||
* @param logicalAddress logical address of HDMI-CEC device
|
||||
* @param physicalAddress physical address of HDMI-CEC device
|
||||
* @param deviceType type of device
|
||||
* @param vendorId vendor id of device. Used for vendor specific command.
|
||||
* @param displayName name of device
|
||||
* @hide
|
||||
*/
|
||||
@ -81,9 +101,7 @@ public final class HdmiCecDeviceInfo implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the logical address of the device. It can have 0-15 values.
|
||||
* For more details, refer constants between {@link HdmiCec#ADDR_TV}
|
||||
* and {@link HdmiCec#ADDR_UNREGISTERED}.
|
||||
* Return the logical address of the device.
|
||||
*/
|
||||
public int getLogicalAddress() {
|
||||
return mLogicalAddress;
|
||||
@ -98,7 +116,7 @@ public final class HdmiCecDeviceInfo implements Parcelable {
|
||||
|
||||
/**
|
||||
* Return type of the device. For more details, refer constants between
|
||||
* {@link HdmiCec#DEVICE_TV} and {@link HdmiCec#DEVICE_INACTIVE}.
|
||||
* {@link DEVICE_TV} and {@link DEVICE_INACTIVE}.
|
||||
*/
|
||||
public int getDeviceType() {
|
||||
return mDeviceType;
|
||||
@ -108,9 +126,9 @@ public final class HdmiCecDeviceInfo implements Parcelable {
|
||||
* Return {@code true} if the device is of a type that can be an input source.
|
||||
*/
|
||||
public boolean isSourceType() {
|
||||
return mDeviceType == HdmiCec.DEVICE_PLAYBACK
|
||||
|| mDeviceType == HdmiCec.DEVICE_RECORDER
|
||||
|| mDeviceType == HdmiCec.DEVICE_TUNER;
|
||||
return mDeviceType == DEVICE_PLAYBACK
|
||||
|| mDeviceType == DEVICE_RECORDER
|
||||
|| mDeviceType == DEVICE_TUNER;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,19 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
parcelable HdmiCecMessage;
|
@ -36,6 +36,20 @@ import android.os.RemoteException;
|
||||
public final class HdmiControlManager {
|
||||
@Nullable private final IHdmiControlService mService;
|
||||
|
||||
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_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;
|
||||
public static final int RESULT_INCORRECT_MODE = 6;
|
||||
|
||||
// True if we have a logical device of type playback hosted in the system.
|
||||
private final boolean mHasPlaybackDevice;
|
||||
// True if we have a logical device of type TV hosted in the system.
|
||||
@ -57,8 +71,8 @@ public final class HdmiControlManager {
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
mHasTvDevice = hasDeviceType(types, HdmiCec.DEVICE_TV);
|
||||
mHasPlaybackDevice = hasDeviceType(types, HdmiCec.DEVICE_PLAYBACK);
|
||||
mHasTvDevice = hasDeviceType(types, HdmiCecDeviceInfo.DEVICE_TV);
|
||||
mHasPlaybackDevice = hasDeviceType(types, HdmiCecDeviceInfo.DEVICE_PLAYBACK);
|
||||
}
|
||||
|
||||
private static boolean hasDeviceType(int[] types, int type) {
|
||||
|
@ -42,7 +42,7 @@ public final class HdmiPlaybackClient {
|
||||
/**
|
||||
* Called when the result of the feature one touch play is returned.
|
||||
*
|
||||
* @param result the result of the operation. {@link HdmiCec#RESULT_SUCCESS}
|
||||
* @param result the result of the operation. {@link HdmiControlManager#RESULT_SUCCESS}
|
||||
* if successful.
|
||||
*/
|
||||
public void onComplete(int result);
|
||||
@ -56,11 +56,11 @@ public final class HdmiPlaybackClient {
|
||||
* 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}
|
||||
* @see {@link HdmiControlManager#POWER_STATUS_ON}
|
||||
* @see {@link HdmiControlManager#POWER_STATUS_STANDBY}
|
||||
* @see {@link HdmiControlManager#POWER_STATUS_TRANSIENT_TO_ON}
|
||||
* @see {@link HdmiControlManager#POWER_STATUS_TRANSIENT_TO_STANDBY}
|
||||
* @see {@link HdmiControlManager#POWER_STATUS_UNKNOWN}
|
||||
*/
|
||||
public void onComplete(int status);
|
||||
}
|
||||
|
@ -30,6 +30,55 @@ import android.util.Log;
|
||||
public final class HdmiTvClient {
|
||||
private static final String TAG = "HdmiTvClient";
|
||||
|
||||
// Definitions used for setOption(). These should be in sync with the definition
|
||||
// in hardware/libhardware/include/hardware/{hdmi_cec.h,mhl.h}.
|
||||
|
||||
/**
|
||||
* TV gets turned on by incoming <Text/Image View On>. {@code ENABLED} by default.
|
||||
* If set to {@code DISABLED}, TV won't turn on automatically.
|
||||
*/
|
||||
public static final int OPTION_CEC_AUTO_WAKEUP = 1;
|
||||
|
||||
/**
|
||||
* If set to {@code DISABLED}, all CEC commands are discarded.
|
||||
*
|
||||
* <p> This option is for internal use only, not supposed to be used by other components.
|
||||
* @hide
|
||||
*/
|
||||
public static final int OPTION_CEC_ENABLE = 2;
|
||||
|
||||
/**
|
||||
* If set to {@code DISABLED}, system service yields control of CEC to sub-microcontroller.
|
||||
* If {@code ENABLED}, it take the control back.
|
||||
*
|
||||
* <p> This option is for internal use only, not supposed to be used by other components.
|
||||
* @hide
|
||||
*/
|
||||
public static final int OPTION_CEC_SERVICE_CONTROL = 3;
|
||||
|
||||
/**
|
||||
* Put other devices to standby when TV goes to standby. {@code ENABLED} by default.
|
||||
* If set to {@code DISABLED}, TV doesn't send <Standby> to other devices.
|
||||
*/
|
||||
public static final int OPTION_CEC_AUTO_DEVICE_OFF = 4;
|
||||
|
||||
/** If set to {@code DISABLED}, TV does not switch ports when mobile device is connected. */
|
||||
public static final int OPTION_MHL_INPUT_SWITCHING = 101;
|
||||
|
||||
/** If set to {@code ENABLED}, TV disables power charging for mobile device. */
|
||||
public static final int OPTION_MHL_POWER_CHARGE = 102;
|
||||
|
||||
/**
|
||||
* If set to {@code DISABLED}, all MHL commands are discarded.
|
||||
*
|
||||
* <p> This option is for internal use only, not supposed to be used by other components.
|
||||
* @hide
|
||||
*/
|
||||
public static final int OPTION_MHL_ENABLE = 103;
|
||||
|
||||
public static final int DISABLED = 0;
|
||||
public static final int ENABLED = 1;
|
||||
|
||||
private final IHdmiControlService mService;
|
||||
|
||||
HdmiTvClient(IHdmiControlService service) {
|
||||
|
@ -18,9 +18,8 @@ package com.android.server.hdmi;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.hardware.hdmi.IHdmiControlCallback;
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecDeviceInfo;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.hardware.hdmi.HdmiControlManager;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
|
||||
@ -62,7 +61,7 @@ final class ActiveSourceHandler {
|
||||
// Seq #17
|
||||
HdmiCecLocalDeviceTv tv = mSource;
|
||||
if (getSourcePath() == activePath && tv.getActiveSource() == getSourceAddress()) {
|
||||
invokeCallback(HdmiCec.RESULT_SUCCESS);
|
||||
invokeCallback(HdmiControlManager.RESULT_SUCCESS);
|
||||
return;
|
||||
}
|
||||
HdmiCecDeviceInfo device = mService.getDeviceInfo(activeAddress);
|
||||
@ -77,7 +76,7 @@ final class ActiveSourceHandler {
|
||||
if (currentActive != activeAddress && currentPath != activePath) {
|
||||
tv.updateActivePortId(mService.pathToPortId(activePath));
|
||||
}
|
||||
invokeCallback(HdmiCec.RESULT_SUCCESS);
|
||||
invokeCallback(HdmiControlManager.RESULT_SUCCESS);
|
||||
} else {
|
||||
// TV is in a mode that should keep its current source/input from
|
||||
// being changed for its operation. Reclaim the active source
|
||||
@ -87,7 +86,7 @@ final class ActiveSourceHandler {
|
||||
HdmiCecMessageBuilder.buildActiveSource(currentActive, currentPath);
|
||||
mService.sendCecCommand(activeSource);
|
||||
tv.updateActiveSource(currentActive, currentPath);
|
||||
invokeCallback(HdmiCec.RESULT_SUCCESS);
|
||||
invokeCallback(HdmiControlManager.RESULT_SUCCESS);
|
||||
} else {
|
||||
HdmiCecMessage routingChange = HdmiCecMessageBuilder.buildRoutingChange(
|
||||
getSourceAddress(), activePath, currentPath);
|
||||
|
200
services/core/java/com/android/server/hdmi/Constants.java
Normal file
200
services/core/java/com/android/server/hdmi/Constants.java
Normal file
@ -0,0 +1,200 @@
|
||||
/*
|
||||
* 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 com.android.server.hdmi;
|
||||
|
||||
/**
|
||||
* Defines constants related to HDMI-CEC protocol internal implementation.
|
||||
* If a constant will be used in the public api, it should be located in
|
||||
* {@link android.hardware.hdmi.HdmiCec}.
|
||||
*/
|
||||
final class Constants {
|
||||
|
||||
/** Logical address for TV */
|
||||
public static final int ADDR_TV = 0;
|
||||
|
||||
/** Logical address for recorder 1 */
|
||||
public static final int ADDR_RECORDER_1 = 1;
|
||||
|
||||
/** Logical address for recorder 2 */
|
||||
public static final int ADDR_RECORDER_2 = 2;
|
||||
|
||||
/** Logical address for tuner 1 */
|
||||
public static final int ADDR_TUNER_1 = 3;
|
||||
|
||||
/** Logical address for playback 1 */
|
||||
public static final int ADDR_PLAYBACK_1 = 4;
|
||||
|
||||
/** Logical address for audio system */
|
||||
public static final int ADDR_AUDIO_SYSTEM = 5;
|
||||
|
||||
/** Logical address for tuner 2 */
|
||||
public static final int ADDR_TUNER_2 = 6;
|
||||
|
||||
/** Logical address for tuner 3 */
|
||||
public static final int ADDR_TUNER_3 = 7;
|
||||
|
||||
/** Logical address for playback 2 */
|
||||
public static final int ADDR_PLAYBACK_2 = 8;
|
||||
|
||||
/** Logical address for recorder 3 */
|
||||
public static final int ADDR_RECORDER_3 = 9;
|
||||
|
||||
/** Logical address for tuner 4 */
|
||||
public static final int ADDR_TUNER_4 = 10;
|
||||
|
||||
/** Logical address for playback 3 */
|
||||
public static final int ADDR_PLAYBACK_3 = 11;
|
||||
|
||||
/** Logical address reserved for future usage */
|
||||
public static final int ADDR_RESERVED_1 = 12;
|
||||
|
||||
/** Logical address reserved for future usage */
|
||||
public static final int ADDR_RESERVED_2 = 13;
|
||||
|
||||
/** Logical address for TV other than the one assigned with {@link #ADDR_TV} */
|
||||
public static final int ADDR_SPECIFIC_USE = 14;
|
||||
|
||||
/** Logical address for devices to which address cannot be allocated */
|
||||
public static final int ADDR_UNREGISTERED = 15;
|
||||
|
||||
/** Logical address used in the destination address field for broadcast messages */
|
||||
public static final int ADDR_BROADCAST = 15;
|
||||
|
||||
/** Logical address used to indicate it is not initialized or invalid. */
|
||||
public static final int ADDR_INVALID = -1;
|
||||
|
||||
/** Logical address used to indicate the source comes from internal device. */
|
||||
public static final int ADDR_INTERNAL = 0xFFFF;
|
||||
|
||||
static final int MESSAGE_FEATURE_ABORT = 0x00;
|
||||
static final int MESSAGE_IMAGE_VIEW_ON = 0x04;
|
||||
static final int MESSAGE_TUNER_STEP_INCREMENT = 0x05;
|
||||
static final int MESSAGE_TUNER_STEP_DECREMENT = 0x06;
|
||||
static final int MESSAGE_TUNER_DEVICE_STATUS = 0x07;
|
||||
static final int MESSAGE_GIVE_TUNER_DEVICE_STATUS = 0x08;
|
||||
static final int MESSAGE_RECORD_ON = 0x09;
|
||||
static final int MESSAGE_RECORD_STATUS = 0x0A;
|
||||
static final int MESSAGE_RECORD_OFF = 0x0B;
|
||||
static final int MESSAGE_TEXT_VIEW_ON = 0x0D;
|
||||
static final int MESSAGE_RECORD_TV_SCREEN = 0x0F;
|
||||
static final int MESSAGE_GIVE_DECK_STATUS = 0x1A;
|
||||
static final int MESSAGE_DECK_STATUS = 0x1B;
|
||||
static final int MESSAGE_SET_MENU_LANGUAGE = 0x32;
|
||||
static final int MESSAGE_CLEAR_ANALOG_TIMER = 0x33;
|
||||
static final int MESSAGE_SET_ANALOG_TIMER = 0x34;
|
||||
static final int MESSAGE_TIMER_STATUS = 0x35;
|
||||
static final int MESSAGE_STANDBY = 0x36;
|
||||
static final int MESSAGE_PLAY = 0x41;
|
||||
static final int MESSAGE_DECK_CONTROL = 0x42;
|
||||
static final int MESSAGE_TIMER_CLEARED_STATUS = 0x043;
|
||||
static final int MESSAGE_USER_CONTROL_PRESSED = 0x44;
|
||||
static final int MESSAGE_USER_CONTROL_RELEASED = 0x45;
|
||||
static final int MESSAGE_GIVE_OSD_NAME = 0x46;
|
||||
static final int MESSAGE_SET_OSD_NAME = 0x47;
|
||||
static final int MESSAGE_SET_OSD_STRING = 0x64;
|
||||
static final int MESSAGE_SET_TIMER_PROGRAM_TITLE = 0x67;
|
||||
static final int MESSAGE_SYSTEM_AUDIO_MODE_REQUEST = 0x70;
|
||||
static final int MESSAGE_GIVE_AUDIO_STATUS = 0x71;
|
||||
static final int MESSAGE_SET_SYSTEM_AUDIO_MODE = 0x72;
|
||||
static final int MESSAGE_REPORT_AUDIO_STATUS = 0x7A;
|
||||
static final int MESSAGE_GIVE_SYSTEM_AUDIO_MODE_STATUS = 0x7D;
|
||||
static final int MESSAGE_SYSTEM_AUDIO_MODE_STATUS = 0x7E;
|
||||
static final int MESSAGE_ROUTING_CHANGE = 0x80;
|
||||
static final int MESSAGE_ROUTING_INFORMATION = 0x81;
|
||||
static final int MESSAGE_ACTIVE_SOURCE = 0x82;
|
||||
static final int MESSAGE_GIVE_PHYSICAL_ADDRESS = 0x83;
|
||||
static final int MESSAGE_REPORT_PHYSICAL_ADDRESS = 0x84;
|
||||
static final int MESSAGE_REQUEST_ACTIVE_SOURCE = 0x85;
|
||||
static final int MESSAGE_SET_STREAM_PATH = 0x86;
|
||||
static final int MESSAGE_DEVICE_VENDOR_ID = 0x87;
|
||||
static final int MESSAGE_VENDOR_COMMAND = 0x89;
|
||||
static final int MESSAGE_VENDOR_REMOTE_BUTTON_DOWN = 0x8A;
|
||||
static final int MESSAGE_VENDOR_REMOTE_BUTTON_UP = 0x8B;
|
||||
static final int MESSAGE_GIVE_DEVICE_VENDOR_ID = 0x8C;
|
||||
static final int MESSAGE_MENU_REQUEST = 0x8D;
|
||||
static final int MESSAGE_MENU_STATUS = 0x8E;
|
||||
static final int MESSAGE_GIVE_DEVICE_POWER_STATUS = 0x8F;
|
||||
static final int MESSAGE_REPORT_POWER_STATUS = 0x90;
|
||||
static final int MESSAGE_GET_MENU_LANGUAGE = 0x91;
|
||||
static final int MESSAGE_SELECT_ANALOG_SERVICE = 0x92;
|
||||
static final int MESSAGE_SELECT_DIGITAL_SERVICE = 0x93;
|
||||
static final int MESSAGE_SET_DIGITAL_TIMER = 0x97;
|
||||
static final int MESSAGE_CLEAR_DIGITAL_TIMER = 0x99;
|
||||
static final int MESSAGE_SET_AUDIO_RATE = 0x9A;
|
||||
static final int MESSAGE_INACTIVE_SOURCE = 0x9D;
|
||||
static final int MESSAGE_CEC_VERSION = 0x9E;
|
||||
static final int MESSAGE_GET_CEC_VERSION = 0x9F;
|
||||
static final int MESSAGE_VENDOR_COMMAND_WITH_ID = 0xA0;
|
||||
static final int MESSAGE_CLEAR_EXTERNAL_TIMER = 0xA1;
|
||||
static final int MESSAGE_SET_EXTERNAL_TIMER = 0xA2;
|
||||
static final int MESSAGE_INITIATE_ARC = 0xC0;
|
||||
static final int MESSAGE_REPORT_ARC_INITIATED = 0xC1;
|
||||
static final int MESSAGE_REPORT_ARC_TERMINATED = 0xC2;
|
||||
static final int MESSAGE_REQUEST_ARC_INITIATION = 0xC3;
|
||||
static final int MESSAGE_REQUEST_ARC_TERMINATION = 0xC4;
|
||||
static final int MESSAGE_TERMINATE_ARC = 0xC5;
|
||||
static final int MESSAGE_ABORT = 0xFF;
|
||||
|
||||
static final int UNKNOWN_VENDOR_ID = 0xFFFFFF;
|
||||
|
||||
// Constants related to operands of HDMI CEC commands.
|
||||
// Refer to CEC Table 29 in HDMI Spec v1.4b.
|
||||
// [Abort Reason]
|
||||
static final int ABORT_UNRECOGNIZED_MODE = 0;
|
||||
static final int ABORT_NOT_IN_CORRECT_MODE = 1;
|
||||
static final int ABORT_CANNOT_PROVIDE_SOURCE = 2;
|
||||
static final int ABORT_INVALID_OPERAND = 3;
|
||||
static final int ABORT_REFUSED = 4;
|
||||
static final int ABORT_UNABLE_TO_DETERMINE = 5;
|
||||
|
||||
// [Audio Status]
|
||||
static final int SYSTEM_AUDIO_STATUS_OFF = 0;
|
||||
static final int SYSTEM_AUDIO_STATUS_ON = 1;
|
||||
|
||||
// Bit mask used to get the routing path of the top level device.
|
||||
// When &'d with the path 1.2.2.0 (0x1220), for instance, gives 1.0.0.0.
|
||||
static final int ROUTING_PATH_TOP_MASK = 0xF000;
|
||||
|
||||
static final int INVALID_PORT_ID = -1;
|
||||
static final int INVALID_PHYSICAL_ADDRESS = 0xFFFF;
|
||||
|
||||
// Send result codes.
|
||||
static final int SEND_RESULT_SUCCESS = 0;
|
||||
static final int SEND_RESULT_NAK = -1;
|
||||
static final int SEND_RESULT_FAILURE = -2;
|
||||
|
||||
// Strategy for device polling.
|
||||
// Should use "OR(|) operation of POLL_STRATEGY_XXX and POLL_ITERATION_XXX.
|
||||
static final int POLL_STRATEGY_MASK = 0x3; // first and second bit.
|
||||
static final int POLL_STRATEGY_REMOTES_DEVICES = 0x1;
|
||||
static final int POLL_STRATEGY_SYSTEM_AUDIO = 0x2;
|
||||
|
||||
static final int POLL_ITERATION_STRATEGY_MASK = 0x30000; // first and second bit.
|
||||
static final int POLL_ITERATION_IN_ORDER = 0x10000;
|
||||
static final int POLL_ITERATION_REVERSE_ORDER = 0x20000;
|
||||
|
||||
static final int UNKNOWN_VOLUME = -1;
|
||||
|
||||
// IRT(Initiator Repetition Time) in millisecond as recommended in the standard.
|
||||
// Outgoing UCP commands, when in 'Press and Hold' mode, should be this much apart
|
||||
// from the adjacent one so as not to place unnecessarily heavy load on the CEC line.
|
||||
// TODO: This value might need tweaking per product basis. Consider putting it
|
||||
// in config.xml to allow customization.
|
||||
static final int IRT_MS = 300;
|
||||
|
||||
private Constants() { /* cannot be instantiated */ }
|
||||
}
|
@ -16,9 +16,7 @@
|
||||
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecDeviceInfo;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.internal.util.Preconditions;
|
||||
@ -72,10 +70,10 @@ final class DeviceDiscoveryAction extends FeatureAction {
|
||||
private static final class DeviceInfo {
|
||||
private final int mLogicalAddress;
|
||||
|
||||
private int mPhysicalAddress = HdmiConstants.INVALID_PHYSICAL_ADDRESS;
|
||||
private int mVendorId = HdmiCec.UNKNOWN_VENDOR_ID;
|
||||
private int mPhysicalAddress = Constants.INVALID_PHYSICAL_ADDRESS;
|
||||
private int mVendorId = Constants.UNKNOWN_VENDOR_ID;
|
||||
private String mDisplayName = "";
|
||||
private int mDeviceType = HdmiCec.DEVICE_INACTIVE;
|
||||
private int mDeviceType = HdmiCecDeviceInfo.DEVICE_INACTIVE;
|
||||
|
||||
private DeviceInfo(int logicalAddress) {
|
||||
mLogicalAddress = logicalAddress;
|
||||
@ -119,8 +117,8 @@ final class DeviceDiscoveryAction extends FeatureAction {
|
||||
allocateDevices(ackedAddress);
|
||||
startPhysicalAddressStage();
|
||||
}
|
||||
}, HdmiConstants.POLL_ITERATION_REVERSE_ORDER
|
||||
| HdmiConstants.POLL_STRATEGY_REMOTES_DEVICES, DEVICE_POLLING_RETRY);
|
||||
}, Constants.POLL_ITERATION_REVERSE_ORDER
|
||||
| Constants.POLL_STRATEGY_REMOTES_DEVICES, DEVICE_POLLING_RETRY);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -140,7 +138,7 @@ final class DeviceDiscoveryAction extends FeatureAction {
|
||||
}
|
||||
|
||||
private boolean verifyValidLogicalAddress(int address) {
|
||||
return address >= HdmiCec.ADDR_TV && address < HdmiCec.ADDR_UNREGISTERED;
|
||||
return address >= Constants.ADDR_TV && address < Constants.ADDR_UNREGISTERED;
|
||||
}
|
||||
|
||||
private void queryPhysicalAddress(int address) {
|
||||
@ -152,7 +150,7 @@ final class DeviceDiscoveryAction extends FeatureAction {
|
||||
mActionTimer.clearTimerMessage();
|
||||
|
||||
// Check cache first and send request if not exist.
|
||||
if (mayProcessMessageIfCached(address, HdmiCec.MESSAGE_REPORT_PHYSICAL_ADDRESS)) {
|
||||
if (mayProcessMessageIfCached(address, Constants.MESSAGE_REPORT_PHYSICAL_ADDRESS)) {
|
||||
return;
|
||||
}
|
||||
sendCommand(HdmiCecMessageBuilder.buildGivePhysicalAddress(getSourceAddress(), address));
|
||||
@ -175,7 +173,7 @@ final class DeviceDiscoveryAction extends FeatureAction {
|
||||
|
||||
mActionTimer.clearTimerMessage();
|
||||
|
||||
if (mayProcessMessageIfCached(address, HdmiCec.MESSAGE_SET_OSD_NAME)) {
|
||||
if (mayProcessMessageIfCached(address, Constants.MESSAGE_SET_OSD_NAME)) {
|
||||
return;
|
||||
}
|
||||
sendCommand(HdmiCecMessageBuilder.buildGiveOsdNameCommand(getSourceAddress(), address));
|
||||
@ -199,7 +197,7 @@ final class DeviceDiscoveryAction extends FeatureAction {
|
||||
|
||||
mActionTimer.clearTimerMessage();
|
||||
|
||||
if (mayProcessMessageIfCached(address, HdmiCec.MESSAGE_DEVICE_VENDOR_ID)) {
|
||||
if (mayProcessMessageIfCached(address, Constants.MESSAGE_DEVICE_VENDOR_ID)) {
|
||||
return;
|
||||
}
|
||||
sendCommand(
|
||||
@ -220,19 +218,19 @@ final class DeviceDiscoveryAction extends FeatureAction {
|
||||
boolean processCommand(HdmiCecMessage cmd) {
|
||||
switch (mState) {
|
||||
case STATE_WAITING_FOR_PHYSICAL_ADDRESS:
|
||||
if (cmd.getOpcode() == HdmiCec.MESSAGE_REPORT_PHYSICAL_ADDRESS) {
|
||||
if (cmd.getOpcode() == Constants.MESSAGE_REPORT_PHYSICAL_ADDRESS) {
|
||||
handleReportPhysicalAddress(cmd);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case STATE_WAITING_FOR_OSD_NAME:
|
||||
if (cmd.getOpcode() == HdmiCec.MESSAGE_SET_OSD_NAME) {
|
||||
if (cmd.getOpcode() == Constants.MESSAGE_SET_OSD_NAME) {
|
||||
handleSetOsdName(cmd);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case STATE_WAITING_FOR_VENDOR_ID:
|
||||
if (cmd.getOpcode() == HdmiCec.MESSAGE_DEVICE_VENDOR_ID) {
|
||||
if (cmd.getOpcode() == Constants.MESSAGE_DEVICE_VENDOR_ID) {
|
||||
handleVendorId(cmd);
|
||||
return true;
|
||||
}
|
||||
@ -285,7 +283,7 @@ final class DeviceDiscoveryAction extends FeatureAction {
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
Slog.w(TAG, "Failed to decode display name: " + cmd.toString());
|
||||
// If failed to get display name, use the default name of device.
|
||||
displayName = HdmiCec.getDefaultDeviceName(current.mLogicalAddress);
|
||||
displayName = HdmiUtils.getDefaultDeviceName(current.mLogicalAddress);
|
||||
}
|
||||
current.mDisplayName = displayName;
|
||||
increaseProcessedDeviceCount();
|
||||
|
@ -16,8 +16,6 @@ package com.android.server.hdmi;
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.hardware.hdmi.HdmiControlManager;
|
||||
import android.hardware.hdmi.IHdmiControlCallback;
|
||||
import android.os.RemoteException;
|
||||
@ -75,7 +73,7 @@ final class DevicePowerStatusAction extends FeatureAction {
|
||||
if (mState != STATE_WAITING_FOR_REPORT_POWER_STATUS) {
|
||||
return false;
|
||||
}
|
||||
if (cmd.getOpcode() == HdmiCec.MESSAGE_REPORT_POWER_STATUS) {
|
||||
if (cmd.getOpcode() == Constants.MESSAGE_REPORT_POWER_STATUS) {
|
||||
int status = cmd.getParams()[0];
|
||||
invokeCallback(status);
|
||||
finish();
|
||||
@ -91,7 +89,7 @@ final class DevicePowerStatusAction extends FeatureAction {
|
||||
}
|
||||
if (state == STATE_WAITING_FOR_REPORT_POWER_STATUS) {
|
||||
// Got no response from TV. Report status 'unknown'.
|
||||
invokeCallback(HdmiCec.POWER_STATUS_UNKNOWN);
|
||||
invokeCallback(HdmiControlManager.POWER_STATUS_UNKNOWN);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
@ -16,9 +16,8 @@
|
||||
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecDeviceInfo;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.hardware.hdmi.HdmiControlManager;
|
||||
import android.hardware.hdmi.HdmiTvClient;
|
||||
import android.hardware.hdmi.IHdmiControlCallback;
|
||||
import android.os.RemoteException;
|
||||
@ -108,12 +107,12 @@ final class DeviceSelectAction extends FeatureAction {
|
||||
|
||||
switch (mState) {
|
||||
case STATE_WAIT_FOR_REPORT_POWER_STATUS:
|
||||
if (opcode == HdmiCec.MESSAGE_REPORT_POWER_STATUS && params.length == 1) {
|
||||
if (opcode == Constants.MESSAGE_REPORT_POWER_STATUS && params.length == 1) {
|
||||
return handleReportPowerStatus(params[0]);
|
||||
}
|
||||
return false;
|
||||
case STATE_WAIT_FOR_ACTIVE_SOURCE:
|
||||
if (opcode == HdmiCec.MESSAGE_ACTIVE_SOURCE && params.length == 2) {
|
||||
if (opcode == Constants.MESSAGE_ACTIVE_SOURCE && params.length == 2) {
|
||||
int activePath = HdmiUtils.twoBytesToInt(params);
|
||||
ActiveSourceHandler
|
||||
.create((HdmiCecLocalDeviceTv) localDevice(), mCallback)
|
||||
@ -133,10 +132,10 @@ final class DeviceSelectAction extends FeatureAction {
|
||||
// If in 'Standby' or 'Transit to standby', remove the banner
|
||||
// and stop this action. Otherwise, send <Set Stream Path>
|
||||
switch (powerStatus) {
|
||||
case HdmiCec.POWER_STATUS_ON:
|
||||
case HdmiControlManager.POWER_STATUS_ON:
|
||||
sendSetStreamPath();
|
||||
return true;
|
||||
case HdmiCec.POWER_STATUS_TRANSIENT_TO_STANDBY:
|
||||
case HdmiControlManager.POWER_STATUS_TRANSIENT_TO_STANDBY:
|
||||
if (mPowerStatusCounter < 4) {
|
||||
mState = STATE_WAIT_FOR_DEVICE_TO_TRANSIT_TO_STANDBY;
|
||||
addTimer(mState, TIMEOUT_TRANSIT_TO_STANDBY_MS);
|
||||
@ -144,14 +143,14 @@ final class DeviceSelectAction extends FeatureAction {
|
||||
sendSetStreamPath();
|
||||
}
|
||||
return true;
|
||||
case HdmiCec.POWER_STATUS_STANDBY:
|
||||
case HdmiControlManager.POWER_STATUS_STANDBY:
|
||||
if (mPowerStatusCounter == 0) {
|
||||
turnOnDevice();
|
||||
} else {
|
||||
sendSetStreamPath();
|
||||
}
|
||||
return true;
|
||||
case HdmiCec.POWER_STATUS_TRANSIENT_TO_ON:
|
||||
case HdmiControlManager.POWER_STATUS_TRANSIENT_TO_ON:
|
||||
if (mPowerStatusCounter < LOOP_COUNTER_MAX) {
|
||||
mState = STATE_WAIT_FOR_DEVICE_POWER_ON;
|
||||
addTimer(mState, TIMEOUT_POWER_ON_MS);
|
||||
@ -197,7 +196,7 @@ final class DeviceSelectAction extends FeatureAction {
|
||||
case STATE_WAIT_FOR_ACTIVE_SOURCE:
|
||||
// TODO: Remove the banner
|
||||
// Display banner "Communication failed. Please check your cable or connection"
|
||||
invokeCallback(HdmiCec.RESULT_TIMEOUT);
|
||||
invokeCallback(HdmiControlManager.RESULT_TIMEOUT);
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
|
@ -16,8 +16,6 @@
|
||||
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.hardware.hdmi.HdmiPortInfo;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
@ -59,7 +57,7 @@ final class HdmiCecController {
|
||||
*
|
||||
* @param deviceType requested device type to allocate logical address
|
||||
* @param logicalAddress allocated logical address. If it is
|
||||
* {@link HdmiCec#ADDR_UNREGISTERED}, it means that
|
||||
* {@link Constants.ADDR_UNREGISTERED}, it means that
|
||||
* it failed to allocate logical address for the given device type
|
||||
*/
|
||||
void onAllocated(int deviceType, int logicalAddress);
|
||||
@ -93,7 +91,7 @@ final class HdmiCecController {
|
||||
private final Predicate<Integer> mSystemAudioAddressPredicate = new Predicate<Integer>() {
|
||||
@Override
|
||||
public boolean apply(Integer address) {
|
||||
return HdmiCec.getTypeFromAddress(address) == HdmiCec.ADDR_AUDIO_SYSTEM;
|
||||
return HdmiUtils.getTypeFromAddress(address) == Constants.ADDR_AUDIO_SYSTEM;
|
||||
}
|
||||
};
|
||||
|
||||
@ -160,7 +158,7 @@ final class HdmiCecController {
|
||||
*
|
||||
* @param deviceType type of device to used to determine logical address
|
||||
* @param preferredAddress a logical address preferred to be allocated.
|
||||
* If sets {@link HdmiCec#ADDR_UNREGISTERED}, scans
|
||||
* If sets {@link Constants.ADDR_UNREGISTERED}, scans
|
||||
* the smallest logical address matched with the given device type.
|
||||
* Otherwise, scan address will start from {@code preferredAddress}
|
||||
* @param callback callback interface to report allocated logical address to caller
|
||||
@ -185,21 +183,21 @@ final class HdmiCecController {
|
||||
int startAddress = preferredAddress;
|
||||
// If preferred address is "unregistered", start address will be the smallest
|
||||
// address matched with the given device type.
|
||||
if (preferredAddress == HdmiCec.ADDR_UNREGISTERED) {
|
||||
if (preferredAddress == Constants.ADDR_UNREGISTERED) {
|
||||
for (int i = 0; i < NUM_LOGICAL_ADDRESS; ++i) {
|
||||
if (deviceType == HdmiCec.getTypeFromAddress(i)) {
|
||||
if (deviceType == HdmiUtils.getTypeFromAddress(i)) {
|
||||
startAddress = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int logicalAddress = HdmiCec.ADDR_UNREGISTERED;
|
||||
int logicalAddress = Constants.ADDR_UNREGISTERED;
|
||||
// Iterates all possible addresses which has the same device type.
|
||||
for (int i = 0; i < NUM_LOGICAL_ADDRESS; ++i) {
|
||||
int curAddress = (startAddress + i) % NUM_LOGICAL_ADDRESS;
|
||||
if (curAddress != HdmiCec.ADDR_UNREGISTERED
|
||||
&& deviceType == HdmiCec.getTypeFromAddress(curAddress)) {
|
||||
if (curAddress != Constants.ADDR_UNREGISTERED
|
||||
&& deviceType == HdmiUtils.getTypeFromAddress(curAddress)) {
|
||||
if (!sendPollMessage(curAddress, curAddress,
|
||||
RETRY_COUNT_FOR_LOGICAL_ADDRESS_ALLOCATION)) {
|
||||
logicalAddress = curAddress;
|
||||
@ -255,7 +253,7 @@ final class HdmiCecController {
|
||||
@ServiceThreadOnly
|
||||
int addLogicalAddress(int newLogicalAddress) {
|
||||
assertRunOnServiceThread();
|
||||
if (HdmiCec.isValidAddress(newLogicalAddress)) {
|
||||
if (HdmiUtils.isValidAddress(newLogicalAddress)) {
|
||||
return nativeAddLogicalAddress(mNativePtr, newLogicalAddress);
|
||||
} else {
|
||||
return -1;
|
||||
@ -315,13 +313,10 @@ final class HdmiCecController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass a option to CEC HAL.
|
||||
* Set an option to CEC HAL.
|
||||
*
|
||||
* @param flag a key of option. For more details, look at
|
||||
* {@link HdmiConstants#FLAG_HDMI_OPTION_WAKEUP} to
|
||||
* {@link HdmiConstants#FLAG_HDMI_OPTION_SYSTEM_CEC_CONTROL}.
|
||||
* @param value a value of option. Actual value varies from flag to flag. For more
|
||||
* details, look at description of flags.
|
||||
* @param flag key of option
|
||||
* @param value value of option
|
||||
*/
|
||||
@ServiceThreadOnly
|
||||
void setOption(int flag, int value) {
|
||||
@ -385,31 +380,31 @@ final class HdmiCecController {
|
||||
}
|
||||
|
||||
private List<Integer> pickPollCandidates(int pickStrategy) {
|
||||
int strategy = pickStrategy & HdmiConstants.POLL_STRATEGY_MASK;
|
||||
int strategy = pickStrategy & Constants.POLL_STRATEGY_MASK;
|
||||
Predicate<Integer> pickPredicate = null;
|
||||
switch (strategy) {
|
||||
case HdmiConstants.POLL_STRATEGY_SYSTEM_AUDIO:
|
||||
case Constants.POLL_STRATEGY_SYSTEM_AUDIO:
|
||||
pickPredicate = mSystemAudioAddressPredicate;
|
||||
break;
|
||||
case HdmiConstants.POLL_STRATEGY_REMOTES_DEVICES:
|
||||
case Constants.POLL_STRATEGY_REMOTES_DEVICES:
|
||||
default: // The default is POLL_STRATEGY_REMOTES_DEVICES.
|
||||
pickPredicate = mRemoteDeviceAddressPredicate;
|
||||
break;
|
||||
}
|
||||
|
||||
int iterationStrategy = pickStrategy & HdmiConstants.POLL_ITERATION_STRATEGY_MASK;
|
||||
int iterationStrategy = pickStrategy & Constants.POLL_ITERATION_STRATEGY_MASK;
|
||||
ArrayList<Integer> pollingCandidates = new ArrayList<>();
|
||||
switch (iterationStrategy) {
|
||||
case HdmiConstants.POLL_ITERATION_IN_ORDER:
|
||||
for (int i = HdmiCec.ADDR_TV; i <= HdmiCec.ADDR_SPECIFIC_USE; ++i) {
|
||||
case Constants.POLL_ITERATION_IN_ORDER:
|
||||
for (int i = Constants.ADDR_TV; i <= Constants.ADDR_SPECIFIC_USE; ++i) {
|
||||
if (pickPredicate.apply(i)) {
|
||||
pollingCandidates.add(i);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case HdmiConstants.POLL_ITERATION_REVERSE_ORDER:
|
||||
case Constants.POLL_ITERATION_REVERSE_ORDER:
|
||||
default: // The default is reverse order.
|
||||
for (int i = HdmiCec.ADDR_SPECIFIC_USE; i >= HdmiCec.ADDR_TV; --i) {
|
||||
for (int i = Constants.ADDR_SPECIFIC_USE; i >= Constants.ADDR_TV; --i) {
|
||||
if (pickPredicate.apply(i)) {
|
||||
pollingCandidates.add(i);
|
||||
}
|
||||
@ -465,7 +460,7 @@ final class HdmiCecController {
|
||||
// new logical address for the device because no device uses
|
||||
// it as logical address of the device.
|
||||
if (nativeSendCecCommand(mNativePtr, sourceAddress, destinationAddress, EMPTY_BODY)
|
||||
== HdmiConstants.SEND_RESULT_SUCCESS) {
|
||||
== Constants.SEND_RESULT_SUCCESS) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -497,7 +492,7 @@ final class HdmiCecController {
|
||||
|
||||
private boolean isAcceptableAddress(int address) {
|
||||
// Can access command targeting devices available in local device or broadcast command.
|
||||
if (address == HdmiCec.ADDR_BROADCAST) {
|
||||
if (address == Constants.ADDR_BROADCAST) {
|
||||
return true;
|
||||
}
|
||||
return isAllocatedLocalDeviceAddress(address);
|
||||
@ -511,12 +506,12 @@ final class HdmiCecController {
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.getDestination() != HdmiCec.ADDR_BROADCAST) {
|
||||
if (message.getDestination() != Constants.ADDR_BROADCAST) {
|
||||
int sourceAddress = message.getDestination();
|
||||
// Reply <Feature Abort> to initiator (source) for all requests.
|
||||
HdmiCecMessage cecMessage = HdmiCecMessageBuilder.buildFeatureAbortCommand(
|
||||
sourceAddress, message.getSource(), message.getOpcode(),
|
||||
HdmiConstants.ABORT_REFUSED);
|
||||
Constants.ABORT_REFUSED);
|
||||
sendCommand(cecMessage);
|
||||
}
|
||||
}
|
||||
@ -537,7 +532,7 @@ final class HdmiCecController {
|
||||
byte[] body = buildBody(cecMessage.getOpcode(), cecMessage.getParams());
|
||||
final int error = nativeSendCecCommand(mNativePtr, cecMessage.getSource(),
|
||||
cecMessage.getDestination(), body);
|
||||
if (error != HdmiConstants.SEND_RESULT_SUCCESS) {
|
||||
if (error != Constants.SEND_RESULT_SUCCESS) {
|
||||
Slog.w(TAG, "Failed to send " + cecMessage);
|
||||
}
|
||||
if (callback != null) {
|
||||
|
@ -16,9 +16,7 @@
|
||||
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecDeviceInfo;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.os.Looper;
|
||||
import android.util.Slog;
|
||||
|
||||
@ -63,16 +61,16 @@ abstract class HdmiCecLocalDevice {
|
||||
protected HdmiCecLocalDevice(HdmiControlService service, int deviceType) {
|
||||
mService = service;
|
||||
mDeviceType = deviceType;
|
||||
mAddress = HdmiCec.ADDR_UNREGISTERED;
|
||||
mAddress = Constants.ADDR_UNREGISTERED;
|
||||
mLock = service.getServiceLock();
|
||||
}
|
||||
|
||||
// Factory method that returns HdmiCecLocalDevice of corresponding type.
|
||||
static HdmiCecLocalDevice create(HdmiControlService service, int deviceType) {
|
||||
switch (deviceType) {
|
||||
case HdmiCec.DEVICE_TV:
|
||||
case HdmiCecDeviceInfo.DEVICE_TV:
|
||||
return new HdmiCecLocalDeviceTv(service);
|
||||
case HdmiCec.DEVICE_PLAYBACK:
|
||||
case HdmiCecDeviceInfo.DEVICE_PLAYBACK:
|
||||
return new HdmiCecLocalDevicePlayback(service);
|
||||
default:
|
||||
return null;
|
||||
@ -82,7 +80,7 @@ abstract class HdmiCecLocalDevice {
|
||||
@ServiceThreadOnly
|
||||
void init() {
|
||||
assertRunOnServiceThread();
|
||||
mPreferredAddress = HdmiCec.ADDR_UNREGISTERED;
|
||||
mPreferredAddress = Constants.ADDR_UNREGISTERED;
|
||||
// TODO: load preferred address from permanent storage.
|
||||
}
|
||||
|
||||
@ -101,7 +99,7 @@ abstract class HdmiCecLocalDevice {
|
||||
final boolean dispatchMessage(HdmiCecMessage message) {
|
||||
assertRunOnServiceThread();
|
||||
int dest = message.getDestination();
|
||||
if (dest != mAddress && dest != HdmiCec.ADDR_BROADCAST) {
|
||||
if (dest != mAddress && dest != Constants.ADDR_BROADCAST) {
|
||||
return false;
|
||||
}
|
||||
// Cache incoming message. Note that it caches only white-listed one.
|
||||
@ -116,47 +114,47 @@ abstract class HdmiCecLocalDevice {
|
||||
return true;
|
||||
}
|
||||
switch (message.getOpcode()) {
|
||||
case HdmiCec.MESSAGE_ACTIVE_SOURCE:
|
||||
case Constants.MESSAGE_ACTIVE_SOURCE:
|
||||
return handleActiveSource(message);
|
||||
case HdmiCec.MESSAGE_INACTIVE_SOURCE:
|
||||
case Constants.MESSAGE_INACTIVE_SOURCE:
|
||||
return handleInactiveSource(message);
|
||||
case HdmiCec.MESSAGE_REQUEST_ACTIVE_SOURCE:
|
||||
case Constants.MESSAGE_REQUEST_ACTIVE_SOURCE:
|
||||
return handleRequestActiveSource(message);
|
||||
case HdmiCec.MESSAGE_GET_MENU_LANGUAGE:
|
||||
case Constants.MESSAGE_GET_MENU_LANGUAGE:
|
||||
return handleGetMenuLanguage(message);
|
||||
case HdmiCec.MESSAGE_GIVE_PHYSICAL_ADDRESS:
|
||||
case Constants.MESSAGE_GIVE_PHYSICAL_ADDRESS:
|
||||
return handleGivePhysicalAddress();
|
||||
case HdmiCec.MESSAGE_GIVE_OSD_NAME:
|
||||
case Constants.MESSAGE_GIVE_OSD_NAME:
|
||||
return handleGiveOsdName(message);
|
||||
case HdmiCec.MESSAGE_GIVE_DEVICE_VENDOR_ID:
|
||||
case Constants.MESSAGE_GIVE_DEVICE_VENDOR_ID:
|
||||
return handleGiveDeviceVendorId();
|
||||
case HdmiCec.MESSAGE_GET_CEC_VERSION:
|
||||
case Constants.MESSAGE_GET_CEC_VERSION:
|
||||
return handleGetCecVersion(message);
|
||||
case HdmiCec.MESSAGE_REPORT_PHYSICAL_ADDRESS:
|
||||
case Constants.MESSAGE_REPORT_PHYSICAL_ADDRESS:
|
||||
return handleReportPhysicalAddress(message);
|
||||
case HdmiCec.MESSAGE_ROUTING_CHANGE:
|
||||
case Constants.MESSAGE_ROUTING_CHANGE:
|
||||
return handleRoutingChange(message);
|
||||
case HdmiCec.MESSAGE_INITIATE_ARC:
|
||||
case Constants.MESSAGE_INITIATE_ARC:
|
||||
return handleInitiateArc(message);
|
||||
case HdmiCec.MESSAGE_TERMINATE_ARC:
|
||||
case Constants.MESSAGE_TERMINATE_ARC:
|
||||
return handleTerminateArc(message);
|
||||
case HdmiCec.MESSAGE_SET_SYSTEM_AUDIO_MODE:
|
||||
case Constants.MESSAGE_SET_SYSTEM_AUDIO_MODE:
|
||||
return handleSetSystemAudioMode(message);
|
||||
case HdmiCec.MESSAGE_SYSTEM_AUDIO_MODE_STATUS:
|
||||
case Constants.MESSAGE_SYSTEM_AUDIO_MODE_STATUS:
|
||||
return handleSystemAudioModeStatus(message);
|
||||
case HdmiCec.MESSAGE_REPORT_AUDIO_STATUS:
|
||||
case Constants.MESSAGE_REPORT_AUDIO_STATUS:
|
||||
return handleReportAudioStatus(message);
|
||||
case HdmiCec.MESSAGE_STANDBY:
|
||||
case Constants.MESSAGE_STANDBY:
|
||||
return handleStandby(message);
|
||||
case HdmiCec.MESSAGE_TEXT_VIEW_ON:
|
||||
case Constants.MESSAGE_TEXT_VIEW_ON:
|
||||
return handleTextViewOn(message);
|
||||
case HdmiCec.MESSAGE_IMAGE_VIEW_ON:
|
||||
case Constants.MESSAGE_IMAGE_VIEW_ON:
|
||||
return handleImageViewOn(message);
|
||||
case HdmiCec.MESSAGE_USER_CONTROL_PRESSED:
|
||||
case Constants.MESSAGE_USER_CONTROL_PRESSED:
|
||||
return handleUserControlPressed(message);
|
||||
case HdmiCec.MESSAGE_SET_STREAM_PATH:
|
||||
case Constants.MESSAGE_SET_STREAM_PATH:
|
||||
return handleSetStreamPath(message);
|
||||
case HdmiCec.MESSAGE_GIVE_DEVICE_POWER_STATUS:
|
||||
case Constants.MESSAGE_GIVE_DEVICE_POWER_STATUS:
|
||||
return handleGiveDevicePowerStatus(message);
|
||||
default:
|
||||
return false;
|
||||
@ -226,8 +224,8 @@ abstract class HdmiCecLocalDevice {
|
||||
Slog.w(TAG, "Only TV can handle <Get Menu Language>:" + message.toString());
|
||||
mService.sendCecCommand(
|
||||
HdmiCecMessageBuilder.buildFeatureAbortCommand(mAddress,
|
||||
message.getSource(), HdmiCec.MESSAGE_GET_MENU_LANGUAGE,
|
||||
HdmiConstants.ABORT_UNRECOGNIZED_MODE));
|
||||
message.getSource(), Constants.MESSAGE_GET_MENU_LANGUAGE,
|
||||
Constants.ABORT_UNRECOGNIZED_MODE));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -305,7 +303,8 @@ abstract class HdmiCecLocalDevice {
|
||||
|
||||
private static boolean isPowerOnOrToggleCommand(HdmiCecMessage message) {
|
||||
byte[] params = message.getParams();
|
||||
return message.getOpcode() == HdmiCec.MESSAGE_USER_CONTROL_PRESSED && params.length == 1
|
||||
return message.getOpcode() == Constants.MESSAGE_USER_CONTROL_PRESSED
|
||||
&& params.length == 1
|
||||
&& (params[0] == HdmiCecKeycode.CEC_KEYCODE_POWER
|
||||
|| params[0] == HdmiCecKeycode.CEC_KEYCODE_POWER_ON_FUNCTION
|
||||
|| params[0] == HdmiCecKeycode.CEC_KEYCODE_POWER_TOGGLE_FUNCTION);
|
||||
@ -313,7 +312,8 @@ abstract class HdmiCecLocalDevice {
|
||||
|
||||
private static boolean isPowerOffOrToggleCommand(HdmiCecMessage message) {
|
||||
byte[] params = message.getParams();
|
||||
return message.getOpcode() == HdmiCec.MESSAGE_USER_CONTROL_PRESSED && params.length == 1
|
||||
return message.getOpcode() == Constants.MESSAGE_USER_CONTROL_PRESSED
|
||||
&& params.length == 1
|
||||
&& (params[0] == HdmiCecKeycode.CEC_KEYCODE_POWER
|
||||
|| params[0] == HdmiCecKeycode.CEC_KEYCODE_POWER_OFF_FUNCTION
|
||||
|| params[0] == HdmiCecKeycode.CEC_KEYCODE_POWER_TOGGLE_FUNCTION);
|
||||
@ -367,7 +367,7 @@ abstract class HdmiCecLocalDevice {
|
||||
@ServiceThreadOnly
|
||||
void clearAddress() {
|
||||
assertRunOnServiceThread();
|
||||
mAddress = HdmiCec.ADDR_UNREGISTERED;
|
||||
mAddress = Constants.ADDR_UNREGISTERED;
|
||||
}
|
||||
|
||||
@ServiceThreadOnly
|
||||
|
@ -16,8 +16,8 @@
|
||||
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.hardware.hdmi.HdmiCecDeviceInfo;
|
||||
import android.hardware.hdmi.HdmiControlManager;
|
||||
import android.hardware.hdmi.IHdmiControlCallback;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
@ -33,7 +33,7 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDevice {
|
||||
private boolean mIsActiveSource = false;
|
||||
|
||||
HdmiCecLocalDevicePlayback(HdmiControlService service) {
|
||||
super(service, HdmiCec.DEVICE_PLAYBACK);
|
||||
super(service, HdmiCecDeviceInfo.DEVICE_PLAYBACK);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -49,16 +49,17 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDevice {
|
||||
assertRunOnServiceThread();
|
||||
if (hasAction(OneTouchPlayAction.class)) {
|
||||
Slog.w(TAG, "oneTouchPlay already in progress");
|
||||
invokeCallback(callback, HdmiCec.RESULT_ALREADY_IN_PROGRESS);
|
||||
invokeCallback(callback, HdmiControlManager.RESULT_ALREADY_IN_PROGRESS);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Consider the case of multiple TV sets. For now we always direct the command
|
||||
// to the primary one.
|
||||
OneTouchPlayAction action = OneTouchPlayAction.create(this, HdmiCec.ADDR_TV, callback);
|
||||
OneTouchPlayAction action = OneTouchPlayAction.create(this, Constants.ADDR_TV,
|
||||
callback);
|
||||
if (action == null) {
|
||||
Slog.w(TAG, "Cannot initiate oneTouchPlay");
|
||||
invokeCallback(callback, HdmiCec.RESULT_EXCEPTION);
|
||||
invokeCallback(callback, HdmiControlManager.RESULT_EXCEPTION);
|
||||
return;
|
||||
}
|
||||
addAndStartAction(action);
|
||||
@ -69,14 +70,14 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDevice {
|
||||
assertRunOnServiceThread();
|
||||
if (hasAction(DevicePowerStatusAction.class)) {
|
||||
Slog.w(TAG, "queryDisplayStatus already in progress");
|
||||
invokeCallback(callback, HdmiCec.RESULT_ALREADY_IN_PROGRESS);
|
||||
invokeCallback(callback, HdmiControlManager.RESULT_ALREADY_IN_PROGRESS);
|
||||
return;
|
||||
}
|
||||
DevicePowerStatusAction action = DevicePowerStatusAction.create(this,
|
||||
HdmiCec.ADDR_TV, callback);
|
||||
Constants.ADDR_TV, callback);
|
||||
if (action == null) {
|
||||
Slog.w(TAG, "Cannot initiate queryDisplayStatus");
|
||||
invokeCallback(callback, HdmiCec.RESULT_EXCEPTION);
|
||||
invokeCallback(callback, HdmiControlManager.RESULT_EXCEPTION);
|
||||
return;
|
||||
}
|
||||
addAndStartAction(action);
|
||||
|
@ -16,9 +16,8 @@
|
||||
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecDeviceInfo;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.hardware.hdmi.HdmiControlManager;
|
||||
import android.hardware.hdmi.IHdmiControlCallback;
|
||||
import android.media.AudioSystem;
|
||||
import android.os.IBinder;
|
||||
@ -57,12 +56,12 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
// be able to switch to it upon receiving <Inactive Source> from currently active source.
|
||||
// This remains valid only when the active source was switched via one touch play operation
|
||||
// (either by TV or source device). Manual port switching invalidates this value to
|
||||
// HdmiConstants.PORT_INVALID, for which case <Inactive Source> does not do anything.
|
||||
// Constants.PORT_INVALID, for which case <Inactive Source> does not do anything.
|
||||
@GuardedBy("mLock")
|
||||
private int mPrevPortId;
|
||||
|
||||
@GuardedBy("mLock")
|
||||
private int mSystemAudioVolume = HdmiConstants.UNKNOWN_VOLUME;
|
||||
private int mSystemAudioVolume = Constants.UNKNOWN_VOLUME;
|
||||
|
||||
@GuardedBy("mLock")
|
||||
private boolean mSystemAudioMute = false;
|
||||
@ -83,8 +82,8 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
private boolean mAutoDeviceOff;
|
||||
|
||||
HdmiCecLocalDeviceTv(HdmiControlService service) {
|
||||
super(service, HdmiCec.DEVICE_TV);
|
||||
mPrevPortId = HdmiConstants.INVALID_PORT_ID;
|
||||
super(service, HdmiCecDeviceInfo.DEVICE_TV);
|
||||
mPrevPortId = Constants.INVALID_PORT_ID;
|
||||
// TODO: load system audio mode and set it to mSystemAudioMode.
|
||||
}
|
||||
|
||||
@ -111,13 +110,13 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
@ServiceThreadOnly
|
||||
void deviceSelect(int targetAddress, IHdmiControlCallback callback) {
|
||||
assertRunOnServiceThread();
|
||||
if (targetAddress == HdmiCec.ADDR_INTERNAL) {
|
||||
if (targetAddress == Constants.ADDR_INTERNAL) {
|
||||
handleSelectInternalSource(callback);
|
||||
return;
|
||||
}
|
||||
HdmiCecDeviceInfo targetDevice = getDeviceInfo(targetAddress);
|
||||
if (targetDevice == null) {
|
||||
invokeCallback(callback, HdmiCec.RESULT_TARGET_NOT_AVAILABLE);
|
||||
invokeCallback(callback, HdmiControlManager.RESULT_TARGET_NOT_AVAILABLE);
|
||||
return;
|
||||
}
|
||||
removeAction(DeviceSelectAction.class);
|
||||
@ -194,7 +193,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
assertRunOnServiceThread();
|
||||
// Seq #20
|
||||
if (!mService.isControlEnabled() || portId == getActivePortId()) {
|
||||
invokeCallback(callback, HdmiCec.RESULT_INCORRECT_MODE);
|
||||
invokeCallback(callback, HdmiControlManager.RESULT_INCORRECT_MODE);
|
||||
return;
|
||||
}
|
||||
// TODO: Make sure this call does not stem from <Active Source> message reception.
|
||||
@ -279,7 +278,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
return true;
|
||||
}
|
||||
int portId = getPrevPortId();
|
||||
if (portId != HdmiConstants.INVALID_PORT_ID) {
|
||||
if (portId != Constants.INVALID_PORT_ID) {
|
||||
// TODO: Do this only if TV is not showing multiview like PIP/PAP.
|
||||
|
||||
HdmiCecDeviceInfo inactiveSource = getDeviceInfo(message.getSource());
|
||||
@ -293,7 +292,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
|
||||
setActivePortId(portId);
|
||||
doManualPortSwitching(portId, null);
|
||||
setPrevPortId(HdmiConstants.INVALID_PORT_ID);
|
||||
setPrevPortId(Constants.INVALID_PORT_ID);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -426,7 +425,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
// For now, simply reply with <Feature Abort> and mark it consumed by returning true.
|
||||
mService.sendCecCommand(HdmiCecMessageBuilder.buildFeatureAbortCommand(
|
||||
message.getDestination(), message.getSource(), message.getOpcode(),
|
||||
HdmiConstants.ABORT_REFUSED));
|
||||
Constants.ABORT_REFUSED));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -516,7 +515,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
assertRunOnServiceThread();
|
||||
HdmiCecDeviceInfo avr = getAvrDeviceInfo();
|
||||
if (avr == null) {
|
||||
invokeCallback(callback, HdmiCec.RESULT_SOURCE_NOT_AVAILABLE);
|
||||
invokeCallback(callback, HdmiControlManager.RESULT_SOURCE_NOT_AVAILABLE);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -737,8 +736,8 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
}
|
||||
|
||||
private boolean isMessageForSystemAudio(HdmiCecMessage message) {
|
||||
if (message.getSource() != HdmiCec.ADDR_AUDIO_SYSTEM
|
||||
|| message.getDestination() != HdmiCec.ADDR_TV
|
||||
if (message.getSource() != Constants.ADDR_AUDIO_SYSTEM
|
||||
|| message.getDestination() != Constants.ADDR_TV
|
||||
|| getAvrDeviceInfo() == null) {
|
||||
Slog.w(TAG, "Skip abnormal CecMessage: " + message);
|
||||
return false;
|
||||
@ -865,7 +864,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
@ServiceThreadOnly
|
||||
HdmiCecDeviceInfo getAvrDeviceInfo() {
|
||||
assertRunOnServiceThread();
|
||||
return getDeviceInfo(HdmiCec.ADDR_AUDIO_SYSTEM);
|
||||
return getDeviceInfo(Constants.ADDR_AUDIO_SYSTEM);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -889,7 +888,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
}
|
||||
|
||||
HdmiCecDeviceInfo getSafeAvrDeviceInfo() {
|
||||
return getSafeDeviceInfo(HdmiCec.ADDR_AUDIO_SYSTEM);
|
||||
return getSafeDeviceInfo(Constants.ADDR_AUDIO_SYSTEM);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -958,7 +957,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
void launchRoutingControl(boolean routingForBootup) {
|
||||
assertRunOnServiceThread();
|
||||
// Seq #24
|
||||
if (getActivePortId() != HdmiConstants.INVALID_PORT_ID) {
|
||||
if (getActivePortId() != Constants.INVALID_PORT_ID) {
|
||||
if (!routingForBootup && !isProhibitMode()) {
|
||||
removeAction(RoutingControlAction.class);
|
||||
int newPath = mService.portIdToPath(getActivePortId());
|
||||
@ -1058,7 +1057,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
}
|
||||
if (!initiatedByCec) {
|
||||
mService.sendCecCommand(HdmiCecMessageBuilder.buildStandby(
|
||||
mAddress, HdmiCec.ADDR_BROADCAST));
|
||||
mAddress, Constants.ADDR_BROADCAST));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,9 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.hardware.hdmi;
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.annotation.SystemApi;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
@ -28,10 +27,7 @@ import java.util.Arrays;
|
||||
* A class to encapsulate HDMI-CEC message used for the devices connected via
|
||||
* HDMI cable to communicate with one another. A message is defined by its
|
||||
* source and destination address, command (or opcode), and optional parameters.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public final class HdmiCecMessage implements Parcelable {
|
||||
|
||||
public static final byte[] EMPTY_PARAM = EmptyArray.BYTE;
|
||||
@ -158,23 +154,23 @@ public final class HdmiCecMessage implements Parcelable {
|
||||
|
||||
private static String opcodeToString(int opcode) {
|
||||
switch (opcode) {
|
||||
case HdmiCec.MESSAGE_FEATURE_ABORT:
|
||||
case Constants.MESSAGE_FEATURE_ABORT:
|
||||
return "Feature Abort";
|
||||
case HdmiCec.MESSAGE_CEC_VERSION:
|
||||
case Constants.MESSAGE_CEC_VERSION:
|
||||
return "CEC Version";
|
||||
case HdmiCec.MESSAGE_REQUEST_ARC_INITIATION:
|
||||
case Constants.MESSAGE_REQUEST_ARC_INITIATION:
|
||||
return "Request ARC Initiation";
|
||||
case HdmiCec.MESSAGE_REQUEST_ARC_TERMINATION:
|
||||
case Constants.MESSAGE_REQUEST_ARC_TERMINATION:
|
||||
return "Request ARC Termination";
|
||||
case HdmiCec.MESSAGE_REPORT_ARC_INITIATED:
|
||||
case Constants.MESSAGE_REPORT_ARC_INITIATED:
|
||||
return "Report ARC Initiated";
|
||||
case HdmiCec.MESSAGE_REPORT_ARC_TERMINATED:
|
||||
case Constants.MESSAGE_REPORT_ARC_TERMINATED:
|
||||
return "Report ARC Terminated";
|
||||
case HdmiCec.MESSAGE_TEXT_VIEW_ON:
|
||||
case Constants.MESSAGE_TEXT_VIEW_ON:
|
||||
return "Text View On";
|
||||
case HdmiCec.MESSAGE_ACTIVE_SOURCE:
|
||||
case Constants.MESSAGE_ACTIVE_SOURCE:
|
||||
return "Active Source";
|
||||
case HdmiCec.MESSAGE_GIVE_DEVICE_POWER_STATUS:
|
||||
case Constants.MESSAGE_GIVE_DEVICE_POWER_STATUS:
|
||||
return "Give Device Power Status";
|
||||
default:
|
||||
return String.format("Opcode: %02X", opcode);
|
@ -16,9 +16,6 @@
|
||||
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -60,7 +57,7 @@ public class HdmiCecMessageBuilder {
|
||||
(byte) originalOpcode,
|
||||
(byte) reason,
|
||||
};
|
||||
return buildCommand(src, dest, HdmiCec.MESSAGE_FEATURE_ABORT, params);
|
||||
return buildCommand(src, dest, Constants.MESSAGE_FEATURE_ABORT, params);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,7 +68,7 @@ public class HdmiCecMessageBuilder {
|
||||
* @return newly created {@link HdmiCecMessage}
|
||||
*/
|
||||
static HdmiCecMessage buildGivePhysicalAddress(int src, int dest) {
|
||||
return buildCommand(src, dest, HdmiCec.MESSAGE_GIVE_PHYSICAL_ADDRESS);
|
||||
return buildCommand(src, dest, Constants.MESSAGE_GIVE_PHYSICAL_ADDRESS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,7 +79,7 @@ public class HdmiCecMessageBuilder {
|
||||
* @return newly created {@link HdmiCecMessage}
|
||||
*/
|
||||
static HdmiCecMessage buildGiveOsdNameCommand(int src, int dest) {
|
||||
return buildCommand(src, dest, HdmiCec.MESSAGE_GIVE_OSD_NAME);
|
||||
return buildCommand(src, dest, Constants.MESSAGE_GIVE_OSD_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,7 +90,7 @@ public class HdmiCecMessageBuilder {
|
||||
* @return newly created {@link HdmiCecMessage}
|
||||
*/
|
||||
static HdmiCecMessage buildGiveDeviceVendorIdCommand(int src, int dest) {
|
||||
return buildCommand(src, dest, HdmiCec.MESSAGE_GIVE_DEVICE_VENDOR_ID);
|
||||
return buildCommand(src, dest, Constants.MESSAGE_GIVE_DEVICE_VENDOR_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -118,8 +115,8 @@ public class HdmiCecMessageBuilder {
|
||||
(byte) normalized.charAt(2),
|
||||
};
|
||||
// <Set Menu Language> is broadcast message.
|
||||
return buildCommand(src, HdmiCec.ADDR_BROADCAST, HdmiCec.MESSAGE_SET_MENU_LANGUAGE,
|
||||
params);
|
||||
return buildCommand(src, Constants.ADDR_BROADCAST,
|
||||
Constants.MESSAGE_SET_MENU_LANGUAGE, params);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -138,7 +135,7 @@ public class HdmiCecMessageBuilder {
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return null;
|
||||
}
|
||||
return buildCommand(src, dest, HdmiCec.MESSAGE_SET_OSD_NAME, params);
|
||||
return buildCommand(src, dest, Constants.MESSAGE_SET_OSD_NAME, params);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -161,8 +158,8 @@ public class HdmiCecMessageBuilder {
|
||||
(byte) deviceType
|
||||
};
|
||||
// <Report Physical Address> is broadcast message.
|
||||
return buildCommand(src, HdmiCec.ADDR_BROADCAST, HdmiCec.MESSAGE_REPORT_PHYSICAL_ADDRESS,
|
||||
params);
|
||||
return buildCommand(src, Constants.ADDR_BROADCAST,
|
||||
Constants.MESSAGE_REPORT_PHYSICAL_ADDRESS, params);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -182,8 +179,8 @@ public class HdmiCecMessageBuilder {
|
||||
(byte) (vendorId & 0xFF)
|
||||
};
|
||||
// <Device Vendor Id> is broadcast message.
|
||||
return buildCommand(src, HdmiCec.ADDR_BROADCAST, HdmiCec.MESSAGE_DEVICE_VENDOR_ID,
|
||||
params);
|
||||
return buildCommand(src, Constants.ADDR_BROADCAST,
|
||||
Constants.MESSAGE_DEVICE_VENDOR_ID, params);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -199,7 +196,7 @@ public class HdmiCecMessageBuilder {
|
||||
byte[] params = new byte[] {
|
||||
(byte) version
|
||||
};
|
||||
return buildCommand(src, dest, HdmiCec.MESSAGE_CEC_VERSION, params);
|
||||
return buildCommand(src, dest, Constants.MESSAGE_CEC_VERSION, params);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -210,7 +207,7 @@ public class HdmiCecMessageBuilder {
|
||||
* @return newly created {@link HdmiCecMessage}
|
||||
*/
|
||||
static HdmiCecMessage buildRequestArcInitiation(int src, int dest) {
|
||||
return buildCommand(src, dest, HdmiCec.MESSAGE_REQUEST_ARC_INITIATION);
|
||||
return buildCommand(src, dest, Constants.MESSAGE_REQUEST_ARC_INITIATION);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -221,7 +218,7 @@ public class HdmiCecMessageBuilder {
|
||||
* @return newly created {@link HdmiCecMessage}
|
||||
*/
|
||||
static HdmiCecMessage buildRequestArcTermination(int src, int dest) {
|
||||
return buildCommand(src, dest, HdmiCec.MESSAGE_REQUEST_ARC_TERMINATION);
|
||||
return buildCommand(src, dest, Constants.MESSAGE_REQUEST_ARC_TERMINATION);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -232,7 +229,7 @@ public class HdmiCecMessageBuilder {
|
||||
* @return newly created {@link HdmiCecMessage}
|
||||
*/
|
||||
static HdmiCecMessage buildReportArcInitiated(int src, int dest) {
|
||||
return buildCommand(src, dest, HdmiCec.MESSAGE_REPORT_ARC_INITIATED);
|
||||
return buildCommand(src, dest, Constants.MESSAGE_REPORT_ARC_INITIATED);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -243,7 +240,7 @@ public class HdmiCecMessageBuilder {
|
||||
* @return newly created {@link HdmiCecMessage}
|
||||
*/
|
||||
static HdmiCecMessage buildReportArcTerminated(int src, int dest) {
|
||||
return buildCommand(src, dest, HdmiCec.MESSAGE_REPORT_ARC_TERMINATED);
|
||||
return buildCommand(src, dest, Constants.MESSAGE_REPORT_ARC_TERMINATED);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -254,7 +251,7 @@ public class HdmiCecMessageBuilder {
|
||||
* @return newly created {@link HdmiCecMessage}
|
||||
*/
|
||||
static HdmiCecMessage buildTextViewOn(int src, int dest) {
|
||||
return buildCommand(src, dest, HdmiCec.MESSAGE_TEXT_VIEW_ON);
|
||||
return buildCommand(src, dest, Constants.MESSAGE_TEXT_VIEW_ON);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -265,7 +262,7 @@ public class HdmiCecMessageBuilder {
|
||||
* @return newly created {@link HdmiCecMessage}
|
||||
*/
|
||||
static HdmiCecMessage buildActiveSource(int src, int physicalAddress) {
|
||||
return buildCommand(src, HdmiCec.ADDR_BROADCAST, HdmiCec.MESSAGE_ACTIVE_SOURCE,
|
||||
return buildCommand(src, Constants.ADDR_BROADCAST, Constants.MESSAGE_ACTIVE_SOURCE,
|
||||
physicalAddressToParam(physicalAddress));
|
||||
}
|
||||
|
||||
@ -277,8 +274,8 @@ public class HdmiCecMessageBuilder {
|
||||
* @return newly created {@link HdmiCecMessage}
|
||||
*/
|
||||
static HdmiCecMessage buildInactiveSource(int src, int physicalAddress) {
|
||||
return buildCommand(src, HdmiCec.ADDR_BROADCAST, HdmiCec.MESSAGE_INACTIVE_SOURCE,
|
||||
physicalAddressToParam(physicalAddress));
|
||||
return buildCommand(src, Constants.ADDR_BROADCAST,
|
||||
Constants.MESSAGE_INACTIVE_SOURCE, physicalAddressToParam(physicalAddress));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -291,8 +288,8 @@ public class HdmiCecMessageBuilder {
|
||||
* @return newly created {@link HdmiCecMessage}
|
||||
*/
|
||||
static HdmiCecMessage buildSetStreamPath(int src, int streamPath) {
|
||||
return buildCommand(src, HdmiCec.ADDR_BROADCAST, HdmiCec.MESSAGE_SET_STREAM_PATH,
|
||||
physicalAddressToParam(streamPath));
|
||||
return buildCommand(src, Constants.ADDR_BROADCAST,
|
||||
Constants.MESSAGE_SET_STREAM_PATH, physicalAddressToParam(streamPath));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -310,7 +307,8 @@ public class HdmiCecMessageBuilder {
|
||||
(byte) ((oldPath >> 8) & 0xFF), (byte) (oldPath & 0xFF),
|
||||
(byte) ((newPath >> 8) & 0xFF), (byte) (newPath & 0xFF)
|
||||
};
|
||||
return buildCommand(src, HdmiCec.ADDR_BROADCAST, HdmiCec.MESSAGE_ROUTING_CHANGE, param);
|
||||
return buildCommand(src, Constants.ADDR_BROADCAST, Constants.MESSAGE_ROUTING_CHANGE,
|
||||
param);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -321,7 +319,7 @@ public class HdmiCecMessageBuilder {
|
||||
* @return newly created {@link HdmiCecMessage}
|
||||
*/
|
||||
static HdmiCecMessage buildGiveDevicePowerStatus(int src, int dest) {
|
||||
return buildCommand(src, dest, HdmiCec.MESSAGE_GIVE_DEVICE_POWER_STATUS);
|
||||
return buildCommand(src, dest, Constants.MESSAGE_GIVE_DEVICE_POWER_STATUS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -336,7 +334,7 @@ public class HdmiCecMessageBuilder {
|
||||
byte[] param = new byte[] {
|
||||
(byte) (powerStatus)
|
||||
};
|
||||
return buildCommand(src, dest, HdmiCec.MESSAGE_REPORT_POWER_STATUS, param);
|
||||
return buildCommand(src, dest, Constants.MESSAGE_REPORT_POWER_STATUS, param);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -351,10 +349,10 @@ public class HdmiCecMessageBuilder {
|
||||
static HdmiCecMessage buildSystemAudioModeRequest(int src, int avr, int avrPhysicalAddress,
|
||||
boolean enableSystemAudio) {
|
||||
if (enableSystemAudio) {
|
||||
return buildCommand(src, avr, HdmiCec.MESSAGE_SYSTEM_AUDIO_MODE_REQUEST,
|
||||
return buildCommand(src, avr, Constants.MESSAGE_SYSTEM_AUDIO_MODE_REQUEST,
|
||||
physicalAddressToParam(avrPhysicalAddress));
|
||||
} else {
|
||||
return buildCommand(src, avr, HdmiCec.MESSAGE_SYSTEM_AUDIO_MODE_REQUEST);
|
||||
return buildCommand(src, avr, Constants.MESSAGE_SYSTEM_AUDIO_MODE_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
@ -366,7 +364,7 @@ public class HdmiCecMessageBuilder {
|
||||
* @return newly created {@link HdmiCecMessage}
|
||||
*/
|
||||
static HdmiCecMessage buildGiveAudioStatus(int src, int dest) {
|
||||
return buildCommand(src, dest, HdmiCec.MESSAGE_GIVE_AUDIO_STATUS);
|
||||
return buildCommand(src, dest, Constants.MESSAGE_GIVE_AUDIO_STATUS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -390,7 +388,7 @@ public class HdmiCecMessageBuilder {
|
||||
* @return newly created {@link HdmiCecMessage}
|
||||
*/
|
||||
static HdmiCecMessage buildUserControlPressed(int src, int dest, byte[] commandParam) {
|
||||
return buildCommand(src, dest, HdmiCec.MESSAGE_USER_CONTROL_PRESSED, commandParam);
|
||||
return buildCommand(src, dest, Constants.MESSAGE_USER_CONTROL_PRESSED, commandParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -401,7 +399,7 @@ public class HdmiCecMessageBuilder {
|
||||
* @return newly created {@link HdmiCecMessage}
|
||||
*/
|
||||
static HdmiCecMessage buildUserControlReleased(int src, int dest) {
|
||||
return buildCommand(src, dest, HdmiCec.MESSAGE_USER_CONTROL_RELEASED);
|
||||
return buildCommand(src, dest, Constants.MESSAGE_USER_CONTROL_RELEASED);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -412,7 +410,7 @@ public class HdmiCecMessageBuilder {
|
||||
* @return newly created {@link HdmiCecMessage}
|
||||
*/
|
||||
static HdmiCecMessage buildGiveSystemAudioModeStatus(int src, int dest) {
|
||||
return buildCommand(src, dest, HdmiCec.MESSAGE_GIVE_SYSTEM_AUDIO_MODE_STATUS);
|
||||
return buildCommand(src, dest, Constants.MESSAGE_GIVE_SYSTEM_AUDIO_MODE_STATUS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -423,7 +421,7 @@ public class HdmiCecMessageBuilder {
|
||||
* @return newly created {@link HdmiCecMessage}
|
||||
*/
|
||||
public static HdmiCecMessage buildStandby(int src, int dest) {
|
||||
return buildCommand(src, dest, HdmiCec.MESSAGE_STANDBY);
|
||||
return buildCommand(src, dest, Constants.MESSAGE_STANDBY);
|
||||
}
|
||||
|
||||
/***** Please ADD new buildXXX() methods above. ******/
|
||||
|
@ -16,8 +16,6 @@
|
||||
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.util.FastImmutableArraySet;
|
||||
import android.util.SparseArray;
|
||||
|
||||
@ -29,12 +27,12 @@ import android.util.SparseArray;
|
||||
* to clean up messages come from the device.
|
||||
*/
|
||||
final class HdmiCecMessageCache {
|
||||
private static final FastImmutableArraySet<Integer> CACHEABLE_OPCODES = new FastImmutableArraySet<>(
|
||||
new Integer[] {
|
||||
HdmiCec.MESSAGE_SET_OSD_NAME,
|
||||
HdmiCec.MESSAGE_REPORT_PHYSICAL_ADDRESS,
|
||||
HdmiCec.MESSAGE_DEVICE_VENDOR_ID,
|
||||
HdmiCec.MESSAGE_CEC_VERSION,
|
||||
private static final FastImmutableArraySet<Integer> CACHEABLE_OPCODES =
|
||||
new FastImmutableArraySet<>(new Integer[] {
|
||||
Constants.MESSAGE_SET_OSD_NAME,
|
||||
Constants.MESSAGE_REPORT_PHYSICAL_ADDRESS,
|
||||
Constants.MESSAGE_DEVICE_VENDOR_ID,
|
||||
Constants.MESSAGE_CEC_VERSION,
|
||||
});
|
||||
|
||||
// It's like [Source Logical Address, [Opcode, HdmiCecMessage]].
|
||||
|
@ -1,98 +0,0 @@
|
||||
/*
|
||||
* 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 com.android.server.hdmi;
|
||||
|
||||
/**
|
||||
* Defines constants related to HDMI-CEC protocol internal implementation.
|
||||
* If a constant will be used in the public api, it should be located in
|
||||
* {@link android.hardware.hdmi.HdmiCec}.
|
||||
*/
|
||||
final class HdmiConstants {
|
||||
|
||||
// Constants related to operands of HDMI CEC commands.
|
||||
// Refer to CEC Table 29 in HDMI Spec v1.4b.
|
||||
// [Abort Reason]
|
||||
static final int ABORT_UNRECOGNIZED_MODE = 0;
|
||||
static final int ABORT_NOT_IN_CORRECT_MODE = 1;
|
||||
static final int ABORT_CANNOT_PROVIDE_SOURCE = 2;
|
||||
static final int ABORT_INVALID_OPERAND = 3;
|
||||
static final int ABORT_REFUSED = 4;
|
||||
static final int ABORT_UNABLE_TO_DETERMINE = 5;
|
||||
|
||||
// [Audio Status]
|
||||
static final int SYSTEM_AUDIO_STATUS_OFF = 0;
|
||||
static final int SYSTEM_AUDIO_STATUS_ON = 1;
|
||||
|
||||
// Bit mask used to get the routing path of the top level device.
|
||||
// When &'d with the path 1.2.2.0 (0x1220), for instance, gives 1.0.0.0.
|
||||
static final int ROUTING_PATH_TOP_MASK = 0xF000;
|
||||
|
||||
// Flags used for setOption to CEC HAL.
|
||||
/**
|
||||
* When set to false, HAL does not wake up the system upon receiving
|
||||
* <Image View On> or <Text View On>. Used when user changes the TV
|
||||
* settings to disable the auto TV on functionality.
|
||||
* True by default.
|
||||
*/
|
||||
static final int FLAG_HDMI_OPTION_WAKEUP = 1;
|
||||
/**
|
||||
* When set to false, all the CEC commands are discarded. Used when
|
||||
* user changes the TV settings to disable CEC functionality.
|
||||
* True by default.
|
||||
*/
|
||||
static final int FLAG_HDMI_OPTION_ENABLE_CEC = 2;
|
||||
/**
|
||||
* Setting this flag to false means Android system will stop handling
|
||||
* CEC service and yield the control over to the microprocessor that is
|
||||
* powered on through the standby mode. When set to true, the system
|
||||
* will gain the control over, hence telling the microprocessor to stop
|
||||
* handling the cec commands. This is called when system goes
|
||||
* in and out of standby mode to notify the microprocessor that it should
|
||||
* start/stop handling CEC commands on behalf of the system.
|
||||
* False by default.
|
||||
*/
|
||||
static final int FLAG_HDMI_OPTION_SYSTEM_CEC_CONTROL = 3;
|
||||
|
||||
static final int INVALID_PORT_ID = -1;
|
||||
static final int INVALID_PHYSICAL_ADDRESS = 0xFFFF;
|
||||
|
||||
// Send result codes.
|
||||
static final int SEND_RESULT_SUCCESS = 0;
|
||||
static final int SEND_RESULT_NAK = -1;
|
||||
static final int SEND_RESULT_FAILURE = -2;
|
||||
|
||||
// Strategy for device polling.
|
||||
// Should use "OR(|) operation of POLL_STRATEGY_XXX and POLL_ITERATION_XXX.
|
||||
static final int POLL_STRATEGY_MASK = 0x3; // first and second bit.
|
||||
static final int POLL_STRATEGY_REMOTES_DEVICES = 0x1;
|
||||
static final int POLL_STRATEGY_SYSTEM_AUDIO = 0x2;
|
||||
|
||||
static final int POLL_ITERATION_STRATEGY_MASK = 0x30000; // first and second bit.
|
||||
static final int POLL_ITERATION_IN_ORDER = 0x10000;
|
||||
static final int POLL_ITERATION_REVERSE_ORDER = 0x20000;
|
||||
|
||||
static final int UNKNOWN_VOLUME = -1;
|
||||
|
||||
// IRT(Initiator Repetition Time) in millisecond as recommended in the standard.
|
||||
// Outgoing UCP commands, when in 'Press and Hold' mode, should be this much apart
|
||||
// from the adjacent one so as not to place unnecessarily heavy load on the CEC line.
|
||||
// TODO: This value might need tweaking per product basis. Consider putting it
|
||||
// in config.xml to allow customization.
|
||||
static final int IRT_MS = 300;
|
||||
|
||||
private HdmiConstants() { /* cannot be instantiated */ }
|
||||
}
|
@ -21,11 +21,11 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecDeviceInfo;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.hardware.hdmi.HdmiControlManager;
|
||||
import android.hardware.hdmi.HdmiHotplugEvent;
|
||||
import android.hardware.hdmi.HdmiPortInfo;
|
||||
import android.hardware.hdmi.HdmiTvClient;
|
||||
import android.hardware.hdmi.IHdmiControlCallback;
|
||||
import android.hardware.hdmi.IHdmiControlService;
|
||||
import android.hardware.hdmi.IHdmiDeviceEventListener;
|
||||
@ -181,7 +181,7 @@ public final class HdmiControlService extends SystemService {
|
||||
private final PowerStateReceiver mPowerStateReceiver = new PowerStateReceiver();
|
||||
|
||||
@ServiceThreadOnly
|
||||
private int mPowerStatus = HdmiCec.POWER_STATUS_STANDBY;
|
||||
private int mPowerStatus = HdmiControlManager.POWER_STATUS_STANDBY;
|
||||
|
||||
@ServiceThreadOnly
|
||||
private boolean mStandbyMessageReceived = false;
|
||||
@ -195,11 +195,12 @@ public final class HdmiControlService extends SystemService {
|
||||
@Override
|
||||
public void onStart() {
|
||||
mIoThread.start();
|
||||
mPowerStatus = HdmiCec.POWER_STATUS_TRANSIENT_TO_ON;
|
||||
mPowerStatus = HdmiControlManager.POWER_STATUS_TRANSIENT_TO_ON;
|
||||
mCecController = HdmiCecController.create(this);
|
||||
|
||||
if (mCecController != null) {
|
||||
mCecController.setOption(HdmiCec.OPTION_CEC_SERVICE_CONTROL, HdmiCec.DISABLED);
|
||||
mCecController.setOption(HdmiTvClient.OPTION_CEC_SERVICE_CONTROL,
|
||||
HdmiTvClient.DISABLED);
|
||||
initializeLocalDevices(mLocalDevices);
|
||||
} else {
|
||||
Slog.i(TAG, "Device does not support HDMI-CEC.");
|
||||
@ -241,7 +242,7 @@ public final class HdmiControlService extends SystemService {
|
||||
localDevice.getPreferredAddress(), new AllocateAddressCallback() {
|
||||
@Override
|
||||
public void onAllocated(int deviceType, int logicalAddress) {
|
||||
if (logicalAddress == HdmiCec.ADDR_UNREGISTERED) {
|
||||
if (logicalAddress == Constants.ADDR_UNREGISTERED) {
|
||||
Slog.e(TAG, "Failed to allocate address:[device_type:" + deviceType + "]");
|
||||
} else {
|
||||
HdmiCecDeviceInfo deviceInfo = createDeviceInfo(logicalAddress, deviceType);
|
||||
@ -254,8 +255,8 @@ public final class HdmiControlService extends SystemService {
|
||||
|
||||
// Address allocation completed for all devices. Notify each device.
|
||||
if (deviceTypes.size() == finished.size()) {
|
||||
if (mPowerStatus == HdmiCec.POWER_STATUS_TRANSIENT_TO_ON) {
|
||||
mPowerStatus = HdmiCec.POWER_STATUS_ON;
|
||||
if (mPowerStatus == HdmiControlManager.POWER_STATUS_TRANSIENT_TO_ON) {
|
||||
mPowerStatus = HdmiControlManager.POWER_STATUS_ON;
|
||||
}
|
||||
notifyAddressAllocated(devices);
|
||||
}
|
||||
@ -344,7 +345,7 @@ public final class HdmiControlService extends SystemService {
|
||||
HdmiPortInfo portInfo = getPortInfo(portId);
|
||||
if (portInfo == null) {
|
||||
Slog.e(TAG, "Cannot find the port info: " + portId);
|
||||
return HdmiConstants.INVALID_PHYSICAL_ADDRESS;
|
||||
return Constants.INVALID_PHYSICAL_ADDRESS;
|
||||
}
|
||||
return portInfo.getAddress();
|
||||
}
|
||||
@ -356,13 +357,13 @@ public final class HdmiControlService extends SystemService {
|
||||
* 0x1000 (1.0.0.0) which is the topmost path of the given routing path.
|
||||
*/
|
||||
int pathToPortId(int path) {
|
||||
int portAddress = path & HdmiConstants.ROUTING_PATH_TOP_MASK;
|
||||
int portAddress = path & Constants.ROUTING_PATH_TOP_MASK;
|
||||
for (HdmiPortInfo info : mPortInfo) {
|
||||
if (portAddress == info.getAddress()) {
|
||||
return info.getId();
|
||||
}
|
||||
}
|
||||
return HdmiConstants.INVALID_PORT_ID;
|
||||
return Constants.INVALID_PORT_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -475,12 +476,12 @@ public final class HdmiControlService extends SystemService {
|
||||
assertRunOnServiceThread();
|
||||
for (HdmiCecLocalDevice device : mCecController.getLocalDeviceList()) {
|
||||
if (device.dispatchMessage(message)
|
||||
&& message.getDestination() != HdmiCec.ADDR_BROADCAST) {
|
||||
&& message.getDestination() != Constants.ADDR_BROADCAST) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (message.getDestination() != HdmiCec.ADDR_BROADCAST) {
|
||||
if (message.getDestination() != Constants.ADDR_BROADCAST) {
|
||||
Slog.w(TAG, "Unhandled cec command:" + message);
|
||||
}
|
||||
return false;
|
||||
@ -520,11 +521,11 @@ public final class HdmiControlService extends SystemService {
|
||||
}
|
||||
|
||||
private int checkPollStrategy(int pickStrategy) {
|
||||
int strategy = pickStrategy & HdmiConstants.POLL_STRATEGY_MASK;
|
||||
int strategy = pickStrategy & Constants.POLL_STRATEGY_MASK;
|
||||
if (strategy == 0) {
|
||||
throw new IllegalArgumentException("Invalid poll strategy:" + pickStrategy);
|
||||
}
|
||||
int iterationStrategy = pickStrategy & HdmiConstants.POLL_ITERATION_STRATEGY_MASK;
|
||||
int iterationStrategy = pickStrategy & Constants.POLL_ITERATION_STRATEGY_MASK;
|
||||
if (iterationStrategy == 0) {
|
||||
throw new IllegalArgumentException("Invalid iteration strategy:" + pickStrategy);
|
||||
}
|
||||
@ -632,7 +633,7 @@ public final class HdmiControlService extends SystemService {
|
||||
HdmiCecLocalDeviceTv tv = tv();
|
||||
if (tv == null) {
|
||||
Slog.w(TAG, "Local tv device not available");
|
||||
invokeCallback(callback, HdmiCec.RESULT_SOURCE_NOT_AVAILABLE);
|
||||
invokeCallback(callback, HdmiControlManager.RESULT_SOURCE_NOT_AVAILABLE);
|
||||
return;
|
||||
}
|
||||
tv.deviceSelect(logicalAddress, callback);
|
||||
@ -649,7 +650,7 @@ public final class HdmiControlService extends SystemService {
|
||||
HdmiCecLocalDeviceTv tv = tv();
|
||||
if (tv == null) {
|
||||
Slog.w(TAG, "Local tv device not available");
|
||||
invokeCallback(callback, HdmiCec.RESULT_SOURCE_NOT_AVAILABLE);
|
||||
invokeCallback(callback, HdmiControlManager.RESULT_SOURCE_NOT_AVAILABLE);
|
||||
return;
|
||||
}
|
||||
tv.doManualPortSwitching(portId, callback);
|
||||
@ -765,7 +766,7 @@ public final class HdmiControlService extends SystemService {
|
||||
HdmiCecLocalDeviceTv tv = tv();
|
||||
if (tv == null) {
|
||||
Slog.w(TAG, "Local tv device not available");
|
||||
invokeCallback(callback, HdmiCec.RESULT_SOURCE_NOT_AVAILABLE);
|
||||
invokeCallback(callback, HdmiControlManager.RESULT_SOURCE_NOT_AVAILABLE);
|
||||
return;
|
||||
}
|
||||
tv.changeSystemAudioMode(enabled, callback);
|
||||
@ -823,10 +824,10 @@ public final class HdmiControlService extends SystemService {
|
||||
if (tv == null) {
|
||||
return;
|
||||
}
|
||||
int value = enabled ? HdmiCec.ENABLED : HdmiCec.DISABLED;
|
||||
mCecController.setOption(HdmiCec.OPTION_CEC_ENABLE, value);
|
||||
int value = enabled ? HdmiTvClient.ENABLED : HdmiTvClient.DISABLED;
|
||||
mCecController.setOption(HdmiTvClient.OPTION_CEC_ENABLE, value);
|
||||
if (mMhlController != null) {
|
||||
mMhlController.setOption(HdmiCec.OPTION_MHL_ENABLE, value);
|
||||
mMhlController.setOption(HdmiTvClient.OPTION_MHL_ENABLE, value);
|
||||
}
|
||||
tv.launchRoutingControl(false);
|
||||
}
|
||||
@ -888,15 +889,15 @@ public final class HdmiControlService extends SystemService {
|
||||
return;
|
||||
}
|
||||
switch (key) {
|
||||
case HdmiCec.OPTION_CEC_AUTO_WAKEUP:
|
||||
case HdmiTvClient.OPTION_CEC_AUTO_WAKEUP:
|
||||
mCecController.setOption(key, value);
|
||||
break;
|
||||
case HdmiCec.OPTION_CEC_AUTO_DEVICE_OFF:
|
||||
case HdmiTvClient.OPTION_CEC_AUTO_DEVICE_OFF:
|
||||
// No need to pass this option to HAL.
|
||||
tv().setAutoDeviceOff(value == HdmiCec.ENABLED);
|
||||
tv().setAutoDeviceOff(value == HdmiTvClient.ENABLED);
|
||||
break;
|
||||
case HdmiCec.OPTION_MHL_INPUT_SWITCHING: // Fall through
|
||||
case HdmiCec.OPTION_MHL_POWER_CHARGE:
|
||||
case HdmiTvClient.OPTION_MHL_INPUT_SWITCHING: // Fall through
|
||||
case HdmiTvClient.OPTION_MHL_POWER_CHARGE:
|
||||
if (mMhlController != null) {
|
||||
mMhlController.setOption(key, value);
|
||||
}
|
||||
@ -924,7 +925,7 @@ public final class HdmiControlService extends SystemService {
|
||||
HdmiCecLocalDevicePlayback source = playback();
|
||||
if (source == null) {
|
||||
Slog.w(TAG, "Local playback device not available");
|
||||
invokeCallback(callback, HdmiCec.RESULT_SOURCE_NOT_AVAILABLE);
|
||||
invokeCallback(callback, HdmiControlManager.RESULT_SOURCE_NOT_AVAILABLE);
|
||||
return;
|
||||
}
|
||||
source.oneTouchPlay(callback);
|
||||
@ -936,7 +937,7 @@ public final class HdmiControlService extends SystemService {
|
||||
HdmiCecLocalDevicePlayback source = playback();
|
||||
if (source == null) {
|
||||
Slog.w(TAG, "Local playback device not available");
|
||||
invokeCallback(callback, HdmiCec.RESULT_SOURCE_NOT_AVAILABLE);
|
||||
invokeCallback(callback, HdmiControlManager.RESULT_SOURCE_NOT_AVAILABLE);
|
||||
return;
|
||||
}
|
||||
source.queryDisplayStatus(callback);
|
||||
@ -1095,16 +1096,17 @@ public final class HdmiControlService extends SystemService {
|
||||
}
|
||||
|
||||
private static boolean hasSameTopPort(int path1, int path2) {
|
||||
return (path1 & HdmiConstants.ROUTING_PATH_TOP_MASK)
|
||||
== (path2 & HdmiConstants.ROUTING_PATH_TOP_MASK);
|
||||
return (path1 & Constants.ROUTING_PATH_TOP_MASK)
|
||||
== (path2 & Constants.ROUTING_PATH_TOP_MASK);
|
||||
}
|
||||
|
||||
private HdmiCecLocalDeviceTv tv() {
|
||||
return (HdmiCecLocalDeviceTv) mCecController.getLocalDevice(HdmiCec.DEVICE_TV);
|
||||
return (HdmiCecLocalDeviceTv) mCecController.getLocalDevice(HdmiCecDeviceInfo.DEVICE_TV);
|
||||
}
|
||||
|
||||
private HdmiCecLocalDevicePlayback playback() {
|
||||
return (HdmiCecLocalDevicePlayback) mCecController.getLocalDevice(HdmiCec.DEVICE_PLAYBACK);
|
||||
return (HdmiCecLocalDevicePlayback)
|
||||
mCecController.getLocalDevice(HdmiCecDeviceInfo.DEVICE_PLAYBACK);
|
||||
}
|
||||
|
||||
AudioManager getAudioManager() {
|
||||
@ -1122,17 +1124,17 @@ public final class HdmiControlService extends SystemService {
|
||||
}
|
||||
|
||||
boolean isPowerOnOrTransient() {
|
||||
return mPowerStatus == HdmiCec.POWER_STATUS_ON
|
||||
|| mPowerStatus == HdmiCec.POWER_STATUS_TRANSIENT_TO_ON;
|
||||
return mPowerStatus == HdmiControlManager.POWER_STATUS_ON
|
||||
|| mPowerStatus == HdmiControlManager.POWER_STATUS_TRANSIENT_TO_ON;
|
||||
}
|
||||
|
||||
boolean isPowerStandbyOrTransient() {
|
||||
return mPowerStatus == HdmiCec.POWER_STATUS_STANDBY
|
||||
|| mPowerStatus == HdmiCec.POWER_STATUS_TRANSIENT_TO_STANDBY;
|
||||
return mPowerStatus == HdmiControlManager.POWER_STATUS_STANDBY
|
||||
|| mPowerStatus == HdmiControlManager.POWER_STATUS_TRANSIENT_TO_STANDBY;
|
||||
}
|
||||
|
||||
boolean isPowerStandby() {
|
||||
return mPowerStatus == HdmiCec.POWER_STATUS_STANDBY;
|
||||
return mPowerStatus == HdmiControlManager.POWER_STATUS_STANDBY;
|
||||
}
|
||||
|
||||
@ServiceThreadOnly
|
||||
@ -1157,9 +1159,9 @@ public final class HdmiControlService extends SystemService {
|
||||
@ServiceThreadOnly
|
||||
private void onWakeUp() {
|
||||
assertRunOnServiceThread();
|
||||
mPowerStatus = HdmiCec.POWER_STATUS_TRANSIENT_TO_ON;
|
||||
mPowerStatus = HdmiControlManager.POWER_STATUS_TRANSIENT_TO_ON;
|
||||
if (mCecController != null) {
|
||||
mCecController.setOption(HdmiCec.OPTION_CEC_SERVICE_CONTROL, HdmiCec.ENABLED);
|
||||
mCecController.setOption(HdmiTvClient.OPTION_CEC_SERVICE_CONTROL, HdmiTvClient.ENABLED);
|
||||
initializeLocalDevices(mLocalDevices);
|
||||
} else {
|
||||
Slog.i(TAG, "Device does not support HDMI-CEC.");
|
||||
@ -1170,7 +1172,7 @@ public final class HdmiControlService extends SystemService {
|
||||
@ServiceThreadOnly
|
||||
private void onStandby() {
|
||||
assertRunOnServiceThread();
|
||||
mPowerStatus = HdmiCec.POWER_STATUS_TRANSIENT_TO_STANDBY;
|
||||
mPowerStatus = HdmiControlManager.POWER_STATUS_TRANSIENT_TO_STANDBY;
|
||||
for (HdmiCecLocalDevice device : mCecController.getLocalDeviceList()) {
|
||||
device.onTransitionToStandby(mStandbyMessageReceived);
|
||||
}
|
||||
@ -1184,15 +1186,15 @@ public final class HdmiControlService extends SystemService {
|
||||
@ServiceThreadOnly
|
||||
void onPendingActionsCleared() {
|
||||
assertRunOnServiceThread();
|
||||
if (mPowerStatus != HdmiCec.POWER_STATUS_TRANSIENT_TO_STANDBY) {
|
||||
if (mPowerStatus != HdmiControlManager.POWER_STATUS_TRANSIENT_TO_STANDBY) {
|
||||
return;
|
||||
}
|
||||
mPowerStatus = HdmiCec.POWER_STATUS_STANDBY;
|
||||
mPowerStatus = HdmiControlManager.POWER_STATUS_STANDBY;
|
||||
for (HdmiCecLocalDevice device : mCecController.getLocalDeviceList()) {
|
||||
device.onStandBy(mStandbyMessageReceived);
|
||||
}
|
||||
mStandbyMessageReceived = false;
|
||||
mCecController.setOption(HdmiCec.OPTION_CEC_SERVICE_CONTROL, HdmiCec.DISABLED);
|
||||
mCecController.setOption(HdmiTvClient.OPTION_CEC_SERVICE_CONTROL, HdmiTvClient.DISABLED);
|
||||
}
|
||||
|
||||
boolean isProhibitMode() {
|
||||
|
@ -16,8 +16,7 @@
|
||||
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.hardware.hdmi.HdmiCecDeviceInfo;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
|
||||
@ -30,8 +29,99 @@ import java.util.List;
|
||||
*/
|
||||
final class HdmiUtils {
|
||||
|
||||
private static final int[] ADDRESS_TO_TYPE = {
|
||||
HdmiCecDeviceInfo.DEVICE_TV, // ADDR_TV
|
||||
HdmiCecDeviceInfo.DEVICE_RECORDER, // ADDR_RECORDER_1
|
||||
HdmiCecDeviceInfo.DEVICE_RECORDER, // ADDR_RECORDER_2
|
||||
HdmiCecDeviceInfo.DEVICE_TUNER, // ADDR_TUNER_1
|
||||
HdmiCecDeviceInfo.DEVICE_PLAYBACK, // ADDR_PLAYBACK_1
|
||||
HdmiCecDeviceInfo.DEVICE_AUDIO_SYSTEM, // ADDR_AUDIO_SYSTEM
|
||||
HdmiCecDeviceInfo.DEVICE_TUNER, // ADDR_TUNER_2
|
||||
HdmiCecDeviceInfo.DEVICE_TUNER, // ADDR_TUNER_3
|
||||
HdmiCecDeviceInfo.DEVICE_PLAYBACK, // ADDR_PLAYBACK_2
|
||||
HdmiCecDeviceInfo.DEVICE_RECORDER, // ADDR_RECORDER_3
|
||||
HdmiCecDeviceInfo.DEVICE_TUNER, // ADDR_TUNER_4
|
||||
HdmiCecDeviceInfo.DEVICE_PLAYBACK, // ADDR_PLAYBACK_3
|
||||
HdmiCecDeviceInfo.DEVICE_RESERVED,
|
||||
HdmiCecDeviceInfo.DEVICE_RESERVED,
|
||||
HdmiCecDeviceInfo.DEVICE_TV, // ADDR_SPECIFIC_USE
|
||||
};
|
||||
|
||||
private static final String[] DEFAULT_NAMES = {
|
||||
"TV",
|
||||
"Recorder_1",
|
||||
"Recorder_2",
|
||||
"Tuner_1",
|
||||
"Playback_1",
|
||||
"AudioSystem",
|
||||
"Tuner_2",
|
||||
"Tuner_3",
|
||||
"Playback_2",
|
||||
"Recorder_3",
|
||||
"Tuner_4",
|
||||
"Playback_3",
|
||||
"Reserved_1",
|
||||
"Reserved_2",
|
||||
"Secondary_TV",
|
||||
};
|
||||
|
||||
private HdmiUtils() { /* cannot be instantiated */ }
|
||||
|
||||
/**
|
||||
* Check if the given type is valid. A valid type is one of the actual
|
||||
* logical device types defined in the standard ({@link #DEVICE_TV},
|
||||
* {@link #DEVICE_PLAYBACK}, {@link #DEVICE_TUNER}, {@link #DEVICE_RECORDER},
|
||||
* and {@link #DEVICE_AUDIO_SYSTEM}).
|
||||
*
|
||||
* @param type device type
|
||||
* @return true if the given type is valid
|
||||
*/
|
||||
static boolean isValidType(int type) {
|
||||
return (HdmiCecDeviceInfo.DEVICE_TV <= type && type <= HdmiCecDeviceInfo.DEVICE_AUDIO_SYSTEM)
|
||||
&& type != HdmiCecDeviceInfo.DEVICE_RESERVED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given logical address is valid. A logical address is valid
|
||||
* if it is one allocated for an actual device which allows communication
|
||||
* with other logical devices.
|
||||
*
|
||||
* @param address logical address
|
||||
* @return true if the given address is valid
|
||||
*/
|
||||
static boolean isValidAddress(int address) {
|
||||
return (Constants.ADDR_TV <= address && address <= Constants.ADDR_SPECIFIC_USE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the device type for the given logical address.
|
||||
*
|
||||
* @param address logical address
|
||||
* @return device type for the given logical address; DEVICE_INACTIVE
|
||||
* if the address is not valid.
|
||||
*/
|
||||
static int getTypeFromAddress(int address) {
|
||||
if (isValidAddress(address)) {
|
||||
return ADDRESS_TO_TYPE[address];
|
||||
}
|
||||
return HdmiCecDeviceInfo.DEVICE_INACTIVE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default device name for a logical address. This is the name
|
||||
* by which the logical device is known to others until a name is
|
||||
* set explicitly using HdmiCecService.setOsdName.
|
||||
*
|
||||
* @param address logical address
|
||||
* @return default device name; empty string if the address is not valid
|
||||
*/
|
||||
static String getDefaultDeviceName(int address) {
|
||||
if (isValidAddress(address)) {
|
||||
return DEFAULT_NAMES[address];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the given address is for the given device type. If not it will throw
|
||||
* {@link IllegalArgumentException}.
|
||||
@ -41,7 +131,7 @@ final class HdmiUtils {
|
||||
* @throw IllegalArgumentException
|
||||
*/
|
||||
static void verifyAddressType(int logicalAddress, int deviceType) {
|
||||
int actualDeviceType = HdmiCec.getTypeFromAddress(logicalAddress);
|
||||
int actualDeviceType = getTypeFromAddress(logicalAddress);
|
||||
if (actualDeviceType != deviceType) {
|
||||
throw new IllegalArgumentException("Device type missmatch:[Expected:" + deviceType
|
||||
+ ", Actual:" + actualDeviceType);
|
||||
@ -74,7 +164,7 @@ final class HdmiUtils {
|
||||
static boolean parseCommandParamSystemAudioStatus(HdmiCecMessage cmd) {
|
||||
// TODO: Handle the exception when the length is wrong.
|
||||
return cmd.getParams().length > 0
|
||||
&& cmd.getParams()[0] == HdmiConstants.SYSTEM_AUDIO_STATUS_ON;
|
||||
&& cmd.getParams()[0] == Constants.SYSTEM_AUDIO_STATUS_ON;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -192,5 +282,4 @@ final class HdmiUtils {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,9 +16,7 @@
|
||||
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecDeviceInfo;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.server.hdmi.HdmiControlService.DevicePollingCallback;
|
||||
@ -46,7 +44,8 @@ final class HotplugDetectionAction extends FeatureAction {
|
||||
private static final int STATE_WAIT_FOR_NEXT_POLLING = 1;
|
||||
|
||||
// All addresses except for broadcast (unregistered address).
|
||||
private static final int NUM_OF_ADDRESS = HdmiCec.ADDR_SPECIFIC_USE - HdmiCec.ADDR_TV + 1;
|
||||
private static final int NUM_OF_ADDRESS = Constants.ADDR_SPECIFIC_USE
|
||||
- Constants.ADDR_TV + 1;
|
||||
|
||||
private int mTimeoutCount = 0;
|
||||
|
||||
@ -126,8 +125,8 @@ final class HotplugDetectionAction extends FeatureAction {
|
||||
public void onPollingFinished(List<Integer> ackedAddress) {
|
||||
checkHotplug(ackedAddress, false);
|
||||
}
|
||||
}, HdmiConstants.POLL_ITERATION_IN_ORDER
|
||||
| HdmiConstants.POLL_STRATEGY_REMOTES_DEVICES, POLL_RETRY_COUNT);
|
||||
}, Constants.POLL_ITERATION_IN_ORDER
|
||||
| Constants.POLL_STRATEGY_REMOTES_DEVICES, POLL_RETRY_COUNT);
|
||||
}
|
||||
|
||||
private void pollAudioSystem() {
|
||||
@ -138,8 +137,8 @@ final class HotplugDetectionAction extends FeatureAction {
|
||||
public void onPollingFinished(List<Integer> ackedAddress) {
|
||||
checkHotplug(ackedAddress, true);
|
||||
}
|
||||
}, HdmiConstants.POLL_ITERATION_IN_ORDER
|
||||
| HdmiConstants.POLL_STRATEGY_SYSTEM_AUDIO, POLL_RETRY_COUNT);
|
||||
}, Constants.POLL_ITERATION_IN_ORDER
|
||||
| Constants.POLL_STRATEGY_SYSTEM_AUDIO, POLL_RETRY_COUNT);
|
||||
}
|
||||
|
||||
private void checkHotplug(List<Integer> ackedAddress, boolean audioOnly) {
|
||||
@ -167,7 +166,7 @@ final class HotplugDetectionAction extends FeatureAction {
|
||||
BitSet set = new BitSet(NUM_OF_ADDRESS);
|
||||
for (HdmiCecDeviceInfo info : infoList) {
|
||||
if (audioOnly) {
|
||||
if (info.getDeviceType() == HdmiCec.DEVICE_AUDIO_SYSTEM) {
|
||||
if (info.getDeviceType() == HdmiCecDeviceInfo.DEVICE_AUDIO_SYSTEM) {
|
||||
set.set(info.getLogicalAddress());
|
||||
}
|
||||
} else {
|
||||
@ -233,7 +232,7 @@ final class HotplugDetectionAction extends FeatureAction {
|
||||
}
|
||||
|
||||
private void mayDisableSystemAudioAndARC(int address) {
|
||||
if (HdmiCec.getTypeFromAddress(address) != HdmiCec.DEVICE_AUDIO_SYSTEM) {
|
||||
if (HdmiUtils.getTypeFromAddress(address) != HdmiCecDeviceInfo.DEVICE_AUDIO_SYSTEM) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,7 @@
|
||||
*/
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecDeviceInfo;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.util.Slog;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@ -65,12 +63,13 @@ final class NewDeviceAction extends FeatureAction {
|
||||
super(source);
|
||||
mDeviceLogicalAddress = deviceLogicalAddress;
|
||||
mDevicePhysicalAddress = devicePhysicalAddress;
|
||||
mVendorId = HdmiCec.UNKNOWN_VENDOR_ID;
|
||||
mVendorId = Constants.UNKNOWN_VENDOR_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
if (HdmiCec.getTypeFromAddress(getSourceAddress()) == HdmiCec.DEVICE_AUDIO_SYSTEM) {
|
||||
if (HdmiUtils.getTypeFromAddress(getSourceAddress())
|
||||
== HdmiCecDeviceInfo.DEVICE_AUDIO_SYSTEM) {
|
||||
if (tv().getAvrDeviceInfo() == null) {
|
||||
// TODO: Start system audio initiation action
|
||||
}
|
||||
@ -82,7 +81,7 @@ final class NewDeviceAction extends FeatureAction {
|
||||
}
|
||||
|
||||
mState = STATE_WAITING_FOR_SET_OSD_NAME;
|
||||
if (mayProcessCommandIfCached(mDeviceLogicalAddress, HdmiCec.MESSAGE_SET_OSD_NAME)) {
|
||||
if (mayProcessCommandIfCached(mDeviceLogicalAddress, Constants.MESSAGE_SET_OSD_NAME)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -111,7 +110,7 @@ final class NewDeviceAction extends FeatureAction {
|
||||
}
|
||||
|
||||
if (mState == STATE_WAITING_FOR_SET_OSD_NAME) {
|
||||
if (opcode == HdmiCec.MESSAGE_SET_OSD_NAME) {
|
||||
if (opcode == Constants.MESSAGE_SET_OSD_NAME) {
|
||||
try {
|
||||
mDisplayName = new String(params, "US-ASCII");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
@ -119,15 +118,15 @@ final class NewDeviceAction extends FeatureAction {
|
||||
}
|
||||
requestVendorId();
|
||||
return true;
|
||||
} else if (opcode == HdmiCec.MESSAGE_FEATURE_ABORT) {
|
||||
} else if (opcode == Constants.MESSAGE_FEATURE_ABORT) {
|
||||
int requestOpcode = params[1] & 0xFF;
|
||||
if (requestOpcode == HdmiCec.MESSAGE_SET_OSD_NAME) {
|
||||
if (requestOpcode == Constants.MESSAGE_SET_OSD_NAME) {
|
||||
requestVendorId();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (mState == STATE_WAITING_FOR_DEVICE_VENDOR_ID) {
|
||||
if (opcode == HdmiCec.MESSAGE_DEVICE_VENDOR_ID) {
|
||||
if (opcode == Constants.MESSAGE_DEVICE_VENDOR_ID) {
|
||||
if (params.length == 3) {
|
||||
mVendorId = HdmiUtils.threeBytesToInt(params);
|
||||
} else {
|
||||
@ -136,9 +135,9 @@ final class NewDeviceAction extends FeatureAction {
|
||||
addDeviceInfo();
|
||||
finish();
|
||||
return true;
|
||||
} else if (opcode == HdmiCec.MESSAGE_FEATURE_ABORT) {
|
||||
} else if (opcode == Constants.MESSAGE_FEATURE_ABORT) {
|
||||
int requestOpcode = params[1] & 0xFF;
|
||||
if (requestOpcode == HdmiCec.MESSAGE_DEVICE_VENDOR_ID) {
|
||||
if (requestOpcode == Constants.MESSAGE_DEVICE_VENDOR_ID) {
|
||||
addDeviceInfo();
|
||||
finish();
|
||||
return true;
|
||||
@ -160,7 +159,8 @@ final class NewDeviceAction extends FeatureAction {
|
||||
// At first, transit to waiting status for <Device Vendor Id>.
|
||||
mState = STATE_WAITING_FOR_DEVICE_VENDOR_ID;
|
||||
// If the message is already in cache, process it.
|
||||
if (mayProcessCommandIfCached(mDeviceLogicalAddress, HdmiCec.MESSAGE_DEVICE_VENDOR_ID)) {
|
||||
if (mayProcessCommandIfCached(mDeviceLogicalAddress,
|
||||
Constants.MESSAGE_DEVICE_VENDOR_ID)) {
|
||||
return;
|
||||
}
|
||||
sendCommand(HdmiCecMessageBuilder.buildGiveDeviceVendorIdCommand(getSourceAddress(),
|
||||
@ -170,11 +170,11 @@ final class NewDeviceAction extends FeatureAction {
|
||||
|
||||
private void addDeviceInfo() {
|
||||
if (mDisplayName == null) {
|
||||
mDisplayName = HdmiCec.getDefaultDeviceName(mDeviceLogicalAddress);
|
||||
mDisplayName = HdmiUtils.getDefaultDeviceName(mDeviceLogicalAddress);
|
||||
}
|
||||
tv().addCecDevice(new HdmiCecDeviceInfo(
|
||||
mDeviceLogicalAddress, mDevicePhysicalAddress,
|
||||
HdmiCec.getTypeFromAddress(mDeviceLogicalAddress),
|
||||
HdmiUtils.getTypeFromAddress(mDeviceLogicalAddress),
|
||||
mVendorId, mDisplayName));
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,6 @@
|
||||
*/
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.hardware.hdmi.HdmiControlManager;
|
||||
import android.hardware.hdmi.IHdmiControlCallback;
|
||||
import android.os.RemoteException;
|
||||
@ -98,11 +96,11 @@ final class OneTouchPlayAction extends FeatureAction {
|
||||
if (mState != STATE_WAITING_FOR_REPORT_POWER_STATUS) {
|
||||
return false;
|
||||
}
|
||||
if (cmd.getOpcode() == HdmiCec.MESSAGE_REPORT_POWER_STATUS) {
|
||||
if (cmd.getOpcode() == Constants.MESSAGE_REPORT_POWER_STATUS) {
|
||||
int status = cmd.getParams()[0];
|
||||
if (status == HdmiCec.POWER_STATUS_ON) {
|
||||
if (status == HdmiControlManager.POWER_STATUS_ON) {
|
||||
broadcastActiveSource();
|
||||
invokeCallback(HdmiCec.RESULT_SUCCESS);
|
||||
invokeCallback(HdmiControlManager.RESULT_SUCCESS);
|
||||
finish();
|
||||
}
|
||||
return true;
|
||||
@ -121,7 +119,7 @@ final class OneTouchPlayAction extends FeatureAction {
|
||||
addTimer(mState, FeatureAction.TIMEOUT_MS);
|
||||
} else {
|
||||
// Couldn't wake up the TV for whatever reason. Report failure.
|
||||
invokeCallback(HdmiCec.RESULT_TIMEOUT);
|
||||
invokeCallback(HdmiControlManager.RESULT_TIMEOUT);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,8 @@
|
||||
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.hardware.hdmi.HdmiCecDeviceInfo;
|
||||
|
||||
import android.util.Slog;
|
||||
|
||||
/**
|
||||
@ -42,8 +42,8 @@ abstract class RequestArcAction extends FeatureAction {
|
||||
*/
|
||||
RequestArcAction(HdmiCecLocalDevice source, int avrAddress) {
|
||||
super(source);
|
||||
HdmiUtils.verifyAddressType(getSourceAddress(), HdmiCec.DEVICE_TV);
|
||||
HdmiUtils.verifyAddressType(avrAddress, HdmiCec.DEVICE_AUDIO_SYSTEM);
|
||||
HdmiUtils.verifyAddressType(getSourceAddress(), HdmiCecDeviceInfo.DEVICE_TV);
|
||||
HdmiUtils.verifyAddressType(avrAddress, HdmiCecDeviceInfo.DEVICE_AUDIO_SYSTEM);
|
||||
mAvrAddress = avrAddress;
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ abstract class RequestArcAction extends FeatureAction {
|
||||
// Handles only <Feature Abort> here and, both <Initiate ARC> and <Terminate ARC>
|
||||
// are handled in HdmiControlService itself because both can be
|
||||
// received wihtout <Request ARC Initiation> or <Request ARC Termination>.
|
||||
case HdmiCec.MESSAGE_FEATURE_ABORT:
|
||||
case Constants.MESSAGE_FEATURE_ABORT:
|
||||
disableArcTransmission();
|
||||
finish();
|
||||
return true;
|
||||
|
@ -16,8 +16,6 @@
|
||||
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
|
||||
/**
|
||||
* Feature action that handles ARC action initiated by TV devices.
|
||||
*
|
||||
@ -42,7 +40,7 @@ final class RequestArcInitiationAction extends RequestArcAction {
|
||||
sendCommand(command, new HdmiControlService.SendMessageCallback() {
|
||||
@Override
|
||||
public void onSendCompleted(int error) {
|
||||
if (error == HdmiConstants.SEND_RESULT_SUCCESS) {
|
||||
if (error == Constants.SEND_RESULT_SUCCESS) {
|
||||
mState = STATE_WATING_FOR_REQUEST_ARC_REQUEST_RESPONSE;
|
||||
addTimer(mState, TIMEOUT_MS);
|
||||
} else {
|
||||
|
@ -16,8 +16,6 @@
|
||||
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
|
||||
/**
|
||||
* Feature action to handle <Request ARC Termination>.
|
||||
*
|
||||
@ -42,7 +40,7 @@ final class RequestArcTerminationAction extends RequestArcAction {
|
||||
sendCommand(command, new HdmiControlService.SendMessageCallback() {
|
||||
@Override
|
||||
public void onSendCompleted(int error) {
|
||||
if (error == HdmiConstants.SEND_RESULT_SUCCESS) {
|
||||
if (error == Constants.SEND_RESULT_SUCCESS) {
|
||||
mState = STATE_WATING_FOR_REQUEST_ARC_REQUEST_RESPONSE;
|
||||
addTimer(mState, TIMEOUT_MS);
|
||||
} else {
|
||||
|
@ -17,9 +17,8 @@
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecDeviceInfo;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.hardware.hdmi.HdmiControlManager;
|
||||
import android.hardware.hdmi.IHdmiControlCallback;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
@ -86,7 +85,7 @@ final class RoutingControlAction extends FeatureAction {
|
||||
int opcode = cmd.getOpcode();
|
||||
byte[] params = cmd.getParams();
|
||||
if (mState == STATE_WAIT_FOR_ROUTING_INFORMATION
|
||||
&& opcode == HdmiCec.MESSAGE_ROUTING_INFORMATION) {
|
||||
&& opcode == Constants.MESSAGE_ROUTING_INFORMATION) {
|
||||
// Keep updating the physicalAddress as we receive <Routing Information>.
|
||||
// If the routing path doesn't belong to the currently active one, we should
|
||||
// ignore it since it might have come from other routing change sequence.
|
||||
@ -100,7 +99,7 @@ final class RoutingControlAction extends FeatureAction {
|
||||
addTimer(mState, TIMEOUT_ROUTING_INFORMATION_MS);
|
||||
return true;
|
||||
} else if (mState == STATE_WAIT_FOR_REPORT_POWER_STATUS
|
||||
&& opcode == HdmiCec.MESSAGE_REPORT_POWER_STATUS) {
|
||||
&& opcode == Constants.MESSAGE_REPORT_POWER_STATUS) {
|
||||
handleReportPowerStatus(cmd.getParams()[0]);
|
||||
return true;
|
||||
}
|
||||
@ -115,7 +114,7 @@ final class RoutingControlAction extends FeatureAction {
|
||||
tv().updateActivePortId(tv().pathToPortId(mCurrentRoutingPath));
|
||||
}
|
||||
}
|
||||
invokeCallback(HdmiCec.RESULT_SUCCESS);
|
||||
invokeCallback(HdmiControlManager.RESULT_SUCCESS);
|
||||
finish();
|
||||
}
|
||||
|
||||
@ -124,7 +123,8 @@ final class RoutingControlAction extends FeatureAction {
|
||||
}
|
||||
|
||||
private static boolean isPowerOnOrTransient(int status) {
|
||||
return status == HdmiCec.POWER_STATUS_ON || status == HdmiCec.POWER_STATUS_TRANSIENT_TO_ON;
|
||||
return status == HdmiControlManager.POWER_STATUS_ON
|
||||
|| status == HdmiControlManager.POWER_STATUS_TRANSIENT_TO_ON;
|
||||
}
|
||||
|
||||
private void sendSetStreamPath() {
|
||||
@ -146,7 +146,8 @@ final class RoutingControlAction extends FeatureAction {
|
||||
queryDevicePowerStatus(deviceLogicalAddress, new SendMessageCallback() {
|
||||
@Override
|
||||
public void onSendCompleted(int error) {
|
||||
handlDevicePowerStatusAckResult(error == HdmiCec.RESULT_SUCCESS);
|
||||
handlDevicePowerStatusAckResult(
|
||||
error == HdmiControlManager.RESULT_SUCCESS);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@ -158,7 +159,7 @@ final class RoutingControlAction extends FeatureAction {
|
||||
tv().updateActivePortId(tv().pathToPortId(mCurrentRoutingPath));
|
||||
sendSetStreamPath();
|
||||
}
|
||||
invokeCallback(HdmiCec.RESULT_SUCCESS);
|
||||
invokeCallback(HdmiControlManager.RESULT_SUCCESS);
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
@ -15,9 +15,8 @@
|
||||
*/
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import static com.android.server.hdmi.HdmiConstants.IRT_MS;
|
||||
import static com.android.server.hdmi.Constants.IRT_MS;
|
||||
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.util.Slog;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
|
@ -16,8 +16,8 @@
|
||||
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.hardware.hdmi.HdmiCecDeviceInfo;
|
||||
|
||||
import android.util.Slog;
|
||||
|
||||
/**
|
||||
@ -45,8 +45,8 @@ final class SetArcTransmissionStateAction extends FeatureAction {
|
||||
SetArcTransmissionStateAction(HdmiCecLocalDevice source, int avrAddress,
|
||||
boolean enabled) {
|
||||
super(source);
|
||||
HdmiUtils.verifyAddressType(getSourceAddress(), HdmiCec.DEVICE_TV);
|
||||
HdmiUtils.verifyAddressType(avrAddress, HdmiCec.DEVICE_AUDIO_SYSTEM);
|
||||
HdmiUtils.verifyAddressType(getSourceAddress(), HdmiCecDeviceInfo.DEVICE_TV);
|
||||
HdmiUtils.verifyAddressType(avrAddress, HdmiCecDeviceInfo.DEVICE_AUDIO_SYSTEM);
|
||||
mAvrAddress = avrAddress;
|
||||
mEnabled = enabled;
|
||||
}
|
||||
@ -68,7 +68,7 @@ final class SetArcTransmissionStateAction extends FeatureAction {
|
||||
sendCommand(command, new HdmiControlService.SendMessageCallback() {
|
||||
@Override
|
||||
public void onSendCompleted(int error) {
|
||||
if (error == HdmiConstants.SEND_RESULT_SUCCESS) {
|
||||
if (error == Constants.SEND_RESULT_SUCCESS) {
|
||||
// Enable ARC status immediately after sending <Report Arc Initiated>.
|
||||
// If AVR responds with <Feature Abort>, disable ARC status again.
|
||||
// This is different from spec that says that turns ARC status to
|
||||
@ -110,7 +110,7 @@ final class SetArcTransmissionStateAction extends FeatureAction {
|
||||
}
|
||||
|
||||
int opcode = cmd.getOpcode();
|
||||
if (opcode == HdmiCec.MESSAGE_FEATURE_ABORT) {
|
||||
if (opcode == Constants.MESSAGE_FEATURE_ABORT) {
|
||||
setArcStatus(false);
|
||||
}
|
||||
finish();
|
||||
|
@ -17,8 +17,8 @@
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.hardware.hdmi.HdmiCecDeviceInfo;
|
||||
import android.hardware.hdmi.HdmiControlManager;
|
||||
import android.hardware.hdmi.IHdmiControlCallback;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
@ -59,7 +59,7 @@ abstract class SystemAudioAction extends FeatureAction {
|
||||
SystemAudioAction(HdmiCecLocalDevice source, int avrAddress, boolean targetStatus,
|
||||
IHdmiControlCallback callback) {
|
||||
super(source);
|
||||
HdmiUtils.verifyAddressType(avrAddress, HdmiCec.DEVICE_AUDIO_SYSTEM);
|
||||
HdmiUtils.verifyAddressType(avrAddress, HdmiCecDeviceInfo.DEVICE_AUDIO_SYSTEM);
|
||||
mAvrLogicalAddress = avrAddress;
|
||||
mTargetAudioStatus = targetStatus;
|
||||
mCallback = callback;
|
||||
@ -73,12 +73,12 @@ abstract class SystemAudioAction extends FeatureAction {
|
||||
sendCommand(command, new HdmiControlService.SendMessageCallback() {
|
||||
@Override
|
||||
public void onSendCompleted(int error) {
|
||||
if (error == HdmiConstants.SEND_RESULT_SUCCESS) {
|
||||
if (error == Constants.SEND_RESULT_SUCCESS) {
|
||||
mState = STATE_WAIT_FOR_SET_SYSTEM_AUDIO_MODE;
|
||||
addTimer(mState, mTargetAudioStatus ? ON_TIMEOUT_MS : OFF_TIMEOUT_MS);
|
||||
} else {
|
||||
setSystemAudioMode(false);
|
||||
finishWithCallback(HdmiCec.RESULT_EXCEPTION);
|
||||
finishWithCallback(HdmiControlManager.RESULT_EXCEPTION);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -88,7 +88,7 @@ abstract class SystemAudioAction extends FeatureAction {
|
||||
if (!mTargetAudioStatus // Don't retry for Off case.
|
||||
|| mSendRetryCount++ >= MAX_SEND_RETRY_COUNT) {
|
||||
setSystemAudioMode(false);
|
||||
finishWithCallback(HdmiCec.RESULT_TIMEOUT);
|
||||
finishWithCallback(HdmiControlManager.RESULT_TIMEOUT);
|
||||
return;
|
||||
}
|
||||
sendSystemAudioModeRequest();
|
||||
@ -103,7 +103,7 @@ abstract class SystemAudioAction extends FeatureAction {
|
||||
switch (mState) {
|
||||
case STATE_WAIT_FOR_SET_SYSTEM_AUDIO_MODE:
|
||||
// TODO: Handle <FeatureAbort> of <SystemAudioModeRequest>
|
||||
if (cmd.getOpcode() != HdmiCec.MESSAGE_SET_SYSTEM_AUDIO_MODE
|
||||
if (cmd.getOpcode() != Constants.MESSAGE_SET_SYSTEM_AUDIO_MODE
|
||||
|| !HdmiUtils.checkCommandSource(cmd, mAvrLogicalAddress, TAG)) {
|
||||
return false;
|
||||
}
|
||||
@ -116,7 +116,7 @@ abstract class SystemAudioAction extends FeatureAction {
|
||||
// Unexpected response, consider the request is newly initiated by AVR.
|
||||
// To return 'false' will initiate new SystemAudioActionFromAvr by the control
|
||||
// service.
|
||||
finishWithCallback(HdmiCec.RESULT_EXCEPTION);
|
||||
finishWithCallback(HdmiControlManager.RESULT_EXCEPTION);
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
|
@ -16,7 +16,8 @@
|
||||
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecDeviceInfo;
|
||||
import android.hardware.hdmi.HdmiControlManager;
|
||||
import android.hardware.hdmi.IHdmiControlCallback;
|
||||
|
||||
/**
|
||||
@ -36,7 +37,7 @@ final class SystemAudioActionFromAvr extends SystemAudioAction {
|
||||
SystemAudioActionFromAvr(HdmiCecLocalDevice source, int avrAddress,
|
||||
boolean targetStatus, IHdmiControlCallback callback) {
|
||||
super(source, avrAddress, targetStatus, callback);
|
||||
HdmiUtils.verifyAddressType(getSourceAddress(), HdmiCec.DEVICE_TV);
|
||||
HdmiUtils.verifyAddressType(getSourceAddress(), HdmiCecDeviceInfo.DEVICE_TV);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -48,13 +49,13 @@ final class SystemAudioActionFromAvr extends SystemAudioAction {
|
||||
|
||||
private void handleSystemAudioActionFromAvr() {
|
||||
if (mTargetAudioStatus == tv().getSystemAudioMode()) {
|
||||
finishWithCallback(HdmiCec.RESULT_SUCCESS);
|
||||
finishWithCallback(HdmiControlManager.RESULT_SUCCESS);
|
||||
return;
|
||||
}
|
||||
if (tv().isProhibitMode()) {
|
||||
sendCommand(HdmiCecMessageBuilder.buildFeatureAbortCommand(
|
||||
getSourceAddress(), mAvrLogicalAddress,
|
||||
HdmiCec.MESSAGE_SET_SYSTEM_AUDIO_MODE, HdmiConstants.ABORT_REFUSED));
|
||||
Constants.MESSAGE_SET_SYSTEM_AUDIO_MODE, Constants.ABORT_REFUSED));
|
||||
mTargetAudioStatus = false;
|
||||
sendSystemAudioModeRequest();
|
||||
return;
|
||||
@ -67,7 +68,7 @@ final class SystemAudioActionFromAvr extends SystemAudioAction {
|
||||
startAudioStatusAction();
|
||||
} else {
|
||||
setSystemAudioMode(false);
|
||||
finishWithCallback(HdmiCec.RESULT_SUCCESS);
|
||||
finishWithCallback(HdmiControlManager.RESULT_SUCCESS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecDeviceInfo;
|
||||
import android.hardware.hdmi.IHdmiControlCallback;
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ final class SystemAudioActionFromTv extends SystemAudioAction {
|
||||
SystemAudioActionFromTv(HdmiCecLocalDevice sourceAddress, int avrAddress,
|
||||
boolean targetStatus, IHdmiControlCallback callback) {
|
||||
super(sourceAddress, avrAddress, targetStatus, callback);
|
||||
HdmiUtils.verifyAddressType(getSourceAddress(), HdmiCec.DEVICE_TV);
|
||||
HdmiUtils.verifyAddressType(getSourceAddress(), HdmiCecDeviceInfo.DEVICE_TV);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,9 +16,6 @@
|
||||
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
|
||||
import com.android.server.hdmi.HdmiControlService.SendMessageCallback;
|
||||
|
||||
/**
|
||||
@ -50,7 +47,7 @@ final class SystemAudioAutoInitiationAction extends FeatureAction {
|
||||
mAvrAddress), new SendMessageCallback() {
|
||||
@Override
|
||||
public void onSendCompleted(int error) {
|
||||
if (error != HdmiConstants.SEND_RESULT_SUCCESS) {
|
||||
if (error != Constants.SEND_RESULT_SUCCESS) {
|
||||
tv().setSystemAudioMode(false);
|
||||
finish();
|
||||
}
|
||||
@ -65,7 +62,7 @@ final class SystemAudioAutoInitiationAction extends FeatureAction {
|
||||
}
|
||||
|
||||
switch (cmd.getOpcode()) {
|
||||
case HdmiCec.MESSAGE_SYSTEM_AUDIO_MODE_STATUS:
|
||||
case Constants.MESSAGE_SYSTEM_AUDIO_MODE_STATUS:
|
||||
handleSystemAudioModeStatusMessage();
|
||||
return true;
|
||||
default:
|
||||
|
@ -17,8 +17,7 @@
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.hardware.hdmi.HdmiControlManager;
|
||||
import android.hardware.hdmi.IHdmiControlCallback;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
@ -57,7 +56,7 @@ final class SystemAudioStatusAction extends FeatureAction {
|
||||
new SendMessageCallback() {
|
||||
@Override
|
||||
public void onSendCompleted(int error) {
|
||||
if (error != HdmiConstants.SEND_RESULT_SUCCESS) {
|
||||
if (error != Constants.SEND_RESULT_SUCCESS) {
|
||||
handleSendGiveAudioStatusFailure();
|
||||
}
|
||||
}
|
||||
@ -67,7 +66,7 @@ final class SystemAudioStatusAction extends FeatureAction {
|
||||
private void handleSendGiveAudioStatusFailure() {
|
||||
// Inform to all application that the audio status (volumn, mute) of
|
||||
// the audio amplifier is unknown.
|
||||
tv().setAudioStatus(false, HdmiConstants.UNKNOWN_VOLUME);
|
||||
tv().setAudioStatus(false, Constants.UNKNOWN_VOLUME);
|
||||
|
||||
int uiCommand = tv().getSystemAudioMode()
|
||||
? HdmiCecKeycode.CEC_KEYCODE_RESTORE_VOLUME_FUNCTION // SystemAudioMode: ON
|
||||
@ -75,7 +74,7 @@ final class SystemAudioStatusAction extends FeatureAction {
|
||||
sendUserControlPressedAndReleased(mAvrAddress, uiCommand);
|
||||
|
||||
// Still return SUCCESS to callback.
|
||||
finishWithCallback(HdmiCec.RESULT_SUCCESS);
|
||||
finishWithCallback(HdmiControlManager.RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -85,7 +84,7 @@ final class SystemAudioStatusAction extends FeatureAction {
|
||||
}
|
||||
|
||||
switch (cmd.getOpcode()) {
|
||||
case HdmiCec.MESSAGE_REPORT_AUDIO_STATUS:
|
||||
case Constants.MESSAGE_REPORT_AUDIO_STATUS:
|
||||
handleReportAudioStatus(cmd);
|
||||
return true;
|
||||
}
|
||||
@ -104,7 +103,7 @@ final class SystemAudioStatusAction extends FeatureAction {
|
||||
// Toggle AVR's mute status to match with the system audio status.
|
||||
sendUserControlPressedAndReleased(mAvrAddress, HdmiCecKeycode.CEC_KEYCODE_MUTE);
|
||||
}
|
||||
finishWithCallback(HdmiCec.RESULT_SUCCESS);
|
||||
finishWithCallback(HdmiControlManager.RESULT_SUCCESS);
|
||||
} else {
|
||||
Slog.e(TAG, "Invalid <Report Audio Status> message:" + cmd);
|
||||
handleSendGiveAudioStatusFailure();
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
|
||||
/**
|
||||
* Handles vendor-specific commands that require a sequence of command exchange,
|
||||
* or need to manage some states to complete the processing.
|
||||
|
@ -16,10 +16,8 @@
|
||||
|
||||
package com.android.server.hdmi;
|
||||
|
||||
import static com.android.server.hdmi.HdmiConstants.IRT_MS;
|
||||
import static com.android.server.hdmi.Constants.IRT_MS;
|
||||
|
||||
import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.internal.util.Preconditions;
|
||||
@ -156,10 +154,10 @@ final class VolumeControlAction extends FeatureAction {
|
||||
}
|
||||
|
||||
switch (cmd.getOpcode()) {
|
||||
case HdmiCec.MESSAGE_REPORT_AUDIO_STATUS:
|
||||
case Constants.MESSAGE_REPORT_AUDIO_STATUS:
|
||||
handleReportAudioStatus(cmd);
|
||||
return true;
|
||||
case HdmiCec.MESSAGE_FEATURE_ABORT:
|
||||
case Constants.MESSAGE_FEATURE_ABORT:
|
||||
// TODO: handle feature abort.
|
||||
finish();
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user