frameworks/base: acquire lock on am only when needed

appendDropBoxProcessHeaders acquires a lock on am while accessing
ProcessRecord (even if it is null). Watchdog thread ends up invoking
this function (with a null ProcessRecord) to add the stack file to
dropbox. This function would block if and when the watchdog thread is
invoked due to unavailability of lock on am resulting in a deadlock.
This would prevent watchdog from killing system_server.

Change-Id: Ieb34b767779cb587e0c5f536b9b7ba44fb9a28d9
1 file changed