1

Now, I've see this type of question posted a few times but they were aimed at developers trying to do this on a smart phone or tablet. What I have here is a custom built system with root privileges and I can modify the underlying Android if need be. I have code that downloads the APK file and I can use the following (which I found bits of code on here for) but it still brings up a dialog box needing confirmation. This is not really possible as my system is designed to run unattended in remote locations so I need a way to update fully without user intervention.

Intent intent = new Intent();
intent.setAction(Intent.ACTION_INSTALL_PACKAGE);
String str = "file://" + Environment.getExternalStorageDirectory() + "/updates/AX9100-DG.apk";
try
{
    intent.setDataAndType(Uri.parse(str), "application/vnd.android.package-archive");

    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
    return;
}
catch (Exception exception)
{
    Log.d("UpdateTask", exception.getMessage());
}

Is this at all possible if I somehow can modify the underlying AOSP for this custom system?

  • see http://androidxref.com/5.0.0_r2/search?q=android.intent.action.INSTALL_PACKAGE&defs=&refs=&path=&hist=&project=abi&project=art&project=bionic&project=bootable&project=build&project=cts&project=dalvik&project=developers&project=development&project=device&project=docs&project=external&project=frameworks&project=hardware&project=libcore&project=libnativehelper&project=ndk&project=packages&project=pdk&project=prebuilts&project=sdk&project=system&project=tools, click on AndroidManifest.xml results – pskink Dec 03 '14 at 14:20
  • The INSTALL_PACKAGES permission is only available to system apps. BUT. This has given me an idea. What I think I need to do is write a custom installer and build this along with the OS and then call this to do the upgrade and it should work without user intervention. – Dave McLaughlin Dec 03 '14 at 14:28
  • 1
    just modify .PackageInstallerActivity so that it doesn't ask any stupid questions, and add some intent extra to switch that feature on/off – pskink Dec 03 '14 at 14:35
  • Ah good point. I'm in the code now so will give that a try. As the market does allow unattended downloads anyway, I should be able to locate how this is done and implement it through this method. Thanks. – Dave McLaughlin Dec 03 '14 at 14:39
  • Thanks for the idea. It works perfectly by bypassing the checks. Now I can add an intent extra so that normal installs work with the dialog but my calls from the app go straight through. – Dave McLaughlin Dec 04 '14 at 05:36
  • @DaveMcLaughlin Could you please post the solution? – Mohamad Ghaith Alzin Dec 08 '22 at 06:31

0 Answers0