diff options
author | Jungshik Jang <jayjang@google.com> | 2014-08-18 16:50:12 +0900 |
---|---|---|
committer | Jungshik Jang <jayjang@google.com> | 2014-08-19 09:49:30 +0900 |
commit | 5691b2f2297b29dc83a7f83f77da517035b11cce (patch) | |
tree | 9ef453a75535281876e16327043ed357ad8c40ec /services/core/java/com/android/server/hdmi | |
parent | d1858574d0d3ba648fc20c55f0caf40e70b5de9a (diff) | |
download | frameworks_base-5691b2f2297b29dc83a7f83f77da517035b11cce.zip frameworks_base-5691b2f2297b29dc83a7f83f77da517035b11cce.tar.gz frameworks_base-5691b2f2297b29dc83a7f83f77da517035b11cce.tar.bz2 |
Remove parameter field in HdmiCecKeycode.
Since we don't support mapping between android key and parameterized
cec keycode, remove parameter fields in HdmiCecKeycode.
Bug: 17099253
Change-Id: I8b6b6b361f0c343b0a263240b49e41bf289d36ca
Diffstat (limited to 'services/core/java/com/android/server/hdmi')
4 files changed, 23 insertions, 48 deletions
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecKeycode.java b/services/core/java/com/android/server/hdmi/HdmiCecKeycode.java index 46b2b3e..aed5dcc 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecKeycode.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecKeycode.java @@ -155,7 +155,7 @@ final class HdmiCecKeycode { } /** - * A mapping between andorid and cec keycode. + * A mapping between Android and CEC keycode. * * <p>Normal implementation of this looks like * <pre> @@ -174,43 +174,28 @@ final class HdmiCecKeycode { private static class KeycodeEntry { private final int mAndroidKeycode; private final int mCecKeycode; - private final int mParam; private final boolean mIsRepeatable; - private KeycodeEntry(int androidKeycode, int cecKeycode, int param, boolean isRepeatable) { + private KeycodeEntry(int androidKeycode, int cecKeycode, boolean isRepeatable) { mAndroidKeycode = androidKeycode; mCecKeycode = cecKeycode; - mParam = param; mIsRepeatable = isRepeatable; } private KeycodeEntry(int androidKeycode, int cecKeycode) { - this(androidKeycode, cecKeycode, NO_PARAM, true); - } - - private KeycodeEntry(int androidKeycode, int cecKeycode, boolean isRepeatable) { - this(androidKeycode, cecKeycode, NO_PARAM, isRepeatable); + this(androidKeycode, cecKeycode, true); } - private byte[] toCecKeycodeIfMatched(int androidKeycode) { + private int toCecKeycodeIfMatched(int androidKeycode) { if (mAndroidKeycode == androidKeycode) { - if (mParam == NO_PARAM) { - return new byte[] { - (byte) (mCecKeycode & 0xFF) - }; - } else { - return new byte[] { - (byte) (mCecKeycode & 0xFF), - (byte) (mParam & 0xFF) - }; - } + return mCecKeycode; } else { - return null; + return UNSUPPORTED_KEYCODE; } } - private int toAndroidKeycodeIfMatched(int cecKeycode, int param) { - if (cecKeycode == mCecKeycode && mParam == param) { + private int toAndroidKeycodeIfMatched(int cecKeycode) { + if (cecKeycode == mCecKeycode) { return mAndroidKeycode; } else { return UNSUPPORTED_KEYCODE; @@ -365,29 +350,28 @@ final class HdmiCecKeycode { * Translate Android keycode to Hdmi Cec keycode. * * @param keycode Android keycode. For details, refer {@link KeyEvent} - * @return array of byte which contains cec keycode and param if it has; - * return null if failed to find matched cec keycode + * @return single byte CEC keycode if matched. */ - static byte[] androidKeyToCecKey(int keycode) { + static int androidKeyToCecKey(int keycode) { for (int i = 0; i < KEYCODE_ENTRIES.length; ++i) { - byte[] cecKeycode = KEYCODE_ENTRIES[i].toCecKeycodeIfMatched(keycode); - if (cecKeycode != null) { + int cecKeycode = KEYCODE_ENTRIES[i].toCecKeycodeIfMatched(keycode); + if (cecKeycode != UNSUPPORTED_KEYCODE) { return cecKeycode; } } - return null; + return UNSUPPORTED_KEYCODE; } /** * Translate Hdmi CEC keycode to Android keycode. * - * @param keycode Cec keycode. If has no param, put {@link #NO_PARAM} + * @param keycode CEC keycode * @return cec keycode corresponding to the given android keycode. * If finds no matched keycode, return {@link #UNSUPPORTED_KEYCODE} */ - static int cecKeyToAndroidKey(int keycode, int param) { + static int cecKeyToAndroidKey(int keycode) { for (int i = 0; i < KEYCODE_ENTRIES.length; ++i) { - int androidKey = KEYCODE_ENTRIES[i].toAndroidKeycodeIfMatched(keycode, param); + int androidKey = KEYCODE_ENTRIES[i].toAndroidKeycodeIfMatched(keycode); if (androidKey != UNSUPPORTED_KEYCODE) { return androidKey; } diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java index 4862f93..b43ad1b 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java @@ -405,8 +405,9 @@ abstract class HdmiCecLocalDevice { final long downTime = SystemClock.uptimeMillis(); final byte[] params = message.getParams(); - final int keycode = HdmiCecKeycode.cecKeyToAndroidKey(params[0], - params.length > 1 ? params[1] : HdmiCecKeycode.NO_PARAM); + // Note that we don't support parameterized keycode now. + // TODO: translate parameterized keycode as well. + final int keycode = HdmiCecKeycode.cecKeyToAndroidKey(params[0]); int keyRepeatCount = 0; if (mLastKeycode != HdmiCecKeycode.UNSUPPORTED_KEYCODE) { if (keycode == mLastKeycode) { diff --git a/services/core/java/com/android/server/hdmi/HdmiControlService.java b/services/core/java/com/android/server/hdmi/HdmiControlService.java index 14c066e..59c2a7f 100644 --- a/services/core/java/com/android/server/hdmi/HdmiControlService.java +++ b/services/core/java/com/android/server/hdmi/HdmiControlService.java @@ -320,7 +320,6 @@ public final class HdmiControlService extends SystemService { } } - private void registerContentObserver() { ContentResolver resolver = getContext().getContentResolver(); String[] settings = new String[] { @@ -330,7 +329,7 @@ public final class HdmiControlService extends SystemService { Global.MHL_INPUT_SWITCHING_ENABLED, Global.MHL_POWER_CHARGE_ENABLED }; - for (String s: settings) { + for (String s : settings) { resolver.registerContentObserver(Global.getUriFor(s), false, mSettingsObserver, UserHandle.USER_ALL); } diff --git a/services/core/java/com/android/server/hdmi/SendKeyAction.java b/services/core/java/com/android/server/hdmi/SendKeyAction.java index 9f09eb4..ed978e0 100644 --- a/services/core/java/com/android/server/hdmi/SendKeyAction.java +++ b/services/core/java/com/android/server/hdmi/SendKeyAction.java @@ -109,12 +109,12 @@ final class SendKeyAction extends HdmiCecFeatureAction { } private void sendKeyDown(int keycode) { - byte[] keycodeAndParam = getCecKeycodeAndParam(keycode); - if (keycodeAndParam == null) { + int cecKeycode = HdmiCecKeycode.androidKeyToCecKey(keycode); + if (cecKeycode == HdmiCecKeycode.UNSUPPORTED_KEYCODE) { return; } sendCommand(HdmiCecMessageBuilder.buildUserControlPressed(getSourceAddress(), - mTargetAddress, keycodeAndParam)); + mTargetAddress, new byte[] { (byte) (cecKeycode & 0xFF) })); } private void sendKeyUp() { @@ -141,13 +141,4 @@ final class SendKeyAction extends HdmiCecFeatureAction { sendKeyDown(mLastKeycode); addTimer(mState, IRT_MS); } - - // Converts the Android key code to corresponding CEC key code definition. Those CEC keys - // with additional parameters should be mapped from individual Android key code. 'Select - // Broadcast' with the parameter 'cable', for instance, shall have its counterpart such as - // KeyEvent.KEYCODE_TV_BROADCAST_CABLE. - // The return byte array contains both UI command (keycode) and optional parameter. - private byte[] getCecKeycodeAndParam(int keycode) { - return HdmiCecKeycode.androidKeyToCecKey(keycode); - } } |