Prevent Accidental Reboots when holding down the power button I often end up accidentally rebooting my Nexus 6 while having it in my pocket, because the power buttons gets pushed for more than 10 seconds.

Considering the long boot times, this can be very annoying.

I can see why it is important to have a way to force-reboot your when it gets stuck, even though I haven't had this type of issue  yet.

Is there are way I can change the force-reboot behaviour?

Perhaps increase the time in which power button must be pushed or change it to a combination of buttons (i.e. volume up + power button for 10 seconds) ...anythign that makes it less likely to be triggered by my pocket.
I was hoping some flexibility in long-press timeout using AutoInput but the apps slows down my OS considerably to do anything with it. 

Anyhow, all I suggest is to use Xposed Additions (free/paid; requires Xposed Framework; if you've Android 5.x, you would need to flash some files from custom recovery. See this XDA thread by rovo89 for such case).

We need Tasker (paid, 7 day free trial) too.

Instructions

(Tested on Android 5.0.2 and 5.1.1)


Install both the apps &rarr; activate Xposed Additions's module &rarr; launch Xposed Additions
Tap Buttons &rarr;  set Long press delay slider to maximum (500ms) &rarr; Add new Key &rarr; press Power key to select it &rarr; Power
Tap Add new Condition &rarr; Screen Off &rarr; Screen Off &rarr; enable Long Press &rarr; Shortcut &rarr; Task Shortcut &rarr; New Task &rarr; name the task. 

Note: You can try MacroDroid's MacroDroid Shortcut in place of Task Shortcut. The free version is restricted to one action per macro, so you wouldn't get any flexibility, but it is acceptable here.
For your task, action would be: 


Alert &rarr; Vibrate &rarr; Time: select the vibration time (in milliseconds) 


It is possible that vibration for 1000ms would not be enough for you. In that case, add combination of actions. For example, in addition to last Vibrate action, you can also do:


Task &rarr; Wait &rarr; select MS or/and Seconds slightly greater than milliseconds selected in last Vibrate action

Wait is important because if you add continuous Vibrate actions then you would end up skipping almost  of them except the first one. Tasker doesn't queue vibrate requests, as it seems to me.
Now, add another Vibrate action and copy-paste the whole cycle as much as you want.

Select an icon for your task and there you go. 


You can now test your solution. 



Experimental

For users having AutoInput satisfactorily running, you can emulate long-press of a key. I tested my solution on Volume Up key and it worked perfectly. Well almost!

For Tasker:

Profile 1: Event &rarr; Plugin &rarr; AutoInput &rarr; Key &rarr; Configuration:


select your key under Keys
select Key Action to Key Down


Task 1: Actions:


Variable &rarr; Variable Set &rarr; Variable: %Set &rarr; To: 0 
Task &rarr; Wait &rarr; select MS or Seconds for your desired long-press timeout. Choose 1 Second for experimental purposes
Task &rarr; If &rarr; %Set eq 0
Alert &rarr; Vibrate &rarr; Time: 1000ms


Profile 2: Event &rarr; Plugin &rarr; AutoInput &rarr; Key &rarr; Configuration:


select your key under Keys
select Key Action to Key Up


Task 2: Actions:


Variable &rarr; Variable Set &rarr; Variable: %Set &rarr; To: 1 


Use the action Key Suppress from Plugin &rarr; AutoInput &rarr; Modes, wherever feels necessary. Also, I didn't yet experiment with screen off state.

Now, the theory: The flow is in this manner:


When your selected key (say Key-X) would be pressed, profile 1 would activate.
When the key would be released, profile 2 would activate.
We know that for long-press the key needs to be continuously pressed for some time. 
Now, if I long-press Key-X then for that time being profile 2 would not activate and so I can set %Set to 0 in profile 1 &rarr; wait for long-press timeout (slightly less) &rarr; check if %Set is still 0 (%Set would become 1 if key gets released) and then execute the Vibrate action.  


Simple! Let me know if it works for Power key.