summaryrefslogtreecommitdiffstats
path: root/services/jni
diff options
context:
space:
mode:
authornadlabak <pavel@doshaska.net>2013-05-13 17:41:57 +0200
committernadlabak <pavel@doshaska.net>2013-09-17 01:23:58 +0200
commit22a4d65f66a6155a60d77a22922c195fb22a1bd6 (patch)
treed282a402ce56e1bcb66eb515bbe08d19c568f781 /services/jni
parentd8574e9aa82071f85b751e1f7dccd19759ffc7a9 (diff)
downloadframeworks_base-22a4d65f66a6155a60d77a22922c195fb22a1bd6.zip
frameworks_base-22a4d65f66a6155a60d77a22922c195fb22a1bd6.tar.gz
frameworks_base-22a4d65f66a6155a60d77a22922c195fb22a1bd6.tar.bz2
Re-implement orientation aware volume buttons at lower level
Rework of http://review.cyanogenmod.org/31979 Fixes: 1. inconsistent volume button behaviour depending on app in use - the buttons were not swapped for some NDK/OPENSL ES apps like e.g. MX Player 2. the function of volume buttons on external input devices like BT/USB keyboards should not be affected by the main unit orientation This commit finishes http://review.cyanogenmod.org/18273 - use of system property has been replaced with config push via JNI as suggested during the original review. Patch Set 7: Circumvent the need for "keyboard.orientationAware = 1" idc Patch Set 8: Don't leak implementation details outside InputReader Change-Id: I19cc60cb0acb0005ab13fa069f52e3d468d694e7
Diffstat (limited to 'services/jni')
-rw-r--r--services/jni/com_android_server_input_InputManagerService.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/services/jni/com_android_server_input_InputManagerService.cpp b/services/jni/com_android_server_input_InputManagerService.cpp
index 55a8061..6d98907 100644
--- a/services/jni/com_android_server_input_InputManagerService.cpp
+++ b/services/jni/com_android_server_input_InputManagerService.cpp
@@ -177,6 +177,7 @@ public:
void setPointerSpeed(int32_t speed);
void setShowTouches(bool enabled);
void setStylusIconEnabled(bool enabled);
+ void setVolumeKeysRotation(int mode);
/* --- InputReaderPolicyInterface implementation --- */
@@ -240,6 +241,9 @@ private:
// Show icon when stylus is used
bool stylusIconEnabled;
+ // Volume keys rotation mode (0 - off, 1 - phone, 2 - tablet)
+ int32_t volumeKeysRotationMode;
+
// Sprite controller singleton, created on first use.
sp<SpriteController> spriteController;
@@ -279,6 +283,7 @@ NativeInputManager::NativeInputManager(jobject contextObj,
mLocked.pointerGesturesEnabled = true;
mLocked.showTouches = false;
mLocked.stylusIconEnabled = false;
+ mLocked.volumeKeysRotationMode = 0;
}
sp<EventHub> eventHub = new EventHub();
@@ -412,6 +417,7 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon
outConfig->showTouches = mLocked.showTouches;
outConfig->stylusIconEnabled = mLocked.stylusIconEnabled;
+ outConfig->volumeKeysRotationMode = mLocked.volumeKeysRotationMode;
outConfig->setDisplayInfo(false /*external*/, mLocked.internalViewport);
outConfig->setDisplayInfo(true /*external*/, mLocked.externalViewport);
@@ -752,6 +758,22 @@ void NativeInputManager::setStylusIconEnabled(bool enabled) {
InputReaderConfiguration::CHANGE_STYLUS_ICON_ENABLED);
}
+void NativeInputManager::setVolumeKeysRotation(int mode) {
+ { // acquire lock
+ AutoMutex _l(mLock);
+
+ if (mLocked.volumeKeysRotationMode == mode) {
+ return;
+ }
+
+ ALOGI("Volume keys: rotation mode set to %d.", mode);
+ mLocked.volumeKeysRotationMode = mode;
+ } // release lock
+
+ mInputManager->getReader()->requestRefreshConfiguration(
+ InputReaderConfiguration::CHANGE_VOLUME_KEYS_ROTATION);
+}
+
bool NativeInputManager::isScreenOn() {
return android_server_PowerManagerService_isScreenOn();
}
@@ -1250,6 +1272,13 @@ static void nativeSetStylusIconEnabled(JNIEnv* env,
im->setStylusIconEnabled(enabled);
}
+static void nativeSetVolumeKeysRotation(JNIEnv* env,
+ jclass clazz, jint ptr, int mode) {
+ NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
+
+ im->setVolumeKeysRotation(mode);
+}
+
static void nativeVibrate(JNIEnv* env,
jclass clazz, jint ptr, jint deviceId, jlongArray patternObj,
jint repeat, jint token) {
@@ -1357,6 +1386,8 @@ static JNINativeMethod gInputManagerMethods[] = {
(void*) nativeSetShowTouches },
{ "nativeSetStylusIconEnabled", "(IZ)V",
(void*) nativeSetStylusIconEnabled },
+ { "nativeSetVolumeKeysRotation", "(II)V",
+ (void*) nativeSetVolumeKeysRotation },
{ "nativeVibrate", "(II[JII)V",
(void*) nativeVibrate },
{ "nativeCancelVibrate", "(III)V",