Based on implementation from hardware/google/pixel as of commit 0338a0e. Change-Id: I3df57bd3e8298141272add55c911fb5eece9aebe