toneiv / UbikiTouch

UbikiTouch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Force Close Forground App Action

Friday13th87 opened this issue · comments

Is there any way to get a function / action to force close the current foreground app?
i tried to record an action by recording while killing a foreground app with another application, but it was not recording the process actually.
Is there a way to write a *.bin file for the action and then import it?
the command i was thinking about would be:
package='dumpsys window windows | grep mCurrentFocus | grep -oP '(?<=\s).\S*?(?=/)''
am force-stop $package

I have done some tests and I think I can come up with a solution. However, unless I am mistaken, this is an action that requires root access.
Is this your case or have you considered another solution?

No actually the ADB command does not require root.
Its looking up the foreground app, saving it and send a force close.
But i think i made a mistake in the first command for the lookup, will have a look at it on the weekend.

You can try it by just connect to a adb shell and type "am force-close anypackage" for example com.whatsapp - no root needed

I tought maybe there is a way to record the action going the system settings way, like
--> opening app info
--> pressing/sending command for force close
as this action-recording is already implemented

Yes, but I don't think it is possible to execute an ADB command to the device from the device itself.
That's why I think root is necessary.

For information I can perform this action as root (so it can be transposed to adb)

  • dumpsys activity recents | grep "Recent #0" returns the application package
  • am force-stop mypackage

The second solution implies that opening the info screen and pressing the button will be perceived by the user, so I'm not too sure that's a good idea. I'll keep digging though.

you can use for example "termux" and use the command with it (without root), so its working from the device itself, but i dont know if its usable by sending a single command by each individual application or if you need something more.

Edit:
I tried to record the "force close" button within the app info screen, but it was not recording the action
Edit2:
On other gesture apps with that action its a "root" option, so most probably you are right or the simplest way is performing it with root

I haven't had much time to dig into it but I think Termux is more of an emulator and doesn't really give access to the device.
It don't have elevated privileges as ADB does. No am force-stop function available and impossible to list the running applications for example.

I'll still look into it and see if I can add a root function that meets this need.

This requires root and the demand is infrequent. No implementation at the moment.