当前位置: 首页>>代码示例>>Java>>正文


Java KeyEvent.FLAG_FROM_SYSTEM属性代码示例

本文整理汇总了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;
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:18,代码来源:PieController.java

示例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);
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:15,代码来源:KeyButtonView.java

示例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;
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:31,代码来源:ModVolumeKeySkipTrack.java


注:本文中的android.view.KeyEvent.FLAG_FROM_SYSTEM属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。