PixelXpert icon indicating copy to clipboard operation
PixelXpert copied to clipboard

Increase time to kill process

Open laufersteppenwolf opened this issue 2 years ago • 2 comments

https://github.com/siavash79/AOSPMods/blob/1612e691a9fb31629445c4e2e194e6b854770997/app/src/main/java/sh/siava/AOSPMods/systemui/BackToKill.java#L39

The BackToKill function uses a regular onLongClickListener, however, some apps also use the onLongClickListener for their features, which means we would rather kill the app before using the apps features. Also, the OnLongClickListener has a rather short time, which means we can easily kill an app by accident

Maybe we could use something like this:

long downTime = 0;
    View.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if(event.getAction() == MotionEvent.ACTION_DOWN){
                downTime = (Long) System.currentTimeMillis();
            }
            else if(event.getAction() == MotionEvent.ACTION_UP){
                if(((Long) System.currentTimeMillis() - downTime) > 3000){
                    if(!isEnabled) return true;

                    Shell.cmd("am force-stop $(dumpsys window | grep mCurrentFocus | cut -d \"/\" -f1 | cut -d \" \" -f5)").submit();

                    return true;
                }
            }
            return false;
        }
    })

Note that this code is not tested, it is just a suggestion

laufersteppenwolf avatar Jun 26 '22 13:06 laufersteppenwolf

such a good idea! why don't you make the changes and send a PR? this way you can test the code, and also have the change registered under your own name

AND: If you know how to code, why don't you contribute more to the project?

siavash79 avatar Jun 27 '22 12:06 siavash79

Well, for once, I haven't coded for Android in like forever :D And actually never ever with xposed, back in the days, I just added whatever feature I wanted directly to my own CustomRom You have probably everything set up and are way faster implementing it ;)

Is this actually a good way to implement this change? This event fires only after you lifted the button after the given time, not as soon as the time has elapsed. Does this make sense or would it be better to fire as soon as the time has elapsed?

laufersteppenwolf avatar Jun 29 '22 20:06 laufersteppenwolf

closing to due drop of the function in sdk 33

siavash79 avatar Sep 27 '22 06:09 siavash79