I have two apps: One is called my-app.apk, the other my-service.apk. The service app just defines a single Android Service, which can be bound by the primary app to execute some methods. This is done using Androids AIDL interface, and it works great - so far.
Now I want to change the interface of the service, and I am wondering what I have to watch out for. I changed the file IRemote.aidl of my-service.apk to the following:
package com.example.myservice;
interface IRemote {
void printHello();
void print(int i);
}
And just out of curiosity I changed the IRemote.aidl of my-app.apk to the following (note the differences!):
package com.example.myservice;
interface IRemote {
void printHello();
void printYeahThisHasADifferentNameAndParam(String s);
}
Now I got a completely unexpected result: The call to
printYeahThisHasADifferentNameAndParam("hello world");
from my application resulted in the log output "11". Why??
- I would not have expected a SecurityException at the bindService() call, although this would be adequate in a situation with completely different interfaces.
- What I would have expected would have been a RemoteException when executing the call, telling me that the method is not available.
- What I didn't expect entirely was that it will just call a different method with different data as parameters. Although I can understand it from a low-level point of view. Maybe they did it to ensure this interface is performant...
So here are my questions:
- What is the best upgrade-strategy? Simply do not delete/alter old methods and order?
- I noticed when my-service.apk is upgraded (re-installed) the service gets lost for my-app.apk. Normally the service gets re-scheduled by the system, which it typically does on crashes. How do I ensure my-app.apk aquires the service again? Watch out for newly installed packages?
Thank you in advance for your help! :-)
Cheers, Marc