Distinguish between fore- and background perms

... in PackageInstalller

The system only cares about app-ops and individual permissions and the
apps only care about permissions.

The only entity caring about permission groups and foreground/background
permissions is the PackageInstaller.

The UI will allow a permission group to be in three states:

Never : foreground and background permissions denied
While using app: foreground permission granted, background denied
Always: foreground and background permissions granted

It is not possible to only grant background permissions.

Further the UI does not show individual permissions, it always shows and
switches groups. For background permissions this means that all
foreground permissions are switched at the same time and all background
permissions are switched at the same time (Note there are slight
differences on the switching behavior based on target SDK version).

It would be possible to leave all permissions in th mPermissions field
of the AppPermissionGroup but then any time an operation is triggered on
the permissions, we have to tell the group if foreground/background/both
should be affected and filter the permissions appropriately.

Alternativly we could put the foreground and background permissions in
separate groups but then we have to take care of that when walking all
groups of the app. This might make sense in some cases, but not in all.

It makes the rest of the code simpler when attaching a "background
group" to the main group and put the background permissions there. There
will still be a lot of checking for (group.getBackgroundPermissions !=
null), but this is the least bad option.

Bug: 78788390
Test: Used package installer to revoke permissions. As of this patch we
      never grant background permissions as the UI is not aware of them
      yet.
Change-Id: Ie9b61513bfbff73a3711868b1f3c858a5d7c22ab
3 files changed
tree: 23ea8d436b449025777fff3d589d23e357077b43
  1. PermissionController/