Wait until the remote side has loaded everything before start copying.

Also added 2 test cases for it.

Test: Manual tests and automatic tests pass.

Bug: 34277120
Change-Id: Ia587909f1490104f2823d67c6bf1bf5d86d86d9d
(cherry picked from commit 99d7f709997570b922181500068a04ad2c972952)
5 files changed