I want to show the turn off/reboot dialog without actually long pressing the power button. Every single source I have found says that this is not possible unless the phone is rooted. However, I found an app called Tasker in the google play store which have the possibility to show the turn off/reboot dialog without the use of the power button or being rooted. This means that it must be possible somehow. The app is using Accessibility Services but I can not figure out how to simulate a long press on the power button. Maybe someone here can help me or point me in the right direction.
I have setup an AccessibilityService which receives events when I press a normal button:
@Override
public void onAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
switch (accessibilityEvent.getEventType()){
case AccessibilityEvent.TYPE_VIEW_CLICKED:
//What should be here ???
break;
}
}
This works but I do not know what to do next.