This is a cherry-pick of https://googleplex-android-review.git.corp.google.com/#/c/859952/ Adjusted to fix merge conflicts. Change-Id: I8395a4172bd34faff88094913ee4afd97f71076a
Bug: 26549507 Change-Id: I6c69b5e2b5492858fc997657b5a06d3e50ca16e3