Fix potential crash in AppAllServicesPreferenceController

This CL contains two fixes:

- Fix potentialcrash when calling getAvailabilityStatus, we should use
  the latest packageName to decide.

- Add test class

Bug: 258270151
Test: atest
Change-Id: I3e6aa7e0773a73d2e3dfa996e42087f3ec80627b
2 files changed