Update Android Things app via USB and package installer

189 Views Asked by At

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.

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. I cannot modify that flag in 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?

1

There are 1 best solutions below

2
devunwired On

You can install or update apps on your device manually using the Android Debug Bridge (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.