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

Commit 0fc03ce0 authored by Jing Ji's avatar Jing Ji
Browse files

Move the call to updateCpuStatsNow() out of the AMS lock

Bug: 162450085
Test: Manual - build & boot
Change-Id: I365c9bdabe6f4a62a2e236ca575b73d0ddebf8ee
parent b2794e3d
Loading
Loading
Loading
Loading
+73 −73
Original line number Diff line number Diff line
@@ -176,7 +176,6 @@ import android.app.PendingIntent;
import android.app.ProcessMemoryState;
import android.app.ProfilerInfo;
import android.app.WaitResult;
import android.app.backup.BackupManager;
import android.app.backup.BackupManager.OperationType;
import android.app.backup.IBackupManager;
import android.app.usage.UsageEvents;
@@ -1795,12 +1794,10 @@ public class ActivityManagerService extends IActivityManager.Stub
                    }
                } break;
            case CHECK_EXCESSIVE_POWER_USE_MSG: {
                synchronized (ActivityManagerService.this) {
                    checkExcessivePowerUsageLocked();
                checkExcessivePowerUsage();
                removeMessages(CHECK_EXCESSIVE_POWER_USE_MSG);
                Message nmsg = obtainMessage(CHECK_EXCESSIVE_POWER_USE_MSG);
                sendMessageDelayed(nmsg, mConstants.POWER_CHECK_INTERVAL);
                }
            } break;
            case REPORT_MEM_USAGE_MSG: {
                final ArrayList<ProcessMemInfo> memInfos = (ArrayList<ProcessMemInfo>)msg.obj;
@@ -16241,9 +16238,10 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
    }
    final void checkExcessivePowerUsageLocked() {
    private void checkExcessivePowerUsage() {
        updateCpuStatsNow();
        synchronized (this) {
            BatteryStatsImpl stats = mBatteryStatsService.getActiveStatistics();
            boolean doCpuKills = true;
            if (mLastPowerCheckUptime == 0) {
@@ -16305,7 +16303,8 @@ public class ActivityManagerService extends IActivityManager.Stub
                            }
                            for (int ipkg = app.pkgList.size() - 1; ipkg >= 0; ipkg--) {
                                ProcessStats.ProcessStateHolder holder = app.pkgList.valueAt(ipkg);
                            FrameworkStatsLog.write(FrameworkStatsLog.EXCESSIVE_CPU_USAGE_REPORTED,
                                FrameworkStatsLog.write(
                                        FrameworkStatsLog.EXCESSIVE_CPU_USAGE_REPORTED,
                                        app.info.uid,
                                        holder.state.getName(),
                                        holder.state.getPackage(),
@@ -16317,6 +16316,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                }
            }
        }
    }
    private boolean isEphemeralLocked(int uid) {
        String packages[] = mContext.getPackageManager().getPackagesForUid(uid);