Improve PackageInstallerService.writeSessionsLocked lock hold

PackageInstallerService.writeSessionsLocked() holds mSession lock,
the method PackageInstallerSession.write() needs to access the mLock
in PackageInstallerSession that may be held by other process to
execute a long operation this may cause long API calls that may need
to wait for mSession lock.

To improve the problem, try to reduce lock holding time, copy session
to a local variable. The code doesn't need to acess mLock in mSession
lock to reduce the API call ANR.

Bug: 317945057
Test: manual
Change-Id: Ief0c97d627bebb9075f4bc6b94870d40dcb7bb4f
1 file changed