Avoid overiding bg perm app-op for pre-M apps

For pre-M apps the only information about the permission state is
encoded in the app-op. This state cannot be computed from the permission
state.

Hence be very careful to only override this state when sure that it is
fine. E.g. one problem is that during the install the permissions are
first not whitelisted and then whitelisted shortly after. At this time
the permissions state might be lost.

Fixes: 135288572, 135190563
Test: atest RestrictedPermissionsTest
Change-Id: I8bf74730a6c632313d68f1558c9b67e273c5d7e1
1 file changed