DO NOT MERGE. Retain DownloadManager Uri grants when clearing.

am: 17010dc0d2

Change-Id: I7c6d507411864912937c9dbacc985cb834760cfe
This commit is contained in:
Jeff Sharkey
2016-12-02 02:05:34 +00:00
committed by android-build-merger
2 changed files with 9 additions and 0 deletions

View File

@@ -41,6 +41,8 @@ public final class Downloads {
public static final class Impl implements BaseColumns {
private Impl() {}
public static final String AUTHORITY = "downloads";
/**
* The permission to access the download manager
*/

View File

@@ -190,6 +190,7 @@ import android.os.UpdateLock;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.WorkSource;
import android.provider.Downloads;
import android.os.storage.IMountService;
import android.os.storage.MountServiceInternal;
import android.os.storage.StorageManager;
@@ -8547,6 +8548,12 @@ public final class ActivityManagerService extends ActivityManagerNative
// Only inspect grants matching package
if (packageName == null || perm.sourcePkg.equals(packageName)
|| perm.targetPkg.equals(packageName)) {
// Hacky solution as part of fixing a security bug; ignore
// grants associated with DownloadManager so we don't have
// to immediately launch it to regrant the permissions
if (Downloads.Impl.AUTHORITY.equals(perm.uri.uri.getAuthority())
&& !persistable) continue;
persistChanged |= perm.revokeModes(persistable
? ~0 : ~Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION, true);