0

What I need is very similar to the How to properly upgrade AIDL interfaces in Android? question, but I also want a newer version of the AIDL Service to launch after it is installed and the old one to stop. Simply put: I need that the newest version is always the running one. (Backwards-compatibilty of the newer version will, of course, be maintained.)

In detail, let's say our:

  • Android app A has the older version of the AIDL Service in its code (and also stated as a special remote process in the manifest).
  • App B is an app with the newer version of the AIDL Service, that the user has just installed.

When app B gets installed I programatically kill processes of both apps, and the remote process of the AIDL Service. Whatever I do to try to launch the AIDL Service contained in the newer app B after that point is of no use, the older version would always get relaunched (unless I uninstall the older app A).

The interesting thing is that I am able to specifically target the newer AIDL Service to start (bind to the Service from the newer app) if both apps are only installed, and the older version of the AIDL Service has never been started before. By this I mean that I launch the older app A and I am able to make it start the newer version of the AIDL Service inside the app B. If the older version of the AIDL has been run at least once in the past before, then it will be the one that the Android will always start in the future no matter what (even after rebooting the device)!

Onik
  • 19,396
  • 14
  • 68
  • 91
VladimirVip
  • 384
  • 3
  • 13
  • You should consider listening to package install / replace broadcasts… in your broadcast receiver, look to see if it's _you_ that's being replaced and if so, terminate yourself. – mah Jun 20 '13 at 12:18
  • I am already doing that thing exactly. All the processes get terminated... – VladimirVip Jun 20 '13 at 13:39
  • The problem you're describing (the app has to have been started at least once) is intentional within Android since either 3.x or 4.0, and it is annoying to people writing services that need to run from boot up. I've been told (and not verified) that once an app is manually started by the user, it can be auto-started via broadcast receivers even following a reboot. I suppose the intention here is that the device owner should be at least a little complicit in having services run on their platform, even in the case of an app installing another app without the user being aware. – mah Jun 20 '13 at 14:18
  • No, my service does not need to be run from the boot up. All my intents do get delivered whenever I want, no issue there. Also, the user is the one to install all these apps, i am not hacking anything... The problem is that Android probably saves somewhere (for example in a system cache file...) the information about where it found the code for this AIDL service in the first place. And later, if I kill the AIDL's process and start the AIDL from the app which has a newer version of it, it will again launch the old code... – VladimirVip Jun 20 '13 at 14:39

0 Answers0