OTA updates for Device Owner Android Application(Kiosk mode)

前端 未结 4 1563
粉色の甜心
粉色の甜心 2021-02-07 04:03

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

相关标签:
4条回答
  • 2021-02-07 04:37

    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.

    0 讨论(0)
  • 2021-02-07 04:41

    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).

    0 讨论(0)
  • 2021-02-07 04:53

    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.

    0 讨论(0)
  • 2021-02-07 04:55

    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.

    0 讨论(0)
提交回复
热议问题