Loading Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -149,6 +149,7 @@ LOCAL_SRC_FILES += \ core/java/android/hardware/hdmi/IHdmiCecService.aidl \ core/java/android/hardware/hdmi/IHdmiControlCallback.aidl \ core/java/android/hardware/hdmi/IHdmiControlService.aidl \ core/java/android/hardware/hdmi/IHdmiHotplugEventListener.aidl \ core/java/android/hardware/input/IInputManager.aidl \ core/java/android/hardware/input/IInputDevicesChangedListener.aidl \ core/java/android/hardware/location/IFusedLocationHardware.aidl \ Loading api/current.txt +15 −0 Original line number Diff line number Diff line Loading @@ -12865,8 +12865,23 @@ package android.hardware.hdmi { } public final class HdmiControlManager { method public void addHotplugEventListener(android.hardware.hdmi.HdmiControlManager.HotplugEventListener); method public android.hardware.hdmi.HdmiPlaybackClient getPlaybackClient(); method public android.hardware.hdmi.HdmiTvClient getTvClient(); method public void removeHotplugeEventListener(android.hardware.hdmi.HdmiControlManager.HotplugEventListener); } public static abstract interface HdmiControlManager.HotplugEventListener { method public abstract void onReceived(android.hardware.hdmi.HdmiHotplugEvent); } public final class HdmiHotplugEvent implements android.os.Parcelable { ctor public HdmiHotplugEvent(int, boolean); method public int describeContents(); method public int getPort(); method public boolean isConnected(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; } public final class HdmiPlaybackClient { core/java/android/hardware/hdmi/HdmiControlManager.java +84 −3 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package android.hardware.hdmi; import android.annotation.Nullable; import android.os.RemoteException; /** * The {@link HdmiControlManager} class is used to send HDMI control messages * to attached CEC devices. Loading @@ -30,6 +32,11 @@ import android.annotation.Nullable; public final class HdmiControlManager { @Nullable private final IHdmiControlService mService; // 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. private final boolean mHasTvDevice; /** * @hide - hide this constructor because it has a parameter of type * IHdmiControlService, which is a system private class. The right way Loading @@ -38,6 +45,28 @@ public final class HdmiControlManager { */ public HdmiControlManager(IHdmiControlService service) { mService = service; int[] types = null; if (mService != null) { try { types = mService.getSupportedTypes(); } catch (RemoteException e) { // Do nothing. } } mHasTvDevice = hasDeviceType(types, HdmiCec.DEVICE_TV); mHasPlaybackDevice = hasDeviceType(types, HdmiCec.DEVICE_PLAYBACK); } private static boolean hasDeviceType(int[] types, int type) { if (types == null) { return false; } for (int t : types) { if (t == type) { return true; } } return false; } /** Loading @@ -51,7 +80,7 @@ public final class HdmiControlManager { */ @Nullable public HdmiPlaybackClient getPlaybackClient() { if (mService == null) { if (mService == null || !mHasPlaybackDevice) { return null; } return new HdmiPlaybackClient(mService); Loading @@ -68,9 +97,61 @@ public final class HdmiControlManager { */ @Nullable public HdmiTvClient getTvClient() { if (mService == null) { if (mService == null || !mHasTvDevice) { return null; } return new HdmiTvClient(mService); } /** * Listener used to get hotplug event from HDMI port. */ public interface HotplugEventListener { void onReceived(HdmiHotplugEvent event); } /** * Adds a listener to get informed of {@link HdmiHotplugEvent}. * * <p>To stop getting the notification, * use {@link #removeHotplugeEventListener(HotplugEventListener)}. * * @param listener {@link HotplugEventListener} instance * @see HdmiControlManager#removeHotplugeEventListener(HotplugEventListener) */ public void addHotplugEventListener(HotplugEventListener listener) { if (mService == null) { return; } try { mService.addHotplugEventListener(getHotplugEventListenerWrapper(listener)); } catch (RemoteException e) { // Do nothing. } } /** * Removes a listener to stop getting informed of {@link HdmiHotplugEvent}. * * @param listener {@link HotplugEventListener} instance to be removed */ public void removeHotplugeEventListener(HotplugEventListener listener) { if (mService == null) { return; } try { mService.removeHotplugEventListener(getHotplugEventListenerWrapper(listener)); } catch (RemoteException e) { // Do nothing. } } private IHdmiHotplugEventListener getHotplugEventListenerWrapper( final HotplugEventListener listener) { return new IHdmiHotplugEventListener.Stub() { public void onReceived(HdmiHotplugEvent event) { listener.onReceived(event);; } }; } } core/java/android/hardware/hdmi/HdmiHotplugEvent.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.hdmi; parcelable HdmiHotplugEvent; core/java/android/hardware/hdmi/HdmiHotplugEvent.java 0 → 100644 +100 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.hdmi; import android.os.Parcel; import android.os.Parcelable; /** * A class that describes the HDMI port hotplug event. */ public final class HdmiHotplugEvent implements Parcelable { private final int mPort; private final boolean mConnected; /** * Constructor. * * <p>Marked as hidden so only system can create the instance. * * @hide */ public HdmiHotplugEvent(int port, boolean connected) { mPort = port; mConnected = connected; } /** * Return the port number for which the event occurred. * * @return port number */ public int getPort() { return mPort; } /** * Return the connection status associated with this event * * @return true if the device gets connected; otherwise false */ public boolean isConnected() { return mConnected; } /** * Describe the kinds of special objects contained in this Parcelable's * marshalled representation. */ @Override public int describeContents() { return 0; } /** * Flatten this object in to a Parcel. * * @param dest The Parcel in which the object should be written. * @param flags Additional flags about how the object should be written. * May be 0 or {@link Parcelable#PARCELABLE_WRITE_RETURN_VALUE}. */ @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(mPort); dest.writeByte((byte) (mConnected ? 1 : 0)); } public static final Parcelable.Creator<HdmiHotplugEvent> CREATOR = new Parcelable.Creator<HdmiHotplugEvent>() { /** * Rebuild a {@link HdmiHotplugEvent} previously stored with * {@link Parcelable#writeToParcel(Parcel, int)}. * * @param p {@link HdmiHotplugEvent} object to read the Rating from * @return a new {@link HdmiHotplugEvent} created from the data in the parcel */ public HdmiHotplugEvent createFromParcel(Parcel p) { int port = p.readInt(); boolean connected = p.readByte() == 1; return new HdmiHotplugEvent(port, connected); } public HdmiHotplugEvent[] newArray(int size) { return new HdmiHotplugEvent[size]; } }; } Loading
Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -149,6 +149,7 @@ LOCAL_SRC_FILES += \ core/java/android/hardware/hdmi/IHdmiCecService.aidl \ core/java/android/hardware/hdmi/IHdmiControlCallback.aidl \ core/java/android/hardware/hdmi/IHdmiControlService.aidl \ core/java/android/hardware/hdmi/IHdmiHotplugEventListener.aidl \ core/java/android/hardware/input/IInputManager.aidl \ core/java/android/hardware/input/IInputDevicesChangedListener.aidl \ core/java/android/hardware/location/IFusedLocationHardware.aidl \ Loading
api/current.txt +15 −0 Original line number Diff line number Diff line Loading @@ -12865,8 +12865,23 @@ package android.hardware.hdmi { } public final class HdmiControlManager { method public void addHotplugEventListener(android.hardware.hdmi.HdmiControlManager.HotplugEventListener); method public android.hardware.hdmi.HdmiPlaybackClient getPlaybackClient(); method public android.hardware.hdmi.HdmiTvClient getTvClient(); method public void removeHotplugeEventListener(android.hardware.hdmi.HdmiControlManager.HotplugEventListener); } public static abstract interface HdmiControlManager.HotplugEventListener { method public abstract void onReceived(android.hardware.hdmi.HdmiHotplugEvent); } public final class HdmiHotplugEvent implements android.os.Parcelable { ctor public HdmiHotplugEvent(int, boolean); method public int describeContents(); method public int getPort(); method public boolean isConnected(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; } public final class HdmiPlaybackClient {
core/java/android/hardware/hdmi/HdmiControlManager.java +84 −3 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package android.hardware.hdmi; import android.annotation.Nullable; import android.os.RemoteException; /** * The {@link HdmiControlManager} class is used to send HDMI control messages * to attached CEC devices. Loading @@ -30,6 +32,11 @@ import android.annotation.Nullable; public final class HdmiControlManager { @Nullable private final IHdmiControlService mService; // 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. private final boolean mHasTvDevice; /** * @hide - hide this constructor because it has a parameter of type * IHdmiControlService, which is a system private class. The right way Loading @@ -38,6 +45,28 @@ public final class HdmiControlManager { */ public HdmiControlManager(IHdmiControlService service) { mService = service; int[] types = null; if (mService != null) { try { types = mService.getSupportedTypes(); } catch (RemoteException e) { // Do nothing. } } mHasTvDevice = hasDeviceType(types, HdmiCec.DEVICE_TV); mHasPlaybackDevice = hasDeviceType(types, HdmiCec.DEVICE_PLAYBACK); } private static boolean hasDeviceType(int[] types, int type) { if (types == null) { return false; } for (int t : types) { if (t == type) { return true; } } return false; } /** Loading @@ -51,7 +80,7 @@ public final class HdmiControlManager { */ @Nullable public HdmiPlaybackClient getPlaybackClient() { if (mService == null) { if (mService == null || !mHasPlaybackDevice) { return null; } return new HdmiPlaybackClient(mService); Loading @@ -68,9 +97,61 @@ public final class HdmiControlManager { */ @Nullable public HdmiTvClient getTvClient() { if (mService == null) { if (mService == null || !mHasTvDevice) { return null; } return new HdmiTvClient(mService); } /** * Listener used to get hotplug event from HDMI port. */ public interface HotplugEventListener { void onReceived(HdmiHotplugEvent event); } /** * Adds a listener to get informed of {@link HdmiHotplugEvent}. * * <p>To stop getting the notification, * use {@link #removeHotplugeEventListener(HotplugEventListener)}. * * @param listener {@link HotplugEventListener} instance * @see HdmiControlManager#removeHotplugeEventListener(HotplugEventListener) */ public void addHotplugEventListener(HotplugEventListener listener) { if (mService == null) { return; } try { mService.addHotplugEventListener(getHotplugEventListenerWrapper(listener)); } catch (RemoteException e) { // Do nothing. } } /** * Removes a listener to stop getting informed of {@link HdmiHotplugEvent}. * * @param listener {@link HotplugEventListener} instance to be removed */ public void removeHotplugeEventListener(HotplugEventListener listener) { if (mService == null) { return; } try { mService.removeHotplugEventListener(getHotplugEventListenerWrapper(listener)); } catch (RemoteException e) { // Do nothing. } } private IHdmiHotplugEventListener getHotplugEventListenerWrapper( final HotplugEventListener listener) { return new IHdmiHotplugEventListener.Stub() { public void onReceived(HdmiHotplugEvent event) { listener.onReceived(event);; } }; } }
core/java/android/hardware/hdmi/HdmiHotplugEvent.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.hdmi; parcelable HdmiHotplugEvent;
core/java/android/hardware/hdmi/HdmiHotplugEvent.java 0 → 100644 +100 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.hdmi; import android.os.Parcel; import android.os.Parcelable; /** * A class that describes the HDMI port hotplug event. */ public final class HdmiHotplugEvent implements Parcelable { private final int mPort; private final boolean mConnected; /** * Constructor. * * <p>Marked as hidden so only system can create the instance. * * @hide */ public HdmiHotplugEvent(int port, boolean connected) { mPort = port; mConnected = connected; } /** * Return the port number for which the event occurred. * * @return port number */ public int getPort() { return mPort; } /** * Return the connection status associated with this event * * @return true if the device gets connected; otherwise false */ public boolean isConnected() { return mConnected; } /** * Describe the kinds of special objects contained in this Parcelable's * marshalled representation. */ @Override public int describeContents() { return 0; } /** * Flatten this object in to a Parcel. * * @param dest The Parcel in which the object should be written. * @param flags Additional flags about how the object should be written. * May be 0 or {@link Parcelable#PARCELABLE_WRITE_RETURN_VALUE}. */ @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(mPort); dest.writeByte((byte) (mConnected ? 1 : 0)); } public static final Parcelable.Creator<HdmiHotplugEvent> CREATOR = new Parcelable.Creator<HdmiHotplugEvent>() { /** * Rebuild a {@link HdmiHotplugEvent} previously stored with * {@link Parcelable#writeToParcel(Parcel, int)}. * * @param p {@link HdmiHotplugEvent} object to read the Rating from * @return a new {@link HdmiHotplugEvent} created from the data in the parcel */ public HdmiHotplugEvent createFromParcel(Parcel p) { int port = p.readInt(); boolean connected = p.readByte() == 1; return new HdmiHotplugEvent(port, connected); } public HdmiHotplugEvent[] newArray(int size) { return new HdmiHotplugEvent[size]; } }; }