Commit Graph

988 Commits

Author SHA1 Message Date
Hugo Benichi
f60833507e NsdService: do not use ContentResolver directly
This patch changes NsdService to call registerContentObserver in the
ContentResolver class indirectly through NsdSettings.

This allows to easily intercept it and mock it in unit tests, and solves
test failures on the internal master branch where
registerContentObserver uses final or static methods that cannot be
worked around.

Bug: 32561414
Bug: 62044295
Test: runtest -x frameworks/base/tests/net/../NsdServiceTest.java
Change-Id: If4deb106de551746babb70196b20f21ece478850
2017-05-26 07:18:15 +09:00
Hugo Benichi
c52f403933 Merge "NsdServiceInfo: move test to tests/net" am: 48859e01d5 am: 1b0f4bf606 am: e8c2700519
am: ca4c03dbb0

Change-Id: I11af75ab8ebc4081cc90d29b83d8a1742f00a3ab
2017-05-25 01:18:45 +00:00
Hugo Benichi
ca4c03dbb0 Merge "NsdServiceInfo: move test to tests/net" am: 48859e01d5 am: 1b0f4bf606
am: e8c2700519

Change-Id: I44cae417fcddad72c13938b6fb751de6ed784046
2017-05-25 01:12:51 +00:00
Hugo Benichi
298ac9487e NsdServiceInfo: move test to tests/net
This patch also
  - adds a license plate to NsdServiceInfoTest
  - fixes some formatting and style issues
      package name
      uses of canonical junit asserts
  - update NsdServiceInfoTest to not use the deprecated AndroidTestCase

Bug: 62044295
Bug: 32561414
Test: $ runtest frameworks-net passes
Change-Id: Ie5ebb00172aef4eec19e6ecd2b41c4467901b93d
2017-05-24 16:03:43 +09:00
Hugo Benichi
ecea72cfca NsdService: simple cleanups
This patch replace some SparseArray<Integer> with SparseIntArray, and
simplify a value lookup function by using indexOfValue().

Test: TODO
Bug: 37013369, 33298084
Bug: 38503832

(cherry picked from commit d2552aee11)

Change-Id: Ifbe4f01bad8964e6f3a6e9633415959ab5feb0af
2017-05-23 12:54:00 +09:00
Hugo Benichi
c0a215d1ad NsdService: test coverage for client requests.
Adding coverage for:
  - NsdManager client disconnection
  - in-flight request GC

Test: new test passes
Bug: 37013369, 33298084
Bug: 38503832

(cherry picked from commit 4dd4db7720)

Change-Id: I02aca772d88306acae09db739ced7a2b1119b72b
2017-05-23 12:53:55 +09:00
Christopher Tate
fde4caf456 Be resilient to restoring unintelligible network templates
Some OEMs have introduced incompatible network bookkeeping.  We now
detect and ignore those network definitions at restore time.

In addition, we now

  * log when an undefined network match type is used to construct a
    NetworkTemplate instance, and
  * quietly refuse to match such a NetworkTemplate against any known
    network identifier, rather than crashing the inquiring app.

Bug 38151335
Test: manual

Change-Id: I565b6f6b87df1f13a8c0c01ae6049bda270b1e48
2017-05-17 10:33:01 -07:00
Hugo Benichi
85c377405c Merge "NetworkStatsFactory: no double looping on stats + stacked interfaces" am: b884b37cea am: cd6537edb5 am: b323e61584
am: 1f27dba36f

Change-Id: I175ffaae545d88b7bc39ab01ab3a811af7e03d60
2017-05-10 09:30:01 +00:00
Hugo Benichi
1f27dba36f Merge "NetworkStatsFactory: no double looping on stats + stacked interfaces" am: b884b37cea am: cd6537edb5
am: b323e61584

Change-Id: I0312882bb8885aaa65f99a445fd0554d6ac054b3
2017-05-10 09:20:04 +00:00
Hugo Benichi
cb4e4db083 Merge "NetworkStatsFactory: fix double accounting on IPv6 only networks" into oc-dev am: f37b271894 -s ours
am: f2daafb681  -s ours

Change-Id: Ia2b1ca862959fb685e6595f41dbfb130cdad6009
2017-05-10 08:49:28 +00:00
Hugo Benichi
f2daafb681 Merge "NetworkStatsFactory: fix double accounting on IPv6 only networks" into oc-dev
am: f37b271894  -s ours

Change-Id: I28f139b2bc5a42eed4caf01bea7a1a9426a91625
2017-05-10 08:38:56 +00:00
Hugo Benichi
b884b37cea Merge "NetworkStatsFactory: no double looping on stats + stacked interfaces" 2017-05-10 08:19:33 +00:00
Hugo Benichi
cab3546780 Merge "NsdService: more cleanups" am: cfd9a290ef am: 49bc06d0f9 am: ea0d4a65f9
am: 9e0bb312f8

Change-Id: If7fe9be600285f70b24de6ad97895555157a6a6a
2017-05-10 02:23:01 +00:00
Hugo Benichi
c1781e6e5e Merge "Merge "NetworkStatsFactory: fix double accounting on IPv6 only networks" am: ce730270bc am: 76dc14ec88 am: 1697d48faf" into oc-dev-plus-aosp
am: 5a015facd7

Change-Id: I97d5fcc43d6f11c05b74b29ebf3182a3ea7198c5
2017-05-10 02:12:15 +00:00
Hugo Benichi
e8a2ba93eb Merge "Merge "NetworkStatsFactory: fix double accounting on IPv6 only networks" am: ce730270bc am: 76dc14ec88 am: 1697d48faf" into oc-dev-plus-aosp
am: f8dbdba5a2

Change-Id: Ie09f2b4e04749e61923781f4b13e796054108fad
2017-05-10 02:06:06 +00:00
Hugo Benichi
9e0bb312f8 Merge "NsdService: more cleanups" am: cfd9a290ef am: 49bc06d0f9
am: ea0d4a65f9

Change-Id: I547138d0f45e621b583cbcc8a4ed5ab334bd4471
2017-05-10 01:15:30 +00:00
Android Build Merger (Role)
5a015facd7 Merge "Merge "NetworkStatsFactory: fix double accounting on IPv6 only networks" am: ce730270bc am: 76dc14ec88 am: 1697d48faf" into oc-dev-plus-aosp 2017-05-10 00:47:39 +00:00
Hugo Benichi
bca6c822ff Merge "NetworkStatsFactory: fix double accounting on IPv6 only networks" am: ce730270bc am: 76dc14ec88
am: 1697d48faf

Change-Id: I8b0cf31ef356aae9992f893ca35001d048999519
2017-05-10 00:44:51 +00:00
Hugo Benichi
286734b834 Merge "NetworkStatsFactory: fix double accounting on IPv6 only networks" am: ce730270bc am: 76dc14ec88
am: 1697d48faf

Change-Id: I7dbfe3c96678e2325eb533f31523ad10d861ad02
2017-05-10 00:40:28 +00:00
Hugo Benichi
cfd9a290ef Merge "NsdService: more cleanups" 2017-05-10 00:37:11 +00:00
Hugo Benichi
b15ed2c488 NetworkStatsFactory: fix double accounting on IPv6 only networks
For 464xlat scenarios on IPv6 networks, the clatd interface setup
introduces double counting of apps ipv4 traffic. NetworkStatsFactory was
accounting for this on the tx path, but not on the rx path. Also it did
not accounted for the 20 bytes added by the IPv6 header.

This patch subtract correctly the rx and tx traffic from the root uid on
the underlying interface, and also adds correctly the 20 bytes cost per
packet on the stacked interface for 464xlat traffic.

Test: added several new unit tests, based on synthetic data and real
      data also.
Bug: 33681750
Change-Id: I4867fe181938d94b5594b3d88896a3c4e01d895c
Merged-In: I2675643b220acbc6110179fa937d4c313b6f5e32

(cherry picked from commit e1bb3a14d1ee1aba2f92e5bccf659774699eaffe)
2017-05-10 09:19:12 +09:00
Hugo Benichi
5efd907d85 NetworkStatsFactory: no double looping on stats + stacked interfaces
This patch uses the associative structure of the stacked/base interface
collection to avoid the two nested for loops over stacked/base
interfaces and all stats entries when correcting 464xlat traffic stats.

Consequently the list of stats entries is iterated only once.

Test: runtest -x frameworks/base/../NetworkStatsFactoryTest.java
Bug: 33681750
Change-Id: I84ae997fb693b909f431764697627b9957131732
2017-05-10 09:14:14 +09:00
Hugo Benichi
ce730270bc Merge "NetworkStatsFactory: fix double accounting on IPv6 only networks" 2017-05-10 00:07:29 +00:00
Hugo Benichi
6d58a32565 NetworkStatsFactory: fix double accounting on IPv6 only networks
For 464xlat scenarios on IPv6 networks, the clatd interface setup
introduces double counting of apps ipv4 traffic. NetworkStatsFactory was
accounting for this on the tx path, but not on the rx path. Also it did
not accounted for the 20 bytes added by the IPv6 header.

This patch subtract correctly the rx and tx traffic from the root uid on
the underlying interface, and also adds correctly the 20 bytes cost per
packet on the stacked interface for 464xlat traffic.

Test: added several new unit tests, based on synthetic data and real
      data also.
Bug: 33681750
Change-Id: I2675643b220acbc6110179fa937d4c313b6f5e32
2017-05-09 22:46:14 +09:00
Android Build Merger (Role)
7adfa61ddd Merge "Merge "Move some NetworkStats tests to tests/net." into oc-dev am: 74fe2cbc3a -s ours am: ea28d269ea -s ours" 2017-05-09 06:49:26 +00:00
Lorenzo Colitti
6290dd23db Merge "Move some NetworkStats tests to tests/net." into oc-dev am: 74fe2cbc3a -s ours
am: ea28d269ea  -s ours

Change-Id: I40b5bb1e640358e6889f92dacdd2a977bc9758fb
2017-05-09 06:46:48 +00:00
Hugo Benichi
66f318d1c6 Merge changes I4872f8ba,I92039f29,Iaad13e13 am: 767ac317e2 am: 717238a614 am: 44e9b81c54
am: 20f5ef9065

Change-Id: Ia0f85518fd0e75e768fa037c5d0bcf062b3c1f93
2017-05-09 06:39:13 +00:00
Hugo Benichi
20f5ef9065 Merge changes I4872f8ba,I92039f29,Iaad13e13 am: 767ac317e2 am: 717238a614
am: 44e9b81c54

Change-Id: I9c38d1254f82b50f4d1e953e72bf15a46562d3b8
2017-05-09 06:30:48 +00:00
Hugo Benichi
912db99ddb NsdService: more cleanups
This patch does some simple refactoring around management of nsd service
enabled status.

Test: TODO
Bug: 37013369, 33298084
Change-Id: If1b124459a814cd0e821f683ccd568e30a698d2e
2017-05-09 10:49:34 +09:00
Hugo Benichi
d2552aee11 NsdService: simple cleanups
This patch replace some SparseArray<Integer> with SparseIntArray, and
simplify a value lookup function by using indexOfValue().

Test: TODO
Bug: 37013369, 33298084
Change-Id: I4872f8baa2bb2ff456c7f848d3afe2e7bcc9892e
2017-05-09 10:49:34 +09:00
Hugo Benichi
4dd4db7720 NsdService: test coverage for client requests.
Adding coverage for:
  - NsdManager client disconnection
  - in-flight request GC

Test: new test passes
Bug: 37013369, 33298084
Change-Id: I92039f297cf99352bbf4196797933d89c0b819ff
2017-05-09 10:49:33 +09:00
Hugo Benichi
f2c64f8725 NsdManager: remove duplicated argument validation
This patch simplifies argument validation in NsdManager public api and
regroup duplicated validation into common methods.

This makes stack traces more actionable as now specific errors will
cause the api to throw exception from specific methods, whereas before
IllegalArgumentException would be thrown from inside the same api method
for different reasons.

This patch also includes a couple of other small cleanups.

Test: $ runtest -x frameworks/base/tests/net/../NsdManagerTest.java
Bug: 37013369
Change-Id: Iaad13e13976e9bf8f508d7188f823f8184ac414b
2017-05-09 10:49:33 +09:00
Hugo Benichi
5af0be7729 Merge "NsdManager: add test coverage for discoverServices()" am: 3e21b1745c am: 60182dbe4e am: 27b0eebb4d
am: 284ecaa201

Change-Id: I2bbd97293d2887824b857d7e20fdc14d574bc097
2017-05-02 09:09:55 +00:00
Hugo Benichi
284ecaa201 Merge "NsdManager: add test coverage for discoverServices()" am: 3e21b1745c am: 60182dbe4e
am: 27b0eebb4d

Change-Id: I46acfd104ac3457126c3ccef5041788e4146321c
2017-05-02 09:04:59 +00:00
Hugo Benichi
be9b90264c Merge "NsdManager: unit test coverage for servive registration" am: b0e408450c am: bc57faa1ac am: 9a3e69d9b6
am: 459c68c725

Change-Id: I88461d537e43fb086366dcc681b5ef2c2bdcdc2f
2017-05-02 06:56:15 +00:00
Hugo Benichi
459c68c725 Merge "NsdManager: unit test coverage for servive registration" am: b0e408450c am: bc57faa1ac
am: 9a3e69d9b6

Change-Id: Ideabb1c929ddd4307e66831cddb20e2feac2c6d9
2017-05-02 06:49:52 +00:00
Hugo Benichi
287730e764 NsdManager: add test coverage for discoverServices()
Test: added new tests
Bug: 37013369, 33298084
Change-Id: If6c1113ee1bd4690db90abd5a61c3e229c827aec
2017-05-02 15:26:33 +09:00
Hugo Benichi
3ec710f6f0 NsdManager: unit test coverage for servive registration
This patch adds test coverage for NsdManager#registerService() and
NsdManager#unregisterService(). This test shows a potential defect in
the api: if unregisterService() fails, the associated listener is always
unregistered from NsdManager. If the service initially registered is
still registered, this potentially make it impossible to unregister.

Test: added new unit test
Bug: 37013369, 33298084
Change-Id: Ia089b6d2f2a349907a8b29d9a3acd7f59e177887
2017-05-02 13:31:24 +09:00
Hugo Benichi
4801469256 Merge "NsdService: disentangle NativeDaemonConnector from ctor" am: fa97f11b20 am: 47748b754c am: 5d0bd13538
am: f659a6775f

Change-Id: Ie0a42ede086cc480830c91e770eaf250bcd2f711
2017-04-27 13:14:10 +00:00
Hugo Benichi
f659a6775f Merge "NsdService: disentangle NativeDaemonConnector from ctor" am: fa97f11b20 am: 47748b754c
am: 5d0bd13538

Change-Id: Ic8ddf92c7c64d4214a75bea6d6e5083f4612a76a
2017-04-27 13:06:59 +00:00
Hugo Benichi
6d70644998 NsdService: disentangle NativeDaemonConnector from ctor
This patch disentangles the creation of NativeDaemonConnector from the
creation of NsdService by introducing a wrapper type DaemonConnection.

This allows to mock this dependency in unit tests.

Test: enhanced previously introduced new tests.
Bug: 37013369, 33298084
Change-Id: I894b7cddfc509f86d0134d214c88c063b81b5e0a
2017-04-27 16:35:30 +09:00
Hugo Benichi
b1347c6287 Merge "NsdService: bootstrap unit tests" am: ec33961ae0 am: dd53c962b2 am: d29ce6ae8c
am: 9fc7343cfb

Change-Id: I018d6fbface4a9d4a568486dedd30d05e0ddd949
2017-04-27 06:01:38 +00:00
Hugo Benichi
9fc7343cfb Merge "NsdService: bootstrap unit tests" am: ec33961ae0 am: dd53c962b2
am: d29ce6ae8c

Change-Id: Iaf0679790e934baaaf48bcb04098aa18deca4d60
2017-04-27 05:49:47 +00:00
Hugo Benichi
ec33961ae0 Merge "NsdService: bootstrap unit tests" 2017-04-27 05:22:54 +00:00
Nathan Harold
9f9a2241e1 Merge "Hide IpSecManager, IpSecTransform, and IpSecAlgorithm" into oc-dev am: 35eb324bf1
am: 0d579f8794

Change-Id: Idf7ca8bc14ba2502ed35fbaa452f7eb49a66be78
2017-04-26 18:17:40 +00:00
Nathan Harold
0d579f8794 Merge "Hide IpSecManager, IpSecTransform, and IpSecAlgorithm" into oc-dev
am: 35eb324bf1

Change-Id: Iba429d1d96e28ccaf95d721b8b13cd107d4a0454
2017-04-26 18:10:04 +00:00
nharold
39d54ca4e3 Merge "Hide IpSecManager, IpSecTransform, and IpSecAlgorithm" am: 01e368f26d am: 939528045a am: 52dab83f7a
am: ee588f0304

Change-Id: Id67890a061c4e7aef91c7dea61e8706cfdd6bc6e
2017-04-26 17:52:39 +00:00
nharold
ee588f0304 Merge "Hide IpSecManager, IpSecTransform, and IpSecAlgorithm" am: 01e368f26d am: 939528045a
am: 52dab83f7a

Change-Id: I3bf240b35c3d509c4e016ffe20519c1bda5ab0b3
2017-04-26 17:38:58 +00:00
Nathan Harold
185f2ccd1c Hide IpSecManager, IpSecTransform, and IpSecAlgorithm
These classes, originally planned to be part of the
public API, are not ready for public consumption.
They are planned to be un-hidden in a future release.

Bug: 37681043
Test: make update-api and make
Change-Id: I8caccd3f8455341cb56a2256354eacbadedff047
2017-04-26 06:50:54 +00:00
Nathan Harold
7194bb9bf9 Hide IpSecManager, IpSecTransform, and IpSecAlgorithm
These classes, originally planned to be part of the
public API, are not ready for public consumption.
They are planned to be un-hidden in a future release.

Bug: 37681043
Test: make update-api and make
Merged-In: I8caccd3f8455341cb56a2256354eacbadedff047
Change-Id: I8caccd3f8455341cb56a2256354eacbadedff047
(cherry picked from commit e38565fc74ee19e27175782be3cf2f0dffefd3a6)
2017-04-25 16:53:50 -07:00