Merge "Wait until any background events are processed." into stage-aosp-master
am: 0589325300

Change-Id: I198e5863a5f4f3e8b7dec0e5ae13be2548719285