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

Commit 4c5c6f43 authored by Ronnie Leng's avatar Ronnie Leng
Browse files

[ProcessStas] fix index out of bounds when add duration.



Root Cause:
There is a defect in current ProcessStats design
and following is the scenario:
1. Process A is started due to activity with
name of A
2. Process A creates ProessState with application
uid of A
3. Process B is started due to isolated service
declared in application A with name of A
4. Process B uses ProcessState of Process A as
it uses same application uid of A
5. Process B is finished and it leads to
ProcessState marked as dead
6. Process A still keeps using the invalid
ProcessState in dead state
7. IndexOutOfBoundsException is triggered when
system tries to update process state of Process A

Resolution:
use process uid to replace application uid for
getProcessStatLocked.

Change-Id: I881ad9fc492c9e1a892c9e957180cebcfef8352d
Signed-off-by: default avatarRonnie Leng <ronnie.leng@gmail.com>
parent 039013c2
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -418,7 +418,7 @@ final class ProcessRecord {
                        tracker.getMemFactorLocked(), SystemClock.uptimeMillis(), pkgList);
                origBase.makeInactive();
            }
            baseProcessTracker = tracker.getProcessStateLocked(info.packageName, info.uid,
            baseProcessTracker = tracker.getProcessStateLocked(info.packageName, uid,
                    info.versionCode, processName);
            baseProcessTracker.makeActive();
            for (int i=0; i<pkgList.size(); i++) {
@@ -426,7 +426,7 @@ final class ProcessRecord {
                if (holder.state != null && holder.state != origBase) {
                    holder.state.makeInactive();
                }
                holder.state = tracker.getProcessStateLocked(pkgList.keyAt(i), info.uid,
                holder.state = tracker.getProcessStateLocked(pkgList.keyAt(i), uid,
                        info.versionCode, processName);
                if (holder.state != baseProcessTracker) {
                    holder.state.makeActive();
@@ -617,7 +617,7 @@ final class ProcessRecord {
                    versionCode);
            if (baseProcessTracker != null) {
                holder.state = tracker.getProcessStateLocked(
                        pkg, info.uid, versionCode, processName);
                        pkg, uid, versionCode, processName);
                pkgList.put(pkg, holder);
                if (holder.state != baseProcessTracker) {
                    holder.state.makeActive();
@@ -664,7 +664,7 @@ final class ProcessRecord {
                }
                pkgList.clear();
                ProcessStats.ProcessState ps = tracker.getProcessStateLocked(
                        info.packageName, info.uid, info.versionCode, processName);
                        info.packageName, uid, info.versionCode, processName);
                ProcessStats.ProcessStateHolder holder = new ProcessStats.ProcessStateHolder(
                        info.versionCode);
                holder.state = ps;