diff options
author | Michael Gernoth <michael@gernoth.net> | 2014-11-18 19:43:45 +0100 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-10-18 00:51:43 -0700 |
commit | 11165e591a0e74e889f7b910d8bd81e9ae176a34 (patch) | |
tree | fc90a44fa4af206555466121f53942d71b119c1f /core/java/android/text/method | |
parent | 4f8045a213600f9115d0e5b43e83627a28ca066c (diff) | |
download | frameworks_base-11165e591a0e74e889f7b910d8bd81e9ae176a34.zip frameworks_base-11165e591a0e74e889f7b910d8bd81e9ae176a34.tar.gz frameworks_base-11165e591a0e74e889f7b910d8bd81e9ae176a34.tar.bz2 |
keyboard: re-add code to detect lid state and handle lights
Depends on libhardware patch for the light ids:
http://review.cyanogenmod.org/77944
This squashes the following commits from cm-11.0 and updates
them for cm-12.0:
From: Dave Daynard <nardholio@gmail.com>
Date: Tue, 19 Nov 2013 18:22:45 -0500
Subject: keyboard: re-add code to detect lid state
keyboard: re-add code to detect lid state
This was lost in the cm-11 merge. Without this, a change in lid state
isn't generated to light up the keyboard backlight
Change-Id: Ief35cebcb62da13afe1ae7531d69ab58e196be9e
From: YuanQY <yuanqingyun@gmail.com>
Date: Fri, 8 Feb 2013 10:59:22 +0800
Subject: Keyboard light: Fix the physical keyboard not light when
Keyboard light: Fix the physical keyboard not light when it's visiable.
Change-Id: I595afd3cb6b422a17ae0f6ec20aa51979db13810
From: tbalden <illespal@gmail.com>
Date: Sun, 31 Mar 2013 18:33:53 +0200
Subject: keyboard: adding functional alt/shift lights
keyboard: adding functional alt/shift lights
This is useful for devices that has QWERTY keyboard
and leds for the Alt/Shift (Fn/Caps) keys, like
htc doubleshot.
Change-Id: I66ebc2d881438f5b51db77eaa885421e65a7da0d
Diffstat (limited to 'core/java/android/text/method')
-rw-r--r-- | core/java/android/text/method/MetaKeyKeyListener.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/core/java/android/text/method/MetaKeyKeyListener.java b/core/java/android/text/method/MetaKeyKeyListener.java index e9db5fd..569ca60 100644 --- a/core/java/android/text/method/MetaKeyKeyListener.java +++ b/core/java/android/text/method/MetaKeyKeyListener.java @@ -23,6 +23,9 @@ import android.text.Spanned; import android.view.KeyEvent; import android.view.View; import android.view.KeyCharacterMap; +import android.os.IPowerManager; +import android.os.RemoteException; +import android.os.ServiceManager; /** * This base class encapsulates the behavior for tracking the state of @@ -273,6 +276,14 @@ public abstract class MetaKeyKeyListener { adjust(content, CAP); adjust(content, ALT); adjust(content, SYM); + try { + IPowerManager power = IPowerManager.Stub.asInterface( + ServiceManager.getService("power")); + if (getMetaState(content, META_SHIFT_ON) <= 0) + power.setKeyboardLight(false, 1); + if (getMetaState(content, META_ALT_ON) <= 0) + power.setKeyboardLight(false, 2); + } catch (RemoteException doe) {} } /** @@ -325,12 +336,32 @@ public abstract class MetaKeyKeyListener { public boolean onKeyDown(View view, Editable content, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_SHIFT_LEFT || keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT) { press(content, CAP); + try { + IPowerManager power = IPowerManager.Stub.asInterface( + ServiceManager.getService("power")); + int state = content.getSpanFlags(CAP); + if (state == PRESSED || state == LOCKED) { + power.setKeyboardLight(true, 1); + } else { + power.setKeyboardLight(false, 1); + } + } catch (RemoteException doe) {} return true; } if (keyCode == KeyEvent.KEYCODE_ALT_LEFT || keyCode == KeyEvent.KEYCODE_ALT_RIGHT || keyCode == KeyEvent.KEYCODE_NUM) { press(content, ALT); + try { + IPowerManager power = IPowerManager.Stub.asInterface( + ServiceManager.getService("power")); + int state = content.getSpanFlags(ALT); + if (state == PRESSED || state == LOCKED) { + power.setKeyboardLight(true, 2); + } else { + power.setKeyboardLight(false, 2); + } + } catch (RemoteException doe) {} return true; } |