IdleTimer tracking can be disabled if configured timeout is 0 or
negative value.
In this case, setupDataActivityTracking does not add idleTimer and
removeDataActivityTracking causes NPE.
This did not cause crash since the code to cause NPE is wrapped by try
catch.
This CL adds check to avoid causing NPE.
Bug: 267870186
Bug: 279380356
Test: atest FrameworksNetTests
Change-Id: Id774c5ee3d0318d9736f287c50ccf4c7c5743aef
Following CLs update LegacyNetworkActivityTracker to support multiple
network activity tracking on U+ devices.
This CL is a preparation for them.
Bug: 267870186
Bug: 279380356
Test: atest FrameworksNetTests
Change-Id: I2598feef93ef34e10bf576560f687ff7fc449ab9
Following CLs update LegacyNetworkActivityTracker to support multiple
network activities including non default network.
To avoid breaking default network activity APIs, this CL adds tests.
Following CL fix known issues of LegacyNetworkActivityTracker so this
CL also adds test for known issue behavior.
Bug: 279380356
Test: FrameworksNetTests
Change-Id: Ic180efe690807e940d0b412a38ebc5e6d22691c4
aosp/2162425 added a WTF if a NetworkAgent changed state before
its native network has been created. This was intended to apply
only to the new U+ codepath, where networks are always created
immediately as soon as their agents register them. But the WTF is
logged on pre-U devices as well.
Fix this so that the WTF is only logged when the new codepath is
running.
Fix: 285999421
Test: TH
Change-Id: I28bda08a006978ab760fe8891bf5cf15b536201a
Currently, when lower/upper bound of Range is incorrect,
there is no useful information for debugging.
Test: atest TrafficStatsTest
Bug: 285452306
Change-Id: I0e390692c20b37e14958ecc0fd45c93f73fe63e2
This commit
- Set the DF flag on the NAT-T keepalive packet
- Add comment for TTL value
- Do some cleanups
Bug: 196453719
Test: m
Change-Id: I401ae52d8f16e43120210cdea223fd251d53ea3b
This is a preparation change for the subsequent changes to
separate the logic for constructing a v4 NAT-T keepalive
packets to a dedicated method.
Bug: 196453719
Test: atest FrameworksNetTests
Change-Id: If72b4875e65a547bbf90367eacce7b145358006a
The receipt time in the MdnsResponse need to be updated every time new
packet is received. And then the record refreshing logic could calculate
remaining TTL correctly.
Bug: 285260665
Test: atest CtsNetTest FrameworksNetTests
Change-Id: Ib7a290ea0ea8e552c71c657696397e8114fcee52
When an mDNS request (discovery, advertising, resolving...) is
registered and gets assigned a socket on a wifi network, take the
multicast lock to ensure that it can reliably receive mDNS responses.
This is limited to when the application has importance
FOREGROUND_SERVICE or higher.
NsdManager is not documented to require usage of the multicast lock,
which has caused various reports about its reliability. Taking the lock
while the app is in the foreground should address the large majority of
cases, while limiting battery impact.
Going forward this should allow developers on U+ to not take the
lock themselves, allowing optimizations on devices supporting APF,
where instead of taking the lock APF would let through only select
mDNS packets.
Bug: 284389438
Test: atest
Change-Id: I1ce85220eac4a1529b6716d50727c1c462356846
CtsNetHttpTestCases were missing a DevSdkIgnoreRule after updating the
min_sdk version to R+ (which made it installable on R where the cronet
classes are not in the bootclasspath.)
Test: atest CtsNetHttpTestCases
Bug: 259632936
Change-Id: I706ff92376227c1759fd6e542066fcff3a7cf052
Test: new test for this behavior in the preliminary change
Test: FrameworksNetTests NetworkStackTests
Fixes: 138810051
Fixes: 140610528
Change-Id: I95a979d232fb60ece2e33e972bf5d66d20357a1f
See system/netd/include/Fwmark.h which reserves the bottom 21 bits
of skb->mark for netid, etc... so out of necessity these have to be
in the top 11 bits.
In practice the only values that really make sense are either:
mark == mask == 0 (disabled)
or (mark == mask) being one of the top 11 available bits, for example:
mark == mask == 0x80000000 (enabled, using top-most bit)
(only a single bit makes sense, as this is really just a boolean signal,
and only the topmost is known to be used on any real devices)
Let's just force the use of 0x80000000 for ecosystem consistency.
Bug: 284334830
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I199e9b00de845b3747940426ea6644426ab72e87
* changes:
FinalizePausedKeepalive in handleStopAllKeepalives.
Add tests for pause, resume and stop keepalives.
Ensure autoKi is not stored when keepalive stops or is not started.
Add tests for NATT keepalives stopped internally in KeepaliveTracker.
aosp/2490881 updated to use InetDiagMessage.destroyLiveTcpSocket for all
devices.
But it is possible that netd socketDestory is modified in T- devices.
So this CL revert changes to keep using netd socketDestroy in T-
devices.
Test: atest FrameworksNetTests
Bug: 284253763
Change-Id: I9b61f10e975d2e38e9829a8c01d3af706e2518ef
If there is no request for all networks, the tethered/local only
interface changes will be ignored. However, these available
interfaces are not used for mDNS when a user requests a socket
with a null network because the interfaces are lost due to the
previous ignore. Therefore, the interface changes should be
retained and will be used for socket creations afterwards.
Bug: 284939720
Test: atest FrameworksNetTests android.net.cts.NsdManagerTest
Change-Id: If830eb53af26f21f497314477b131ce28468a971
mDNS is used by wifi p2p in many places. However,
MdnsSocketProvider does not monitor changes to the wifi p2p
connection to get the names of the available wifi p2p interfaces.
This prevents mDNS from registering or discovering services on
the wifi p2p interfaces. Therefore, listen to the wifi p2p change
intent to know the available interfaces and status changes that
can be used by mDNS.
Bug: 284263838
Test: atest FrameworksNetTests android.net.cts.NsdManagerTest
Change-Id: If03514f1286c0507e5862372272234dd07eb084d
As mentioned in RFC6762 7.1. The records only needed to be renewed if
at least half of the TTL passed. Usually A/AAAA records are included in
the response to the SRV record query, they are not refreshed individually.
Bug: 285261577
Test: atest CtsNetTest FrameworksNetTests
Change-Id: Ifd7140de0d733191256184c5481412e1822d279b
Turn on removeExpiredService feature by: 1) Remove the unnecessary
allowSearchOptionsToRemoveExpiredService flag. 2) Turn on the
removeExpiredService flag in the MdnsSearchOptions.
Bug: 285260665
Test: atest CtsNetTest FrameworksNetTests
Change-Id: Ib115b40e70b0f81a7877deb73af7d61e2e0c385f
EthernetTetheringTest#testTetherZeroLengthDhcpPacket requires the latest
NetworkStack module, otherwise, the test will fail due to the loss of
the fix. Apply @NetworkStackModuleTest to exclude this testcase from
target test suite CtsTetheringTestLatestSdk.
Bug: 283200648
Test: atest CtsTetheringTestLatestSdk
Change-Id: Iebfb043e2b71427a6feaf90788fe79b6ab6b678d
In the case that a keepalive is paused and handleStopAllKeepalives is
called, there is no KeepaliveInfo for the paused keepalive and so no
onError callback will be called. The autoKi will also be cleaned up so
no callback will ever called that notifies the keepalive is stopped.
Bug: 281646074
Test: atest FrameworksNetTests
Change-Id: I8fcaa1f07746235326c7ae05d97e20fd27927fea
The tests added verify the following:
1. Stopping the keepalive will cleanup the autoKi.
2. Pausing the keepalive does not cleanup the autoKi and stopping
a paused keepalive will still call the onStopped callback.
3. A starting error by resuming the keepalive will cleanup the
autoKi.
4. handleStopAllKeepalives also does the appropriate callback for paused
keepalives.
5. Stopping a resumed keepalive stops the correct slot when a second
keepalive is started while the first is paused.
Bug: 281646074
Test: atest FrameworksNetTests
Change-Id: I8925fbe40323dc4584a111d0cf31de016525ef41
In the cases below, the keepalive is already cleaned up internally in
KeepaliveTracker, but are not be cleaned up in
AutomaticOnOffKeepaliveTracker. This means the mAutomaticOnOffKeepalives
list is storing stopped keepalives and the metrics will still conisder
the keepalive as active.
1. In KeepaliveInfo.start, return whether the keepalive is successfully
starting(i.e. mStartedState == STARTING). Check for this in
handleStartKeepalive and return early on failure, without storing the
autoKi. Also check in handleResumeKeepalive.
2. In handleEventSocketKeepalive, return whether the handleStopKeepalive
is called, indicating the keepalive is forced to stop and was not
already STOPPING. This should happen when the state is STARTING but
the network agent returned an unsuccessful event.
3. In handleCheckKeepalivesStillValid, move the checking logic to
AutomaticOnOffKeepaliveTracker so the handleStopKeepalive is called.
Bug: 281646074
Test: atest FrameworksNetTests
Change-Id: I7839464534baed43abbd40b321287132da25b978
MdnsSocketClient doesn't support requesting specific network. As a
result, when processing the response, all the MdnsServiceTypeClient
should be called.
Bug: 285064577
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: Id95f1e78d60063ccee7f5855a21fa6b5a48fbd3e
Add tests where NATT keepalives are stopped and cleaned up within
KeepaliveTracker in these scenarios:
1. startNattKeepalive is called with an invalid interval.
2. The state is STARTING and the network agent returns an error event.
3. The keepalive started successfully but becomes invalid and
handleCheckKeepalivesStillValid is called on the network.
Bug: 281646074
Test: atest FrameworksNetTests
Change-Id: Iadf9f06030cae20f36d950f520c8dcc4181924ad
In some use cases for the MdnsDiscoveryManager, providing looper as an
argument to the MdnsDiscoveryManager constructor is not feasible. Adding
a constructor without looper can help to match those use cases. If
constructor without looper is used. The shutDown() must be called as a
part of cleanup process.
Bug: 283914408
Test: atest FrameworksNetTests
Change-Id: I0ab04d67bae127628c6d67c4b8c109201612a54b