简体   繁体   English

通过 USB 和 package 安装程序更新 Android Things 应用程序

[英]Update Android Things app via USB and package installer

Due to the shutdown of Android Things console in 2022 I would like to know if someone of you tried to update the app via USB.由于 Android Things 控制台在 2022 年关闭,我想知道你们中是否有人尝试通过 USB 更新应用程序。

I tried with no success:我试过没有成功:

First try:第一次尝试:

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

Result: Package installer cannot install the app due to MANAGE_UNKNOWN_APP_SOURCES.结果:由于 MANAGE_UNKNOWN_APP_SOURCES,Package 安装程序无法安装应用程序。 I cannot modify that flag in MANAGE_UNKNOWN_APP_SOURCES.我无法在 MANAGE_UNKNOWN_APP_SOURCES 中修改该标志。

Second try:第二次尝试:

Log.e(TAG,layoutPath.getPath());
Runtime.getRuntime().exec("chmod 777 " + layoutPath.getPath());
Runtime.getRuntime().exec("pm install -r " + layoutPath.getPath());

Result:结果:

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

Do you have better ideas?你有更好的想法吗?

You can install or update apps on your device manually using the Android Debug Bridge (adb).您可以使用Android 调试桥(adb) 在您的设备上手动安装或更新应用程序。 Versions of your app installed using this method will override any existing version bundled into the factory image so long as you have specified a higher version .只要您指定了更高版本,使用此方法安装的应用程序版本将覆盖捆绑到工厂映像中的任何现有版本

For more details on connecting to your specific device with ADB, see the hardware guides .有关使用 ADB 连接到特定设备的更多详细信息,请参阅硬件指南

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM