Search code examples
androidautomationupdatesauto-updatehotswap

How can I force remote updates or remote hotswap code without human interaction?


I'm currently working on an app that does timelapse images and saves them to Google Drive automatically, that part is working fine. However these phones might be deployed in places where physical access might be limited, so whatever we can do remotely should be done remotely.

This app is intended for internal purposes only, it will not see a public users, so rooting and hacky solutions are acceptable. Currently it's deployed via the play store as a beta app.

So how can I remotely update the app?

My current best approach would be to send a force upgrade push notification that would tell the app that there's an update on the playstore. Close the app, wait for the playstore to auto update it and then start the app again with a PACKAGE_REPLACED broadcast receiver.

But with this I'm at the mercy of the play store, I can't tell if it would auto update within minutes, hours or even days. While I don't expect updates to be critical and they can wait, they should happen eventually and with minimum downtime.

I know that A/B Testing frameworks like mixpanel can hot swap some code, at least string resources and the likes, but I was wondering if there's a way I can hot swap code myself, perhaps even whole fragments. It's ok if the app has to restart.

So what would be the best way to do this be? Feel free to suggest other approaches as well.


Solution

  • While me and some colleagues were arguing how to solve this, the company CEO quickly figured out the best solution. He simply reminded us that it's possible to remotely install apps and updates on your phone via the playstore on your PC.

    If the app is running that closes the app, but with the PACKAGE_REPLACED broadcast receiver, the app can start itself again.

    While there's some human interaction, no interaction is needed with the phones themselfes.

    The only issue is that it's tedious to do it for a large number of phones, but if we find the need to do it, I'm sure we can automate that somehow as well.