Also update the test to ensure mFactory.hasInterface is mocked to match
mFactory.getInterfaceState: previously it would be called by the factory
in the mocked getInterfaceState, but the new code calls it directly.
Bug: 171872016
Test: atest EthernetManagerTest
Change-Id: I9ac959f181c88a7992991923b98a836f2833fa88
(cherry picked from commit f33f276b29)
Merged-In: I9ac959f181c88a7992991923b98a836f2833fa88
The test cannot pass in branches that use an old prebuilt tethering
module.
Bug: 234099453
Test: atest NetworkStatsServiceTest
Merged-In: Ib1d180cc799dde94ada642ce752623b4b65f1e31
Merged-In: I44dda14cae265e600010c6f8efe1471ac481c6ea
Merged-In: I702a75e91be0bb582f9cbd7b4a23e1286f8252cf
Change-Id: I7ce44dac1b5d730f84f882ba8ae1b741a633e765
In current design, the interface will be removed from the list if
the network disconnected which will cause getUidStatsForTransport()
returns unexpected snapshot to caller since the list is empty.
This change also remove interface name from all entries before
the method returns the result.
Ignore-AOSP-First: non-AOSP CL is included in the same topic
Bug: 231514741
Test: FrameworksNetTests
manual test
Change-Id: Ie60829a65d0d9b5b63ad353695a820c0586e3665
The unit tests cannot pass before a newer prebuilt of Tethering is used,
as bootclasspath classes that it tests would be outdated.
This change is not merged in downstreams that build from source (changes
in the merged-in tags are not related changes, however).
Bug: 234099453
Test: atest
Merged-In: Ib1d180cc799dde94ada642ce752623b4b65f1e31
Merged-In: I44dda14cae265e600010c6f8efe1471ac481c6ea
Merged-In: I702a75e91be0bb582f9cbd7b4a23e1286f8252cf
Change-Id: I5b0cb131fcb5feb6b3cfd70e95ba7c5e54fa2294
Tethering downstreams do not have NetworkAgents, and although they have
a netid of 99, Networks with netId 99 are not usable by apps for most
connectivity APIs.
Recent refactoring in NsdService adds the Network of a found service
into its NsdServiceInfo, and uses that network to resolve the service.
In that case the Network has netId 99 and resolving the service fails.
Avoid that problem by:
- Keeping the Network field null when a service is found on a tethering
downstream; this avoids giving apps a confusing and unusable Network
with netId 99
- Using the interface index found during discovery to resolve the
service, if the app uses the NsdServiceInfo that was obtained from
discovery to resolve. If not, all interfaces will be used to resolve,
as per legacy APIs.
Bug: 233979892
Test: atest NsdServiceTest
Also manual test with 2 devices connected via hotspot
Change-Id: Idd176153b67ccbd1d4f1b1fd66dafaa2f3a9e27a
(cherry picked from commit 1a8ee102d3)
Merged-In: Idd176153b67ccbd1d4f1b1fd66dafaa2f3a9e27a
In internalGetSummaryForNetwork, the history object will not
include the latest bucket because of the logic in
NetworkStatsHistory#recordHistory would only include buckets
that atomically occur in the inclusive time range.
This makes querySummaryForDevice callers who are also sensitive
to the latest bucket fails.
This CL revert the behavior back to S, in T this is temporarily
changed after aosp/1937268.
Also, for test purpose, this CL change System.currentTimeMillis to
use mClock when querying.
Ignore-AOSP-First: Urgent fix
Test: NetworkStatsServiceTest#testGetLatestSummary
Bug: 233733267
Change-Id: I55e2a5d953622b68da36a9b8d3e57c88d57543b0
This CL adds unit test to test onThresholdReached event
would unregister and re-register usage callback.
Ignore-AOSP-First: Urgent fix
Test: MultipathPolicyTrackerTest#testOnThresholdReached
Bug: 233733267
Change-Id: I6e43ae93055009d91b0795a4466f2c02f4403c0a
* changes:
Temporarily ignore ethernet tests until prebuilts are updated
Add CTS tests for EthernetNetworkProvider changes
Move EthernetNetworkFactory to using the NetworkProvider API
Add NetworkOfferCallback to NetworkInterfaceState
Change NetworkInterfaceState to hold NetworkProvider instance
Improve waiting for interface added or removed
Always wait for interface to be up in EthernetManagerTest
Assume all Ethernet interfaces have an MTU of 1500.
Using Merged-In line of commit that adds the CTS tests to prevent this
change from going anywhere it should not.
Unfortunately, the test runner does not properly parse tests ignored at
the class level.
Test: TH
Bug: 233824546
Ignore-AOSP-First: only needed on tm-dev
Change-Id: Ia911cdfc39614ccda5f2cf8bfd1d913cf80a60ae
Merged-In: I8e806b3b884f2e0b6c1a1d2fffdb9a99c5dd60e8
This CL makes EthernetNetworkFactory inherit from NetworkProvider rather
than NetworkFactory. The name of the class is purposefully unchanged to
make the code review easier (it will be changed to
EthernetNetworkProvider in a follow up).
As part of the conversion, NetworkInterfaceState now registers a
NetworkOffer when the link comes up and unregisters it when the link
goes down. It updates the existing offer when capabilities change (by
calling registerNetworkOffer with an already registered
NetworkOfferCallback).
This change should fix existing refCount issues. When a NetworkOffer is
first registered, it receives callbacks for all existing requests. This
is the main problem with the NetworkFactory implementation where only
one NetworkOffer is registered when the factory is first created; so
when interfaces come up, they do not receive callbacks for existing
requests.
Test: atest EthernetNetworkTest
Bug: 197548738
Change-Id: I5e8e4673d2ed04bc1a0c8d232a8772edfff65b5d
Merged-In: I5e8e4673d2ed04bc1a0c8d232a8772edfff65b5d
When unregistering, if the caller process is dead. The system
can unregsiter for the caller. But the request decrement should
be counted onto the caller uid instead of system uid.
Ignore-AOSP-First: Urgent fix
Test: NetworkStatsObserversTest#testUnregister_knownRequest_invalidUid_doesNotUnregister
Bug: 233580307
Change-Id: I85aee8f395739929bc7086883ace81ac1ecd0730
This CL also stop from incresing "successes" counter if the
importer finishes with fallback.
Ignore-AOSP-First: in a topic with internal-only changes
Test: manual
Bug: 230289468
Change-Id: I88fce1b2d0dea3772a8b31df8f8fa93bf13bffad
In order to support rollbacks, the ethernet ipconfig file needs to be
written to the data apex's data directory. We still need to support
reading from the legacy location to be backwards compatible.
If the apex file path already exists, then read the IP configuration
from there directly, otherwise, check if the legacy file path exists,
if yes, read the legacy IP configuration and copy it to the new apex
file path.
Support for default IpConfiguration is also being removed in this CL.
The default IpConfiguration (configuration entry for interface "0")
was a way to transition from supporting a single interface to
supporting multiple interfaces and was introduced in P. Every device
that has used such a configuration and has connected to an ethernet
network since upgrading to P+ has already removed the "0" config and
has assigned it to the first interface (probably "eth0"). There has
never been an API to set this, but if someone wanted to install a
default IpConfiguration, they could just configure "eth0" instead.
Bug: 224919694
Test: atest EthernetConfigStoreTest --iterations
Test: manually test
- adb push <fake ipconfig.txt> /data/misc/ethernet/
- adb reboot
- read the IP config from legacy path and the same config
file is created in the apex file path
- adb reboot
- read the IP config from the apex file path directly
Change-Id: Ifb82a5d7fa13d17ea8fd3a42a19cd020cb95e26a
(cherry picked from commit 47641d75d9)
Merged-In: Ifb82a5d7fa13d17ea8fd3a42a19cd020cb95e26a
Updating the automotive allowed UIDs check to only work if the
capabilities have a single transport equal to ethernet.
CP of https://r.android.com/2101472
Bug: 229419469
Test: atest FrameworksNetTests
Change-Id: I91e987d6b943a3c5986ab88553a6eef0d479b079
Merged-In: I91e987d6b943a3c5986ab88553a6eef0d479b079
* changes:
Skip PersistentIntTest on S- device
Don't clobber existing history entries.
Ensure NetworkStats migrated snapshot is identical
[MS82.1] Support network stats data migration process
Add a PersistentInt class.
Allow ethernet factories on automotive devices to set the allowed UIDs
on NetworkCapabilities.
CP of https://r.android.com/2072767
Bug: 229419469
Test: atest FrameworksNetTests
Change-Id: I03e7cda75f1c530e0d0e4a756330bc9847a96668
Merged-In: I03e7cda75f1c530e0d0e4a756330bc9847a96668
This class is only used in the service runs on T+ devices.
Thus run this test on S- device does not make senses.
Ignore-AOSP-First: in a topic with internal-only changes
Bug: 230289468
Test: atest ConnectivityCoverageTests:PersistentIntTest
on S device
Change-Id: I97a29df17ef9ee9ab373655f045cdb5c820e06ef
After turning off the ethernet settings via api, the ethernet service
can still be started when plugging-in the cable. Improve the api by
ignoring the upcoming interface unsolicited event listener callbacks
and register new interface observer once the ethernet setting is enabled
again.
Bug: 231933028
Test: atest testListenEthernetStateChange_unsolicitedEventListener
Change-Id: I1b1cb7d157f023fca82d75592168bd360a6fa6e1
(cherry picked from commit 94a00dfc64)
Merged-In: I1b1cb7d157f023fca82d75592168bd360a6fa6e1
Currently, adding a history to a NetworkStatsCollection.Builder
will overwrite any history that was previously passed in with the
same key. This breaks the importer (which is the primary/only
caller of this code), because the importer re-uses the same
NetworkStatsCollection object to import multiple files.
Instead, simply add any passed-in entries after the ones that
were already there. Require the caller to pass in entries in
order, because NetworkStatsHistory internally assumes that
entris are always sorted.
Ignore-AOSP-First: in a topic with internal-only changes
Bug: 230289468
Test: manually verified this unbreaks the importer
Change-Id: Ic8647ff28fca78d579d5f759f96a864877f8158b
Read migration snapshot both from the platform API and the legacy
method, and Log.wtf if they are different. Use the legacy method data if
they are.
This ensures that using the migration API is a no-op, and that errors
are reported (through Log.wtf) if it would not have been if used as-is.
Ignore-AOSP-First: in a topic with internal-only changes
Test: NetworkStatsServiceTest
Bug: 230289468
Change-Id: I857ad18183d63d1aa16e89f89eb24009648720a2
This includes:
1. Provide NetworkStatsRecorder#importCollectionLocked to
allow caller to write a NetworkStatsCollection object to
a standalone file.
2. Do not clear the collection in NetworkStatsRecorder#
CombiningRewriter, this is safe since pending set will
still be cleared during forcePersistLocked.
3. Implement the migration process, including recovery and
safety measures.
Test: NetworkStatsServiceTest NetworkStatsCollectionTest
Test: manual test with
adb shell device_config put tethering \
netstats_store_files_in_apexdata true
adb shell device_config put tethering \
netstats_import_legacy_target_attempts 1
Ignore-AOSP-First: in a topic with internal-only changes
Bug: 230289468
Change-Id: Ic2002cbfd5a6b3c2226fa8dab22481f8ce656574
This implements a simple integer written to disk backed by
AtomicFile.
Bug: 230289468
Test: new unit test
Ignore-AOSP-First: in a topic with internal-only changes
Change-Id: I1c73c8ac2429f92153cfba3b006b4374e75e65df
Currently, even when VPN Lockdown mode is enabled, incoming packets are
not dropped if VPN is not connected.
This commit fixed this issue.
After this commit, If VPN Lockdown mode is enabled, incoming packets
are dropped regardless of the VPN connectivity.
Bug: 206482423
Test: atest TrafficControllerTest ConnectivityServiceTest PermissionMonitorTest
Change-Id: If52ece613c8aac1073355e43b6fb9cb3fcc87d1d
(cherry picked from commit b08654ca04)
Merged-In: If52ece613c8aac1073355e43b6fb9cb3fcc87d1d
This is needed to ensure corrupted data can be clean up if
the data migration process dones't go well.
Test: NetworkStatsCollectionTest
Bug: 197717846
Change-Id: Ic76ad6f3e96f03791b48988fb2622c9c647ffc7c
(cherry picked from commit 306a00316c)
Merged-In: Ic76ad6f3e96f03791b48988fb2622c9c647ffc7c
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
(cherry picked from commit f3c946278c)
Merged-In: I8299f46fd47a82ec9b25ba2e0d3c95db5512c331
This is a follow-up commit from aosp/2076483. Mainly to update:
1. Update the hex string to human understandable code instead of
byte code.
2. Use IgnoreUpTo() to do the SDK check
3. Avoid relying on the code being tested
Bug: 192078259
Test: atest FrameworksNetTests
Change-Id: I8973d248a1d30fdcb597677dbf051e146041f905
(cherry picked from commit a023f88193)
Merged-In: I8973d248a1d30fdcb597677dbf051e146041f905
VPN configurations in T should automatically include the corresponding
SDK sandbox UID of an application.
The existing tests used a UID range outside the regular application
range, which means the new sandbox UIDs wouldn't be tested. Modified the
UIDs to run in the regular UID range of [10000, 19999]. Changed the
tests to include the SDK sandbox UID where necessary.
Also, changed the entire class to only run on T+, since that is the only
place where the SDK sandbox UIDs will be added. Since VPN code is not
mainline updatable, having coverage on earlier releases doesn't really
help anyway.
Finally, fixed up testNetworkBlockedStatusAlwaysOnVpn() in
ConnectivityServiceTest, and only have that run on T+ for the same
reasons.
Bug: 225317905
Test: atest VpnTest
Test: atest ConnectivityServiceTest
Change-Id: I83009344c270e520ac8ad1558c067cf7e46b1d2e
Merged-In: I83009344c270e520ac8ad1558c067cf7e46b1d2e
1) alowFallback flag was incorrectly not reset while setting profile
preference. Corrected it.
2) Threw exception if default preference and enterprise preference are
set together
3) renamed clearUser to withoutUser
Bug: 231670730
Test: ConnectivityServiceTest
Change-Id: If92ebe0cc23f18c8808893926d5e1d12ff2e3650
Merged-In: Iaf49237bdc791c7e1dd884d069eff64e74757477
Normally if an app calls requestNetwork with capabilities that it
does not have permission to request, it gets a SecurityException,
except if it requests NET_CAPABILITY_CBS, in which case the request
will not throw but the app will get an onUnavailable callback.
Make this codepath throw as well. This simplifies the code and makes
the app-visible behaviour more consistent (and consistent with what
happens in S and below). The reason the code was written this way is because the carrier privilege app should receive a callback if it
loses permission. But onUnavailable is also not the best callback to
send, since it is used very rarely and also releases the app's
request. It seems better to leave the request registered and send
onLost.
Test: atest FrameworksNetTests
Bug: 194332512
Change-Id: I5eaeb415a6654851246e38599a996fbd9366fde0
(cherry picked from commit 96bd9fe4de)
Merged-In: I5eaeb415a6654851246e38599a996fbd9366fde0
In order to have better logging to gather information
about the callers. This change includes:
1. Add pid and package name into RequestInfo for better logging.
2. Print current observers in dumpsys section.
3. Enable register/unregister usage request logging by default.
The log added in the dumpsys section looks like:
Stats Observers:
RequestInfo from pid/uid:2001/1000(android) for DataUsageRequest [...] accessLevel:3
...
Test: NetworkStatsObserversTest
Bug: 229103088
Change-Id: Ide68776dc279610e8dee0efd924b59a1fac2b7b6
(cherry picked from commit c259e615e6)
Merged-In: Ide68776dc279610e8dee0efd924b59a1fac2b7b6
Multiple enterprise slice can be setup within single user profile based
on different uids. So do not remove profile network preference with same
user profile but with different uids
Bug: 229644102
Test: manual system test and ConnectivityServciceTest
Change-Id: I897b643e01240958fff575de9e15182069efc698
(cherry picked from commit 9cc129f37d)
Merged-In: I897b643e01240958fff575de9e15182069efc698