am 13701b50: Merge "Bundle correlated switch changes atomically." into jb-mr1-dev
* commit '13701b50f533775fd7a547fd0e479c1ec9035ce8': Bundle correlated switch changes atomically.
This commit is contained in:
@@ -2485,15 +2485,15 @@ bool InputDispatcher::shouldSendMotionToInputFilterLocked(const NotifyMotionArgs
|
||||
|
||||
void InputDispatcher::notifySwitch(const NotifySwitchArgs* args) {
|
||||
#if DEBUG_INBOUND_EVENT_DETAILS
|
||||
ALOGD("notifySwitch - eventTime=%lld, policyFlags=0x%x, switchCode=%d, switchValue=%d",
|
||||
ALOGD("notifySwitch - eventTime=%lld, policyFlags=0x%x, switchValues=0x%08x, switchMask=0x%08x",
|
||||
args->eventTime, args->policyFlags,
|
||||
args->switchCode, args->switchValue);
|
||||
args->switchValues, args->switchMask);
|
||||
#endif
|
||||
|
||||
uint32_t policyFlags = args->policyFlags;
|
||||
policyFlags |= POLICY_FLAG_TRUSTED;
|
||||
mPolicy->notifySwitch(args->eventTime,
|
||||
args->switchCode, args->switchValue, policyFlags);
|
||||
args->switchValues, args->switchMask, policyFlags);
|
||||
}
|
||||
|
||||
void InputDispatcher::notifyDeviceReset(const NotifyDeviceResetArgs* args) {
|
||||
|
||||
@@ -248,7 +248,7 @@ public:
|
||||
/* Notifies the policy about switch events.
|
||||
*/
|
||||
virtual void notifySwitch(nsecs_t when,
|
||||
int32_t switchCode, int32_t switchValue, uint32_t policyFlags) = 0;
|
||||
uint32_t switchValues, uint32_t switchMask, uint32_t policyFlags) = 0;
|
||||
|
||||
/* Poke user activity for an event dispatched to a window. */
|
||||
virtual void pokeUserActivity(nsecs_t eventTime, int32_t eventType) = 0;
|
||||
|
||||
@@ -104,14 +104,14 @@ void NotifyMotionArgs::notify(const sp<InputListenerInterface>& listener) const
|
||||
// --- NotifySwitchArgs ---
|
||||
|
||||
NotifySwitchArgs::NotifySwitchArgs(nsecs_t eventTime, uint32_t policyFlags,
|
||||
int32_t switchCode, int32_t switchValue) :
|
||||
uint32_t switchValues, uint32_t switchMask) :
|
||||
eventTime(eventTime), policyFlags(policyFlags),
|
||||
switchCode(switchCode), switchValue(switchValue) {
|
||||
switchValues(switchValues), switchMask(switchMask) {
|
||||
}
|
||||
|
||||
NotifySwitchArgs::NotifySwitchArgs(const NotifySwitchArgs& other) :
|
||||
eventTime(other.eventTime), policyFlags(other.policyFlags),
|
||||
switchCode(other.switchCode), switchValue(other.switchValue) {
|
||||
switchValues(other.switchValues), switchMask(other.switchMask) {
|
||||
}
|
||||
|
||||
void NotifySwitchArgs::notify(const sp<InputListenerInterface>& listener) const {
|
||||
|
||||
@@ -116,13 +116,13 @@ struct NotifyMotionArgs : public NotifyArgs {
|
||||
struct NotifySwitchArgs : public NotifyArgs {
|
||||
nsecs_t eventTime;
|
||||
uint32_t policyFlags;
|
||||
int32_t switchCode;
|
||||
int32_t switchValue;
|
||||
uint32_t switchValues;
|
||||
uint32_t switchMask;
|
||||
|
||||
inline NotifySwitchArgs() { }
|
||||
|
||||
NotifySwitchArgs(nsecs_t eventTime, uint32_t policyFlags,
|
||||
int32_t switchCode, int32_t switchValue);
|
||||
uint32_t switchValues, uint32_t switchMask);
|
||||
|
||||
NotifySwitchArgs(const NotifySwitchArgs& other);
|
||||
|
||||
|
||||
@@ -1800,7 +1800,7 @@ void InputMapper::dumpRawAbsoluteAxisInfo(String8& dump,
|
||||
// --- SwitchInputMapper ---
|
||||
|
||||
SwitchInputMapper::SwitchInputMapper(InputDevice* device) :
|
||||
InputMapper(device) {
|
||||
InputMapper(device), mUpdatedSwitchValues(0), mUpdatedSwitchMask(0) {
|
||||
}
|
||||
|
||||
SwitchInputMapper::~SwitchInputMapper() {
|
||||
@@ -1813,14 +1813,33 @@ uint32_t SwitchInputMapper::getSources() {
|
||||
void SwitchInputMapper::process(const RawEvent* rawEvent) {
|
||||
switch (rawEvent->type) {
|
||||
case EV_SW:
|
||||
processSwitch(rawEvent->when, rawEvent->code, rawEvent->value);
|
||||
processSwitch(rawEvent->code, rawEvent->value);
|
||||
break;
|
||||
|
||||
case EV_SYN:
|
||||
if (rawEvent->code == SYN_REPORT) {
|
||||
sync(rawEvent->when);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SwitchInputMapper::processSwitch(nsecs_t when, int32_t switchCode, int32_t switchValue) {
|
||||
NotifySwitchArgs args(when, 0, switchCode, switchValue);
|
||||
getListener()->notifySwitch(&args);
|
||||
void SwitchInputMapper::processSwitch(int32_t switchCode, int32_t switchValue) {
|
||||
if (switchCode >= 0 && switchCode < 32) {
|
||||
if (switchValue) {
|
||||
mUpdatedSwitchValues |= 1 << switchCode;
|
||||
}
|
||||
mUpdatedSwitchMask |= 1 << switchCode;
|
||||
}
|
||||
}
|
||||
|
||||
void SwitchInputMapper::sync(nsecs_t when) {
|
||||
if (mUpdatedSwitchMask) {
|
||||
NotifySwitchArgs args(when, 0, mUpdatedSwitchValues, mUpdatedSwitchMask);
|
||||
getListener()->notifySwitch(&args);
|
||||
|
||||
mUpdatedSwitchValues = 0;
|
||||
mUpdatedSwitchMask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t SwitchInputMapper::getSwitchState(uint32_t sourceMask, int32_t switchCode) {
|
||||
|
||||
@@ -962,7 +962,11 @@ public:
|
||||
virtual int32_t getSwitchState(uint32_t sourceMask, int32_t switchCode);
|
||||
|
||||
private:
|
||||
void processSwitch(nsecs_t when, int32_t switchCode, int32_t switchValue);
|
||||
uint32_t mUpdatedSwitchValues;
|
||||
uint32_t mUpdatedSwitchMask;
|
||||
|
||||
void processSwitch(int32_t switchCode, int32_t switchValue);
|
||||
void sync(nsecs_t when);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ private:
|
||||
}
|
||||
|
||||
virtual void notifySwitch(nsecs_t when,
|
||||
int32_t switchCode, int32_t switchValue, uint32_t policyFlags) {
|
||||
uint32_t switchValues, uint32_t switchMask, uint32_t policyFlags) {
|
||||
}
|
||||
|
||||
virtual void pokeUserActivity(nsecs_t eventTime, int32_t eventType) {
|
||||
|
||||
@@ -1493,12 +1493,16 @@ TEST_F(SwitchInputMapperTest, Process) {
|
||||
addMapperAndConfigure(mapper);
|
||||
|
||||
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SW, SW_LID, 1);
|
||||
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SW, SW_JACK_PHYSICAL_INSERT, 1);
|
||||
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SW, SW_HEADPHONE_INSERT, 0);
|
||||
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
|
||||
|
||||
NotifySwitchArgs args;
|
||||
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifySwitchWasCalled(&args));
|
||||
ASSERT_EQ(ARBITRARY_TIME, args.eventTime);
|
||||
ASSERT_EQ(SW_LID, args.switchCode);
|
||||
ASSERT_EQ(1, args.switchValue);
|
||||
ASSERT_EQ((1 << SW_LID) | (1 << SW_JACK_PHYSICAL_INSERT), args.switchValues);
|
||||
ASSERT_EQ((1 << SW_LID) | (1 << SW_JACK_PHYSICAL_INSERT) | (1 << SW_HEADPHONE_INSERT),
|
||||
args.switchMask);
|
||||
ASSERT_EQ(uint32_t(0), args.policyFlags);
|
||||
}
|
||||
|
||||
|
||||
@@ -1238,11 +1238,15 @@ public class InputManagerService extends IInputManager.Stub
|
||||
}
|
||||
|
||||
// Native callback.
|
||||
private void notifySwitch(long whenNanos, int switchCode, int switchValue) {
|
||||
switch (switchCode) {
|
||||
case SW_LID:
|
||||
mWindowManagerCallbacks.notifyLidSwitchChanged(whenNanos, switchValue == 0);
|
||||
break;
|
||||
private void notifySwitch(long whenNanos, int switchValues, int switchMask) {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "notifySwitch: values=" + Integer.toHexString(switchValues)
|
||||
+ ", mask=" + Integer.toHexString(switchMask));
|
||||
}
|
||||
|
||||
if ((switchMask & (1 << SW_LID)) != 0) {
|
||||
final boolean lidOpen = ((switchValues & (1 << SW_LID)) == 0);
|
||||
mWindowManagerCallbacks.notifyLidSwitchChanged(whenNanos, lidOpen);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ public:
|
||||
|
||||
/* --- InputDispatcherPolicyInterface implementation --- */
|
||||
|
||||
virtual void notifySwitch(nsecs_t when, int32_t switchCode, int32_t switchValue,
|
||||
virtual void notifySwitch(nsecs_t when, uint32_t switchValues, uint32_t switchMask,
|
||||
uint32_t policyFlags);
|
||||
virtual void notifyConfigurationChanged(nsecs_t when);
|
||||
virtual nsecs_t notifyANR(const sp<InputApplicationHandle>& inputApplicationHandle,
|
||||
@@ -527,17 +527,17 @@ String8 NativeInputManager::getDeviceAlias(const InputDeviceIdentifier& identifi
|
||||
return result;
|
||||
}
|
||||
|
||||
void NativeInputManager::notifySwitch(nsecs_t when, int32_t switchCode,
|
||||
int32_t switchValue, uint32_t policyFlags) {
|
||||
void NativeInputManager::notifySwitch(nsecs_t when,
|
||||
uint32_t switchValues, uint32_t switchMask, uint32_t policyFlags) {
|
||||
#if DEBUG_INPUT_DISPATCHER_POLICY
|
||||
ALOGD("notifySwitch - when=%lld, switchCode=%d, switchValue=%d, policyFlags=0x%x",
|
||||
when, switchCode, switchValue, policyFlags);
|
||||
ALOGD("notifySwitch - when=%lld, switchValues=0x%08x, switchMask=0x%08x, policyFlags=0x%x",
|
||||
when, switchValues, switchMask, policyFlags);
|
||||
#endif
|
||||
|
||||
JNIEnv* env = jniEnv();
|
||||
|
||||
env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifySwitch,
|
||||
when, switchCode, switchValue);
|
||||
when, switchValues, switchMask);
|
||||
checkAndClearExceptionFromCallback(env, "notifySwitch");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user