本文整理汇总了Java中android.view.KeyEvent.FLAG_FROM_SYSTEM属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.FLAG_FROM_SYSTEM属性的具体用法?Java KeyEvent.FLAG_FROM_SYSTEM怎么用?Java KeyEvent.FLAG_FROM_SYSTEM使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.view.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.FLAG_FROM_SYSTEM属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleMessage
public void handleMessage(Message m) {
switch (m.what) {
case MSG_INJECT_KEY:
final long eventTime = SystemClock.uptimeMillis();
final InputManager inputManager = (InputManager)
XposedHelpers.callStaticMethod(InputManager.class, "getInstance");
int flags = KeyEvent.FLAG_FROM_SYSTEM;
XposedHelpers.callMethod(inputManager, "injectInputEvent",
new KeyEvent(eventTime - 50, eventTime - 50, KeyEvent.ACTION_DOWN, m.arg1, 0,
0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, flags, InputDevice.SOURCE_UNKNOWN), 0);
XposedHelpers.callMethod(inputManager, "injectInputEvent",
new KeyEvent(eventTime - 50, eventTime - 25, KeyEvent.ACTION_UP, m.arg1, 0,
0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, flags, InputDevice.SOURCE_UNKNOWN), 0);
break;
}
}
示例2: sendEvent
void sendEvent(int action, int flags, long when, boolean applyDefaultFlags) {
try {
final int repeatCount = (flags & KeyEvent.FLAG_LONG_PRESS) != 0 ? 1 : 0;
if (applyDefaultFlags) {
flags |= KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY;
}
final KeyEvent ev = new KeyEvent(mDownTime, when, action, mCode, repeatCount,
0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, flags,
InputDevice.SOURCE_KEYBOARD);
final Object inputManager = XposedHelpers.callStaticMethod(InputManager.class, "getInstance");
XposedHelpers.callMethod(inputManager, "injectInputEvent", ev, 0);
} catch (Throwable t) {
XposedBridge.log(t);
}
}
示例3: beforeHookedMethod
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (!allowSkipTrack) return;
final KeyEvent event = (KeyEvent) param.args[0];
final int keyCode = event.getKeyCode();
initManagers((Context) XposedHelpers.getObjectField(param.thisObject, "mContext"));
if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
keyCode == KeyEvent.KEYCODE_VOLUME_UP) &&
(event.getFlags() & KeyEvent.FLAG_FROM_SYSTEM) != 0 &&
!mPowerManager.isInteractive() &&
mAudioManager != null && mAudioManager.isMusicActive()) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
mIsLongPress = false;
handleVolumeLongPress(param.thisObject, keyCode);
} else {
handleVolumeLongPressAbort(param.thisObject);
if (!mIsLongPress) {
if (mShoudTriggerWakeUp) {
wakeUp();
} else {
mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC,
keyCode == KeyEvent.KEYCODE_VOLUME_UP ?
AudioManager.ADJUST_RAISE : AudioManager.ADJUST_LOWER, 0);
}
}
}
param.setResult(0);
return;
}
}