Throw appropriate exception for session transferring

If the parameter "packageName" is invalid, such as null or
empty string for package name, an IllegalArgumentException is thrown.

In PackageInstallerSession.transfer(packageName), in order to let
the throwing exception more close to the real situation, we throw
IllegalStateException rather than IllegalArgumentException when
one file isn't closed or the state is wrong.

Test: atest InstallSessionTransferTest
Bug: 158804946
Change-Id: Ib0a3e8dc19b829c7382791e622e0b86ee8b387e8
2 files changed