2 ms·
It seems like 80% of your trouble comes from trying to subvert the "your service won't start until you use it" solution to the "everybody is lazy and/or anti-so
by Zigurd 10y ago
It seems like 80% of your trouble comes from trying to subvert the "your service won't start until you use it" solution to the "everybody is lazy and/or anti-social and wants to start their service on boot" problem. In other words, Google intended to make the life of an app author who wants this extremely difficult and would have suggested that they attack the "because there might be a high cost associated with starting up" problem instead. But, yeah, if it is your device with your AOSP build, and you really really have The Most Important Service, go ahead and compile it into the system.
On top of all that, the usual reason there is a "high cost to starting something" is that it hits a server and hasn't cached the data it needs. The OS can't solve that for you.
- BoorishBears 10y agoThat was really a digression of my main point of intents forming an unstable API but our problem was 100% subverting your service won't start until you use it, but Google's approach is insanely heavy handed. A saner solution would to be to give a permission for daemon style services that comes with a warning to the user about battery life and network implications. Our service really is the most important service on the device because if our service goes down the device is essentially "bricked" (these are embedded android devices so we lose visibility on the installation), but adding our service to the image means managing images for every device variation we use (and some of those device's manufacturer's won't be happy to have someone else managing said images since it means more work for them [build image, send it to us, we modify it, send it back to them, they use it vs just building an image and using it]). It's a unique use case, but it's not hard to imagine more common software that could take advantage of daemons, even if it's just to provide smarter background processing than the "all-or-nothing" defaults provide (like START_STICKY). Besides being rather unique to our use case, I'd also say it doesn't have to do with apps from different creators working together... And I don't think the network is involved most cases of expensive services, because the OS (or more specifically, Google's services on most end user devices) already help solve that with things like the GCMNetworkManager and ConnectivityManager callbacks for optimizing network access.
- Zigurd 10y agoOk I see what your situation is. And I'm curious, because this is sort of my thing. I don't think allowing greedy services with a big red warning would be a good solution for you either because your users would tire of seeing the warning, even if only at boot. I would put a service-starter service in the device images. I see that might be a problem, too, because it seems like you are only "lightly embedded," with multiple hardware platforms. But this could be a really lo-impact thing for your hardware partners and relatively clean. Alternatively, provide a modified launcher, if you are not already replacing the launcher with your own embedded app, that tickles the service on startup. There are probably other advantages to having your own Home app if I understand your situation correctly. Google has to be heavy handed because too much mobile development is crap, and a low-bidder contract development shop wouldn't hesitate to take the anti-social way to an implementation if they could. The road to hell is paved with cheapass outsourcing.
- BoorishBears 10y agoWe experimented with a lightweight bootstrap service, but there was too much resistance from the manufacturers. It'd pretty much require changing our contract to have much more expensive terms because from their pov it crossed the line from them providing pre-installed software (our apps) , to them providing custom devices ("our image"). I also tried some tricks with replacing the launcher since we have full root access, but the launcher process was getting killed almost as often as our custom services. Since I moved to a single-process model I've had fewer killed services, but we still have the AlarmManager kicking them off just in case. A lot of the moves Google's been making, from shutting down file uris for content providers feel like they're meant to shut down the "easiest way out for developers", things that are easy for devs, but bad for the average mobile user, but they're also hurting Android for other usecases. I guess the plan is to push Brillo for that, but being able to leverage Android's ecosystem on embedded has some advantages
- Zigurd 10y agoYou don't need any special access to replace the launcher. They just need to set your Launcher as default as part of the pre-load. Since I don't know your product it's a little hard to say but the combination of a Home app that check on configuration sanity and a watchdog, which it sounds like what you are using AlarmManager for should do you. Point of sale system?