Do not add permission while cleaning permissions state
A app might reuqest a permission it might never get such as e.g. a
platform signature permission. In this case the permission is in
ps.pkg.requestedPermissions but not in ps.getPermissionsState.
Before this change the code decided that the flags changed hence it
called permissionsState.updatePermissionFlags for this never grantable
permission which then added the permission via ensurePermissionData.
If this was a pre-M app this lead to the permission appearing granted as
all permissions a pre-M app has are granted. If the permission does not
have a appOp, the permission becomes actually granted.
Fixes: 112044785
Test: Repreated repro case as in the bug
atest PermissionsHostTest
Change-Id: I0c0ea1bb06893f9b3edc37238ea57175da7dd86f
1 file changed