Loading core/java/android/hardware/hdmi/HdmiCec.java +6 −0 Original line number Diff line number Diff line Loading @@ -160,6 +160,12 @@ public final class HdmiCec { public static final int MESSAGE_SET_EXTERNAL_TIMER = 0xA2; public static final int MESSAGE_ABORT = 0xFF; public static final int POWER_STATUS_UNKNOWN = -1; public static final int POWER_STATUS_ON = 0; public static final int POWER_STATUS_STANDBY = 1; public static final int POWER_TRANSIENT_TO_ON = 2; public static final int POWER_TRANSIENT_TO_STANDBY = 3; private static final int[] ADDRESS_TO_TYPE = { DEVICE_TV, // ADDR_TV DEVICE_RECORDER, // ADDR_RECORDER_1 Loading core/java/android/hardware/hdmi/HdmiCecClient.java +10 −6 Original line number Diff line number Diff line Loading @@ -110,16 +110,20 @@ public final class HdmiCecClient { } /** * Send <GiveDevicePowerStatus> message. * Returns true if the TV or attached display is powered on. * <p> * The result of this method is only meaningful on playback devices (where the device * type is {@link HdmiCec#DEVICE_PLAYBACK}). * </p> * * @param address logical address of the device to send the message to, such as * {@link HdmiCec#ADDR_TV}. * @return true if TV is on; otherwise false. */ public void sendGiveDevicePowerStatus(int address) { public boolean isTvOn() { try { mService.sendGiveDevicePowerStatus(mBinder, address); return mService.isTvOn(mBinder); } catch (RemoteException e) { Log.e(TAG, "sendGiveDevicePowerStatus threw exception ", e); Log.e(TAG, "isTvOn threw exception ", e); } return false; } } core/java/android/hardware/hdmi/HdmiCecManager.java +3 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,9 @@ public final class HdmiCecManager { * @return {@link HdmiCecClient} instance. {@code null} on failure. */ public HdmiCecClient getClient(int type, HdmiCecClient.Listener listener) { if (mService == null) { return null; } try { IBinder b = mService.allocateLogicalDevice(type, getListenerWrapper(listener)); return HdmiCecClient.create(mService, b); Loading core/java/android/hardware/hdmi/IHdmiCecService.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ interface IHdmiCecService { void sendInactiveSource(IBinder b); void sendImageViewOn(IBinder b); void sendTextViewOn(IBinder b); void sendGiveDevicePowerStatus(IBinder b, int address); boolean isTvOn(IBinder b); void sendMessage(IBinder b, in HdmiCecMessage message); } services/core/java/com/android/server/hdmi/HdmiCecDevice.java +45 −4 Original line number Diff line number Diff line Loading @@ -27,8 +27,12 @@ import java.util.ArrayList; import java.util.List; /** * CecDevice class represents a CEC logical device characterized * by its device type. A physical device can contain the functions of * HdmiCecDevice class represents a CEC logical device characterized * by its device type. It is a superclass of those serving concrete device type. * Currently we're interested in playback(one of sources), display(sink) device type * only. The support for the other types like recorder, audio system will come later. * * <p>A physical device can contain the functions of * more than one logical device, in which case it should create * as many logical devices as necessary. * Loading @@ -41,7 +45,7 @@ import java.util.List; * * <p>Declared as package-private, accessed by HdmiCecService only. */ final class HdmiCecDevice { abstract class HdmiCecDevice { private static final String TAG = "HdmiCecDevice"; private final int mType; Loading @@ -49,18 +53,38 @@ final class HdmiCecDevice { // List of listeners to the message/event coming to the device. private final List<IHdmiCecListener> mListeners = new ArrayList<IHdmiCecListener>(); private final Binder mBinder = new Binder(); private final HdmiCecService mService; private String mName; private boolean mIsActiveSource; /** * Factory method that creates HdmiCecDevice instance to the device type. */ public static HdmiCecDevice create(HdmiCecService service, int type) { if (type == HdmiCec.DEVICE_PLAYBACK) { return new HdmiCecDevicePlayback(service, type); } else if (type == HdmiCec.DEVICE_TV) { return new HdmiCecDeviceTv(service, type); } return null; } /** * Constructor. */ public HdmiCecDevice(int type) { public HdmiCecDevice(HdmiCecService service, int type) { mService = service; mType = type; mIsActiveSource = false; } /** * Called right after the class is instantiated. This method can be used to * implement any initialization tasks for the instance. */ abstract public void initialize(); /** * Return the binder token that identifies this instance. */ Loading @@ -68,6 +92,13 @@ final class HdmiCecDevice { return mBinder; } /** * Return the service instance. */ public HdmiCecService getService() { return mService; } /** * Return the type of this device. */ Loading Loading @@ -128,6 +159,7 @@ final class HdmiCecDevice { if (opcode == HdmiCec.MESSAGE_ACTIVE_SOURCE) { mIsActiveSource = false; } if (mListeners.size() == 0) { return; } Loading Loading @@ -167,4 +199,13 @@ final class HdmiCecDevice { public void setIsActiveSource(boolean state) { mIsActiveSource = state; } /** * Check if the connected sink device is in powered-on state. The default implementation * simply returns false. Should be overriden by subclass to report the correct state. */ public boolean isSinkDeviceOn() { Log.w(TAG, "Not valid for the device type: " + mType); return false; } } Loading
core/java/android/hardware/hdmi/HdmiCec.java +6 −0 Original line number Diff line number Diff line Loading @@ -160,6 +160,12 @@ public final class HdmiCec { public static final int MESSAGE_SET_EXTERNAL_TIMER = 0xA2; public static final int MESSAGE_ABORT = 0xFF; public static final int POWER_STATUS_UNKNOWN = -1; public static final int POWER_STATUS_ON = 0; public static final int POWER_STATUS_STANDBY = 1; public static final int POWER_TRANSIENT_TO_ON = 2; public static final int POWER_TRANSIENT_TO_STANDBY = 3; private static final int[] ADDRESS_TO_TYPE = { DEVICE_TV, // ADDR_TV DEVICE_RECORDER, // ADDR_RECORDER_1 Loading
core/java/android/hardware/hdmi/HdmiCecClient.java +10 −6 Original line number Diff line number Diff line Loading @@ -110,16 +110,20 @@ public final class HdmiCecClient { } /** * Send <GiveDevicePowerStatus> message. * Returns true if the TV or attached display is powered on. * <p> * The result of this method is only meaningful on playback devices (where the device * type is {@link HdmiCec#DEVICE_PLAYBACK}). * </p> * * @param address logical address of the device to send the message to, such as * {@link HdmiCec#ADDR_TV}. * @return true if TV is on; otherwise false. */ public void sendGiveDevicePowerStatus(int address) { public boolean isTvOn() { try { mService.sendGiveDevicePowerStatus(mBinder, address); return mService.isTvOn(mBinder); } catch (RemoteException e) { Log.e(TAG, "sendGiveDevicePowerStatus threw exception ", e); Log.e(TAG, "isTvOn threw exception ", e); } return false; } }
core/java/android/hardware/hdmi/HdmiCecManager.java +3 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,9 @@ public final class HdmiCecManager { * @return {@link HdmiCecClient} instance. {@code null} on failure. */ public HdmiCecClient getClient(int type, HdmiCecClient.Listener listener) { if (mService == null) { return null; } try { IBinder b = mService.allocateLogicalDevice(type, getListenerWrapper(listener)); return HdmiCecClient.create(mService, b); Loading
core/java/android/hardware/hdmi/IHdmiCecService.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ interface IHdmiCecService { void sendInactiveSource(IBinder b); void sendImageViewOn(IBinder b); void sendTextViewOn(IBinder b); void sendGiveDevicePowerStatus(IBinder b, int address); boolean isTvOn(IBinder b); void sendMessage(IBinder b, in HdmiCecMessage message); }
services/core/java/com/android/server/hdmi/HdmiCecDevice.java +45 −4 Original line number Diff line number Diff line Loading @@ -27,8 +27,12 @@ import java.util.ArrayList; import java.util.List; /** * CecDevice class represents a CEC logical device characterized * by its device type. A physical device can contain the functions of * HdmiCecDevice class represents a CEC logical device characterized * by its device type. It is a superclass of those serving concrete device type. * Currently we're interested in playback(one of sources), display(sink) device type * only. The support for the other types like recorder, audio system will come later. * * <p>A physical device can contain the functions of * more than one logical device, in which case it should create * as many logical devices as necessary. * Loading @@ -41,7 +45,7 @@ import java.util.List; * * <p>Declared as package-private, accessed by HdmiCecService only. */ final class HdmiCecDevice { abstract class HdmiCecDevice { private static final String TAG = "HdmiCecDevice"; private final int mType; Loading @@ -49,18 +53,38 @@ final class HdmiCecDevice { // List of listeners to the message/event coming to the device. private final List<IHdmiCecListener> mListeners = new ArrayList<IHdmiCecListener>(); private final Binder mBinder = new Binder(); private final HdmiCecService mService; private String mName; private boolean mIsActiveSource; /** * Factory method that creates HdmiCecDevice instance to the device type. */ public static HdmiCecDevice create(HdmiCecService service, int type) { if (type == HdmiCec.DEVICE_PLAYBACK) { return new HdmiCecDevicePlayback(service, type); } else if (type == HdmiCec.DEVICE_TV) { return new HdmiCecDeviceTv(service, type); } return null; } /** * Constructor. */ public HdmiCecDevice(int type) { public HdmiCecDevice(HdmiCecService service, int type) { mService = service; mType = type; mIsActiveSource = false; } /** * Called right after the class is instantiated. This method can be used to * implement any initialization tasks for the instance. */ abstract public void initialize(); /** * Return the binder token that identifies this instance. */ Loading @@ -68,6 +92,13 @@ final class HdmiCecDevice { return mBinder; } /** * Return the service instance. */ public HdmiCecService getService() { return mService; } /** * Return the type of this device. */ Loading Loading @@ -128,6 +159,7 @@ final class HdmiCecDevice { if (opcode == HdmiCec.MESSAGE_ACTIVE_SOURCE) { mIsActiveSource = false; } if (mListeners.size() == 0) { return; } Loading Loading @@ -167,4 +199,13 @@ final class HdmiCecDevice { public void setIsActiveSource(boolean state) { mIsActiveSource = state; } /** * Check if the connected sink device is in powered-on state. The default implementation * simply returns false. Should be overriden by subclass to report the correct state. */ public boolean isSinkDeviceOn() { Log.w(TAG, "Not valid for the device type: " + mType); return false; } }