Merge "KernelCpuUidBpfMapReader: Verify presence of Uids before deleting" am: 907124607f am: 5f016c8deb am: b736478a80 am: 2d8aceac0a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1321018 Change-Id: I04df7616651b454f21ecc4f78f8583e8a8644d11
This commit is contained in:
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.android.internal.os;
|
package com.android.internal.os;
|
||||||
|
|
||||||
import android.os.StrictMode;
|
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
@@ -90,9 +89,21 @@ public abstract class KernelCpuUidBpfMapReader {
|
|||||||
if (mErrors > ERROR_THRESHOLD) {
|
if (mErrors > ERROR_THRESHOLD) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (endUid < startUid || startUid < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mWriteLock.lock();
|
mWriteLock.lock();
|
||||||
int firstIndex = mData.indexOfKey(startUid);
|
int firstIndex = mData.indexOfKey(startUid);
|
||||||
|
if (firstIndex < 0) {
|
||||||
|
mData.put(startUid, null);
|
||||||
|
firstIndex = mData.indexOfKey(startUid);
|
||||||
|
}
|
||||||
int lastIndex = mData.indexOfKey(endUid);
|
int lastIndex = mData.indexOfKey(endUid);
|
||||||
|
if (lastIndex < 0) {
|
||||||
|
mData.put(endUid, null);
|
||||||
|
lastIndex = mData.indexOfKey(endUid);
|
||||||
|
}
|
||||||
mData.removeAtRange(firstIndex, lastIndex - firstIndex + 1);
|
mData.removeAtRange(firstIndex, lastIndex - firstIndex + 1);
|
||||||
mWriteLock.unlock();
|
mWriteLock.unlock();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user