2

I try to find some way to kill unnecessary services/processes in Android from shell. The problem is that after killing the process it starts again after few seconds!

for example I tried to kill batterywarning, but it keep starting again:

root@w812a_kk:/ # ps  | grep batteryw
shell     17986 1     1044   364   c00601dc b6e9f094 S /system/bin/batterywarning
1|root@w812a_kk:/ # ps  | grep batteryw
shell     17781 1     1044   364   c00601dc b6ee6094 S /system/bin/batterywarning
root@w812a_kk:/ # busybox killall batterywarning
root@w812a_kk:/ # ps  | grep batteryw
1|root@w812a_kk:/ # ps  | grep batteryw
shell     17986 1     1044   364   c00601dc b6e9f094 S /system/bin/batterywarning

I did find several methods to kill service/process in the following link, yet the process is starting again.

Android ADB stop application command like "force-stop" for non rooted device.

Is it something that can only be done in init.rc ?

Thanks,

Community
  • 1
  • 1
ransh
  • 1,589
  • 4
  • 30
  • 56

3 Answers3

2

This service is probably started as STICKY - it will be automatically restarted by OS after some predefined timeout.

You can check it by pulling the logcat from the device and grepping it for the name of the service you attempted to kill:

$ adb logcat -d > logcat.txt
$ grep -C 5 -i batterywarning logcat.txt

If you see something along the lines scheduling restart of crashed service in X seconds then you know for sure that the service is being restarted by OS.

If it is indeed the case, I doubt that you can kill it completely on a non-rooted device (neither I know how to achieve this on a rooted one).

Vasiliy
  • 16,221
  • 11
  • 71
  • 127
0

kill a process when you have the process name (basically you don't have to search 'ps' for the process ID and then kill it with PID):

adb shell kill $(pidof com.android.phone)

BizMoto
  • 147
  • 3
  • 7
  • 14
0

Use the following command from terminal: adb shell am crash [applicationId]

IgorGanapolsky
  • 26,189
  • 23
  • 116
  • 147