Fix permission is not granted to work profile system app by default

After creating user, we will grant some runtime permissions to a set of
apps in that user.
However, DefaultPermissionGrantPolicy failed to look up some apps in
work profile cases as most apps are disabled by default.
Using MATCH_UNINSTALLED_PACKAGES flag to resolve the intent can fix
the issue.


Test: create work profile, enable calendar in work profile, observe
      that permission is granted.

Change-Id: Icee02e7257a77cb7e2d15b848628f02e7bca0b9c
Fix: 62051433
This commit is contained in:
Tony Mak
2017-05-24 16:56:36 +01:00
parent 6c0aba7d4f
commit 193311a07c

View File

@@ -77,8 +77,9 @@ final class DefaultPermissionGrantPolicy {
private static final String TAG = "DefaultPermGrantPolicy"; // must be <= 23 chars
private static final boolean DEBUG = false;
private static final int DEFAULT_FLAGS = PackageManager.MATCH_DIRECT_BOOT_AWARE
| PackageManager.MATCH_DIRECT_BOOT_UNAWARE;
private static final int DEFAULT_FLAGS =
PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE
| PackageManager.MATCH_UNINSTALLED_PACKAGES;
private static final String AUDIO_MIME_TYPE = "audio/mpeg";