Commit Graph

4080 Commits

Author SHA1 Message Date
Hugo Benichi
b2d70b403f Nat464Xlat: interface notification handler on ConnectivityService
This patch adds a layer of asynchonicity to the NetworkBaseObserver
callbacks implemented by Nat464Xlat in order to allow these callbacks
to run on the main ConnectivityService handler.

This allows to run interfaceLinkStateChanged and interfaceRemoved
callbacks in the same thread context as other Nat464Xlat methods and
solves the following issues:
  - NPE risk due to race between fixupLinkProperties called on the
    ConnectivityService thread and interfaceRemoved called as a
    callback by NetworkManagementService.
  - stale LinkProperties reads in both callbacks not called on
    ConnectivityService handler.
  - removes the race between stop() and interfaceRemoved().

This patch also:
  - removes/simplifies comments related to the threading
    model which are no obsolete.
  - extract clatd management logic from ConnectivityService into
    NetworkAgentInfo

Bug: 62997041
Bug: 64571917
Test:  runtest frameworks-net
       manually connected to ipv6 network and went to test-ipv6.com
Change-Id: I889d98e47423ff3d4746d6ed8015b265286e7c52
2017-08-29 08:55:18 +09:00
Hugo Benichi
6d7e12ed6e Merge "Nat464Xlat: internal state guards cleanup + state enum"
am: aee703e7e4

Change-Id: I188ac4c367db11cb33b67fe92df3a120e3c6fbce
2017-08-28 22:49:50 +00:00
Hugo Benichi
bd5610af79 Merge "Nat464Xlat: clat management cleanup"
am: 81b179cfdd

Change-Id: Ic3808a1afe48efac745b1b378fb12cc5678918ec
2017-08-28 12:01:25 +00:00
Hugo Benichi
adbbac97c5 Nat464Xlat: internal state guards cleanup + state enum
This patch does some cleanup of Nat464Xlat internal state guards
against the Nat464Xlat state Idle | Started | Running, which reduces
code nesting.

It also replaces introspection of internal state for distinguishing
between different stages in 464xlat lifecycle with an enum explicitly
introducing these three Idle | Started | Running states.

Bug: 62997041
Bug: 64571917
Test:  runtest frameworks-net
       manually connected to ipv6 network and went to test-ipv6.com
Change-Id: I6efc9fed2420ca488731a2b9b9c3c025b16eca10
2017-08-28 15:29:27 +09:00
Hugo Benichi
55d8ae3377 Nat464Xlat: clat management cleanup
This patch does some minor refactoring of clat starting/stopping code:
 - remove unused LinkProperties arguments in updateClat
 - remove unused Context argument in Nat464Xlat ctor
 - introduce ensureClatIsStarted and ensureClatIsStopped methods and
   simplify updateClat
 - add clatd to NetworkAgentInfo toString() method
 - clarify some comments

This changes prepare for moving BaseNetworkObserver callbacks to
ConnectivityService.

Bug: 62997041
Bug: 64571917
Test: runtest frameworks-net
      manually connected to IPv6 only network and went to test-ipv6.com
Change-Id: Idb204784614cfe700f73255a7a7b78c5e9ee6eca
2017-08-28 15:29:23 +09:00
Hugo Benichi
bfe44f641d Merge "Make NetworkManagementServiceTest pass again."
am: 29b1826ff2

Change-Id: If7fafa0922fdbc499c0c911a3f88ede9c8a26c1d
2017-08-24 03:46:07 +00:00
Lorenzo Colitti
3b43a4a047 Make NetworkManagementServiceTest pass again.
1. Mock the service manager so that NMS can fetch mock versions
   of INetd and IBatteryStats.
2. Call LocalServices.removeServiceForTest to avoid a duplicate
   service registration error. // check this
3. Change the timeout from 100ms to 200ms, as otherwise the tests
   that check for IfaceClass fail.
4. Convert NetworkManagementServiceTest to JUnit 4.
5. Move NetworkManagementServiceTest to tests/net

Bug: 29337859
Bug: 32163131
Bug: 32561414
Bug: 62918393
Test: runtest frameworks-net
Change-Id: Ic7371b427b35809ccd446addf35c9d8ae99ccfd3
2017-08-23 09:49:05 +09:00
Tobias Thierer
8f55753777 Merge "Network: Use HttpURLConnectionFactory rather than OkHttp APIs" am: 811e215e2c am: 41ff948711
am: e7776bd372

Change-Id: I048a7695ec98711163494e3dedab785e1400d1da
2017-08-22 15:28:07 +00:00
Tobias Thierer
e7776bd372 Merge "Network: Use HttpURLConnectionFactory rather than OkHttp APIs" am: 811e215e2c
am: 41ff948711

Change-Id: I0e15e22f4e1561102012b012cdea74db63ac2163
2017-08-22 15:16:31 +00:00
Tobias Thierer
41ff948711 Merge "Network: Use HttpURLConnectionFactory rather than OkHttp APIs"
am: 811e215e2c

Change-Id: I79db2f0dc0870f71ec21397545e2e6abb5c7142b
2017-08-22 15:00:24 +00:00
Tobias Thierer
811e215e2c Merge "Network: Use HttpURLConnectionFactory rather than OkHttp APIs" 2017-08-22 14:07:16 +00:00
Baligh Uddin
c8a6298b3f DO NOT MERGE ANYWHERE Revert "Merge "Remove gender-specific pronouns from documentation" into oc-dev" am: e811770999 -s ours
am: 92363c4e9f  -s ours

Change-Id: I1a912ffd002f35c31fe5a2cd47cb43cc7a66d2aa
2017-08-21 23:33:54 +00:00
Baligh Uddin
92363c4e9f DO NOT MERGE ANYWHERE Revert "Merge "Remove gender-specific pronouns from documentation" into oc-dev"
am: e811770999  -s ours

Change-Id: I9493ada35e2b660ffdf73793e621f4b295778d63
2017-08-21 22:57:31 +00:00
Android Build Merger (Role)
6c182d2c61 Merge "DO NOT MERGE ANYWHERE: Manually merge commit 'fd35d7c0a284' into oc-dev-plus-aosp am: 732df7fec9 -s ours" into oc-dr1-dev-plus-aosp 2017-08-21 22:02:00 +00:00
Tyler Freeman
2b1ce8b6ef DO NOT MERGE ANYWHERE: Manually merge commit 'fd35d7c0a284' into oc-dev-plus-aosp
am: 732df7fec9  -s ours

Change-Id: I8d58d5898771aaee6729225efff0389dd8c6c1ca
2017-08-21 21:57:57 +00:00
Baligh Uddin
a174dd26d3 DO NOT MERGE ANYWHERE Revert "Merge "Remove gender-specific pronouns from documentation" into oc-dev" am: e811770999 -s ours
am: 0a92e1584e  -s ours

Change-Id: Ie8381ac10bdab3e6ac56a37bd98583e03ea15451
2017-08-21 21:52:52 +00:00
Tyler Freeman
9e41f13ae6 DO NOT MERGE ANYWHERE Manually merge commit 'fd35d7c0a284' into oc-dr1-dev
am: 27b9dd89db  -s ours

Change-Id: I055554715c9ea2095926a01fa539c20bb6dd67f3
2017-08-21 21:41:22 +00:00
Baligh Uddin
0a92e1584e DO NOT MERGE ANYWHERE Revert "Merge "Remove gender-specific pronouns from documentation" into oc-dev"
am: e811770999  -s ours

Change-Id: Ida80fe80780bf4f811aa54e0163f5c936f4d16a6
2017-08-21 21:40:53 +00:00
The Android Automerger
732df7fec9 DO NOT MERGE ANYWHERE: Manually merge commit 'fd35d7c0a284' into oc-dev-plus-aosp
BUG:64864568
2017-08-21 21:34:43 +00:00
The Android Automerger
27b9dd89db DO NOT MERGE ANYWHERE Manually merge commit 'fd35d7c0a284' into oc-dr1-dev
BUG:64864568
2017-08-21 21:28:42 +00:00
Baligh Uddin
e811770999 DO NOT MERGE ANYWHERE Revert "Merge "Remove gender-specific pronouns from documentation" into oc-dev"
Bug: 64864568

This reverts commit fd35d7c0a284e31231e2f424cade864be695965b, reversing
changes made to 07a21754f45672b27e765d8c7677c9663c6dce91.
2017-08-19 15:49:05 -07:00
Lorenzo Colitti
0e2bdae581 Merge changes I325b13d5,I89719fe7 am: 06b75147b3 am: 09f500e6a4
am: ed2b08430a

Change-Id: Ib980879b0e50ffe1c8209339df22da4a50d5b74e
2017-08-19 03:38:10 +00:00
Lorenzo Colitti
ed2b08430a Merge changes I325b13d5,I89719fe7 am: 06b75147b3
am: 09f500e6a4

Change-Id: Iac0d1a08c45816f32b0f8ab81a079883a9965e21
2017-08-19 03:25:21 +00:00
Lorenzo Colitti
09f500e6a4 Merge changes I325b13d5,I89719fe7
am: 06b75147b3

Change-Id: Iaced543ab17ea87c8f701975764d957bc1b17fc7
2017-08-19 03:15:08 +00:00
Treehugger Robot
06b75147b3 Merge changes I325b13d5,I89719fe7
* changes:
  Add tether offload traffic to interface stats as well.
  Tell the system when tethering offload hits a limit.
2017-08-19 03:05:14 +00:00
Lorenzo Colitti
3d7b64c52d Add tether offload traffic to interface stats as well.
Currently, we only count add tethering traffic to per-UID
stats, but not to total data usage (i.e., dev and XT stats). This
is correct for software tethering, because all software forwarded
packets are already included in interface counters, but it is
incorrect for hardware offload, because such packets do not
increment interface counters.

To fix this:
1. Add an argument to ITetheringStatsProvider#getTetherStats to
   indicate whether per-UID stats are requested. For clarity,
   define integer constants STATS_PER_IFACE and STATS_PER_UID
   to represent these operations.
2. Make NetdTetheringStatsProvider return stats only if per-UID
   stats are requested. (Otherwise tethering traffic would be
   double-counted).
3. Make OffloadController's stats provider return the same
   stats regardless of whether per-UID stats were requested or
   not.
4. Make NetworkStatsService add non-per-UID tethering stats to
   the dev and XT snapshots. The per-UID snapshots were already
   correctly adding in per-UID stats.

(cherry picked from commit 49ab263c0b)

Bug: 29337859
Bug: 32163131
Test: runtest frameworks-net
Test: runtest frameworks-telephony
Change-Id: I325b13d50e88841dfb0db4c35e7e27f163ee72fe
Merged-In: I4e8e923d68dce1a4a68608dbd6c75a91165aa4ee
2017-08-19 10:12:05 +09:00
Hugo Benichi
77efec92fe Merge "Really allow NetworkAgent immutable updates to NetworkCapabilities" am: cb3c24e36b am: 46a7508229
am: 886144c1ff

Change-Id: If3742ea0e2151b9b710eda2fed280c31f7960393
2017-08-18 12:25:56 +00:00
Hugo Benichi
886144c1ff Merge "Really allow NetworkAgent immutable updates to NetworkCapabilities" am: cb3c24e36b
am: 46a7508229

Change-Id: Id352fdb6da21a2150d3e8d062d7eba11878f6919
2017-08-18 12:14:56 +00:00
Hugo Benichi
46a7508229 Merge "Really allow NetworkAgent immutable updates to NetworkCapabilities"
am: cb3c24e36b

Change-Id: Ifbdd005576b3f0fbf278ecec81ce3e4308c6276d
2017-08-18 11:59:02 +00:00
Hugo Benichi
7afbea0e6e Really allow NetworkAgent immutable updates to NetworkCapabilities
This patch completes commit 1ebf219ed9 to
really allow updates of immutable capabilities to NetworkCapabilities of
NetworkAgents by using satisfiedByImmutableNetworkCapabilities instead
satisfiedByNetworkCapabilities.

Bug: 64125969
Test: runtest frameworks-net
Change-Id: I9beeb623792f0ee31abcd4ba9d0ba2451304fb2e
2017-08-18 14:51:03 +09:00
Hugo Benichi
7a2f77b3a0 Merge "Add convenience methods to IpPrefix and LinkAddress" am: aabc00fad6 am: 3ca020fe8b
am: caafb4d9f5

Change-Id: I8d6dd5efd226a8b1c4b05d1e1102362b58e094a1
2017-08-16 15:09:12 +00:00
Hugo Benichi
caafb4d9f5 Merge "Add convenience methods to IpPrefix and LinkAddress" am: aabc00fad6
am: 3ca020fe8b

Change-Id: Iddfec82a08f845e728adadfa6ec58a60a078d6af
2017-08-16 14:56:51 +00:00
Hugo Benichi
3ca020fe8b Merge "Add convenience methods to IpPrefix and LinkAddress"
am: aabc00fad6

Change-Id: I6d3f3c50eaec44e3a0787e849ab28e89f6f4a72d
2017-08-16 14:49:27 +00:00
Treehugger Robot
aabc00fad6 Merge "Add convenience methods to IpPrefix and LinkAddress" 2017-08-16 14:38:29 +00:00
Hugo Benichi
8253be9fb7 Add convenience methods to IpPrefix and LinkAddress
Also moving relevant test files into tests/net as part of runtest
framworks-net.

Also removes testHashCode in LinkAddress() because this test relies on
the assumption that hashCode() is stable across releases or jdk
versions, which is absolutely not true.

This creates maintenance work for little benefit since hashCode is
already tested as part of the equality test.

For instance this test is now broken because hashing for InetAddress
changed.

Bug: 62988545
Bug: 62918393
Test: runtest frameworks-net, added coverage in tests
Change-Id: I695bc3f0e801bf13bc4fc0706565758f12b775b4
2017-08-16 21:42:21 +09:00
Hugo Benichi
b77d06e971 Merge "Allow NetworkAgent "immutable updates" to NetworkCapabilities" am: b35719a057 am: eea3a77efc
am: 34ea4f9088

Change-Id: I01e287b4df82a53a522566d33b3166f7801badca
2017-08-16 12:14:09 +00:00
Hugo Benichi
34ea4f9088 Merge "Allow NetworkAgent "immutable updates" to NetworkCapabilities" am: b35719a057
am: eea3a77efc

Change-Id: Ied592bf6112574399a1e808da337004e1c35f244
2017-08-16 12:04:38 +00:00
Hugo Benichi
eea3a77efc Merge "Allow NetworkAgent "immutable updates" to NetworkCapabilities"
am: b35719a057

Change-Id: I0ab76de59e87c46a6961229399ff7200bce49838
2017-08-16 11:50:55 +00:00
Hugo Benichi
1ebf219ed9 Allow NetworkAgent "immutable updates" to NetworkCapabilities
This patch loosens the validation checks when a NetworkAgent updates it
NetworkCapabilities: instead of checking that capabilities labeled as
"immutable" stay identical across updates, it is now accepted to change
immutable capabilities in a way that the new NetworkCapabilities
satisfies the old NetworkCapabilities.

This allows a NetworkAgent to update itself in order to match more
requests, but will still catch NetworkAgents that sends degradation
updates causing potentially requests to not match anymore.

Bug: 64125969
Test: runtest frameworks-net
Change-Id: I2a1b3f9c0be6415e40edc989d0c1b03b5631f7b1
2017-08-16 18:30:30 +09:00
Tobias Thierer
5efcea8a39 Network: Use HttpURLConnectionFactory rather than OkHttp APIs
This is a refactoring with no behavior change.

The new class provides an abstraction layer to hide knowledge
about OkHttp-specific APIs. Logic from android.net.Network that
knew about OkHttp is moving into that abstraction layer.

This CL refactors android.net.Network to make use of this
abstraction layer instead of the tight coupling onto OkHttp
APIs. The class no longer imports any classes from okhttp
packages.

The values of mDns and mConnectionPool, which never change after
the initial call to maybeInitHttpClient(), are now set directly on
the AndroidHttpClient instance when it is constructed in that method.

Applications can overwrite getSocketFactory() and might depend on
that method being called (and the result used) every time a
connection is opened; therefore, for maximum app compatibility this
call was kept inside openConnection().

This CL is a prerequisite for introducing an additional frameworks
dependency on a richer API than HttpURLConnection.

Test: Build and install apk for FrameworksCoreTests, then run:
      adb shell am instrument -e class android.net.NetworkTest -w com.android.frameworks.coretests
Bug: 64021405

Change-Id: I2c73d260508ee20c6a40fd6e95e2d058d3ea2330
2017-08-08 13:08:36 +01:00
Hugo Benichi
deb9ca18aa Merge "Fix flaky IpPrefixTest." am: 39a0b6b58e -s ours am: 9e59475003 -s ours
am: 38e86ba9f4  -s ours

Change-Id: I64b9214694132f874d5546b4ade1917524db50d7
2017-08-08 07:40:11 +00:00
Hugo Benichi
38e86ba9f4 Merge "Fix flaky IpPrefixTest." am: 39a0b6b58e -s ours
am: 9e59475003  -s ours

Change-Id: I216b50a8d0f51f2f731b17598b205a7b0ad65324
2017-08-08 07:34:42 +00:00
Hugo Benichi
9e59475003 Merge "Fix flaky IpPrefixTest."
am: 39a0b6b58e  -s ours

Change-Id: Iabc8a365a6c18c19754da7ddfcc0385eb5b0f768
2017-08-08 07:28:32 +00:00
Treehugger Robot
39a0b6b58e Merge "Fix flaky IpPrefixTest." 2017-08-08 07:16:48 +00:00
Hugo Benichi
f9c61862cc Fix flaky IpPrefixTest.
Test: IpPrefixTest passes
Bug: 32561414
Merged-In: Ib4bffe9d33a6d4f5c2bd97798073de0f66d77645

(cherry pick from commit f5ec69155d)

Change-Id: Ibaf11aae9b13af868bebff820c9e7615b63c8eb2
2017-08-08 14:54:08 +09:00
Hugo Benichi
4ba82b261f Merge "NetworkCapabilities: fix describeImmutableDifferences" into oc-dr1-dev
am: 1b3877a965  -s ours

Change-Id: I42723162b29e8a8c966201e1b4da811e2d266f00
2017-08-07 05:49:17 +00:00
Hugo Benichi
dec642b9b3 NetworkCapabilities: fix describeImmutableDifferences
This patch fixes the mask used in describeImmutableDifferences which did
not correctly turn NET_CAPABILITY_NOT_METERED into bit flag.

Bug: 63326103
Test: added unit tests, runtest frameworks-net
Merged-In: Ib6b390b1daef5912859302692af7dcd6cfd3e39a
Merged-In: If38efacdeec8476880835657938e435f9b598525
Merged-In: Ieccad46fcffcaf748f5644b04617e9a82527000e
Merged-In: I533ef8fe369cec19d283ff2950314fce6e28cffd
Merged-In: I12636c6699ff60487a28570208e819ea0b66fa2e
Merged-In: Ie5df14e0ea1c12e0cfabe87978ac6c9b744353b2

(cherry picked from commit 2ecb9408f4102687f20f9ca19c13071ac6098cc6)

Change-Id: I74ecf34a2c079c74152d00caea2c220e9c6d1fa5
2017-08-05 11:37:10 +09:00
Hugo Benichi
09cb221afb Merge "NetworkCapabilities: fix describeImmutableDifferences" am: 7575ec2240 am: 9d951bf6f3
am: 7dac4ce465

Change-Id: I533ef8fe369cec19d283ff2950314fce6e28cffd
2017-08-05 01:14:30 +00:00
Hugo Benichi
7dac4ce465 Merge "NetworkCapabilities: fix describeImmutableDifferences" am: 7575ec2240
am: 9d951bf6f3

Change-Id: Ieccad46fcffcaf748f5644b04617e9a82527000e
2017-08-05 01:01:04 +00:00
Hugo Benichi
9d951bf6f3 Merge "NetworkCapabilities: fix describeImmutableDifferences"
am: 7575ec2240

Change-Id: If38efacdeec8476880835657938e435f9b598525
2017-08-05 00:54:43 +00:00