Dealing with Samsung SPCM killer

吃可爱长大的小学妹 提交于 2019-11-28 20:58:35

Make sure that ActivityManager is not targeting your service too.

AFAIK there's no other way to ensure survival than having a persistent notification, that's also what Samsung's developer docs state. As for Facebook and TrueCaller I have no answers. Possibly they leverage other related processes to get services back up.

As for devices affected, the earliest I saw was a Galaxy Tab S SM-T805 with 5.0.2. A lot of 5.1.1 Samsung devices have SPCM too. We initially reproduced the issue on a S6 also and I can confirm that it's still present on 6.0.1.

As for documentation, this Samsung forums topic goes as far as it possible.

For testing and reproduction steps I advise to:

  1. Ensure that the device actually has SPCM adb shell getprop | grep spcm.
  2. Unplug it from any power sources.
  3. Install Tinycore to observe RAM usage (enable persistent notification for it).
  4. Load a lot of RAM hungry apps to bump your services score down. Alternatively try the Developer Toolbelt, it should be faster than filling it by hand but I haven't tested it.
  5. Turn off the screen and give the device 15 minutes.
  6. adb shell logcat -v threadtime | grep spcm to confirm that processes got killed.
  7. Rinse and repeat until successful.

I will try to help you answering your 3rd question:

I'm facing the same issue and the best workaround I found is to use AlarmManager to start my service. So I set AlarmManager to run each 30 minutes and start my service. If it's still running, onStartCommand will be called again, otherwise service will be recreated. I did some adjustments in my code to deal with new calls to onStartCommand each 30 minutes and it's working the way I expected. The downside is the battery drain, since my service is always running and Android is never entering in sleep mode (still working on it). Another approach is to set your service to run in foreground, but in my case it's not I want to do.

You can try to disable SPCM, open your build.prop and change the following line (requires root):

sys.config.spcm_enable=true

to:

sys.config.spcm_enable=false

Take a look here and here.

Hope it helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!