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

Commit 07bb03c4 authored by Olawale Ogunwale's avatar Olawale Ogunwale Committed by Gerrit Code Review
Browse files

Merge "Avoid deadlock between ActivityManagerService and ProcessStatsService."

parents 5cd79d07 61231a5e
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);