Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5cb6837f authored by Olawale Ogunwale's avatar Olawale Ogunwale Committed by Android Git Automerger
Browse files

am 07bb03c4: Merge "Avoid deadlock between ActivityManagerService and ProcessStatsService."

* commit '07bb03c4':
  Avoid deadlock between ActivityManagerService and ProcessStatsService.
parents e37f3af7 07bb03c4
Loading
Loading
Loading
Loading
+16 −16
Original line number Diff line number Diff line
@@ -445,14 +445,14 @@ public final class ProcessStatsService extends IProcessStats.Stub {
        mAm.mContext.enforceCallingOrSelfPermission(
                android.Manifest.permission.PACKAGE_USAGE_STATS, null);
        Parcel current = Parcel.obtain();
        mWriteLock.lock();
        try {
        synchronized (mAm) {
            long now = SystemClock.uptimeMillis();
            mProcessStats.mTimePeriodEndRealtime = SystemClock.elapsedRealtime();
            mProcessStats.mTimePeriodEndUptime = now;
            mProcessStats.writeToParcel(current, now, 0);
        }
        mWriteLock.lock();
        try {
            if (historic != null) {
                ArrayList<String> files = getCommittedFiles(0, false, true);
                if (files != null) {
@@ -476,8 +476,6 @@ public final class ProcessStatsService extends IProcessStats.Stub {
    public ParcelFileDescriptor getStatsOverTime(long minTime) {
        mAm.mContext.enforceCallingOrSelfPermission(
                android.Manifest.permission.PACKAGE_USAGE_STATS, null);
        mWriteLock.lock();
        try {
        Parcel current = Parcel.obtain();
        long curTime;
        synchronized (mAm) {
@@ -488,6 +486,8 @@ public final class ProcessStatsService extends IProcessStats.Stub {
            curTime = mProcessStats.mTimePeriodEndRealtime
                    - mProcessStats.mTimePeriodStartRealtime;
        }
        mWriteLock.lock();
        try {
            if (curTime < minTime) {
                // Need to add in older stats to reach desired time.
                ArrayList<String> files = getCommittedFiles(0, false, true);