From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Dmitry Muhomor Date: Tue, 30 Aug 2022 12:37:03 +0300 Subject: [PATCH] improve compatibility with revoked INTERNET in DownloadManager --- core/java/android/app/DownloadManager.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/java/android/app/DownloadManager.java b/core/java/android/app/DownloadManager.java index ee412eb50064..f1bda3d1a81f 100644 --- a/core/java/android/app/DownloadManager.java +++ b/core/java/android/app/DownloadManager.java @@ -1163,6 +1163,11 @@ public class DownloadManager { * @return the number of downloads actually removed */ public int remove(long... ids) { + if (SpecialRuntimePermAppUtils.isInternetCompatEnabled()) { + // underlying provider is protected by the INTERNET permission + return 0; + } + return markRowDeleted(ids); } @@ -1589,6 +1594,11 @@ public class DownloadManager { throw new IllegalArgumentException(" invalid value for param: totalBytes"); } + if (SpecialRuntimePermAppUtils.isInternetCompatEnabled()) { + // underlying provider is protected by the INTERNET permission + return -1; + } + // if there is already an entry with the given path name in downloads.db, return its id Request request; if (uri != null) {