summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Kilbourn <tkilbourn@google.com>2015-07-23 20:39:44 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-07-23 20:39:44 +0000
commitcc855ad737e61fc02a057e811f2e6e34bbff0e37 (patch)
treea9180db4a962765e19dff313766c0e7a7c7c72bb
parent157ad64dbeedd43a444d3eb1cc538ee975ed2d59 (diff)
parenta405121b5a76d37f29dfa6d95177abbac9cfb101 (diff)
downloadframeworks_base-cc855ad737e61fc02a057e811f2e6e34bbff0e37.zip
frameworks_base-cc855ad737e61fc02a057e811f2e6e34bbff0e37.tar.gz
frameworks_base-cc855ad737e61fc02a057e811f2e6e34bbff0e37.tar.bz2
Merge "Properly synchronize interactivity state." into mnc-dev
-rw-r--r--services/core/jni/com_android_server_input_InputManagerService.cpp36
1 files changed, 31 insertions, 5 deletions
diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp
index f3edbd1..e29d0a9 100644
--- a/services/core/jni/com_android_server_input_InputManagerService.cpp
+++ b/services/core/jni/com_android_server_input_InputManagerService.cpp
@@ -27,6 +27,8 @@
#include "JNIHelp.h"
#include "jni.h"
+#include <atomic>
+#include <cinttypes>
#include <limits.h>
#include <android_runtime/AndroidRuntime.h>
#include <android_runtime/Log.h>
@@ -56,6 +58,8 @@
#include "com_android_server_input_InputApplicationHandle.h"
#include "com_android_server_input_InputWindowHandle.h"
+#define INDENT " "
+
namespace android {
// The exponent used to calculate the pointer speed scaling factor.
@@ -126,6 +130,10 @@ inline static T max(const T& a, const T& b) {
return a > b ? a : b;
}
+static inline const char* toString(bool value) {
+ return value ? "true" : "false";
+}
+
static jobject getInputApplicationHandleObjLocalRef(JNIEnv* env,
const sp<InputApplicationHandle>& inputApplicationHandle) {
if (inputApplicationHandle == NULL) {
@@ -262,7 +270,7 @@ private:
wp<PointerController> pointerController;
} mLocked;
- volatile bool mInteractive;
+ std::atomic<bool> mInteractive;
void updateInactivityTimeoutLocked(const sp<PointerController>& controller);
void handleInterceptActions(jint wmActions, nsecs_t when, uint32_t& policyFlags);
@@ -292,6 +300,7 @@ NativeInputManager::NativeInputManager(jobject contextObj,
mLocked.pointerGesturesEnabled = true;
mLocked.showTouches = false;
}
+ mInteractive = true;
sp<EventHub> eventHub = new EventHub();
mInputManager = new InputManager(eventHub, this, this);
@@ -305,6 +314,21 @@ NativeInputManager::~NativeInputManager() {
}
void NativeInputManager::dump(String8& dump) {
+ dump.append("Input Manager State:\n");
+ {
+ dump.appendFormat(INDENT "Interactive: %s\n", toString(mInteractive.load()));
+ }
+ {
+ AutoMutex _l(mLock);
+ dump.appendFormat(INDENT "System UI Visibility: 0x%0" PRIx32 "\n",
+ mLocked.systemUiVisibility);
+ dump.appendFormat(INDENT "Pointer Speed: %" PRId32 "\n", mLocked.pointerSpeed);
+ dump.appendFormat(INDENT "Pointer Gestures Enabled: %s\n",
+ toString(mLocked.pointerGesturesEnabled));
+ dump.appendFormat(INDENT "Show Touches: %s\n", toString(mLocked.showTouches));
+ }
+ dump.append("\n");
+
mInputManager->getReader()->dump(dump);
dump.append("\n");
@@ -830,7 +854,8 @@ void NativeInputManager::interceptKeyBeforeQueueing(const KeyEvent* keyEvent,
// - Ignore untrusted events and pass them along.
// - Ask the window manager what to do with normal events and trusted injected events.
// - For normal events wake and brighten the screen if currently off or dim.
- if (mInteractive) {
+ bool interactive = mInteractive.load();
+ if (interactive) {
policyFlags |= POLICY_FLAG_INTERACTIVE;
}
if ((policyFlags & POLICY_FLAG_TRUSTED)) {
@@ -854,7 +879,7 @@ void NativeInputManager::interceptKeyBeforeQueueing(const KeyEvent* keyEvent,
handleInterceptActions(wmActions, when, /*byref*/ policyFlags);
} else {
- if (mInteractive) {
+ if (interactive) {
policyFlags |= POLICY_FLAG_PASS_TO_USER;
}
}
@@ -866,7 +891,8 @@ void NativeInputManager::interceptMotionBeforeQueueing(nsecs_t when, uint32_t& p
// - No special filtering for injected events required at this time.
// - Filter normal events based on screen state.
// - For normal events brighten (but do not wake) the screen if currently dim.
- if (mInteractive) {
+ bool interactive = mInteractive.load();
+ if (interactive) {
policyFlags |= POLICY_FLAG_INTERACTIVE;
}
if ((policyFlags & POLICY_FLAG_TRUSTED) && !(policyFlags & POLICY_FLAG_INJECTED)) {
@@ -885,7 +911,7 @@ void NativeInputManager::interceptMotionBeforeQueueing(nsecs_t when, uint32_t& p
handleInterceptActions(wmActions, when, /*byref*/ policyFlags);
}
} else {
- if (mInteractive) {
+ if (interactive) {
policyFlags |= POLICY_FLAG_PASS_TO_USER;
}
}