(cherry-pick of commit 7df9b7a1) Bug: 31470256 Test: unit tests + integrated (sl4a) tests Change-Id: I1554b5b7961a5c46656a40ad395431125da7aa7f