Fix scan volume crash

PublicVolumes typically get mounted before user unlock. This can cause
a race in ExternalStorageService#onStorageStateChanged when scanning
the volume.

When we request the StorageVolume from the StorageManagerService,
SV#getDirectory will return null if SMS#completeUnlockUser hasn't
finshed.

This cl fixes because the ACTION_MEDIA_MOUNTED broadcast is only sent
when user is unlocked (meanwhile onStorageStateChanged can be sent
regardless of unlock).

Test: atest AdoptableHostTest
Bug: 152746690

Change-Id: I75cb3453576ac524ae408199e6f3bb45d7a59fac
2 files changed