Tiefkuehlpizze / oandbackupx

backup manager for android
GNU Affero General Public License v3.0
5 stars 0 forks source link

Never kill uid 1000's processes (system apps) #8

Closed Tiefkuehlpizze closed 3 years ago

Tiefkuehlpizze commented 4 years ago

Backing up or restoring a system app lets OABX kill all processes of the owning UID which is 1000 in a system app's case. This is equal to killing the operating system.

Two steps have to be taken:

  1. Never kill processes by UID 1000! Refuse it in the method.
  2. Never kill a process if a system app is backed up or restored.

Additional steps:

  1. Stop offering problematic system apps for a backup such as "Android"
  2. Don't kill and instead suspend processes:

@hg42x did some great testing on this topic and shared it in the Telegram channel:

example test: using clock display (showing seconds)

pm suspend com.google.android.deskclock ; sleep 5 ; pm unsuspend com.google.android.deskclock

works somehow but closes the app, makes the widget showing it's icon, then resumes the widget, but the clock remains closed. You also get a refresh of the whole home screen on suspend and unsuspend (I saw this on another backup app, may be buggybackup).

The command: kill -STOP 13799 ; sleep 5 ; kill -CONT 13799 works without closing, the secsonds stop and resume afterwards.

I used this to find the PID:

# ps -A | grep com\.google\.android\.deskclock
u0_a205      13799   717 5594500 170908 SyS_epoll_wait      0 S com.google.android.deskclock

may be there are better ways I think a complete group of corresponding processes (the app may have sub processes and a service etc.) should be suspended. I never used that, but it seems, a process group is the corresponding "thing".

use e.g.: ps -A -o PGID,PPID,PID,USER,GROUP,CMDLINE | sort to show the groups (first number) sorted. On my phone I have a lot of processes in group 717, which is the PID of zygote64.

If I use: kill -STOP -717 ; sleep 5 ; kill -CONT -717 (note the -PGID parameter) they all will be stopped. I tested thsi by looking at different apps like internet radio or clock. They are all stopped until CONT is sent.

Oh...that will not help, because all user apps run in this group (unless suspending all to gether, but OABX would stop itself). Listing all PIDs of the app user should do the same

Tiefkuehlpizze commented 3 years ago

Outdated. OABX is not killing apps anymore.