Commit Graph

2842 Commits

Author SHA1 Message Date
Felipe Leme
6670ab4480 DO NOT MERGE: Refactored NetworkStatsServiceTest to use Mockito instead of EasyMock.
Test: m -j32 FrameworksServicesTests && adb install -r -g ${ANDROID_PRODUCT_OUT}/data/app/FrameworksServicesTests/FrameworksServicesTests.apk && adb shell am instrument -e class "com.android.server.net.NetworkStatsServiceTest" -w "com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner"

BUG: 30943463

(cherry picked from commit de2a6f1b1d)

Change-Id: Ia9929295ab2396a7ebb133e65d157f98414e4dfa
2016-12-09 13:59:14 +09:00
Felipe Leme
b8a440f538 DO NOT MERGE: Use @Ignore to explicitly disable a @Test method.
BUG: 30839080
BUG: 31007021

(cherry picked from commit a4dc2a7129)

Change-Id: I35942e60493adebb22871541a34240368c691ee7
2016-12-09 13:59:10 +09:00
Felipe Leme
00a6e6c111 DO NOT MERGE: Fixed NetworkStatsServiceTest and converted it to JUnit4.
Most tests were failing because due to a null NetworkCapabilities.
Example:

1) testNetworkStatsWifi(com.android.server.net.NetworkStatsServiceTest)
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.net.NetworkCapabilities.hasCapability(int)' on a null object reference
	at
	com.android.server.net.NetworkStatsService.updateIfacesLocked(NetworkStatsService.java:983)

BUG: 30839080

(cherry picked from commit f96df4b298)

Change-Id: Ie09b2f43cf6ec745e404d5ec98bd0b072d211ea3
2016-12-09 13:59:04 +09:00
Jeremy Joslin
8c7be6114c DO NOT MERGE: VPN network stat accounting changes.
Properly account for VPN apps that make heavy use of the tun
interface. Prior to this change a VPN app could be incorrectly charged
for more data than it actually used if it sent more traffic through
the tun interface than the underlying interface.

This change excludes VPN app traffic on the tun interface from the
adjustment pool and doesn't redistribute traffic to the VPN app.
Instead all of the redistributed traffic is deducted from the VPN app
which effectively represents any overhead incurred by the VPN app.

BUG: 30557871

(cherry picked from commit 13dd0e99ba)

Change-Id: I06f01aa8fe5fdc06b2d36cfb9c68feb244c2e5de
2016-12-09 13:42:29 +09:00
Hugo Benichi
8f201294fe DO NOT MERGE: ConnectivityThread: use lazy holder idiom
This patch changes the way that the ConnectivityThread is lazily
instantiated by using the "lazy initialization holder class idiom".

The first code point that tries to obtain a reference to the unique
ConnectivityThread instance will trigger the creation of the Singleton
class, which will guarantee a thread-safe initialization of the static
INSTANCE field inside Singleton according to the language specs.

This is the Item #71 of Effective Java.

The unique static instance of ConnectivityThread is not stored directly
inside ConnectivityThread class but is stored in a static nested class.
This is to avoid triggering the creation of that unique instance when
Zygote does class preloading at phone startup. Otherwise this would lead
to Zygote creating a new OS thread during preloading, which is a fatal
error.

Test: frameworks-wifi tests pass
Bug: 26749700
Bug: 28537383
Bug: 32130437

(cherry picked from commit 3ab84b087a)

Change-Id: If13b363889a8e9396273a90c3d9f9421a48aecbc
2016-12-09 13:42:26 +09:00
Hugo Benichi
301b09738a DO NOT MERGE: ConnectivityManager: use ConnectivityThread looper
This patch removes the static singleton looper used by
ConnectivityManager and instead uses the common ConnectivityThread.

This allows to removes the static atomic counter used to track
the number of registered NetworkCallback in ConnectivityManager, because
the looper is not turned off anymore when no callbacks are registered.

Also an overloaded version of sendRequestForNetwork is added taking as a
new parameter a Handler. This will allow to overload various callback
and request related API calls with user provided Handlers.

Test: ConnectivityServiceTest passes
Bug: 26749700
Bug: 28537383
Bug: 32130437

(cherry picked from commit 3b41f05d68)

Change-Id: If956addbf8e7b11b36a4b966de7fca00e8f362c1
2016-12-09 13:42:24 +09:00
Hugo Benichi
56260ed9cb DO NOT MERGE: ConnectivityManager: a simpler CallbackHandler
This patch simplifies CallbackHandler in the following way:
  - CallbackHandler directly uses the static references to
    sNetworkCallback and sCallbackRefCount. This allows to remove
    instance fields in CallbackHandler.
  - CallbackHandler does not have a reference to ConnectivityManager
    anymore
  - CallbackHandler.getObject() is now generic in a type-safe way.

Test: ConnectivityServiceTest passes
Bug: 28537383
Bug: 32130437

(cherry picked from commit 0b42baf68a)

Change-Id: I1b5fe2a361b5f623a8310ae698497c83d72f3034
2016-12-09 13:42:20 +09:00
Jeremy Klein
fb63d5a4ef DO NOT MERGE: Add a null check for the OnStartTetheringCallback.
This avoids a NullPointerException when trying to call the callback
and gives a more readable error message.

(cherry picked from commit 35e99ea8ef)

Change-Id: Ia419ff68ef10f308f9e44be47420e27099ee6070
2016-12-09 13:42:02 +09:00
Treehugger Robot
6b0570513e Merge changes from topic 'framework-net-aosp'
* changes:
  DO NOT MERGE: IpConnectivityMetrics: rate limit ApfProgramEvents
  DO NOT MERGE: TokenBucket for rate-limiting and throttling
  DO NOT MERGE: IpConnectivityMetrics reads buffer size in settings
  DO NOT MERGE: CaptivePortalLogin: set mixed content policy to compatibility.
  DO NOT MERGE: Add IP conn metrics to dumpsys and bug reports
  DO NOT MERGE: IpConnectivity metrics: add version number
2016-12-09 03:19:13 +00:00
Hugo Benichi
6d442d82d0 DO NOT MERGE: IpConnectivityMetrics: rate limit ApfProgramEvents
This patch uses the previously introduced TokenBucket to rate limit
ApfProgramEvents, still allowing for burst of ApfProgramEvents when a
new interface is set up (due to ipv4 provisioning, multicast lock, ipv6 RAs
triggering new APF program events in short amounts of time).

Test: new test in IpConnectivityMetricsTest
Bug: 1550402

(cherry picked from commit e3f7299ce2)

Change-Id: Idb640dec13ba64180985544b9709a586af66eb6e
2016-12-09 11:21:31 +09:00
Hugo Benichi
834405cbe4 DO NOT MERGE: IpConnectivityMetrics reads buffer size in settings
Test: IpConnectivityMetricsTest passes. Also manually changed the new
setting and verified the buffer size is as expected after flushing the
buffer.
Bug: 32198637

(cherry picked from commit 6d8c1dfe4b)

Change-Id: Iefbeac3a688b260fb3f92dfe0bfd9db28e26749d
2016-12-09 11:21:26 +09:00
Hugo Benichi
8ce412614a DO NOT MERGE: IpConnectivity metrics: add version number
This patch adds a version field to ipconnectivity.proto and populates it
to 2, which is the logical version number for NYC-MR2.

Test: IpConnectivity{EventBuilder,Metrics}Test pass
Bug: 32127906

(cherry picked from commit f04b01f0a0)

Change-Id: If8f167c0dc4c1abe0e235e2adfd131168a4ddc52
2016-12-09 11:21:11 +09:00
Etan Cohen
3fb372fe9f DO NOT MERGE: [CS] Remove timeout event after first available
Guarantees that timeouts are only delivered if a network never
becomes available. Once a network is available the timeout is
canceled.

Bug: 31402633
Test: all timeout related unit tests pass (new one added)

(cherry picked from commit 5eba9d7061)

Change-Id: I7cd3086544c881915fc6dbf14b87a24ab0cd8748
2016-12-08 17:13:37 +09:00
Lorenzo Colitti
cf8c8d55f8 DO NOT MERGE: Move the connectivity tests to frameworks/base/tests/net.
This will give us a good place to put all the networking tests.

Fix: 31479480
Test: adb  shell am instrument -w -e notClass com.android.server.connectivity.tethering.TetherInterfaceStateMachineTest 'com.android.frameworks.tests.net/android.support.test.runner.AndroidJUnitRunner'  # PASS

(cherry picked from commit 5a7c486d70)

Change-Id: I993eeaa5dec001c39389023f355f506129b356e7
2016-12-08 17:13:35 +09:00
Lorenzo Colitti
834805275a DO NOT MERGE: De-guava BroadcastInterceptingContext and move it to testutils.
Removing the static dependency on guava reduces test compile time
by about 20 seconds on a Z840, thus substantially speeding up the
compile/test cycle.

Make FutureIntent public instead of package-private because it is
used directly by NetworkPolicyManagementServiceTest, which as of
this CL is now in a different package.

(cherry picked from commit 6a64dd2178)

Test: runtest frameworks-services -c com.android.server.ConnectivityServiceTest  # PASS
Test: runtest frameworks-services -c com.android.server.NetworkPolicyManagerServiceTest  # PASS
Test: runtest frameworks-services -c com.android.server.net.NetworkStatsServiceTest  # PASS
Test: runtest frameworks-services -c com.android.server.NetworkManagementServiceTest  # Already failing.
Bug: 31479480
Change-Id: Ifab32c9214e9caab71dbf93b3d3ca88df6f49636
2016-12-08 17:13:35 +09:00
Lorenzo Colitti
4166a1fcfa DO NOT MERGE: Move FakeSettingsProvider to a common location.
(cherry picked from commit 4163f9ca8f)

Test: runtest frameworks-util -c com.android.internal.util.test.FakeSettingsProviderTest
Test: runtest frameworks-services -c com.android.server.ConnectivityServiceTest
Test: runtest frameworks-services -c com.android.server.retaildemo.PreloadAppsInstallerTest
Test: runtest frameworks-services -c com.android.server.retaildemo.RetailDemoModeServiceTest
Bug: 31479480
Change-Id: I8d4d4de2937012dd33924f53e68f96241a9b2b4f
2016-12-08 17:13:34 +09:00
Hugo Benichi
64d0a0deab DO NOT MERGE: ConnectivityServiceTest: mark flaky test as such
This patch extracts into its own independent test a test sub-block looking
for a race condition when not waiting on handlers to become idle:
there is no way to prevent the race from not happening when looking for
it this way. This makes the test flakky.

This new independent test is tagged with @FlakkyTest(tolerance = 3).

Test: ConnectivityServiceTest passes, with higher probability.
Bug: 31479480

(cherry picked from commit 144810b6cf)

Change-Id: I3c702bd981ed80ed606be0fb52d61eb3d7195a6f
2016-12-08 17:13:34 +09:00
Calvin On
a3cbcca3cc DO NOT MERGE: Add option to skip and avoid captive portals.
Test: ConnectivityServiceTest updated with test cases.
Test: Manually tested against att-wifi in B42.
Bug: 30222699

(cherry picked from commit dada145a85)

Change-Id: I90c0f97fe0e41de4059bceae7b56ab3a70145696
2016-12-08 17:13:33 +09:00
Erik Kline
5791c5f681 DO NOT MERGE: Support timeouts for requestNetwork() invocations.
(cherry-pick of 0b7a74842b)
(cherry picked from commit 155a59aa63)

Bug: 21414325
Change-Id: I1a58823a372154589f972b98c4c428eab0e0523e
2016-12-08 17:13:01 +09:00
Pierre Imai
fb3178adfc DO NOT MERGE: Silence the obnoxious MTU 0 error message that occur when no MTU is
specified for a given network.

Bug: 10705136

(cherry picked from commit 07c53a35ae)

Change-Id: I89e2fdfbbfa981d435a2974422d9d9c009872d76
2016-12-08 16:49:22 +09:00
Etan Cohen
4ddc6321ef Merge "[NAN-AWARE] Rename NAN to Aware"
am: 6c75254555

Change-Id: I2e788e19a11f2709f2e542dbdc4b58433a3574bf
2016-11-06 03:13:31 +00:00
Etan Cohen
6c75254555 Merge "[NAN-AWARE] Rename NAN to Aware" 2016-11-06 03:05:40 +00:00
Etan Cohen
7e93db5bda [NAN-AWARE] Rename NAN to Aware
~Rename only (and any reformatting needed to pass lint) - no
functional changes!

Remove android.net.wifi.nan.STATE_CHANGED from manifest:
redundant/remnant of an older configuration.

(cherry-pick of commit a0edbf0ac8)

Bug: 32263750
Test: All unit tests and integration (sl4a) tests pass.
Merged-In: Ie4ff675fa61041e8fcf6a9bf9900ea835d0a7614
Change-Id: I4206d2fd722dc7dec9df4aee5c818101d7f9dccc
2016-11-05 09:41:38 -07:00
Michal Karpinski
bca2d211f6 Extending DNS event reporting
This adds hostname, array of addresses, total count of IP addresses
and uid to the existing pipeline.
Currently ignores the new data it receives, further work will be
done in the subsequent CLs.

Test: for now just the benchmarking, in the future unit and CTS

Bug: 29748723
Change-Id: Ice7db208282934e74f0e1808ffbae96d476c4216
(cherry picked from commit 58a5c98b40)
2016-10-27 16:39:21 +00:00
Christopher Wiley
d2b306dee1 Merge "Add unit tests for Tethering.isTetherProvisioningRequired"
am: 836ffa6e1c

Change-Id: I1dab386e3891c01a2917c32847d2aecdbfa10102
2016-10-25 18:23:02 +00:00
Christopher Wiley
fcc0d9fd8b Add unit tests for Tethering.isTetherProvisioningRequired
Check that we tolerate various dependencies not being available.

Bug: 31946071
Test: These are tests

Change-Id: Ic0a9cd6f255ba9ff4c774dee640df1a0bdf8dc39
2016-10-24 17:07:05 -07:00
Erik Kline
18cc602880 Refactor "avoid bad wifi" logic into a utility class am: 95ecfee674 am: 567fc7861d
am: 23d83b031f

Change-Id: I7db61e54c80ec836d00bf4ae087137bb296c30f1
2016-10-06 20:44:56 +00:00
Erik Kline
23d83b031f Refactor "avoid bad wifi" logic into a utility class am: 95ecfee674
am: 567fc7861d

Change-Id: Id670d13b99ab6935b67335e19d2389e5b4f61111
2016-10-06 20:16:57 +00:00
Christopher Wiley
30a5755afc Notify NetworkPolicyManagerService on tethering changes am: cfd438e0fd
am: deed245740

Change-Id: Ic1b99f8bbeffde72dd93d4879aa25954d0d98554
2016-10-06 20:08:44 +00:00
Christopher Wiley
deed245740 Notify NetworkPolicyManagerService on tethering changes
am: cfd438e0fd

Change-Id: I43b25305c730966da83acdaccb127c27be0e2332
2016-10-06 19:57:15 +00:00
Erik Kline
567fc7861d Refactor "avoid bad wifi" logic into a utility class
am: 95ecfee674

Change-Id: I4a6ad3791ac551b0d64b37dd4e2afef1e8e8ee10
2016-10-04 07:47:52 +00:00
Erik Kline
95ecfee674 Refactor "avoid bad wifi" logic into a utility class
Additionally, add this utility class to IpManager for compatibility
verification.  A follow-on CL will make use of IpManager's local
AvoidBadWifiTracker.

Bug: 31827713
Change-Id: If8c56c3f8076d6a5157ea180e361bbdadc2bc1dd
2016-10-04 15:07:42 +09:00
Christopher Wiley
cfd438e0fd Notify NetworkPolicyManagerService on tethering changes
(cherry-pick of d73faf07606d40d3915d22a72fa14f7ba956d459)

No longer do this in ConnectivityService#tether/untether.
Instead, have Tethering do it when an interface is actually
tethered.

Bug: 31405407
Test: Toggling hotspot now disables data saver

Change-Id: I9910a2e488c30c92d45f817c8f5df0fac5510de6
2016-09-30 10:33:19 -07:00
Hugo Benichi
9fc1b97ca5 New Settings symbols for captive portal detection am: e8b7aea6bb
am: 4710228e81

Change-Id: I6e965696ed03b0eb4a49db3b21ad6a382ba1d081
2016-09-29 01:23:59 +00:00
Hugo Benichi
82d7d36a22 Captive portal detection uses 3rd fallback probe am: 6767b7a40a
am: 580194d336

Change-Id: Iec8ccdbcd433d8b2f5538d7b4bed5c945b5b688a
2016-09-29 01:22:01 +00:00
Hugo Benichi
4710228e81 New Settings symbols for captive portal detection
am: e8b7aea6bb

Change-Id: Id8c19f16c50b22034278c00b55c5431d892f8a95
2016-09-29 01:15:17 +00:00
Hugo Benichi
580194d336 Captive portal detection uses 3rd fallback probe
am: 6767b7a40a

Change-Id: I15607fbfae9dc127b72b6f299b69d6b648117338
2016-09-29 01:13:59 +00:00
Hugo Benichi
e8b7aea6bb New Settings symbols for captive portal detection
This patch defines new Settings symbols for
  - setting the probe urls for captive portal detection.
  - setting which User-Agent to use for captive portal detection.

The existing default values for these settings are not changed, i.e:
  - HTTP and HTTPS probes urls are unchanged.
  - the fallback probe is not used.
  - User-Agent is empty by default.

Bug: 29367974
Change-Id: I6e4b3b172e56b8b67fffa4b51f776d68d5851f25
2016-09-28 23:13:25 +09:00
Hugo Benichi
6767b7a40a Captive portal detection uses 3rd fallback probe
This patch adds the possitibility to send a 3rd fallback validation
probe in sendParallelHttpProbes when neither the 1st http probe nor the
https probe came back with a conclusive answer.

This 3rd probe is only used for trying again captive portal detection
and does not return success, so that network validation always fails if
the https probe fails.

In addition, the url reveals a captive portal is now sent to the
CaptivePortalLoginActivity so that all three probes can use different
urls.

Bug: 29367974

Change-Id: I7385fde1aa1316d94aac350af0e956cb193aa4ee
2016-09-28 23:12:31 +09:00
Christopher Wiley
15d636e8d2 Merge "Notify NetworkPolicyManagerService on tethering changes" am: 4062bec04e am: 8d7e3b0205
am: 8402cf5078

Change-Id: I4d1081c832c1d3bff9a0946c670929eca4f0f695
2016-09-27 14:18:46 +00:00
Christopher Wiley
8402cf5078 Merge "Notify NetworkPolicyManagerService on tethering changes" am: 4062bec04e
am: 8d7e3b0205

Change-Id: I9595856421a848a570f4894fa55523a72a7fec44
2016-09-27 13:32:06 +00:00
Michal Karpinski
7a8d38a62e Fix naming of the service in NetdEventListenerServiceTest
Bug: 29748723
Change-Id: I285cb77fba824036df80a9ed2560ee95d1d1919c
(cherry picked from commit b4e1df3240)
2016-09-26 10:43:56 +00:00
Hugo Benichi
e794d6fbdf Merge "IpConnectivityLog uses new metrics service" into nyc-mr1-dev am: fa21c8ce1c
am: bb48787720

Change-Id: Ib9e1bc6873ad1fb045b57eb54c4a164148d68f14
2016-09-23 06:03:59 +00:00
Hugo Benichi
3cabd2665c resolve merge conflicts of 6d40db6 to nyc-mr1-dev-plus-aosp
Change-Id: I82865b2847c584f8a1d728ef76113e3969f222ca
2016-09-23 14:48:01 +09:00
Hugo Benichi
bb48787720 Merge "IpConnectivityLog uses new metrics service" into nyc-mr1-dev
am: fa21c8ce1c

Change-Id: I7fae7760d5ec872a0a989ca3964419d3839694ad
2016-09-23 04:48:51 +00:00
Hugo Benichi
6d40db67c3 IpConnectivityLog uses new metrics service
am: a6c8879b49

Change-Id: I1e3b611eeec448e333e83cb8d630f0e9906b7f14
2016-09-23 04:48:49 +00:00
Hugo Benichi
fa21c8ce1c Merge "IpConnectivityLog uses new metrics service" into nyc-mr1-dev 2016-09-23 04:43:23 +00:00
Lorenzo Colitti
45a6252d6d Merge "Restrict access to background networks to CHANGE_NETWORK_STATE." into nyc-mr1-dev am: 3972d910f1
am: f96a37fb8d

Change-Id: I7d47b6c065f45edeecf3fd5df133545dad561d0f
2016-09-23 04:02:09 +00:00
Lorenzo Colitti
494c218bff Restrict access to background networks to CHANGE_NETWORK_STATE. am: b8d9f52adb
am: 9410bde219

Change-Id: Ie4179344aa12e38d2e2a5fab43e028ca0c97150d
2016-09-23 04:01:07 +00:00
Lorenzo Colitti
f96a37fb8d Merge "Restrict access to background networks to CHANGE_NETWORK_STATE." into nyc-mr1-dev
am: 3972d910f1

Change-Id: I8fa53ac5143bd5df0177a11e5961acef63072007
2016-09-23 03:57:34 +00:00