Reputation: 3602
I need your help to understand some concept about android system apps. Given the following conditions:
What is the least intrusive solution that allows me to run that service in such a way that the operating system sees it as a sort of system service?
Is it enough to install the app in /system/app or /system/priv-app in order to make the operating system giver to my service an higher importance when some memory needs to be released?
I noticed that using START_STICKY
on a Service helps it to survive in certain situations, but since I can integrate a little bit deeper with the system I just was wandering which options I have to make it more reliable
I also noticed android:persistent="true"
on the <application>
tag in the manifest, the documentation says about it:
Whether or not the application should remain running at all times — "true" if it should, and "false" if not. The default value is "false". Applications should not normally set this flag; persistence mode is intended only for certain system applications.
When an application is considered to be a system application? Is it enough that it's installed in /system/app or /system/priv-app? Or it need to be signed with the firmware key?
Thanks for your help
Upvotes: 2
Views: 271
Reputation: 449
From what I understand, if you want to run your app in the background (without showing the UI), Foreground Service might be the way. You'll need to show a notification to the user (e.g. letting the user know your app is running the background). See more details here (https://developer.android.com/guide/components/services)
As with you signing your app with firmware key, I don't think that's possible. You can contact OEMs like Samsung etc or Google to package your app with the firmware image so that it gets deployed as a system app - again I doubt it unless you work for Facebook or Microsoft writing next gen office or Facebook apps. The easiest to deploy your app as system app would be to root the device.
My 2 cents....
Upvotes: 1
Reputation: 553
Depending on why you need such a service, you can code yourself a daemon in native c and start it via init just like su daemon, 100% persistent service is almost impossible otherwise.
You can also implement actions similar to boot_completed or sms_received to make service do its work when required and let it shutdown.
Upvotes: 0