diff options
| author | Sudheer Shanka <sudheersai@google.com> | 2022-04-04 16:08:00 -0700 |
|---|---|---|
| committer | Sudheer Shanka <sudheersai@google.com> | 2022-04-15 09:39:49 +0000 |
| commit | efa4f742360efc714082d04d7224aae7058e186e (patch) | |
| tree | 254f02976afbff8ad9aa95bc88727ced45e57d9e /core/java/android | |
| parent | 3d9f5e63c1d2fec02cabe7aa27ad0dd2c0747637 (diff) | |
Ignore older UID state change callbacks in NPMS.
Since the onUidStateChanged() callbacks will be
happening from more than one thread, we need to make
sure we only handle the latest uid state change
callbacks and ignore any older callbacks that could
override the latest uid states in NPMS. In order to
this, every uid state change will be associated with
a unique seq number.
Also, remove the UidRecord.lastDispatchedProcStateSeq.
This was added as a safety measure to make sure we
don't unnecessarily end up waiting but it isn't
necessary and if we need to keep it, we need to add
a way to access it without holding global AMS lock,
which isn't worth the complexity.
Bug: 226299593
Test: atest tests/cts/hostside/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
Change-Id: I631f5e01f6627916a96c930c22849a1d11eab636
Merged-In: I631f5e01f6627916a96c930c22849a1d11eab636
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/net/NetworkPolicyManager.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/core/java/android/net/NetworkPolicyManager.java b/core/java/android/net/NetworkPolicyManager.java index 2c2a703b16e2..9341105675a2 100644 --- a/core/java/android/net/NetworkPolicyManager.java +++ b/core/java/android/net/NetworkPolicyManager.java @@ -817,11 +817,13 @@ public class NetworkPolicyManager { public static final class UidState { public int uid; public int procState; + public long procStateSeq; public int capability; - public UidState(int uid, int procState, int capability) { + public UidState(int uid, int procState, long procStateSeq, int capability) { this.uid = uid; this.procState = procState; + this.procStateSeq = procStateSeq; this.capability = capability; } @@ -830,6 +832,8 @@ public class NetworkPolicyManager { final StringBuilder sb = new StringBuilder(); sb.append("{procState="); sb.append(procStateToString(procState)); + sb.append(",seq="); + sb.append(procStateSeq); sb.append(",cap="); ActivityManager.printCapabilitiesSummary(sb, capability); sb.append("}"); |
