FileDocCategorySizeDatePackage
DebugTrigger.javaAPI DocAndroid 5.1 API2136Thu Mar 12 22:22:42 GMT 2015com.android.systemui.recents.misc

DebugTrigger

public class DebugTrigger extends Object
A trigger for catching a debug chord. We currently use volume up then volume down to trigger this mode.

Fields Summary
android.os.Handler
mHandler
Runnable
mTriggeredRunnable
int
mLastKeyCode
long
mLastKeyCodeTime
Constructors Summary
public DebugTrigger(Runnable triggeredRunnable)

        mHandler = new Handler();
        mTriggeredRunnable = triggeredRunnable;
    
Methods Summary
public voidonKeyEvent(int keyCode)
Processes a key event and tests if it is a part of the trigger. If the chord is complete, then we just call the callback.

        if (!Constants.DebugFlags.App.EnableDebugMode) return;

        if (mLastKeyCode == 0) {
            if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
                mLastKeyCode = keyCode;
                mLastKeyCodeTime = SystemClock.uptimeMillis();
                return;
            }
        } else {
            if (mLastKeyCode == KeyEvent.KEYCODE_VOLUME_UP &&
                    keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
                if ((SystemClock.uptimeMillis() - mLastKeyCodeTime) < 750) {
                    mTriggeredRunnable.run();
                }
            }
        }
        reset();
    
voidreset()
Resets the debug trigger

        mLastKeyCode = 0;
        mLastKeyCodeTime = 0;