Minor getPackagesForSharedUserIdLocked() fixes.

Only shrink the array at most once - clearer & more efficient.

Also make sure we don't return null, in the unlikely event we end up
with zero entries, since that's the contract of this method.

(Similar to change I62aa9d84a95a017269953e4e4f4c86e20a5a1838).

Test: atest PackageManagerTests
Change-Id: Id15e6cfd832b177e7a18a4980f3e1e79b780c4f4
1 file changed