如何安装/更新/删除APK使用" PackageInstaller"在Android中大号类? [英] How to install/update/remove APK using "PackageInstaller" class in Android L?

查看:501
本文介绍了如何安装/更新/删除APK使用" PackageInstaller"在Android中大号类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PLZ检查以下CLASSE和放大器;给我的建议对如何使用它们 <一href="https://developer.android.com/reference/android/content/pm/PackageInstaller.html">https://developer.android.com/reference/android/content/pm/PackageInstaller.html <一href="https://developer.android.com/reference/android/content/pm/PackageInstaller.Session.html">https://developer.android.com/reference/android/content/pm/PackageInstaller.Session.html

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.android.com/reference/android/content/pm/PackageInstaller.Session.html

所以,请给我安装/更新/删除应用程序的一个例子。 难道是可能的,新的应用程序将在设备配置文件的所有者安装?

So please give me an example to install/update/remove app. Can it be possible that the new application will install in device profile owner?

推荐答案

您不能静默安装在新创建的用户提供第三方应用程序与<一个href="https://developer.android.com/reference/android/content/pm/PackageInstaller.Session.html#commit(android.content.IntentSender)"相对=nofollow> PackageInstaller.Session.commit()没有具体的权利。
你要么需要:

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

  • INSTALL_PACKAGES 权限。但此权限不提供第三方应用程序。因此,即使您的个人资料拥有者的应用程序,你会不会有这种特定的权限。
  • 运行过程 ROOT_UID 。这意味着你必须以root设备。
  • 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.

从<一个href="https://github.com/android/platform_frameworks_base/blob/59701b9ba5c453e327bc0e6873a9f6ff87a10391/services/core/java/com/android/server/pm/PackageInstallerSession.java#L211"相对=nofollow> Android的源$ C ​​$ C :

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

如果你既​​没有root访问权限和 INSTALL_PACKAGES 许可,然后一条消息会提示用户问他是否确认权限。此确认在提交过程 PackageInstaller的届的再使用。很显然,在这种情况下,这是不透明的,因为用户必须手动确认的应用程序的安装。

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.

这篇关于如何安装/更新/删除APK使用&QUOT; PackageInstaller&QUOT;在Android中大号类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆