Fix a potential deadlock in ProcessStatsService.

The potential deadlock:
ThreadA (backtrace),
  at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java)
  at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java)
  at com.android.server.am.ProcessStatsService.performWriteState(ProcessStatsService.java)
     --- try to lock mWriteLock.
  at com.android.server.am.ProcessStatsService.writeStateLocked(ProcessStatsService.java)
  at com.android.server.am.ProcessStatsService.writeStateLocked(ProcessStatsService.java)
  at com.android.server.am.ProcessStatsService.writeStateSyncLocked(ProcessStatsService.java)
  at com.android.server.am.ProcessStatsService.shutdownLocked(ProcessStatsService.java)
  at com.android.server.am.ActivityManagerService.shutdown(ActivityManagerService.java)
     --- lock AMS

ThreadB (backtrace),
  at com.android.server.am.ProcessStatsService.getStatsOverTime(ProcessStatsService.java),
     --- lock mWriteLock and then try to lock AMS.
  at com.android.server.am.ProcessStatsService.dumpAggregatedStats(ProcessStatsService.java)
  at com.android.server.am.ProcessStatsService.dumpInner(ProcessStatsService.java)
  at com.android.server.am.ProcessStatsService.dump(ProcessStatsService.java)

Change-Id: I437a5cedceb34292a6bd1d9e7610f52b1478e424
Signed-off-by: hanpengx <pengfeix.han@intel.com>
Prevent system server dump stuck by pipe buffer full.

Symptom:
Watchdog timeout during dumping db info.

Root Cause:
When the caller is system server, this invocation is not IPC
that means it is not asynchronous, it will need writer has
written all data to finish. But pipe has 16*4KB buffer limit,
if no reader consumes the data, it will keep waiting.

Solution:
Check if caller is system server, then use another thread to write
so reader could consume the data in buffer.

Change-Id: I4bf80fd645cc9396f51ffc0eb27fb895756c1dcf