Add existing and visibility check in addPackageDependency

We should check if the target package is existing or visible to the
caller before adding the dependency.

Bug: 216633741
Test: atest -p services/core/java/com/android/server/am
Test: manually using the PoC in the buganizer to ensure the symptom
      no longer exists.
Change-Id: I8b3b6579bdfb040c8a10065ac14367ba7e4b15a9
1 file changed