Commit graph android_packages_modules_Co.../tests/unit/java/com/android
Message SHA1
Test VpnManager event for CATEGORY_EVENT_NETWORK_ERROR
Bug: 191413541
Test: atest FrameworksNetTests:VpnTest
Change-Id: Idffd5f5f8fc6614281f3fb0884228a797d783fe3
(cherry picked from commit cfec723ef9)
Merged-In: Idffd5f5f8fc6614281f3fb0884228a797d783fe3

lucaslin   authored and   Cherrypicker Worker   commited 2022-05-28 06:01:17 +00:00
affb72d2b8
Test VpnManager event for CATEGORY_EVENT_IKE_ERROR
Bug: 191413541
Test: atest FrameworksNetTests:VpnTest
Change-Id: Iebc0ac281eb03fac9626c64e44cdd14be1462d89
(cherry picked from commit 827b44daea)
Merged-In: Iebc0ac281eb03fac9626c64e44cdd14be1462d89

lucaslin   authored and   Cherrypicker Worker   commited 2022-05-28 06:01:13 +00:00
744c8967e5
Merge changes from topics "cherrypicker-L37800000954756398:N06400001268122372", "cherrypicker-L61200000954646707:N00900001267167505", "cherrypicker-L64000000954631044:N08200001267145803" into tm-dev
* 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.

Patrick Rohr   authored and   Android (Google) Code Review   commited 2022-05-25 23:31:09 +00:00
d84c99cad2
Temporarily ignore ethernet tests until prebuilts are updated
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

Patrick Rohr   commited 2022-05-25 11:54:36 -07:00
14f45a3e98
Move EthernetNetworkFactory to using the NetworkProvider API
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

Patrick Rohr   commited 2022-05-25 11:50:30 -07:00
0ccff8a30b
Merge changes from topics "CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED", "CATEGORY_EVENT_DEACTIVATED_BY_USER" into tm-dev
* changes:
  Test VpnManager event for CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED
  Test VpnManager event for CATEGORY_EVENT_DEACTIVATED_BY_USER

Lucas Lin   authored and   Android (Google) Code Review   commited 2022-05-25 10:20:18 +00:00
81f05b9011
Merge "Fix crash when decrementing data usage request" into tm-dev
TreeHugger Robot   authored and   Android (Google) Code Review   commited 2022-05-24 23:52:30 +00:00
898a5f9acc
Address comment at ag/18491259 and ag/18486388
Ignore-AOSP-First: in a topic with internal-only changes
Test: TH
Bug: 230289468
Change-Id: Id91fabb47b542d8526d6aa787b5947238c3934fb

Junyu Lai   commited 2022-05-25 00:41:49 +08:00
ecec6d9350
Fix crash when decrementing data usage request
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

Junyu Lai   commited 2022-05-24 23:41:05 +08:00
a69db7de03
Persisting status int on the device if fallback happened
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

Junyu Lai   commited 2022-05-23 17:48:55 +08:00
bfc68ac08a
Test VpnManager event for CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED
Bug: 225010642
Test: atest FrameworksNetTests:VpnTest
Change-Id: I078be4e00470efd9d7a2a87b40919116b99c83b8
(cherry picked from commit 0772c169b5)
Merged-In: I078be4e00470efd9d7a2a87b40919116b99c83b8

lucaslin   authored and   Lucas Lin   commited 2022-05-23 08:34:39 +00:00
12c30b9e82
Test VpnManager event for CATEGORY_EVENT_DEACTIVATED_BY_USER
Bug: 191413541
Test: atest FrameworksNetTests:VpnTest
Change-Id: Idc876275b88c2f4ddeb85c43d37d5f657b0f307b
(cherry picked from commit c5bf088ced)
Merged-In: Idc876275b88c2f4ddeb85c43d37d5f657b0f307b

lucaslin   commited 2022-05-23 16:32:27 +08:00
1c0e75628b
Move ipconfig file inside apex data directory
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

Patrick Rohr   authored and   Cherrypicker Worker   commited 2022-05-20 07:50:55 +00:00
64468d1494
Merge changes I91e987d6,I03e7cda7 into tm-dev
* changes:
  Changing automotive ethernet allowed UIDs check
  Allow ethernet on automotive to set allowed UIDs

TreeHugger Robot   authored and   Android (Google) Code Review   commited 2022-05-20 03:29:14 +00:00
0657071494
Changing automotive ethernet allowed UIDs check
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

James Mattis   commited 2022-05-19 09:13:31 -07:00
a2ea68df28
Merge changes from topic "stats-migration" into tm-dev
* 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.

Junyu Lai   authored and   Android (Google) Code Review   commited 2022-05-19 14:54:01 +00:00
ac6213123a
Allow ethernet on automotive to set allowed UIDs
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

James Mattis   commited 2022-05-19 07:48:05 -07:00
45f3e41a6a
Skip PersistentIntTest on S- device
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

Junyu Lai   commited 2022-05-19 15:09:42 +08:00
c3f7cabe59
Fix the ethernet setting API bug.
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

Xiao Ma   authored and   Cherrypicker Worker   commited 2022-05-19 01:58:15 +00:00
9cae3c8a99
Ensure NetworkStats migrated snapshot is identical
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

Remi NGUYEN VAN   authored and   Junyu Lai   commited 2022-05-18 23:51:03 +08:00
3776d862e2
[MS82.1] Support network stats data migration process
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

Junyu Lai   commited 2022-05-18 23:34:30 +08:00
27e0a9833e
Add a PersistentInt class.
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

Lorenzo Colitti   authored and   Junyu Lai   commited 2022-05-18 20:54:50 +08:00
76c0f6f0e8
Merge changes from topics "cherrypicker-L31300000954565189:N38500001265926579", "cherrypicker-L33500000954572563:N23000001265907389", "cherrypicker-L61500000954569605:N47200001265868358" into tm-dev
* changes:
  Block incoming packets in VPN Lockdown mode.
  Refactor VPN interface filtering necessity check
  Support 32 match types in UidOwnerValue rule

Lorenzo Colitti   authored and   Android (Google) Code Review   commited 2022-05-17 23:40:57 +00:00
327eb4d6ca
Merge "Limit data usage request per uid" into tm-dev
Junyu Lai   authored and   Android (Google) Code Review   commited 2022-05-17 09:57:16 +00:00
9a0f148675
Block incoming packets in VPN Lockdown mode.
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

Motomu Utsumi   commited 2022-05-17 09:35:28 +00:00
966ff7f82a
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
(cherry picked from commit f3c946278c)
Merged-In: I8299f46fd47a82ec9b25ba2e0d3c95db5512c331

Junyu Lai   authored and   Cherrypicker Worker   commited 2022-05-13 10:01:07 +00:00
6621705f83
Address leftover comments
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

Chiachang   commited 2022-05-13 03:01:50 +00:00
bc65e7e992
Test [set|get]AppExclusionList
Bug: 192078259
Test: atest FrameworksNetTests
Change-Id: Iee81d84b4127420121ce2d5a7defc3dbe34b6cde
(cherry picked from commit 218d5652de)
Merged-In: Iee81d84b4127420121ce2d5a7defc3dbe34b6cde

chiachangwang   authored and   Chiachang   commited 2022-05-13 02:47:56 +00:00
f2897b8a93
Modify VPN unit tests to include SDK sandbox UIDs.
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

Martijn Coenen   commited 2022-05-12 12:11:45 +00:00
c0cf5a9bac
Merge changes from topic "cherrypicker-L53700000954454916:N44100001263878999" into tm-dev
* changes:
  Check carrier privilege for CBS network requests synchronously
  Allow 3p apps to request restricted networks

Paul Hu   authored and   Android (Google) Code Review   commited 2022-05-12 02:48:34 +00:00
2edf88960a
Fallback should be evaluated for each preference
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

Sooraj Sasindran   authored and   Lorenzo Colitti   commited 2022-05-11 23:56:48 +00:00
d359d19813
Check carrier privilege for CBS network requests synchronously
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

junyulai   authored and   Cherrypicker Worker   commited 2022-05-11 13:50:06 +00:00
f9fc36ea3a
Improve logging for NetworkStatsObservers
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

Junyu Lai   commited 2022-05-10 10:56:44 +08:00
4c14d7a94d
Do not remove profile network preference for different uids
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

Sooraj Sasindran   authored and   Cherrypicker Worker   commited 2022-05-09 09:44:35 +00:00
ca9e8fe1c9
Add more tests for setProfileNetworkPreferences
1. Test that adding a new preference replaces the existing preference.
2. Test that if we pass in two simultaneous preferences for the same user.
   (e.g., two different groups of apps), the second overrides the first.

Bug: 229644102
Test: ConnectivityServciceTest
Change-Id: I819247711f8457b12792585216ff47be31457ae8
(cherry picked from commit 95e02c5d5a)
Merged-In: I819247711f8457b12792585216ff47be31457ae8

Sooraj Sasindran   authored and   Cherrypicker Worker   commited 2022-05-09 09:44:33 +00:00
38b5ce570c
Follow-up 2076940: Allow device owner to configure profile network preference
https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2076940

Fixes build failure

Bug: 231104107
Bug: 226966328
Bug: 231071836
Test: tests/unit/java/com/android/server/ConnectivityServiceTest.java
Change-Id: I7b6a3880ce0b0b9ad6fc6aa7a5fd4e249bb1606d
(cherry picked from commit baade1ca1e)
Merged-In: I7b6a3880ce0b0b9ad6fc6aa7a5fd4e249bb1606d

Vadim Caen   authored and   Sooraj Sasindran   commited 2022-05-05 16:47:33 +00:00
77abf9b3c1
Allow device owner to configure profile network preference
isMangedProfile returns true for managed profiles.
But enterprise device can be fully managed like device owner.
Hence check specifically if request is coming on fully managed
device.

Bug: 226966328
Bug: 231071836

Test: ran DevicePolicyManager CTS and ConnectivityServiceTest
Change-Id: I7827466bd61e24ba9c36c3a2e25043257e2ed602
(cherry picked from commit bb65aa8fc2)
Merged-In: I7827466bd61e24ba9c36c3a2e25043257e2ed602

Sooraj Sasindran   commited 2022-05-04 06:19:28 +00:00
f7b4c451ce
Merge "Test Ikev2VpnProfile provisioned with IkeTunnelConnectionParams" am: 2e670756ac am: 9942af20c0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2063922

Change-Id: I966e6dac28759075313774966039097ff033d686
Ignore-AOSP-First: this is an automerge
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Chiachang Wang   authored and   Automerger Merge Worker   commited 2022-04-25 09:31:52 +00:00
fe35305b32
Merge "Test Ikev2VpnProfile provisioned with IkeTunnelConnectionParams"
Chiachang Wang   authored and   Gerrit Code Review   commited 2022-04-25 08:44:45 +00:00
2e670756ac
adjust for new T bpfloader net_shared location am: 0736d7bd91 am: 96706b661f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2071008

Change-Id: Iba57cbfe6f3c41fc7c396098f0caa662d68b1e0e
Ignore-AOSP-First: this is an automerge
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Maciej Żenczykowski   authored and   Automerger Merge Worker   commited 2022-04-23 09:56:33 +00:00
4249b8be1d
adjust for new T bpfloader net_shared location
(this is safe because on pre-T none of these maps and programs are mainlined
 and thus safe to access from mainline code anyway)

Test: TreeHugger, manual
Bug: 218408035
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I23e565d665247f33e084978890a1ee8ffe0fe568

Maciej Żenczykowski   commited 2022-04-23 09:03:06 +00:00
0736d7bd91
Merge "[CLATJ#27] Use ClatdCoordinator since T+ devices" am: b4bf6cea38 am: 8d75a93995
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1951099

Change-Id: I3878e5359349d8195e8741ea69ae437edab68909
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Maciej Żenczykowski   authored and   Automerger Merge Worker   commited 2022-04-21 14:34:12 +00:00
2fadc5413c
Test Ikev2VpnProfile provisioned with IkeTunnelConnectionParams
Bug: 223841137
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: I683f6242e4ed4a469893e3a17fe7b479a7a768e5

chiachangwang   commited 2022-04-21 14:49:41 +08:00
476e2a08bf
[CLATJ#27] Use ClatdCoordinator since T+ devices
- For clatd start and stop, use ClatdCoordinator on T+ and Netd on S-
- Fix the unit test for T+ and S- devices
  Note that mokito.verify(.., times(1)) is replaced by verify(..)
  because times(1) is the default and can be omitted.
  See verify in mockito/src/main/java/org/mockito/Mockito.java

Note that this commit needs to be merged with aosp/1956072.

Bug: 212345928
Test: atest FrameworksNetTests
      manual test
      1. Connect to ipv6-only wifi.
      2. Try IPv4 traffic.
         $ ping 8.8.8.8
      3. Check bpf entries are added
      4. Disconnect from ipv6-only wifi.
      5. Check bpf entries are removed
      6. testipv4.com shows 10/10

Change-Id: I7dfda6eec19de94e4258971effcd8a1210542473

Hungming Chen   commited 2022-04-21 13:24:36 +08:00
eb15a2d816
Fix permission bypass problem for Tethering deprecated APIs
Since the tethering functions in ConnectivityService is delegated
to TetheringManager instance and get caches informataion in
TetheringManager without checking ACCESS_NETWORK_STATE permission.
If application use reflection call getTetherXXX functions in
ConnectivityService, it can get tethering status with no additional
execution privileges needed.

Bug: 162952629
Test: manual
Ignore-AOSP-First: security fix
Change-Id: I5b897f216db19fead6ba6ac07915aa0f6ff5bf42

markchien   commited 2022-04-19 19:13:10 +08:00
28160b3141
Merge "Save appIds permissions for each user"
Natasha Lee   authored and   Gerrit Code Review   commited 2022-04-12 23:55:06 +00:00
7f85379b07
Save appIds permissions for each user
PermissionMonitor does not store any information regarding
traffic permission. It just checks permission from each package
and sends the result to netd. In addition, bpf can store traffic
permissions for appIds only because of memory limitations.

However, there is a mistaken permission overwriting when
different packages are installed on multi-user. Because
PermissionMonitor updates appIds traffic permissions to netd
from each user, so the permission result will depend on the
latest user state.

To fix the problem, save the traffic permissions by each user and
appId on PermissionMonitor. An appId has a permission if and
only if at least one uid in that appId has that permission.

bug: 224775316
Test: atest FrameworksNetTests CtsNetTestCases \
      CtsNetTestCasesUpdateStatsPermission \
      CtsNetTestCasesInternetPermission
Change-Id: Ieb01fb21f6201a58723eb7e6446b127627be2c0e

paulhu   commited 2022-04-12 11:06:46 +00:00
a501e47e19
Merge "Remove NativeDaemonConnector relevant files"
Paul Hu   authored and   Gerrit Code Review   commited 2022-04-12 07:37:16 +00:00
631c2387a6
Remove NativeDaemonConnector relevant files
NsdService is using binder call to communicate with
mdnsresponder, so there is no one to use NativeDaemonConnector
now. Thus, remove NativeDaemonConnector relevant files.

Bug: 209894875
Test: atest FrameworksNetTests
Change-Id: Ic70d9417dc85c04c537e09d8f8586a762ac9a97b

paulhu   authored and   Paul Hu   commited 2022-04-12 07:35:31 +00:00
cee953bd09
Merge changes I2c3242f8,Iaa67d5ae
* changes:
  Remove unused TcUtils{, Test}, bpfhelper from libclat
  ClatCoordinator: use Java class TcUtils to detach program

Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2022-04-11 20:47:50 +00:00
b3bf5fedab