Commit Graph

2881 Commits

Author SHA1 Message Date
Hugo Benichi
858eef0c7d DO NOT MERGE: ConnectivityServiceTest: fix testAvoidBadWifiSettings am: b1bddc92c5 -s ours
am: a30ae5542b  -s ours

Change-Id: If1fe794f87060443d721f0f269f519046a9ee321
2016-12-09 10:00:41 +00:00
Hugo Benichi
11051ef7f8 DO NOT MERGE: Fix ConnectivityServiceTest testRequestBenchmark am: 8436dae4c3 -s ours
am: 0bef352535  -s ours

Change-Id: I92e3730002c11f3c2d5ea9c324f61237190f44bc
2016-12-09 09:59:49 +00:00
Felipe Leme
2672fd0196 DO NOT MERGE: Refactored NetworkStatsServiceTest to use Mockito instead of EasyMock. am: 6670ab4480 -s ours
am: fbbaf25665  -s ours

Change-Id: I66000b3cd40a8494ad144610436f6ee953821a06
2016-12-09 09:57:16 +00:00
Felipe Leme
38dd9dec90 DO NOT MERGE: Use @Ignore to explicitly disable a @Test method. am: b8a440f538 -s ours
am: b296948b3b  -s ours

Change-Id: I43b77614b0ccdd573cf8b29b08ef518bad617aff
2016-12-09 09:55:47 +00:00
Felipe Leme
0866b93abf DO NOT MERGE: Fixed NetworkStatsServiceTest and converted it to JUnit4. am: 00a6e6c111 -s ours
am: 82393f7b98  -s ours

Change-Id: I175601094ae486700c8a6886470abb3147b6ef4e
2016-12-09 09:54:55 +00:00
Jeremy Joslin
652c3e59e9 DO NOT MERGE: VPN network stat accounting changes. am: 8c7be6114c -s ours
am: 12bb3f057b  -s ours

Change-Id: Id9d26bf1b9512a85cd9b6a3253b86b77a6f62e77
2016-12-09 09:54:07 +00:00
Hugo Benichi
fde28b4f2b DO NOT MERGE: ConnectivityThread: use lazy holder idiom am: 8f201294fe -s ours
am: f6cb43ae32  -s ours

Change-Id: I08a03dd249d30bc474a5d16472883737d12fec37
2016-12-09 09:53:16 +00:00
Hugo Benichi
8358a5fbdf DO NOT MERGE: ConnectivityManager: use ConnectivityThread looper am: 301b09738a -s ours
am: 7337239702  -s ours

Change-Id: Ida0d76b540e800db215569717a1c5d26e0f583b0
2016-12-09 09:52:26 +00:00
Hugo Benichi
7135d5e6f2 DO NOT MERGE: ConnectivityManager: a simpler CallbackHandler am: 56260ed9cb -s ours
am: ef148edaa2  -s ours

Change-Id: Ie8ebf41835e62b64ceb22e552208c77482d96c73
2016-12-09 09:50:57 +00:00
Jeremy Klein
aa7506310c DO NOT MERGE: Add a null check for the OnStartTetheringCallback. am: fb63d5a4ef -s ours
am: 3cd1ae2261  -s ours

Change-Id: I3c471a8971c21cdbf1ebf7e1302524b038b20375
2016-12-09 09:48:50 +00:00
Hugo Benichi
b1bddc92c5 DO NOT MERGE: ConnectivityServiceTest: fix testAvoidBadWifiSettings
This patch introduces an assertEventuallyThat helper function in
ConnectivityServiceTest which given a boolean function retries until the
function returns true or until a maximum retry time is reached.

This function is used to fix flakyness of testAvoidBadWifiSetting where
the Message posted by reevaluate() could reach the Handler's
MessageQueue after waitForIdle takes effect, resulting in the test to
fail.

Instead of fixing the flakyness by introdcing hard sleep times,
assertEventuallyThat is used to reduce the overall test time.

With this change the test has been observed to pass with 100% success
rate over 50000 invocations.

Test: $ runtest frameworks-net
Bug: 32561414

(cherry picked from commit b54c8cffa8)

Change-Id: If41a24989d5f65aeb439f68741f511b5eb53b18d
2016-12-09 13:59:19 +09:00
Hugo Benichi
8436dae4c3 DO NOT MERGE: Fix ConnectivityServiceTest testRequestBenchmark
This patch fixes flakyness of testRequestBenchmark by adjusting time
limit for callback registration from 100ms to 180ms, and time limits for
onAvailable and onLost triggers from 30ms to 40ms.

With these timeouts the test succeeds 100% over 5000 iterations.

When using 150ms for registration timeout, running the test 5000 times
fails 2 times.

When using 30ms for onLost timeout, running the test 5000 times fails
1 times.

In addition, this patch also cleans testRequestBenchmark and uses the
more stable SystemClock.elapsedRealtime() for duration measurements.

Test: $ runtest frameworks-net
Bug: 32561414

(cherry picked from commit 766e564647)

Change-Id: I196ab9ef7f5abe456a783eed65db09279d2ecb8c
2016-12-09 13:59:18 +09:00
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
Hugo Benichi
72f8bb8b7f Merge changes from topic 'framework-net-aosp' am: 6b0570513e
am: 5910f412bd

Change-Id: I919fd8d8075c89aa9eb42b505017c075f61824ff
2016-12-09 03:47:48 +00:00
Hugo Benichi
c19960bf85 DO NOT MERGE: IpConnectivityMetrics: rate limit ApfProgramEvents am: 6d442d82d0 -s ours
am: 6765bc08d0  -s ours

Change-Id: I9e3ca112a654018d9d0b72ba1b0963e7fb678cf0
2016-12-09 03:46:50 +00:00
Hugo Benichi
7e64d17a53 DO NOT MERGE: IpConnectivityMetrics reads buffer size in settings am: 834405cbe4 -s ours
am: f3b4c26453  -s ours

Change-Id: I7f2eee043702be1a8878851793b9b17bdb89766b
2016-12-09 03:45:08 +00:00
Hugo Benichi
6a77e74a49 DO NOT MERGE: IpConnectivity metrics: add version number am: 8ce412614a -s ours
am: 0e67ef7d3f  -s ours

Change-Id: I05ffe76ca4f266bd341fc298cbc03da62991e4bb
2016-12-09 03:41:57 +00: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
98c799e134 DO NOT MERGE: [CS] Remove timeout event after first available am: 3fb372fe9f -s ours
am: a8b73b23d6  -s ours

Change-Id: I61fbbf03bc011ae0b6b0e011bfb69dea33195c79
2016-12-08 11:07:46 +00:00
Lorenzo Colitti
60584ca47e DO NOT MERGE: Move the connectivity tests to frameworks/base/tests/net. am: cf8c8d55f8 -s ours
am: d1e22a3f07  -s ours

Change-Id: I92f0f18ed7ee196f1cdb1369393ff7c4e2c800fc
2016-12-08 11:04:38 +00:00
Lorenzo Colitti
f6eae67d18 DO NOT MERGE: De-guava BroadcastInterceptingContext and move it to testutils. am: 834805275a -s ours
am: bcb7e32954  -s ours

Change-Id: I377b66283b29bb97e02ec796352bc3a5dbea1454
2016-12-08 11:03:45 +00:00
Lorenzo Colitti
ab28abf325 DO NOT MERGE: Move FakeSettingsProvider to a common location. am: 4166a1fcfa -s ours
am: a84ede299c  -s ours

Change-Id: Ia6f433944c63245436199b8b9b1a022794ab939e
2016-12-08 11:02:57 +00:00
Hugo Benichi
f0c14184c2 DO NOT MERGE: ConnectivityServiceTest: mark flaky test as such am: 64d0a0deab -s ours
am: e47b0886ad  -s ours

Change-Id: I803b51cae7b20502d11701cb99ab3816d6995555
2016-12-08 11:02:09 +00:00
Calvin On
ad526b446c DO NOT MERGE: Add option to skip and avoid captive portals. am: a3cbcca3cc -s ours
am: 8006bd5c66  -s ours

Change-Id: I9984984de7f72e23fbc11e972ff851a1d2adc6c1
2016-12-08 11:00:46 +00:00
Erik Kline
b87f698fc6 DO NOT MERGE: Support timeouts for requestNetwork() invocations. am: 5791c5f681 -s ours
am: eb6be2c826  -s ours

Change-Id: Id91b2267ffcd7c66a1be8e01761ffb1d943082d3
2016-12-08 10:56:13 +00:00
Pierre Imai
2e3f5c5d6b DO NOT MERGE: Silence the obnoxious MTU 0 error message that occur when no MTU is specified for a given network. am: fb3178adfc -s ours
am: 8a73b2896d  -s ours

Change-Id: Ic529525e6671da1b6a85890c8eb40238b07da2b3
2016-12-08 10:54:56 +00: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
Baligh Uddin
2ff98c432c Merge remote-tracking branch 'goog/cw-f-dev' into fix_merger
Bug: 32849428

* goog/cw-f-dev: (98 commits)
  Revert "Catch KeyStoreException for setting profile lock"
  Fix createConfirmDeviceCredentialIntent for wear for CTS.
  Fix default dialog background colour for watch devices.
  Catch KeyStoreException for setting profile lock
  Add cross-links between FINE and COARSE location permissions. bug: 25371600
  Fixed a bug with the emergency affordance in multi user
  Zygote: Additional whitelists for runtime overlay / other static resources.
  Import translations. DO NOT MERGE
  Import translations. DO NOT MERGE
  Import translations. DO NOT MERGE
  Import translations. DO NOT MERGE
  Import translations. DO NOT MERGE
  Import translations. DO NOT MERGE
  Import translations. DO NOT MERGE
  Zygote : Block SIGCHLD during fork.
  colors: add missing accent_material_{700,50} resources.
  Import translations. DO NOT MERGE
  Import translations. DO NOT MERGE
  Zygote : Block SIGCHLD during fork.
  DO NOT MERGE ANYWHERE Revert "DO NOT MERGE ANYWHERE libhwui: make setSurface asynchronous"
  ...

Change-Id: I63468da5bfa21ed9ac5985bbdbf3a61d4c389aa0
2016-11-22 17:19:45 -08:00
Hugo Benichi
05c86a58be DO NOT MERGE ANYWHERE Add CONNECTIVITY_USE_RESTRICTED_NETWORKS permission am: 849682f5a0 -s ours am: d55ff11c4b -s ours am: 0a159e0967 -s ours am: 24c196f55f -s ours
am: ec451e5173  -s ours

Change-Id: I5bb53669285c0878905f8a2a70ff2dbe06c09ab2
2016-11-10 18:42:57 +00:00
Hugo Benichi
ec451e5173 DO NOT MERGE ANYWHERE Add CONNECTIVITY_USE_RESTRICTED_NETWORKS permission am: 849682f5a0 -s ours am: d55ff11c4b -s ours am: 0a159e0967 -s ours
am: 24c196f55f  -s ours

Change-Id: I42aabc35fa30e242125015eac1b7d32790cc4528
2016-11-10 18:36:30 +00:00
Hugo Benichi
24c196f55f DO NOT MERGE ANYWHERE Add CONNECTIVITY_USE_RESTRICTED_NETWORKS permission am: 849682f5a0 -s ours am: d55ff11c4b -s ours
am: 0a159e0967  -s ours

Change-Id: Ibe074076d22a736394a01d27aa9e1c7ed73458b2
2016-11-10 18:23:58 +00:00
Hugo Benichi
0a159e0967 DO NOT MERGE ANYWHERE Add CONNECTIVITY_USE_RESTRICTED_NETWORKS permission am: 849682f5a0 -s ours
am: d55ff11c4b  -s ours

Change-Id: If1903ace2a31d8ccf3c66916211a07ac342fc360
2016-11-10 18:11:02 +00:00
Hugo Benichi
d55ff11c4b DO NOT MERGE ANYWHERE Add CONNECTIVITY_USE_RESTRICTED_NETWORKS permission
am: 849682f5a0  -s ours

Change-Id: I2ba3b591df623298f41e92e6f0d067a6fcf30533
2016-11-10 18:04:26 +00:00