summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJungshik Jang <jayjang@google.com>2014-08-22 05:22:44 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-08-22 05:22:47 +0000
commit63859536047e907fbcde87f12511ec3b35bf53dc (patch)
tree6135ebefd8df74111bd96bc10d0a2b32e0f4105c /core
parentbc070818271981df5a475666f005aa2084a2c40b (diff)
parentf424932cfb1b16b01a37500d09e295912700a51d (diff)
downloadframeworks_base-63859536047e907fbcde87f12511ec3b35bf53dc.zip
frameworks_base-63859536047e907fbcde87f12511ec3b35bf53dc.tar.gz
frameworks_base-63859536047e907fbcde87f12511ec3b35bf53dc.tar.bz2
Merge "Implement interfaces for MHL scratchpad command" into lmp-dev
Diffstat (limited to 'core')
-rw-r--r--core/java/android/hardware/hdmi/HdmiClient.java2
-rw-r--r--core/java/android/hardware/hdmi/HdmiTvClient.java145
-rw-r--r--core/java/android/hardware/hdmi/IHdmiControlService.aidl3
-rw-r--r--core/java/android/hardware/hdmi/IHdmiMhlScratchpadCommandListener.aidl27
4 files changed, 136 insertions, 41 deletions
diff --git a/core/java/android/hardware/hdmi/HdmiClient.java b/core/java/android/hardware/hdmi/HdmiClient.java
index f95ed0f..aba90e4 100644
--- a/core/java/android/hardware/hdmi/HdmiClient.java
+++ b/core/java/android/hardware/hdmi/HdmiClient.java
@@ -50,7 +50,7 @@ public abstract class HdmiClient {
try {
mService.sendKeyEvent(getDeviceType(), keyCode, isPressed);
} catch (RemoteException e) {
- Log.e(TAG, "queryDisplayStatus threw exception ", e);
+ Log.e(TAG, "sendKeyEvent threw exception ", e);
}
}
diff --git a/core/java/android/hardware/hdmi/HdmiTvClient.java b/core/java/android/hardware/hdmi/HdmiTvClient.java
index 354c05e..c37fb5b 100644
--- a/core/java/android/hardware/hdmi/HdmiTvClient.java
+++ b/core/java/android/hardware/hdmi/HdmiTvClient.java
@@ -35,6 +35,11 @@ import libcore.util.EmptyArray;
public final class HdmiTvClient extends HdmiClient {
private static final String TAG = "HdmiTvClient";
+ /**
+ * Size of MHL scratchpad register.
+ */
+ public static final int SCRATCHPAD_DATA_SIZE = 16;
+
HdmiTvClient(IHdmiControlService service) {
super(service);
}
@@ -80,6 +85,15 @@ public final class HdmiTvClient extends HdmiClient {
}
}
+ private static IHdmiControlCallback getCallbackWrapper(final SelectCallback callback) {
+ return new IHdmiControlCallback.Stub() {
+ @Override
+ public void onComplete(int result) {
+ callback.onComplete(result);
+ }
+ };
+ }
+
/**
* Select a HDMI port to be a new route path.
*
@@ -126,6 +140,15 @@ public final class HdmiTvClient extends HdmiClient {
}
}
+ private static IHdmiInputChangeListener getListenerWrapper(final InputChangeListener listener) {
+ return new IHdmiInputChangeListener.Stub() {
+ @Override
+ public void onChanged(HdmiDeviceInfo info) {
+ listener.onChanged(info);
+ }
+ };
+ }
+
/**
* Set system audio volume
*
@@ -170,6 +193,38 @@ public final class HdmiTvClient extends HdmiClient {
}
}
+ private static IHdmiRecordListener getListenerWrapper(final HdmiRecordListener callback) {
+ return new IHdmiRecordListener.Stub() {
+ @Override
+ public byte[] getOneTouchRecordSource(int recorderAddress) {
+ HdmiRecordSources.RecordSource source =
+ callback.getOneTouchRecordSource(recorderAddress);
+ if (source == null) {
+ return EmptyArray.BYTE;
+ }
+ byte[] data = new byte[source.getDataSize(true)];
+ source.toByteArray(true, data, 0);
+ return data;
+ }
+
+ @Override
+ public void onOneTouchRecordResult(int result) {
+ callback.onOneTouchRecordResult(result);
+ }
+
+ @Override
+ public void onTimerRecordingResult(int result) {
+ callback.onTimerRecordingResult(
+ HdmiRecordListener.TimerStatusData.parseFrom(result));
+ }
+
+ @Override
+ public void onClearTimerRecordingResult(int result) {
+ callback.onClearTimerRecordingResult(result);
+ }
+ };
+ }
+
/**
* Start one touch recording with the given recorder address and recorder source.
* <p>
@@ -276,53 +331,63 @@ public final class HdmiTvClient extends HdmiClient {
}
}
- private static IHdmiControlCallback getCallbackWrapper(final SelectCallback callback) {
- return new IHdmiControlCallback.Stub() {
- @Override
- public void onComplete(int result) {
- callback.onComplete(result);
- }
- };
+ /**
+ * Interface used to get incoming MHL scratchpad command.
+ */
+ public interface HdmiMhlScratchpadCommandListener {
+ void onReceived(int portId, int offset, int length, byte[] data);
}
- private static IHdmiInputChangeListener getListenerWrapper(final InputChangeListener listener) {
- return new IHdmiInputChangeListener.Stub() {
- @Override
- public void onChanged(HdmiDeviceInfo info) {
- listener.onChanged(info);
- }
- };
+ /**
+ * Set {@link HdmiMhlScratchpadCommandListener} to get incoming MHL sSratchpad command.
+ *
+ * @param listener to receive incoming MHL Scratchpad command
+ */
+ public void setHdmiMhlScratchpadCommandListener(HdmiMhlScratchpadCommandListener listener) {
+ if (listener == null) {
+ throw new IllegalArgumentException("listener must not be null.");
+ }
+ try {
+ mService.addHdmiMhlScratchpadCommandListener(getListenerWrapper(listener));
+ } catch (RemoteException e) {
+ Log.e(TAG, "failed to set hdmi mhl scratchpad command listener: ", e);
+ }
}
- private static IHdmiRecordListener getListenerWrapper(final HdmiRecordListener callback) {
- return new IHdmiRecordListener.Stub() {
+ private IHdmiMhlScratchpadCommandListener getListenerWrapper(
+ final HdmiMhlScratchpadCommandListener listener) {
+ return new IHdmiMhlScratchpadCommandListener.Stub() {
@Override
- public byte[] getOneTouchRecordSource(int recorderAddress) {
- HdmiRecordSources.RecordSource source =
- callback.getOneTouchRecordSource(recorderAddress);
- if (source == null) {
- return EmptyArray.BYTE;
- }
- byte[] data = new byte[source.getDataSize(true)];
- source.toByteArray(true, data, 0);
- return data;
- }
-
- @Override
- public void onOneTouchRecordResult(int result) {
- callback.onOneTouchRecordResult(result);
+ public void onReceived(int portId, int offset, int length, byte[] data) {
+ listener.onReceived(portId, offset, length, data);
}
+ };
+ }
- @Override
- public void onTimerRecordingResult(int result) {
- callback.onTimerRecordingResult(
- HdmiRecordListener.TimerStatusData.parseFrom(result));
- }
+ /**
+ * Send MHL Scratchpad command to the device connected to a port of the given portId.
+ *
+ * @param portId id of port to send MHL Scratchpad command
+ * @param offset offset in the in given data
+ * @param length length of data. offset + length should be bound to length of data.
+ * @param data container for Scratchpad data. It should be 16 bytes.
+ * @throws IllegalArgumentException if the given parameters are invalid
+ */
+ public void sendScratchpadCommand(int portId, int offset, int length, byte[] data) {
+ if (data == null || data.length != SCRATCHPAD_DATA_SIZE) {
+ throw new IllegalArgumentException("Invalid scratchpad data.");
+ }
+ if (offset < 0 || offset >= SCRATCHPAD_DATA_SIZE) {
+ throw new IllegalArgumentException("Invalid offset:" + offset);
+ }
+ if (length < 0 || offset + length > SCRATCHPAD_DATA_SIZE) {
+ throw new IllegalArgumentException("Invalid length:" + length);
+ }
- @Override
- public void onClearTimerRecordingResult(int result) {
- callback.onClearTimerRecordingResult(result);
- }
- };
+ try {
+ mService.sendScratchpadCommand(portId, offset, length, data);
+ } catch (RemoteException e) {
+ Log.e(TAG, "failed to send scratchpad command: ", e);
+ }
}
}
diff --git a/core/java/android/hardware/hdmi/IHdmiControlService.aidl b/core/java/android/hardware/hdmi/IHdmiControlService.aidl
index 17f290b..3bd45ed 100644
--- a/core/java/android/hardware/hdmi/IHdmiControlService.aidl
+++ b/core/java/android/hardware/hdmi/IHdmiControlService.aidl
@@ -22,6 +22,7 @@ import android.hardware.hdmi.IHdmiControlCallback;
import android.hardware.hdmi.IHdmiDeviceEventListener;
import android.hardware.hdmi.IHdmiHotplugEventListener;
import android.hardware.hdmi.IHdmiInputChangeListener;
+import android.hardware.hdmi.IHdmiMhlScratchpadCommandListener;
import android.hardware.hdmi.IHdmiRecordListener;
import android.hardware.hdmi.IHdmiSystemAudioModeChangeListener;
import android.hardware.hdmi.IHdmiVendorCommandListener;
@@ -66,4 +67,6 @@ interface IHdmiControlService {
void stopOneTouchRecord(int recorderAddress);
void startTimerRecording(int recorderAddress, int sourceType, in byte[] recordSource);
void clearTimerRecording(int recorderAddress, int sourceType, in byte[] recordSource);
+ void sendScratchpadCommand(int portId, int offset, int length, in byte[] data);
+ void addHdmiMhlScratchpadCommandListener(IHdmiMhlScratchpadCommandListener listener);
}
diff --git a/core/java/android/hardware/hdmi/IHdmiMhlScratchpadCommandListener.aidl b/core/java/android/hardware/hdmi/IHdmiMhlScratchpadCommandListener.aidl
new file mode 100644
index 0000000..4176597
--- /dev/null
+++ b/core/java/android/hardware/hdmi/IHdmiMhlScratchpadCommandListener.aidl
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+ /**
+ * Callback interface definition for MHL client to get the scratchpad
+ * command.
+ *
+ * @hide
+ */
+ oneway interface IHdmiMhlScratchpadCommandListener {
+ void onReceived(int portId, int offset, int length, in byte[] data);
+ }