Commit Graph

12070 Commits

Author SHA1 Message Date
Lorenzo Colitti
cecb2bfcf4 Merge "Make MockVpn more realistic and easier to use." am: 0dd10f43c7 am: c927d555cd am: 49156dc401 am: d591886ab8
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1501814

Change-Id: I1beca5148b05724042e3c2415015f2ffa3ed2be5
2020-11-19 12:31:03 +00:00
Lorenzo Colitti
7992b7baa6 Merge changes I3711b362,I49421183,Icc0701cb,I2f5ccc1d am: 40b4ef6dd7 am: 49038a76c2 am: 3968347b84 am: 3dea488951
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1501951

Change-Id: I5c7847bac88b574737ab80e5a20e9e22afb5b2e4
2020-11-19 12:30:34 +00:00
Lorenzo Colitti
d591886ab8 Merge "Make MockVpn more realistic and easier to use." am: 0dd10f43c7 am: c927d555cd am: 49156dc401
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1501814

Change-Id: I949afe9dfa706ecce66f3b80a7f3e330dcc49413
2020-11-19 12:14:27 +00:00
Lorenzo Colitti
3dea488951 Merge changes I3711b362,I49421183,Icc0701cb,I2f5ccc1d am: 40b4ef6dd7 am: 49038a76c2 am: 3968347b84
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1501951

Change-Id: I5e26e04f0ec77a2ea54681100d9dcfb991acdc95
2020-11-19 12:14:00 +00:00
Lorenzo Colitti
49156dc401 Merge "Make MockVpn more realistic and easier to use." am: 0dd10f43c7 am: c927d555cd
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1501814

Change-Id: I96385c6463b791920199fd008743cddeaae6d348
2020-11-19 11:58:00 +00:00
Lorenzo Colitti
3968347b84 Merge changes I3711b362,I49421183,Icc0701cb,I2f5ccc1d am: 40b4ef6dd7 am: 49038a76c2
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1501951

Change-Id: If8bab0ac75da87f417bc9bd925822a73002cecb7
2020-11-19 11:57:47 +00:00
Lorenzo Colitti
c927d555cd Merge "Make MockVpn more realistic and easier to use." am: 0dd10f43c7
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1501814

Change-Id: I6584e231913841dc218573dc586429cd720621a3
2020-11-19 10:42:04 +00:00
Lorenzo Colitti
49038a76c2 Merge changes I3711b362,I49421183,Icc0701cb,I2f5ccc1d am: 40b4ef6dd7
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1501951

Change-Id: I021b2719e8b6d76cbb64d979f1ce5f661a1a25a5
2020-11-19 10:37:25 +00:00
Lorenzo Colitti
0dd10f43c7 Merge "Make MockVpn more realistic and easier to use." 2020-11-19 10:32:19 +00:00
Lorenzo Colitti
40b4ef6dd7 Merge changes I3711b362,I49421183,Icc0701cb,I2f5ccc1d
* changes:
  Increase test coverage for VPN info sent to NetworkStatsService.
  Simplify MockVpn.
  Test a VPN with an underlying network that does not yet exist.
  Minor fixes to NetworkCapabilities#toString.
2020-11-19 10:20:00 +00:00
Lorenzo Colitti
925d1a9a82 Make MockVpn more realistic and easier to use.
MockVpn is very difficult to use because it requires the test
caller keeping track of both the MockVpn object and an
accompanying TestNetworkAgentWrapper.

It's also not very realistic: for example, connect() doesn't
actually connect anything, it just makes it so that if
ConnectivityService tries to update the capabilities, the attempt
will not be ignored. Also, unlike the real code in Vpn, it
connects with empty NetworkCapabilities (in particular, with
empty UID ranges).

Make this easier to use and a bit more realistic by:
- Allowing TestNetworkAgentWrapper to take a "NetworkCapabilities
  template" that will form the initial capabilities sent when the
  agent registers with ConnectivityService. This allows the VPN
  to register its agent with its UID ranges already set, like the
  production code does.
- Providing separate methods to register the NetworkAgent and
  mark it connected for cases where the test needs to make
  changes to the NetworkAgent before connecting (e.g., poking
  NetworkMonitor).
- Putting the TestNetworkAgentWrapper inside MockVpn and driving
  it through MockVpn's methods. In order not to have too many
  wrapper functions (and because we can't delegate like in
  Kotlin), there's still an agent() method that returns the
  TestNetworkAgentWrapper.

Bug: 173331190
Test: test-only change
Change-Id: I749ff325bc13ac96f512270b86d1f67686eec378
2020-11-19 16:23:07 +09:00
Lorenzo Colitti
fdce3dde08 Increase test coverage for VPN info sent to NetworkStatsService.
Bug: 173331190
Test: test-only change
Change-Id: I3711b362f31cb92b759e9f5c9d244fb88d9bd5e7
2020-11-19 14:56:50 +09:00
Lorenzo Colitti
d97d6e304b Simplify MockVpn.
This CL removes four methods in MockVpn by slightly changing the
test code to leverage the actual methods implemented by the
(production) Vpn superclass.

This works because setting mInterface results in
isRunningLocked() returning true, which makes a number of methods
behave as if the VPN is connected (which is what the test
expects).

The more realistic behaviour exposes a minor bug in the treatment
of underlying networks. Add a TODO to fix it.

Bug: 173331190
Test: test-only change
Change-Id: I49421183538ba61ca790af71e309ece36b653bf9
2020-11-19 14:53:53 +09:00
Lorenzo Colitti
e50c0f8af4 Test a VPN with an underlying network that does not yet exist.
This test checks that if a VPN declares an underlying network
that does not exist, the capabilities of that network are applied
to the VPN as soon as the network starts to exist.

Bug: 173331190
Test: test-only change
Change-Id: Icc0701cb4cea7d91f7738c1e426e94cd26686b74
2020-11-19 14:46:32 +09:00
Lucas Lin
4ce0ae8aae [automerger skipped] Separate 2 tests to verify canBeSatisfiedBy() am: 3e3bffbcdb -s ours
am skip reason: Change-Id I1391bae9a0fc0298beb8fe80b5f388b492244566 with SHA-1 43e1a7971e is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13070579

Change-Id: I6d0f23ee0415758c125e41582ddfc3b7a7d56d8a
2020-11-19 03:25:22 +00:00
Rambo Wang
6a41d22386 [automerger skipped] Rename satisfiedBy to canBeSatisfiedBy for MatchAllNetworkSpecifier am: e5d9cf4577 -s ours
am skip reason: Change-Id Ibe32fd50fae43aa635c1c0dad66eaea82011c8b7 with SHA-1 4d1afeb672 is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13077159

Change-Id: Id2fc2a9449ab79842471ded3d67d06e7335b52dd
2020-11-19 03:25:16 +00:00
Chiachang Wang
9837aeb4a1 Merge "Move BasicShellCommandHandler to frameworks/lib/modules-utils" 2020-11-19 00:45:29 +00:00
Chiachang Wang
bb26bd6f94 Merge "Replace InterfaceConfiguration usage with stable aidl" am: c0c71a50d6 am: 75cd8abbc7 am: 4ff4b9910f am: 50e11a6414
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1488356

Change-Id: I60b7d3c863121e4f766913c4b536795f6cc3b758
2020-11-18 10:47:38 +00:00
Chiachang Wang
50e11a6414 Merge "Replace InterfaceConfiguration usage with stable aidl" am: c0c71a50d6 am: 75cd8abbc7 am: 4ff4b9910f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1488356

Change-Id: Iec15205660c6a9bddb3cf644d91713a720e4178a
2020-11-18 09:57:33 +00:00
Lucas Lin
3e3bffbcdb Separate 2 tests to verify canBeSatisfiedBy()
In Android R, NetworkSpecifier#satisfiedBy() has changed to
NetworkSpecifier#canBeSatisfiedBy(), but its subclass -
MatchAllNetworkSpecifier hasn't.
In Android S, both of MatchAllNetworkSpecifier and
NetworkSpecifier has changed satisfiedBy() to canBeSatisfiedBy().
So if running the latest CTS on R device, it will verify
NetworkSpecifier#canBeSatisfiedBy() instead of
MatchAllNetworkSpecifier#satisfiedBy() and get the unexpected
result.
The fix is to separate 2 tests to verify canBeSatisfiedBy(), one
is for Android R or older version and the other is for Android
S+.

Bug: 172401624
Test: Run MatchAllNetworkSpecifierTest on Android R and S.

Change-Id: I9aeddaa3e331f609bbdba8ab0c2d6e014123f242
Merged-In: I1391bae9a0fc0298beb8fe80b5f388b492244566
2020-11-18 09:52:58 +00:00
Chiachang Wang
4ff4b9910f Merge "Replace InterfaceConfiguration usage with stable aidl" am: c0c71a50d6 am: 75cd8abbc7
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1488356

Change-Id: I29d12cfa0b7ad7f048b253284077411484acc4a3
2020-11-18 09:28:34 +00:00
Chiachang Wang
e51f66472f Move BasicShellCommandHandler to frameworks/lib/modules-utils
BasicShellCommandHandler is used by mainline modules and the
framwork. There is a new repo that was created for putting
this kind of utility class. Move BasicShellCommandHandler for
the incoming ConnectivityService mainline and updating the
related usage.

Bug: 170598012
Test: m ; verify with adb shell cmd
Change-Id: Ida30c877116090616d4bf3f87fdad835446dac84
2020-11-18 09:18:06 +00:00
Chiachang Wang
75cd8abbc7 Merge "Replace InterfaceConfiguration usage with stable aidl" am: c0c71a50d6
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1488356

Change-Id: I7be60028fb07d0d6fcc65d110c2d198a85ff2b29
2020-11-18 09:14:35 +00:00
Chiachang Wang
c0c71a50d6 Merge "Replace InterfaceConfiguration usage with stable aidl" 2020-11-18 09:05:59 +00:00
Lorenzo Colitti
104d9701f9 Minor fixes to NetworkCapabilities#toString.
1. The current code only prints the array of administrator UIDs
   if it's empty. This is clearly an oversight. Print it only if
   it's non-empty.
2. Only print requestor UID and package name if they are set.
   This makes output shorter in the common case that they are
   unset.
3. Reorder the output at the end: group all UIDs together, and
   place SSID and private DNS broken bit after that.
4. Make the private DNS broken indication a single word instead
   of a sentence. This saves space and makes it easier to write
   regexps.

New format:
... SignalStrength: -72 OwnerUid: 1000 AdminUids: [1000] SSID: ...
... Uid: 1000 RequestorUid: 1000 RequestorPkg: android ...

Test: manual
Change-Id: I2f5ccc1d9e4af6ddacc4d193185a17723822972b
2020-11-18 17:10:11 +09:00
Rambo Wang
e5d9cf4577 Rename satisfiedBy to canBeSatisfiedBy for MatchAllNetworkSpecifier
MatchAllNetworkSpecifier is a subclass of NetworkSpecifer. The method
satisfiedBy should be renamed to canBeSatisfiedBy together with other
subclass of NetworkSpecifer in b/152238712.

Add annotation @Overide for the method to make sure it will not get
ignored when refactor in the future.

Bug: 154956584
Test: atest android.net.MatchAllNetworkSpecifierTest
Original-Change: https://android-review.googlesource.com/1295946
Merged-In: Ibe32fd50fae43aa635c1c0dad66eaea82011c8b7
Change-Id: Ibe32fd50fae43aa635c1c0dad66eaea82011c8b7
2020-11-18 06:59:52 +00:00
Chiachang Wang
db04f067b0 Replace InterfaceConfiguration usage with stable aidl
Replace InterfaceConfiguration with InterfaceConfigurationParcel
for the incoming ConnectivityService mainline since mainline
modules could not use @hide API.

Bug: 170598012
Test: atest FrameworksNetTests
Change-Id: I17ce8741e985fd30e3c8f0c34e79564a82890dc6
2020-11-18 14:46:13 +08:00
Lucas Lin
cde9b30cad Merge "Separate 2 tests to verify canBeSatisfiedBy()" am: 59c5a7ee61 am: 2fd5ddbffd am: 1102259c8a am: e4674acfbe
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1495268

Change-Id: I9aeddaa3e331f609bbdba8ab0c2d6e014123f242
2020-11-17 12:43:30 +00:00
Automerger Merge Worker
a3c19abab3 Merge "Merge "Fix the comments left on aosp/1481197" am: 51a4f05ef8 am: ba157d8b07" into rvc-d1-dev-plus-aosp am: 95fd9d13c5 am: 38aaba118c
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1494036

Change-Id: I18a1e42198fc6febc3d88e740f6750b046def0c0
2020-11-17 12:43:15 +00:00
Lucas Lin
e4674acfbe Merge "Separate 2 tests to verify canBeSatisfiedBy()" am: 59c5a7ee61 am: 2fd5ddbffd am: 1102259c8a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1495268

Change-Id: Ifcad77aabc1ee8b3ec40c7c23c61a6dfcc4e678b
2020-11-17 12:21:49 +00:00
Automerger Merge Worker
38aaba118c Merge "Merge "Fix the comments left on aosp/1481197" am: 51a4f05ef8 am: ba157d8b07" into rvc-d1-dev-plus-aosp am: 95fd9d13c5
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1494036

Change-Id: I583b1b7dd5ab13a35c41b76f1425f15b5a3117bf
2020-11-17 12:21:12 +00:00
Lucas Lin
1102259c8a Merge "Separate 2 tests to verify canBeSatisfiedBy()" am: 59c5a7ee61 am: 2fd5ddbffd
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1495268

Change-Id: If94d24c57b5f982180b04bad236c524183e4c5af
2020-11-17 11:56:30 +00:00
Automerger Merge Worker
95fd9d13c5 Merge "Merge "Fix the comments left on aosp/1481197" am: 51a4f05ef8 am: ba157d8b07" into rvc-d1-dev-plus-aosp 2020-11-17 11:56:14 +00:00
Lucas Lin
34bf1ff904 Merge "Fix the comments left on aosp/1481197" am: 51a4f05ef8 am: ba157d8b07
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1494036

Change-Id: I6fca5804b1b70803cf0e3666da2870c299f089e5
2020-11-17 11:54:58 +00:00
Lucas Lin
c67d5ebb5d Merge "Fix the comments left on aosp/1481197" am: 51a4f05ef8 am: ba157d8b07 am: bae14aa611 am: dce5a4370c
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1494036

Change-Id: I0758a4e38d349ffe01d8e1fd78c5b6337cdb9242
2020-11-17 10:01:41 +00:00
Lucas Lin
dce5a4370c Merge "Fix the comments left on aosp/1481197" am: 51a4f05ef8 am: ba157d8b07 am: bae14aa611
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1494036

Change-Id: Iefb07ae46a42b5ad751298470e11ec2c94716e37
2020-11-17 09:50:57 +00:00
Lucas Lin
2fd5ddbffd Merge "Separate 2 tests to verify canBeSatisfiedBy()" am: 59c5a7ee61
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1495268

Change-Id: I8b2d43d11570f90b1bfa23c27fccb592269b16c9
2020-11-17 09:22:34 +00:00
Lucas Lin
59c5a7ee61 Merge "Separate 2 tests to verify canBeSatisfiedBy()" 2020-11-17 08:38:07 +00:00
Lucas Lin
bae14aa611 Merge "Fix the comments left on aosp/1481197" am: 51a4f05ef8 am: ba157d8b07
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1494036

Change-Id: Iea77eb0ed2ca0b5603d1257496bd1e8a14ed0d77
2020-11-17 08:11:57 +00:00
Lucas Lin
ba157d8b07 Merge "Fix the comments left on aosp/1481197" am: 51a4f05ef8
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1494036

Change-Id: I7f13f380db5fe30e67be9cedc9429519b9fd4b6e
2020-11-17 07:47:54 +00:00
Lucas Lin
51a4f05ef8 Merge "Fix the comments left on aosp/1481197" 2020-11-17 07:06:46 +00:00
Dan Shi
ac6adb0744 Merge "Revert "Move BasicShellCommandHandler to frameworks/lib/modules-..."" 2020-11-12 22:46:35 +00:00
Dan Shi
f42e56f08e Revert "Move BasicShellCommandHandler to frameworks/lib/modules-..."
Revert "Update import path of BasicShellCommandHandler"

Revert "Update path for BasicShellCommandHandler"

Revert "Update path for BasicShellCommandHandler"

Revert "Update rule for BasicShellCommandHandler"

Revert submission 12975279-move_BSCH

Reason for revert: b/173120275
Reverted Changes:
Ib750f4774:Move BasicShellCommandHandler
I43c0dc327:Update import path of BasicShellCommandHandler
I73d58c07c:Update path for BasicShellCommandHandler
I21f103949:Update path for BasicShellCommandHandler
I8a2873df6:Move BasicShellCommandHandler to frameworks/lib/mo...
I91df774a3:Update rule for BasicShellCommandHandler

Exempt-From-Owner-Approval: to fix b/173120275

Change-Id: Iaa44f9aa4c1621f331275dc76ecb7505100fe9c5
2020-11-12 22:44:12 +00:00
Junyu Lai
e0873a4c09 Merge changes I6a48d4db,I6741c41c,Ifec6bde5,Icd0717c5 am: 38ec07ff9e am: 63fbab6e6a am: 99b7bcd09c am: 62229d3d33
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1490617

Change-Id: I2c5895c223a5843cfe11a1736a243b6847ad1b9a
2020-11-12 10:19:29 +00:00
Junyu Lai
62229d3d33 Merge changes I6a48d4db,I6741c41c,Ifec6bde5,Icd0717c5 am: 38ec07ff9e am: 63fbab6e6a am: 99b7bcd09c
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1490617

Change-Id: Ie76caf460ac86251cd0ceca981bdf2c7e4bcfc44
2020-11-12 09:47:50 +00:00
Junyu Lai
99b7bcd09c Merge changes I6a48d4db,I6741c41c,Ifec6bde5,Icd0717c5 am: 38ec07ff9e am: 63fbab6e6a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1490617

Change-Id: I11a56ed8d67f321a66fecc7550383db7d9f9c897
2020-11-12 09:35:38 +00:00
Junyu Lai
63fbab6e6a Merge changes I6a48d4db,I6741c41c,Ifec6bde5,Icd0717c5 am: 38ec07ff9e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1490617

Change-Id: I5545dddcb5c8499ac9c53325cbafd424124429e1
2020-11-12 09:02:13 +00:00
Junyu Lai
38ec07ff9e Merge changes I6a48d4db,I6741c41c,Ifec6bde5,Icd0717c5
* changes:
  Remove unused variables
  Return offloaded traffic when querying from TrafficStats API
  Add hardware tethering traffic in testTethering test
  Remove unused getTetherStats
2020-11-12 08:45:15 +00:00
junyulai
2fae9c3667 Add hardware tethering traffic in testTethering test
Test: atest com.android.server.net.NetworkStatsServiceTest#testTethering
Bug: 162292214
Change-Id: Ifec6bde5fd3231f2135f12536c42e42ec6b707de
2020-11-12 14:22:31 +08:00
Chiachang Wang
2628efa2db Merge "Move BasicShellCommandHandler to frameworks/lib/modules-utils" 2020-11-12 05:08:48 +00:00