We are writing an Android app that shows ads on large screens. We have a backend where advertisers can select the ads, so they are updated almost instantly. Because there will be a lot of Android boxes running (plugged into HDMI screens), we should be able to update our software remotely.
This is the case:
Main app is running continuously (unless turned off) and the users never see anything Android related. We need an updater app that listens for updates and deletes the main apk, installs a new apk. While updating we will show an activity with "Updating, please wait", until the new main apk is installed and showing.
What we need:
We need help on how to implement the update mechanism without prompting the user on ROOTED DEVICE.
What we have:
The updater app is hooked into the boot received event, where a service starts (this service will listen for updates, which will be implemented by a colleague soon). The service can start an activity which will prompt the update info while updating.
In the updater activity
try {
Process proc = Runtime.getRuntime().exec(new String[]{"su", "pm install -r /mnt/sdcard/MYFOLDER/testAPK.apk"});
stringBuilder.append(String.valueOf(proc.waitFor()));
stringBuilder.append("\n");
} catch (Exception e) {
if (e instanceof IOException) {
Log.d(TAG, "IOException");
} else if (e instanceof InterruptedException) {
Log.d(TAG, "InterruptedException");
} else {
e.printStackTrace();
}
}
The StringBuilder prints 11, but does the same if I give random unexisting command..
In the Manifest
<!-- Permission to start UpdaterService on boot -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- Install/delete permissions, only granted to system apps -->
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.DELETE_PACKAGES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
The Install packages and delete packages are useless if I don't install my app as system app, am I correct?
Long story short, no installation of my test APK, and I have no idea how to solve this. Any help would be appreciated!