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

Commit 90b8057e authored by Jing Ji's avatar Jing Ji
Browse files

Create a new ProcessStats instance for each file read

As the existing instance could be accessed by another thread in
the meanwhile.

Bug: 260727845
Test: b/260727845#comment6
Change-Id: I941ea853b9c01ed0eba4f5c6df924b6d1dacc1fc
parent 9c1c1754
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -634,7 +634,6 @@ public final class ProcessStatsService extends IProcessStats.Stub {
            if (files != null) {
            if (files != null) {
                String highWaterMarkStr =
                String highWaterMarkStr =
                        DateFormat.format("yyyy-MM-dd-HH-mm-ss", highWaterMarkMs).toString();
                        DateFormat.format("yyyy-MM-dd-HH-mm-ss", highWaterMarkMs).toString();
                ProcessStats stats = new ProcessStats(false);
                for (int i = files.size() - 1; i >= 0; i--) {
                for (int i = files.size() - 1; i >= 0; i--) {
                    String fileName = files.get(i);
                    String fileName = files.get(i);
                    try {
                    try {
@@ -647,7 +646,7 @@ public final class ProcessStatsService extends IProcessStats.Stub {
                                    new File(fileName),
                                    new File(fileName),
                                    ParcelFileDescriptor.MODE_READ_ONLY);
                                    ParcelFileDescriptor.MODE_READ_ONLY);
                            InputStream is = new ParcelFileDescriptor.AutoCloseInputStream(pfd);
                            InputStream is = new ParcelFileDescriptor.AutoCloseInputStream(pfd);
                            stats.reset();
                            final ProcessStats stats = new ProcessStats(false);
                            stats.read(is);
                            stats.read(is);
                            is.close();
                            is.close();
                            if (stats.mTimePeriodStartClock > newHighWaterMark) {
                            if (stats.mTimePeriodStartClock > newHighWaterMark) {