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?