Limit data usage request per uid

Currently, there is no limtation for an app to request
data usage callback, which is dangerous if the app fire
hundreds of thousands requests and potientially this might
cause OOM if the apps don't free them.

Test: atest NetworkStatsObserversTest#testRegister_limit
Bug: 229103088
Change-Id: I8299f46fd47a82ec9b25ba2e0d3c95db5512c331
This commit is contained in:
Junyu Lai
2022-05-05 15:27:52 +08:00
parent 018cf3fb46
commit f3c946278c
3 changed files with 59 additions and 1 deletions

View File

@@ -1187,6 +1187,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
/**
* Keeps track of the number of requests made under different uids.
*/
// TODO: Remove the hack and use com.android.net.module.util.PerUidCounter instead.
public static class PerUidCounter {
private final int mMaxCountPerUid;