OTA updates for Device Owner Android Application(Kiosk mode)

这一生的挚爱 提交于 2019-12-03 15:14:13

问题


I am able to make my app, the device owner app through NFC as mentioned here. Now I want to update my app over the air, but I couldn't find a method without rooting.

Google is providing many options for enterprises to develop apps as mentioned here, but nowhere providing a way to update the application through OTA.

Looking for a solution.


回答1:


This is just pure speculation as I've never tried to use the package installer API myself:

You could try to set an installer package for your device owner app (using PackageManager.setInstallerPackageName()). This installer package would need to be a separate APK signed with the same certificate as the device owner APK.

getPackageManager().setInstallerPackage("<device.owner.package.name>", "<installer.package.name>");

From your installer APK, you could then use PackageInstaller to prepare an update:

PackageInstaller pi = getPackageManager().getPackageInstaller();
int sessId = pi.createSession(new PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL));
PackageInstaller.Session session = pi.openSession(sessId);
OutputStream out = session.openWrite("app");
// .. write updated APK file to out
session.fsync(out);
session.commit(...);
session.close();

I'm not sure if this silently installs your update though (or if that works at all in the way I would have expected).




回答2:


Create a service to background check for update. if update available download apk file and write it on some where like sdcard. wait some seconds to write completely flush. then call following code to install your new apk.

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive");
startActivity(intent);

fileName is path of your new apk file on sd card.




回答3:


You could use Play Store to provide updates for your app:

  1. Provision device owner app through NFC, just as you already did.

  2. Provide an updated version (same package name, same signature, higher version number) of your device owner app on Play Store.

  3. In the Play Store app on your device, search for your Play Store version of the app and install the update.

  4. Activate auto-updates for your device owner app in Play Store (on the Play Store page of your app, click menu (three dots) and activate the checkbox for auto-update.

That's quite some effort for the provisioning phase, but the device should receive future updates automatically.




回答4:


I guess you might want to become an EMM/MDM partner app-it is similar to device owner app but with enhanced privileges and APIs. Normally OEMs like Samsung/HTC provides hidden APIs to the MDM partner apps for upgrading apps.I am not sure whether Android for Work also provides this api.

For eg: OEMs provides an api called updatePackage(String packageName) which can be use by MDM client on the device to update the package.You can use this API to update the Device Owner App too.



来源:https://stackoverflow.com/questions/31041832/ota-updates-for-device-owner-android-applicationkiosk-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!