I have a system application with all the necessary permissions. previously, i would download apks using the DownloadManager and then use reflection via PackageManager's installPackage() to install said apk.
unfortunately, following N's behaviour changes http://developer.android.com/preview/behavior-changes.html :
The DownloadManager can no longer share privately stored files by filename. Legacy applications may end up with an unaccessible path when accessing COLUMN_LOCAL_FILENAME. Apps targeting Android N or higher trigger a SecurityException when attempting to access COLUMN_LOCAL_FILENAME. Legacy applications that set the download location to a public location by using setDestinationInExternalFilesDir(Context, String, String) or setDestinationInExternalPublicDir(String, String) can still access the path in COLUMN_LOCAL_FILENAME, however, this method is strongly discouraged. The preferred way of accessing a file exposed by the DownloadManager is using openFileDescriptor(Uri, String).
I am now getting a permission denied error when trying it the old way.
I need a Uri to pass to PM's installPackage(), and so i currently just copy the file to my application's private folder with a (depcrecated) WORLD_READABLE mode, so that the PM can later access it and install. This feels very hacky and i was wondering if anyone knows of a better way (The other option suggested by androiddev is to download the file to a public dir, but this would require me to add the WRITE_EXTERNAL_STORAGE permissions which is not an option.)