Commit Graph

169 Commits

Author SHA1 Message Date
Stephen Chen
9369e9d105 Implement metered tracking for NetworkStats summary queries.
Dependent on ag/1550196 where API is defined.

Bug: 31015360
Bug: 26545374
Test: runtest --path
frameworks/base/core/tests/coretests/src/android/net/NetworkStatsTest.java,
other test classes.

Change-Id: I968b9e3352d7880e3fc438f12de628a2da057e0a
2016-11-04 09:55:21 -07:00
Lorenzo Colitti
5a7c486d70 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
Change-Id: I4b389f7f4e33a996885b38670f585e58ca66f777
2016-10-28 17:12:36 +09:00
Lorenzo Colitti
6a64dd2178 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.

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-10-28 17:12:36 +09:00
Lorenzo Colitti
4163f9ca8f Move FakeSettingsProvider to a common location.
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: I82a1a1a7219cf1385092b84d85eddf9dda90c685
2016-10-28 17:12:31 +09:00
Glen Kuhne
9318e37e71 Merge "Move ipconnectivity.proto to services-proto.jar" 2016-10-27 16:27:27 +00:00
Hugo Benichi
144810b6cf 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
Change-Id: Ic0e2ffbe669f2ea8cc62e8a0d4763703368db019
2016-10-27 09:38:54 +09:00
Glen Kuhne
1f0cb8f6ab Move ipconnectivity.proto to services-proto.jar
Moved ipconnectivity.proto from services.core.jar to
framework-protos.jar.
Replaced 'mergeFrom' MessageNano base class calls, with 'parseFrom'
IpConnectivityLog calls.

This solves an issue where the services.jar would conflict with
duplicate nano proto base class definitions in other .jars
(wifi-service.jar).

Bug: 32261442
Test: Existing unit tests pass
Change-Id: I49100935fcae2e85e12eaa7f3462864f3a340b97
2016-10-26 10:18:46 -07:00
TreeHugger Robot
70544b339b Merge changes I1a544a8d,Ie78d3fb0
* changes:
  IpConnectivityMetrics: rate limit ApfProgramEvents
  IpConnectivityMetrics reads buffer size in settings
2016-10-24 14:45:46 +00:00
Hugo Benichi
e3f7299ce2 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
Change-Id: I1a544a8d62e6b02f0ed0088ab76c4bad338d2f44
2016-10-24 21:54:37 +09:00
Hugo Benichi
6d8c1dfe4b 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
Change-Id: Ie78d3fb03cea7883585549dac4f2063f0a8d9f4b
2016-10-24 13:52:41 +09:00
Hugo Benichi
dbac14ba69 Merge "IpConnectivity metrics: add version number" 2016-10-21 04:35:52 +00:00
Calvin On
dada145a85 Add option to skip and avoid captive portals.
Test: ConnectivityServiceTest updated with test cases.
Test: Manually tested against att-wifi in B42.
Bug: 30222699
Change-Id: Ibe63942da04748ab0406e24e0f44be31d47710a0
2016-10-20 00:51:39 -07:00
TreeHugger Robot
4320474eb2 Merge "Show notification for always-on app VPN" 2016-10-17 15:33:59 +00:00
Hugo Benichi
f04b01f0a0 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
Change-Id: I1439f012b7f9b4211d5d5429c274ad03d2ac9d6b
2016-10-17 16:24:19 +09:00
Michal Karpinski
58a5c98b40 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
2016-10-10 16:49:07 +01:00
Erik Kline
d44ea3ce1e Refactor "avoid bad wifi" logic into a utility class am: 95ecfee674 am: 567fc7861d am: 23d83b031f
am: 18cc602880

Change-Id: Ie3d058d6c9da43763d10b0a2bc96171d07673e9d
2016-10-07 01:03:58 +00: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
Tony Mak
9ca892f698 Show notification for always-on app VPN
This is the same notification as the one shown during legacy lockdown
mode, sans the 'reset' button.

The notification is only shown during times when VPN has not yet
established or has failed, for example during boot or after a crash.

Bug: 29123115
Change-Id: If0e2eb4f8fb220a21d6d462363a05869e27c7b6e
2016-10-06 19:58:04 +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
Hugo Benichi
8b5dcafc44 Captive portal detection uses 3rd fallback probe am: 6767b7a40a am: 580194d336
am: 82d7d36a22

Change-Id: I221cf47aa43105d4094ec724f8d6f4f6c98d0757
2016-09-29 06:07:53 +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
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
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
Michal Karpinski
b4e1df3240 Fix naming of the service in NetdEventListenerServiceTest
Bug: 29748723
Change-Id: I285cb77fba824036df80a9ed2560ee95d1d1919c
2016-09-26 09:20:25 +01:00
Hugo Benichi
344acf4541 resolve merge conflicts of 6d40db6 to nyc-mr1-dev-plus-aosp
am: 3cabd2665c

Change-Id: I4bfd7a9bc5ef4c3c5a30bed63b92eaef90b1a30e
2016-09-25 20:18:16 +00:00
Hugo Benichi
2741f10188 Add ipconnectivity.proto to services jar am: a54812907b am: 446a3847b4
am: c0c25c8a6e

Change-Id: Id194acbb25c8f3dd8fdf03af67912f7a0f0f770f
2016-09-24 02:11:20 +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
c0c25c8a6e Add ipconnectivity.proto to services jar am: a54812907b
am: 446a3847b4

Change-Id: I1fc947f98715a7a352753d85cd4ef4970be2b027
2016-09-23 00:18:31 +00:00
Hugo Benichi
a6c8879b49 IpConnectivityLog uses new metrics service
This patch connects existing IpConnectivityLog to the new
IpConnectivityMetrics service:
  - IpConnectivityLog is now an independent class that pushes events
    directly to the new IpConnectivityMetrics service.
  - DnsEventListenerService is moved from MetricsLoggerService to
    IpConnectivityMetrics.
  - this patch also features end to end tests from IpConnectivityLog to
    IpConnectivityMetrics dumpsys output.

Bug: 31254800
Change-Id: I4fe4a209eedde2814d5f13c574a1a0d854bd05c9
2016-09-22 23:08:37 +09:00
Hugo Benichi
a54812907b Add ipconnectivity.proto to services jar
This patch moves ipconnectivity.proto and companion serialization
classes from /vendor/google/app/ConnectivityMetrics into the framework
services jar.

This will allow to implement a dumpsys interface for IpConnectivity
metrics events defined in android.net.metrics that output metrics as
a serialized proto.

Bug: 31254800
Change-Id: Ia4449103fd7222c9d899352fea2dce47a790a49c
2016-09-22 22:21:41 +09:00
Michal Karpinski
fbf1d8638c Rename DnsEventListenerServiceTest to NetdEventListenerServiceTest
Change-Id: I67e645306444938a4675e91a9db5d716c0bd4881
(cherry picked from commit d82fccd368ca605c8efc21b198e667fd30c4182e)
2016-09-21 14:33:56 +00:00
Michal Karpinski
66d4a5baf2 Rename DnsEventListenerServiceTest to NetdEventListenerServiceTest
Change-Id: I67e645306444938a4675e91a9db5d716c0bd4881
2016-09-21 18:48:57 +09:00
Lorenzo Colitti
e414d2ef36 Support "don't ask again" in the avoid bad wifi dialog. am: c65750c8a0 am: 74cb76ff80 am: 63275aba54
am: ec500d94b0

Change-Id: I60ebe27ec892658c5a051457b13506e59ba33824
2016-09-21 06:04:15 +00:00
Lorenzo Colitti
74cb76ff80 Support "don't ask again" in the avoid bad wifi dialog.
am: c65750c8a0

Change-Id: Ic6a1917a83e2d847bd673790e2c36f7316ca7acd
2016-09-20 17:14:50 +00:00
Lorenzo Colitti
c65750c8a0 Support "don't ask again" in the avoid bad wifi dialog.
This contains the following changes:

1. Make NETWORK_AVOID_BAD_WIFI a tristate: 0 means never avoid
   bad wifi, unset means prompt the user, 1 means always avoid.
2. Look at NETWORK_AVOID_BAD_WIFI only if the carrier restricts
   avoiding bad wifi (previously, we relied on the setting being
   null and defaulting to the value of the config variable).
3. Add an avoidUnvalidated bit to NetworkAgentInfo to track
   whether the user has requested switching away from this
   unvalidated network even though avoiding bad wifi is generally
   disabled. This is set to true when the user selects "switch"
   in the dialog without setting the "Don't ask again" checkbox.
4. Add a hidden setAvoidUnvalidated API to ConnectivityManager to
   set the avoidUnvalidated bit.
5. Additional unit test coverage.

Bug: 31075769
Change-Id: I1be60c3016c8095df3c4752330149ce638bd0ce1
2016-09-20 16:03:53 +09:00
Lorenzo Colitti
1f80a59004 resolve merge conflicts of b62007a to master
Change-Id: Ib09134090aa135d88bb807034b262a23c8b40e5f
2016-09-16 01:45:15 +09:00
Lorenzo Colitti
26b930e3c7 Unit tests for avoid bad wifi networks setting.
am: 83633c897a

Change-Id: I6491f1a93f93f222e23ef6e5e437631556637e44
2016-09-15 16:05:45 +00:00
Lorenzo Colitti
83633c897a Unit tests for avoid bad wifi networks setting.
Bug: 31075769
Change-Id: I21ba20df59ddce5731ef1ebe8846b3f00578a674
2016-09-15 23:45:07 +09:00
Lorenzo Colitti
440aba8c9c Add test coverage for background networks. am: d8a23ad61f am: 815bbf5678
am: 620562c61c

Change-Id: Ibbb14bd30b9b18799d301f023eb6770affbca518
2016-09-14 20:25:59 +00:00
Lorenzo Colitti
d8a23ad61f Add test coverage for background networks.
Bug: 23113288
Change-Id: Idad62f5f025825f99007ccf7b20f530dc3cf6daa
2016-09-13 12:02:13 +09:00
Lorenzo Colitti
34de7a3e55 Network switch notifications: rate & daily limits am: 9bf6fef270 am: 858499b2c0 am: 2c535a4f7c
am: e6c813b201

Change-Id: I0c067ec355eb2a50af3c828b1fe3ee8a78e44536
2016-08-31 23:31:56 +00:00
Hugo Benichi
6d2cb61e35 Network Switching Notifications: add unit tests am: 01f7228f5c am: 56f1281888 am: cf5f5785c9
am: 7ded0138f0

Change-Id: Idf4986df6f0f2b232aeaa5e43feb51615089dc71
2016-08-31 23:30:34 +00:00
Lorenzo Colitti
9bf6fef270 Network switch notifications: rate & daily limits
This patch adds a daily limit to the maximum number of notifications
shown when switching networks.

It also adds a rate limit to prevent rapid successive notifications in
flapping scenarios.

Bug: 31132499
Change-Id: Iccb6d0899646ea6df3cfad32a421922263e0eb85
2016-08-31 00:36:11 +09:00
Hugo Benichi
01f7228f5c Network Switching Notifications: add unit tests
BUG: 31132499
Change-Id: I9c50a59fe48efdcb51d2517f0a756691700c3ebe
2016-08-31 00:35:16 +09:00
TreeHugger Robot
f9e188bc2a Merge "Refactored NetworkStatsServiceTest to use Mockito instead of EasyMock." 2016-08-22 21:46:29 +00:00
Felipe Leme
de2a6f1b1d 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
Change-Id: I3fbdb0918f1d0e68f32afe07ca38d4ef217025df
2016-08-22 13:14:21 -07:00
Felipe Leme
a4dc2a7129 Use @Ignore to explicitly disable a @Test method.
BUG: 30839080
BUG: 31007021
Change-Id: Ia93f6b3c8fd1d2d2826c3b04b05f66339672a7e6
2016-08-22 09:02:12 -07:00
Felipe Leme
f96df4b298 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

Change-Id: Ib81d81df2828fc573c40b26c23af9d80ae43d3f6
2016-08-18 15:45:09 -07:00
Erik Kline
155a59aa63 Support timeouts for requestNetwork() invocations.
(cherry-pick of 06c3ef1367e850746eef0a5462bdce8674d74c30)

Bug: 21414325
Change-Id: I08118be8e8cf92fc406d431e99a6c9191a863ff3
2016-08-15 10:19:45 -07:00