How to install/update/remove APK using “PackageInstaller” class in Android L?

前端 未结 7 2177
长发绾君心
长发绾君心 2020-11-30 23:22

Plz check below classe & give me the suggestion for how to use them https://developer.android.com/reference/android/content/pm/PackageInstaller.html https://developer.an

相关标签:
7条回答
  • 2020-11-30 23:44

    You cannot silently install a third party application in the newly created user with PackageInstaller.Session.commit() without specific "rights".
    You either need :

    • the INSTALL_PACKAGES permission. But this permission is not available for third-party application. So even with your profile owner app, you won't have this specific permission.
    • Run the process as ROOT_UID. Which means you'll have to root the device.

    From the Android source code:

    if ((mPm.checkUidPermission(android.Manifest.permission.INSTALL_PACKAGES, installerUid) == PackageManager.PERMISSION_GRANTED) 
       || (installerUid == Process.ROOT_UID)) {
        mPermissionsAccepted = true;
    } else {
        mPermissionsAccepted = false;
    }
    

    If you neither have root access and the INSTALL_PACKAGES permission, then a message will be prompted to the user to ask if he confirms the permissions. This confirmation is then used during the commit process of the PackageInstaller's session. Obviously, in this case, this is not transparent, since the user will have to manually confirm the installation of your apps.

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