summaryrefslogtreecommitdiff
path: root/tests/unit/java/android/net/IpSecAlgorithmTest.java
diff options
context:
space:
mode:
authorChalard Jean <jchalard@google.com>2021-07-29 20:03:04 +0900
committerChalard Jean <jchalard@google.com>2021-07-30 19:10:07 +0900
commit9473c984b86cfdb1647f8d068a7f0fb277a4ca78 (patch)
tree913dfb98e9fd82ef1ab9e1589bcd0d2591daed1b /tests/unit/java/android/net/IpSecAlgorithmTest.java
parent93bda73970778d94cca72ba81524f72345dd0e45 (diff)
Fix a crash when changing preferences
The crash occurs when some app has more than half its limit in requests that will need to be moved to some other default network upon changing the preferences. This will send the requests for this app over the limit temporarily when creating new requests for the reevaluated ones. While ConnectivityService has a provision for making a transaction-like addition/removal of requests that is meant to avoid exactly this kind of crash with the transact() method on PerUidCounter, the code only transacts on mSystemNetworkRequestCounter. But these requests are counted in the mNetworkRequestCounters, which is not part of the transaction, causing the crash anyway. To avoid the problem, this patch allows the request counters to go over the max if and only if the system server is updating the request counts for a UID other than its own. This should allow only the case where ConnectivityService is moving the requests over to the new per-uid default, while keeping the exception when registering from an app (then the calling UID is not the system server), or when the system server registers its own requests (then the UID inside the request is that of the system server). A much better solution than this patch would be to completely eliminate the transact() method by somehow unregistering the old ones before creating the new ones. However this would be a much bigger and difficult patch than this, and much more dangerous, because callers depend on the list of requests to find out the old requests to remove, so they have to be created first. Another possible clean solution would be to count the requests not in the NRI constructor, but later. This would be more error-prone though because it would be very easy to create an NRI without counting it. Bug: 192470012 Test: ConnectivityServiceTest. Improve tests so they catch this case. Change-Id: Ia482e6fbf2bf300ce6cbaca72810d394ed201b98
Diffstat (limited to 'tests/unit/java/android/net/IpSecAlgorithmTest.java')
0 files changed, 0 insertions, 0 deletions