I am trying to create a system for performing over-the-air updates for APK and OS on my android devices. My question pertains to the part of actually performing the upgrade once the packages for OS and APK have been downloaded. Please note the following:
- I cannot use play-store/play-services since my device does not have play-services installed on it.
- I need the update process for both APK and OS to be done silently without any user intervention.
- I have root/admin privileges on the devices.
- The android versions I will be using are Kitkat, Lollipop and Marshmallow.
- I have an APK running on the device which checks for updates from my server and downloads it. I then want it to initiate update for both APK and OS from the code.
Regarding APK update:
I have actually tried and successfully performed APK update by running the shell command
pm install -r $PATH_TO_DOWNLOADED_APK, after getting the shell from
Runtime.getRuntime().exec("su") in my App code.
My Questions are:
- In case something goes wrong while installing the APK- for example if the device shuts down while update is happening , or there was some issue in the APK package or something like that - in this case will android ensure that the APP is rolled back to the previous version correctly and no data is lost or there is something I need to take care of in my code.
Regarding OS update:
I referred to the following link: https://source.android.com/devices/tech/ota/ However, I didn't understand it completely.
My questions are:
- Is there a particular folder where I need to keep the downloaded OS package? If yes, then which is the folder? If no then how do I specify the path to it?
- What is the equivalent command for
pm install -r $PATH_TO_APKin case of OS updates?
- How do I boot a device in "recovery mode" as mentioned in point # 3, in the link?
- Where are the boot and recovery partitions in the device? Does it vary from device to device? In one of the devices which I have with me, I don't see any /boot or /recovery folder? Does boot mean the / (root) folder?
- In case the OS update fails due to some reason( the device shuts down during the update, there was issue in the update package etc)- does android ensure proper rollback and that the device is in a consistent state and no data is lost? If no then how should the code which initiates it handle this?