sixo / silent-update

Sample that shows how to update Android app silently without user confirmation
Apache License 2.0
30 stars 7 forks source link

permission denied in android 10, Mi #3

Open rahulsharmagbpec opened 4 years ago

rahulsharmagbpec commented 4 years ago

its working in mostly devices what i have, but creating problem in Mi a7 android 10, app is not getting update error E/PackageInstallerSession: Commit of session 819901162 failed: Permission Denied

sixo commented 4 years ago

Where did you store the apk with the update? There are significant changes in Android 10 related scoped storage.

On Wed, Aug 12, 2020 at 1:24 PM rahulsharmagbpec notifications@github.com wrote:

its working in mostly devices what i have, but creating problem in Mi a7 android 10 error E/PackageInstallerSession: Commit of session 819901162 failed: Permission Denied

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sixo/silent-update/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSRRJVDGSUTSYQGQZ3GJR3SAJ3VXANCNFSM4P4RCIIQ .

-- Blog: www.sisik.eu My apps https://play.google.com/store/apps/dev?id=9177152940126947746

rahulsharmagbpec commented 4 years ago

i am storing the updated apk inside downloads folder(app have storage permission), i believe scoped storage is from Android 11.

sixo commented 4 years ago

If you target 10 (api 29), try to add android:requestLegacyExternalStorage="true" to your tag in AndroidManifest.xml.

On Wed, Aug 12, 2020 at 1:42 PM rahulsharmagbpec notifications@github.com wrote:

i am storing the updated apk inside downloads folder(app have storage permission), i believe scoped storage is from Android 11.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sixo/silent-update/issues/3#issuecomment-672820997, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSRRJXR4UKZMFBHOLTF5D3SAJ5ZVANCNFSM4P4RCIIQ .

-- Blog: www.sisik.eu My apps https://play.google.com/store/apps/dev?id=9177152940126947746

rahulsharmagbpec commented 4 years ago

our target sdk is 28,

if i do like below its working, but i wants to update silently

File downloadAPK = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath(), Constants.APK_NAME); Uri apkUri = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".provider", downloadAPK); Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE); intent.setData(apkUri); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(intent);

sixo commented 4 years ago

Did you make sure that all the details mentioned in the accompanying blogpost are followed?

For example

Additionally, try to store the APK for update in cache folder to see if the issue is with file permission permissions.

On Wed, Aug 12, 2020 at 2:16 PM rahulsharmagbpec notifications@github.com wrote:

our target sdk is 28,

if i do like below its working, but i wants to update silently

Uri apkUri = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".provider", downloadAPK); Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE); intent.setData(apkUri); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(intent);

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sixo/silent-update/issues/3#issuecomment-672835512, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSRRJR5AWZD36IVDIW2UXDSAKB3HANCNFSM4P4RCIIQ .

-- Blog: www.sisik.eu My apps https://play.google.com/store/apps/dev?id=9177152940126947746

rahulsharmagbpec commented 4 years ago

yes i followed the same mentioned in blogpost.

  1. not using testOnly=ture(free to hard-reset the phone is getting locked)
  2. device owner is also getting successful

after searching and analysing from 2 days, i came to a conclusion that its MIUI related issue, some of other developers also mentioned the same on stackoverflow and other places.