android - 通过 USB 和包安装程序更新 Android Things 应用程序
问题描述
由于 Android Things 控制台于 2022 年关闭,我想知道你们中是否有人尝试通过 USB 更新应用程序。
我试过没有成功:
第一次尝试:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(FileProvider.getUriForFile(this, this.getApplicationContext().getPackageName() + ".provider", layoutPath), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent);
结果:由于 MANAGE_UNKNOWN_APP_SOURCES,包安装程序无法安装应用程序。我无法在 MANAGE_UNKNOWN_APP_SOURCES 中修改该标志。
第二次尝试:
Log.e(TAG,layoutPath.getPath());
Runtime.getRuntime().exec("chmod 777 " + layoutPath.getPath());
Runtime.getRuntime().exec("pm install -r " + layoutPath.getPath());
结果:
Permission Denial: runInstallCreate from pm command asks to run as user -1 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
你有更好的想法吗?
解决方案
您可以使用Android Debug Bridge (adb)在您的设备上手动安装或更新应用程序。只要您指定了更高版本,使用此方法安装的应用程序版本将覆盖捆绑到工厂映像中的任何现有版本。
有关使用 ADB 连接到特定设备的更多详细信息,请参阅硬件指南。
推荐阅读
- php - 将 HTML 输出转换为 BLOB 图像
- python-2.7 - 如何将 os.system() 调用更改为 subprocess.call() 以获取以下代码
- java - .eml 预览与 html 正文中的图像
- android - 找不到 android.support.v7.widget.Toolbar
- android - 在哪里为移动应用编写测试用例
- powerbi - 在每一行上复制一个值
- ansible - 与 Ansible 并行运行 python 脚本
- c# - 在 C# 中检索网络共享权限的问题
- java - spring 如何使用 localhost 而不是 localhost IP?
- r - gsub 匹配后的第一个单词