diff options
author | Jinsuk Kim <jinsukkim@google.com> | 2014-06-16 11:41:42 +0900 |
---|---|---|
committer | Jinsuk Kim <jinsukkim@google.com> | 2014-06-16 14:01:45 +0900 |
commit | 6d97f5b91c6c82f28a2a3a5d3b922f0e5844e733 (patch) | |
tree | 7ac0804bbb88ddf3268f0450f248f0028cf26032 | |
parent | 7237cd811cd760be2daa18fb495b2e05172d5fd4 (diff) | |
download | frameworks_base-6d97f5b91c6c82f28a2a3a5d3b922f0e5844e733.zip frameworks_base-6d97f5b91c6c82f28a2a3a5d3b922f0e5844e733.tar.gz frameworks_base-6d97f5b91c6c82f28a2a3a5d3b922f0e5844e733.tar.bz2 |
A few more APIs for HdmiControlService
Added following APIs in HdmiControlService:
- portSelect
- sendKeyEvent
- getPortInfo
- addDeviceEventListener
Some are not fleshed out yet. Will work on it in a follow up CL.
Change-Id: Ia8c635176c0378f6e8db589bf714d82bf21ce85d
-rw-r--r-- | Android.mk | 1 | ||||
-rw-r--r-- | core/java/android/hardware/hdmi/HdmiCecDeviceInfo.aidl | 19 | ||||
-rw-r--r-- | core/java/android/hardware/hdmi/IHdmiControlService.aidl | 10 | ||||
-rw-r--r-- | core/java/android/hardware/hdmi/IHdmiDeviceEventListener.aidl | 35 | ||||
-rw-r--r-- | services/core/java/com/android/server/hdmi/HdmiControlService.java | 65 |
5 files changed, 129 insertions, 1 deletions
@@ -152,6 +152,7 @@ LOCAL_SRC_FILES += \ core/java/android/hardware/display/IDisplayManagerCallback.aidl \ core/java/android/hardware/hdmi/IHdmiControlCallback.aidl \ core/java/android/hardware/hdmi/IHdmiControlService.aidl \ + core/java/android/hardware/hdmi/IHdmiDeviceEventListener.aidl \ core/java/android/hardware/hdmi/IHdmiHotplugEventListener.aidl \ core/java/android/hardware/input/IInputManager.aidl \ core/java/android/hardware/input/IInputDevicesChangedListener.aidl \ diff --git a/core/java/android/hardware/hdmi/HdmiCecDeviceInfo.aidl b/core/java/android/hardware/hdmi/HdmiCecDeviceInfo.aidl new file mode 100644 index 0000000..1615910 --- /dev/null +++ b/core/java/android/hardware/hdmi/HdmiCecDeviceInfo.aidl @@ -0,0 +1,19 @@ +/* + * 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 HdmiCecDeviceInfo; diff --git a/core/java/android/hardware/hdmi/IHdmiControlService.aidl b/core/java/android/hardware/hdmi/IHdmiControlService.aidl index 8d7c638..a0bf552 100644 --- a/core/java/android/hardware/hdmi/IHdmiControlService.aidl +++ b/core/java/android/hardware/hdmi/IHdmiControlService.aidl @@ -16,10 +16,14 @@ package android.hardware.hdmi; -import android.hardware.hdmi.HdmiCecMessage; +import android.hardware.hdmi.HdmiCecDeviceInfo; +import android.hardware.hdmi.HdmiPortInfo; import android.hardware.hdmi.IHdmiControlCallback; +import android.hardware.hdmi.IHdmiDeviceEventListener; import android.hardware.hdmi.IHdmiHotplugEventListener; +import java.util.List; + /** * Binder interface that clients running in the application process * will use to perform HDMI-CEC features by communicating with other devices @@ -33,5 +37,9 @@ interface IHdmiControlService { void queryDisplayStatus(IHdmiControlCallback callback); void addHotplugEventListener(IHdmiHotplugEventListener listener); void removeHotplugEventListener(IHdmiHotplugEventListener listener); + void addDeviceEventListener(IHdmiDeviceEventListener listener); void deviceSelect(int logicalAddress, IHdmiControlCallback callback); + void portSelect(int portId, IHdmiControlCallback callback); + void sendKeyEvent(int keyCode); + List<HdmiPortInfo> getPortInfo(); } diff --git a/core/java/android/hardware/hdmi/IHdmiDeviceEventListener.aidl b/core/java/android/hardware/hdmi/IHdmiDeviceEventListener.aidl new file mode 100644 index 0000000..c4e5989 --- /dev/null +++ b/core/java/android/hardware/hdmi/IHdmiDeviceEventListener.aidl @@ -0,0 +1,35 @@ +/* + * 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.hardware.hdmi.HdmiCecDeviceInfo; + +/** + * Callback interface definition for HDMI client to get informed of + * the CEC logical device status change event. + * + * @hide + */ +oneway interface IHdmiDeviceEventListener { + + /** + * @param deviceInfo {@link HdmiCecDeviceInfo} of the logical device whose + * status has changed + * @param activated true if the device gets activated + */ + void onStatusChanged(in HdmiCecDeviceInfo deviceInfo, in boolean activated); +} diff --git a/services/core/java/com/android/server/hdmi/HdmiControlService.java b/services/core/java/com/android/server/hdmi/HdmiControlService.java index bccfa36..5fffada 100644 --- a/services/core/java/com/android/server/hdmi/HdmiControlService.java +++ b/services/core/java/com/android/server/hdmi/HdmiControlService.java @@ -25,6 +25,7 @@ import android.hardware.hdmi.HdmiHotplugEvent; import android.hardware.hdmi.HdmiPortInfo; import android.hardware.hdmi.IHdmiControlCallback; import android.hardware.hdmi.IHdmiControlService; +import android.hardware.hdmi.IHdmiDeviceEventListener; import android.hardware.hdmi.IHdmiHotplugEventListener; import android.os.Build; import android.os.Handler; @@ -118,6 +119,14 @@ public final class HdmiControlService extends SystemService { private final ArrayList<HotplugEventListenerRecord> mHotplugEventListenerRecords = new ArrayList<>(); + // List of listeners registered by callers that want to get notified of + // device status events. + private final ArrayList<IHdmiDeviceEventListener> mDeviceEventListeners = new ArrayList<>(); + + // List of records for device event listener to handle the the caller killed in action. + private final ArrayList<DeviceEventListenerRecord> mDeviceEventListenerRecords = + new ArrayList<>(); + // Handler running on service thread. It's used to run a task in service thread. private final Handler mHandler = new Handler(); @@ -777,6 +786,22 @@ public final class HdmiControlService extends SystemService { } } + private final class DeviceEventListenerRecord implements IBinder.DeathRecipient { + private final IHdmiDeviceEventListener mListener; + + public DeviceEventListenerRecord(IHdmiDeviceEventListener listener) { + mListener = listener; + } + + @Override + public void binderDied() { + synchronized (mLock) { + mDeviceEventListenerRecords.remove(this); + mDeviceEventListeners.remove(mListener); + } + } + } + private void enforceAccessPermission() { getContext().enforceCallingOrSelfPermission(PERMISSION, TAG); } @@ -854,6 +879,33 @@ public final class HdmiControlService extends SystemService { } }); } + + @Override + public void addDeviceEventListener(final IHdmiDeviceEventListener listener) { + enforceAccessPermission(); + runOnServiceThread(new Runnable() { + @Override + public void run() { + HdmiControlService.this.addDeviceEventListener(listener); + } + }); + } + + @Override + public void portSelect(int portId, IHdmiControlCallback callback) { + // TODO: Implement this + } + + @Override + public void sendKeyEvent(int keyCode) { + // TODO: Implement this + } + + @Override + public List<HdmiPortInfo> getPortInfo() { + enforceAccessPermission(); + return mPortInfo; + } } private void oneTouchPlay(IHdmiControlCallback callback) { @@ -930,6 +982,19 @@ public final class HdmiControlService extends SystemService { } } + private void addDeviceEventListener(IHdmiDeviceEventListener listener) { + synchronized (mLock) { + for (DeviceEventListenerRecord record : mDeviceEventListenerRecords) { + if (record.mListener.asBinder() == listener.asBinder()) { + listener.asBinder().unlinkToDeath(record, 0); + mDeviceEventListenerRecords.remove(record); + break; + } + } + mHotplugEventListeners.remove(listener); + } + } + private void invokeCallback(IHdmiControlCallback callback, int result) { try { callback.onComplete(result); |