Avoid deadlock between ActivityManagerService and ProcessStatsService.

Root Cause:
Case 1
getStatsOverTime(#483) // lock mWriteLock, wait AMS
async performWriteState(#269) // lock mPendingWriteLock, wait mWriteLock
writeStateLocked(#218) // lock AMS, wait mPendingWriteLock

Case 2
getStatsOverTime(#483) // lock mWriteLock, wait AMS
writeStateSyncLocked,writeStateLocked(#269) // lock AMS, wait mWriteLock

Solution:
Reduce nested lock.

Others also post the same solution:
I437a5cedceb34292a6bd1d9e7610f52b1478e424

Change-Id: Ie9395f3f6359fe59e2282674fcfec9d123e53f25
Move the remaining ZygoteInit native code over to Java.

Bug: 18719692
Change-Id: I5f9834edecdbcc065a33a9921c740a53441636a4
Merge "Move the remaining ZygoteInit native code over to Java."
Merge "Avoid deadlock between ActivityManagerService and ProcessStatsService."