(cherry pick of commits 2154caf2f80fa87df84813b8e344f85094a454fd and
da1fc0a9c23697cc255efdccc47862bd1277da3f).
Change-Id: I5a019d771da6ff52ea36ee683a44405f6ea24853
Bug: 30900628
Bug: 28722556
Fixes: 32972310
(cherry picked from commit 20488d97cd)