Fix NPEs in AppIdPermissionPolicy.

In edge cases we may see race conditions and unexpected removal of packages. We should be more tolerant of those and don't crash with NPEs.

The remaining !!s are mostly for assumptions like packages that are checked to be existent earlier should continue to be there, and for knownPackages nullability.

Bug: 319592101
Bug: 314260787
Change-Id: I8db88c38f9f256fee343b6f2d857d2053f7b509a
Test: presubmit
1 file changed