b8320b8021
Also make the code thread-safe with lock. Bug: 20666100 Change-Id: I0f331a617b75280f36179c187418450230d713ef (cherry picked from commit 166112531558a1d4ea179c29147f27db7045db22)