Commit Graph

6112 Commits

Author SHA1 Message Date
Chenbo Feng
1401715e6f Add tests for PermissionMonitor
Add more tests to PermissionMonitor to verify the functionality related
to INTERNET permission and UPDATE_DEVIE_STATS permission. Modified some
of the class design of PermissionMonitor so that it is easier to test
the new functionalities.

Bug: 111560570
Test: PermissionMonitorTest

Change-Id: Ic5585f337db5de48e2f87bf4f01ed7d85c349827
2019-04-02 20:31:49 -07:00
Junyu Lai
8680cda689 Merge "Ignore the asynchronous result while stopping keepalive"
am: ea6508f9b7

Change-Id: Idc6d76ca412f7bbae3b32e81756c419d84dc2c80
2019-04-02 04:05:49 -07:00
Junyu Lai
ea6508f9b7 Merge "Ignore the asynchronous result while stopping keepalive" 2019-04-02 10:48:23 +00:00
Paul Hu
bc8ca075ef Merge "Address leftover comments on 923337 and 930217."
am: a9b8e31cf8

Change-Id: I733160ae51b8f0e80f78ab375cdb0a547b74f68d
2019-04-02 00:58:18 -07:00
Paul Hu
a9b8e31cf8 Merge "Address leftover comments on 923337 and 930217." 2019-04-02 07:39:04 +00:00
Paul Hu
b9cffc513e Merge "Fix IpPrefixTest#testContainsInetAddress fail."
am: 9c58ddc48e

Change-Id: I0926ee39c306fefdd158e1c4c7e4c1ba4b7c5f7d
2019-04-01 18:47:42 -07:00
Remi NGUYEN VAN
04c58fe907 Fix API in CaptivePortal, StaticIpConfiguration
- Add documentation to CaptivePortal#logEvent
 - Add paragraph breaks to StaticIpConfiguration class javadoc
 - Format javadoc for API documentation
 - Move setters to a builder and hide fields for apps targeting P or
   older
 - Document StaticIpConfiguration getters and builder setters
 - Add documentation for StaticIpConfiguration#getRoutes

Bug: 129362244
Bug: 129433304
Test: built, flashed, booted, WiFi working
Test: atest FrameworksNetTests NetworkStackTests
Change-Id: Ia66c1097f01ca87d02eba3456547aedb1e480186
2019-04-02 10:43:04 +09:00
Paul Hu
9c58ddc48e Merge "Fix IpPrefixTest#testContainsInetAddress fail." 2019-04-02 01:33:02 +00:00
Chalard Jean
c1e58995da Merge "Cleanup SystemReady in the network stack"
am: ff23b6dce0

Change-Id: I1a55078b74d5f94afde94da0dc5f6e1d2af10de3
2019-04-01 17:12:06 -07:00
Chalard Jean
ff23b6dce0 Merge "Cleanup SystemReady in the network stack" 2019-04-01 23:28:47 +00:00
paulhu
207037a243 Fix IpPrefixTest#testContainsInetAddress fail.
The argument of IpPreFix#contains() has been marked as @NonNull.
So the IpPrefixTest#testContainsInetAddress should not test
contains() method wiht null object.

Bug: None
Test: atest FrameworksNetTests
      atest IpPrefixTest#testContainsInetAddress

Change-Id: I2f6bee19514dc47702f64d2a2bbf02d8b7b1b407
2019-04-02 00:49:00 +08:00
Xiao Ma
bdb1f90f32 Merge "Add DHCP address lease expiry in IpMemoryStore."
am: 98aa76e2e8

Change-Id: Idb73423aaf875bb77d19f9661e243f152f734fa3
2019-04-01 06:16:08 -07:00
Xiao Ma
98aa76e2e8 Merge "Add DHCP address lease expiry in IpMemoryStore." 2019-04-01 12:59:20 +00:00
paulhu
1a40765101 Address leftover comments on 923337 and 930217.
- Restrict unprivileged apps to use
  NetworkRequest.Builder#setSignalStrength.

- Remove the "throws NullPointerException" in
  CaptivePortalProbeSpec constructor.

- Remove the null check in LinkProperties.

- Add annotataion into all ConnectivityManager.NetworkCallback
  methods.

Change-Id: Id275cac1d6a30d7515cd7b113394f5e8a0179314
Fix: 129097486
Test: atest FrameworksNetTests
2019-04-01 16:24:10 +08:00
junyulai
646ee4621c Ignore the asynchronous result while stopping keepalive
Currently, onStopped callback are synchronizely triggered when
stop() was called, since the framework don't really care
about the result of stopping keepalive.

However, if keepalive failed to stop for some reason, the
handleStopKeepalive was called mistakenly and trigger additional
callback that fail the test case.

This commit is the behavior change prior to state machine
refactoring, and introduce a stopping state for ignoring the
result in the stopping state.

Bug: 129512753
Bug: 123988249
Test: 1. atest com.android.server.ConnectivityServiceTest \
         #testNattSocketKeepalives --generate-new-metrics 100
      2. atest FrameworksNetTests

Change-Id: I4fa94e0740ba488fb5fe7ac7c3812c195dd0ec4c
2019-04-01 16:22:02 +08:00
Paul Hu
9420c284b5 Merge "Fix ApfCapabilities, LinkAddress, RouteInfo, IpPrefix API issues."
am: 1f041d1443

Change-Id: I8d848c559e1c1e021a72bf525876aad9bddb3374
2019-04-01 00:34:26 -07:00
Paul Hu
1f041d1443 Merge "Fix ApfCapabilities, LinkAddress, RouteInfo, IpPrefix API issues." 2019-04-01 07:20:53 +00:00
Chalard Jean
3ee6100881 Cleanup SystemReady in the network stack
The system server (in SystemServer.java) defines the boot
sequence, during which an event called SystemReady happens.
This corresponds to a time when critical system services
that are depended upon by other components in the system
server are ready to handle requests from their dependencies.
Some system services are listening to this event to defer
initializations that depend on the critical services.

Because the network stack is only started after SystemReady,
there is no way any NetworkMonitor may be started before
SystemReady. Remove the associated mechanism.

Fix: 129376083
Test: FrameworksNetTests
Change-Id: I071eeb10d0b7c4f71af6653d322c7b442b2cc7ee
2019-04-01 13:32:25 +09:00
Remi NGUYEN VAN
ea71c49a0e Merge "Fix race when starting NetworkMonitor"
am: ef8485cc65

Change-Id: I3fe792704b9dfaafe09c83da57081d6668216a97
2019-03-31 21:13:48 -07:00
Remi NGUYEN VAN
ef8485cc65 Merge "Fix race when starting NetworkMonitor" 2019-04-01 03:54:03 +00:00
Remi NGUYEN VAN
ca33d197d9 Fix race when starting NetworkMonitor
NetworkMonitor obtained LinkProperties and NetworkCapabilities via
synchronous calls to ConnectivityManager after receiving an asynchronous
notification, which is prone to races: the network could be gone before
the LinkProperties/NetworkCapabilities can be fetched.

Fix the race by passing LinkProperties/NetworkCapabilities directly to
NetworkMonitor in the asynchronous notifications.

Test: atest FrameworksNetTests NetworkStackTests
Test: booted, WiFi works
Bug: 129375892
Change-Id: I200ac7ca6ff79590b11c9be705f650c92fd3cb63
2019-04-01 11:33:10 +09:00
paulhu
895a741bf1 Fix ApfCapabilities, LinkAddress, RouteInfo, IpPrefix API issues.
Fix: 129362082
Fix: 129361362
Fix: 129360330
Fix: 129362379
Test: atest FrameworksNetTests NetworkStackTests
Change-Id: I05fbc6f98207d5cf002e3cbc5829040af7d6be52
2019-04-01 10:23:51 +08:00
Luke Huang
e0b323df1b Merge "Minor change for async DNS API"
am: 80be1b1127

Change-Id: I54a7695484b6523a92eaf246a4bb836fabc8957f
2019-03-29 11:38:24 -07:00
Lorenzo Colitti
f674528970 Merge "Unremove DnsResolver#query method used by external developers"
am: 3dd6df002b

Change-Id: I0c8b5b5fe68b99cacc4da10ae27b69fcab8685b7
2019-03-29 08:09:18 -07:00
Luke Huang
293ffaa081 Minor change for async DNS API
do the minor changes to address comments before

Bug: 129395490
Test: atest DnsResolverTest
Change-Id: I56e2e5bc4352ff5c979579247a333a41950079da
2019-03-29 18:12:26 +08:00
Luke Huang
fb5afabcb8 Unremove DnsResolver#query method used by external developers
This method was removed as part of addressing API council feedback in b/129261432
Add back previous DnsResolver#query which is already being used by developers.

Bug: 129395490
Test: atest DnsResolverTest

Change-Id: Ic956db204f3940d39d42e1b11dda39e57d356fad
2019-03-29 18:12:26 +08:00
Luke Huang
8ef15888a5 Merge "Use IDnsResolver instead of INetd for resolver related binder commands"
am: efa4301a7f

Change-Id: Icca07604bc8f922c51493e72fde8c7377105bf8b
2019-03-29 01:57:44 -07:00
Luke Huang
efa4301a7f Merge "Use IDnsResolver instead of INetd for resolver related binder commands" 2019-03-29 08:45:19 +00:00
Xiao Ma
3c33ee5d81 Add DHCP address lease expiry in IpMemoryStore.
Bug:122710829
Test: atest FrameworksNetTests
Change-Id: I643fe1231edcd18923514ab66c64a6cf83e69443
2019-03-29 16:51:47 +09:00
Luke Huang
829e409827 Merge "Fix cancellation race problem for aysnc DNS API"
am: de6217b8e2

Change-Id: I7e22c38c502fa0181e97057d9992c2a43c11b378
2019-03-28 20:32:40 -07:00
Luke Huang
de6217b8e2 Merge "Fix cancellation race problem for aysnc DNS API" 2019-03-29 03:15:32 +00:00
Varun Anand
f714bf2fad Merge changes from topic "vpn_data_accounting"
am: 06b4b6f92e

Change-Id: Iaa4b2dd9be2fc6e9833c6c846b6858aab507ca8b
2019-03-28 18:06:12 -07:00
Varun Anand
06b4b6f92e Merge changes from topic "vpn_data_accounting"
* changes:
  Move BatteryStats and StatsCompanionService to use NetworkStatsService.
  NetworkStatsService: Fix getDetailedUidStats to take VPNs into account.
  Take all VPN underlying networks into account when migrating traffic for VPN uid.
2019-03-29 00:40:53 +00:00
Varun Anand
2af0b66aba NetworkStatsService: Fix getDetailedUidStats to take VPNs into account.
This API is similar to one provided by NetworkStatsFactory with the
difference that NSS also migrates traffic from VPN UID to other apps.

Since traffic can only be migrated over NetworkStats delta, NSS
therefore maintains NetworkStats snapshot across all UIDs/ifaces/tags.

This snapshot gets updated whenever NSS records a new snapshot
(based on various hooks such as VPN updating its underlying networks,
network getting lost, etc.), or getDetailedUidStats API is invoked by
one of its callers.

Bug: 113122541
Bug: 120145746
Test: atest FrameworksNetTests
Test: manually verified that battery stats are migrating traffic off of
TUN (after patching above CL where we point BatteryStats to use this
API).
Change-Id: Ib0f0c2d4d41ee1d7a027ea9da457baaf198d649e
2019-03-28 10:31:51 -07:00
Varun Anand
612520f544 Take all VPN underlying networks into account when migrating traffic for
VPN uid.

Bug: 113122541
Bug: 120145746
Test: atest FrameworksNetTests
Test: Manually verified on device that stats from VPN UID are moved
      appropriately based on its declared underlying network set.
Test: vogar --mode app_process --benchmark NetworkStatsBenchmark.java

Change-Id: I9d8d0cc58d18002c1c96f8ddff780ef8dc452d21
2019-03-28 10:31:49 -07:00
Luke Huang
e17bb2dff4 Fix cancellation race problem for aysnc DNS API
This problem might cause double-close fd and result in app crash
or unexpected behaviour

Bug: 129317069
Test: atest DnsResolverTest
      manual test with delaying response callback/cancel
Change-Id: I223234f527edafc51d34fa6be390419c05def8d8
2019-03-28 19:46:56 +08:00
chen xu
3555617d90 Merge "support msim for captiveportal notification"
am: 5c83418408

Change-Id: I3bed0b6d44a13a4dd1c68b21a28b75e4e6c7aa81
2019-03-27 20:42:44 -07:00
Treehugger Robot
5c83418408 Merge "support msim for captiveportal notification" 2019-03-28 03:28:19 +00:00
Junyu Lai
a0540419f9 Merge changes I0baf582f,I4bba01ba
am: 6d7c97dc5c

Change-Id: Ie69a03e6c61e172ba7e9948706fe6780be61a41b
2019-03-27 18:17:27 -07:00
Junyu Lai
6d7c97dc5c Merge changes I0baf582f,I4bba01ba
* changes:
  Block unpriviledged apps which create keepalives with null fd
  Fix keepalive don't get removed when lower layer error
2019-03-28 00:53:20 +00:00
junyulai
828dad188c Block unpriviledged apps which create keepalives with null fd
Currently, socketKeepalive implementation is accepting null fd
due to backward compatibility with legacy packet keepalive API.
However, due to lack of the fd, the service cannot guarantee the
port is not reused by another app if the caller release the port
for any reason.

Thus, grant the null fd access only for priviledged apps.

This commit also address some comments from aosp/918533.

Bug: 126699232
Test: atest FrameworksNetTests
Change-Id: I0baf582ff4ca8af6082c3754e8dfbcd867f39792
2019-03-27 19:51:08 +08:00
Luke Huang
8141319b4d Use IDnsResolver instead of INetd for resolver related binder commands
migrate resolver related commands from INetd to IDnsResolver

Bug: 126141549
Test: atest FrameworksNetTests ConnectivityServiceTest Nat464XlatTest
      atest DnsManagerTest
Change-Id: I559c0c1304d53dde408c062e1a52e742595e7cbe
2019-03-27 17:39:07 +08:00
chen xu
5b5447e421 support msim for captiveportal notification
Bug: 123025093
Test: Manual
Change-Id: Ie04f3ae9a825ab75077a94b108ac92075b6d4753
2019-03-27 00:11:52 -07:00
Chenbo Feng
2a029a210c Merge "Get the permission information for native services"
am: 743a1c8001

Change-Id: I806e3e948dfab0cc8c691c20f377bbc3a24240a6
2019-03-26 22:33:27 -07:00
junyulai
8b381dd91b Fix keepalive don't get removed when lower layer error
Currently, if the lower layer, e.g. wifi, didn't successfully
start keepalive by any reason. Due to the startedState changed
to NOT_STARTED first, the logic inside stop() will skip the
removing process and cause leak.

Thus, moving the changing of startedState to proper place first
to unblock subsequent changes first.

Bug: 123988249
Bug: 129371366
Test: atest FrameworksNetTests
Change-Id: I4bba01bacc80e1dac2023ef831b5ade5501894e4
2019-03-27 11:38:58 +08:00
Chenbo Feng
5289cdd37e Merge "Fix the INTERNET related permissions"
am: 65cef6401a

Change-Id: Id97b1ea945409e938158f30efd564b10c9e81380
2019-03-26 19:52:57 -07:00
Chenbo Feng
d72e9ab720 Get the permission information for native services
For native services such as mediaserver and audioserver, the permission
information cannot be retrieved from getInstalledPackages. Instead, the
high level permission information is avalaible in systemConfigs. With
those permission information, netd can store the complete list of uids
that have UPDATE_DEVICE_STATS permission.

Bug: 128944261
Test: dumpsys netd trafficcontroller
Change-Id: I0331d5a3a5b927a351fcfe6689ef1ba2b993db0c
2019-03-27 02:45:37 +00:00
Treehugger Robot
65cef6401a Merge "Fix the INTERNET related permissions" 2019-03-27 02:35:35 +00:00
Lucas Lin
b7977acec0 Merge "Fix flaky test for ConnectivityServiceTest#testPartialConnectivity"
am: 52feef4450

Change-Id: I0639d4ccd7c3211595ede82bce3daa87ae759e10
2019-03-26 18:41:00 -07:00
Lucas Lin
52feef4450 Merge "Fix flaky test for ConnectivityServiceTest#testPartialConnectivity" 2019-03-27 01:29:51 +00:00