OTA updates for Device Owner Android Application(Kiosk mode)

前端 未结 4 1552
粉色の甜心
粉色の甜心 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: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("", "");
    

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

提交回复
热议问题