5

I'm developping an application that will run on a tablet device in a store (e.g. restaurant). The device does not have Google Play and is rooted. How do I install an update to my application automatically, with absolutelly NO user interaction?

To clarify, checking for a new version of APK hosted on my server and downloading it are not part of this question, only the "silent" update part is.

knezmilos
  • 517
  • 1
  • 8
  • 19
  • Possible duplicate of [Upgrade apk downloaded from own web server](http://stackoverflow.com/questions/8923643/upgrade-apk-downloaded-from-own-web-server) – OneCricketeer Feb 02 '17 at 14:03
  • Have you not seen this in your searches? https://github.com/lazydroid/auto-update-apk-client – OneCricketeer Feb 02 '17 at 14:05
  • ^The solution provided on that link requires user interaction. – knezmilos Feb 02 '17 at 14:07
  • Right, and it's an OS security flaw not to require interaction for upgrading rouge apps. You're in an environment where it shouldn't be hard to update nightly / weekly IMO – OneCricketeer Feb 02 '17 at 14:11
  • As android is quite security conscious I am not sure it is possible to update without user interaction. You would need at least a user to press a button to authorize update, the app itself can search and download updates without user interaction - but cannot install ! – ChickenFeet Feb 02 '17 at 14:11
  • 1
    My second link has a `SilentAutoUpdate`. Maybe it does what you want – OneCricketeer Feb 02 '17 at 14:13
  • @ChickenFeet I have found answers stating that it is not possible unless rooted, which my device is. However, none of those answers specify how to do it when rooted... – knezmilos Feb 02 '17 at 14:13
  • Perhaps you can design you app to download a file that includes the necessary updates, depending on what kind of update the app requires - if it is for a restaurant and you only need to make menu changes this could work. Sorry if this isn't the answer you're looking for. Keep searching!! :) – ChickenFeet Feb 02 '17 at 14:22

1 Answers1

2

First of all, your device needs to be rooted. It seems this is already done for you. Now all you have to do is to make your application check if a new version of the APK is available. If so, launch a service in background to download the required APK and run this code to silently install it.

public static void InstallAPK(String filename){
    File file = new File(filename); 
    if(file.exists()){
        try {   
            String command;
            command = "adb install -r " + filename;
            Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", command });
            proc.waitFor();
        } catch (Exception e) {
        e.printStackTrace();
        }
     }
  }

You can basically modify the ABD command to perform whatever you want. Please note that a rooted device can be dangerous and cause security breach.

DustyMan
  • 366
  • 3
  • 9