Commit Graph

191 Commits

Author SHA1 Message Date
Lorenzo Colitti
c73cc60d57 Make NetworkStack actually build in an unbundled setup.
The Java code was already using sdk_version: "current", but the
JNI library did not have an sdk_version attribute, and had
forbidden dependencies on internal libraries such as libcutils,
liblog and libnativehelper.

This CL fixes things as follows:
- Use the NDK log functions, and switch to the NDK liblog.
- Switch to the NDK libnativehelper.
- Drop the dependencies on libcutils and libpcap, which were
  unused.
- Use the libc++ STL, and set the sdk_version of the library to
  current.

Bug: 131703417
Test: m
Test: installed NetworkStack APK via "adb install --staged" results in working networking
Test: builds, boots, wifi works
Test: atest FrameworksNetTests NetworkStackTests

(cherry picked from commit 3d680e887b)

Change-Id: I8a0a8d4b4e8872cb88ee526772ae519a8e6df615
2019-05-01 21:52:21 +09:00
Aaron Huang
9eeaa3aa9e Support adding NATT keepalive packet filter
Support adding NATT keepalive packet filter to APF
filter.
Generating APF program will be addressed in another CL.

Bug: 33530442
Test: - atest NetworkStackTests
      - atest FrameworksNetTests

Change-Id: I4961d5da343d8700600269632787c28112f0f9f1
2019-04-29 19:33:45 +08:00
Lorenzo Colitti
d38eaa8820 Merge "Revert "Make the network stack a persistent process."" 2019-04-29 01:40:34 +00:00
Lorenzo Colitti
5574fd5248 Revert "Make the network stack a persistent process."
This reverts commit 796afddd6c.

Reason for revert: breaks updatability because persistent processes are not updatable.

Change-Id: I35ded113b31e742f13ad8523a10af3a83a111374
2019-04-27 15:02:50 +00:00
Lorenzo Colitti
65f6ae271b Fix some checkstyle nits in DhcpPacketTest.
Use the Generated code suppression comment filter instead of the
IndentationCheck suppression comment filter because the latter
complains that '+' should be on a new line.

Bug: 120584519
Bug: 127423755
Test: atest NetworkStackTests
Test: atest FrameworksNetTests
Change-Id: Ia9865c75f940e2fbb3aef374a297339e8ea2fd1b
2019-04-27 16:36:39 +09:00
Lorenzo Colitti
681f33cc6a Additional code for server name in DHCP packets.
- Add the hostname to DhcpResultsParcelable.
- Don't store the server hostname if option overload is in use,
  as this is not valid.
- Add unit tests.

Bug: 120584519
Bug: 127423755
Test: atest NetworkStackTests
Test: atest FrameworksNetTests
Change-Id: I47d9d53d1fb58968322cc8b071a44fbc8f7156e1
2019-04-27 16:36:10 +09:00
yuanyunli
43f1bc9d53 Parse the server host name field of the dhcp package
Some hotspot devices will fill in the server host name field of the DHCP
package, such as iphone. Parsing the server host name of the DHCP
package can help identify ios hotspots.

Bug: 120584519
Test: 127423755
Test: builds, boots, wifi works
Change-Id: Idbe10c36332ce421f1bba93eb87e9e1e12463088
2019-04-26 22:59:52 +09:00
Chiachang Wang
d32d766a04 Merge "Remove Settings constants for NetworkStack" 2019-04-25 04:49:04 +00:00
Chiachang Wang
e6d0ab916a Remove Settings constants for NetworkStack
The definitions reference of these constants are moved from
Settings to DeviceConfig. These definitions are @hide and the
usage in the Settings are removed. Thus, remove the definitions
from API level.

Bug: 123167629
Test: make system-api-stubs-docs-update-current-api \
      test-api-stubs-docs-update-current-api
Test: atest NetworkStackTests
Change-Id: I28c4bf2c0b72e154cea91d11007a9497c7f21570
Merged-In: I7291cfa86cd6e907df35e8fbc97e2e9a77e56cab
Merged-In: Ic48bea07e79490dd3787068bc88c748525752a61
2019-04-25 02:40:51 +00:00
Treehugger Robot
d0e7befaaf Merge "Make the network stack a persistent process." 2019-04-24 16:25:24 +00:00
Lorenzo Colitti
796afddd6c Make the network stack a persistent process.
The network stack should never be killed, because if it does,
recovering networking requires a reboot. Make the process
persistent to reduce the chances of it being killed by the OOM
killer.

Bug: 131046856
Test: builds, boots
Test: process oom_score_adj is -800
Test: process goes from "Persistent Service" to "Persistent" in dumpsys meminfo
Change-Id: Ic8ebf6356e23489f6cd984d680ff9f1b4cbbe52d
2019-04-24 22:36:55 +09:00
Lorenzo Colitti
11aaadd6ae Delete unused timeout constant.
Test: m
Bug: 129312219
Change-Id: I5b4c8b42dea515f674ff10d64d0e1d06d849cca1
2019-04-24 17:11:12 +09:00
Lorenzo Colitti
e721b4b83e Merge "Add a timeout for the DNS probe." 2019-04-23 14:13:14 +00:00
Remi NGUYEN VAN
1232fe37be Freeze the networkstack-aidl-interfaces interface
This freezes the interface as of the latest beta build, not the tip of
tree. IIpClient#setL2KeyAndGroupHint is not in the frozen definition in
particular.

Generated with:
m networkstack-aidl-interfaces-freeze-api \
    ipmemorystore-aidl-interfaces-freeze-api

Test: flashed, booted, WiFi and captive portal working
Bug: 128803828
Change-Id: Ideabe73fc93bbefca2d624ee9ca190cf31419424
2019-04-23 06:49:58 +00:00
Lorenzo Colitti
6413419435 Add a timeout for the DNS probe.
Bug: 129312219
Test: atest NetworkStackTests
Test: atest --generate-new-metrics 50 NetworkStackTests:com.android.server.connectivity.NetworkMonitorTest
Change-Id: Ib3ab9105d7ae39f551b51e8d5a04b9ec5e549655
2019-04-22 23:38:58 +09:00
Chalard Jean
1ad99fb064 Merge changes Id598ae1d,I475bd011
* changes:
  Fix a possible crash when the listener is null
  Straighten AIDL interface for the memory store
2019-04-22 02:15:04 +00:00
Chalard Jean
da3421e6e5 Straighten AIDL interface for the memory store
Some names were still wrong somehow, and the wrappers were
missing.

Test: NetworkStack & FrameworkNetTests
Change-Id: I475bd011ad9bc714a07021a9dfd85c4876f8e9ad
Merged-In: I475bd011ad9bc714a07021a9dfd85c4876f8e9ad
2019-04-22 00:40:28 +00:00
Chiachang Wang
32df8810c6 Merge changes from topic "StatsLog.write_migrate"
* changes:
  Java code for mainline modules to log to statsd.
  Migrate NetworkStack metrics off StatsLog.write
2019-04-19 00:58:24 +00:00
Chiachang Wang
587ee7240e Merge "Move Setting constants for NetworkStack" 2019-04-18 07:35:19 +00:00
Chiachang Wang
e987ba6ccd Migrate NetworkStack metrics off StatsLog.write
Now that the new metrics API can be used, NetworkStack
metrics need to migrate off the legacy StatsLog.write.

Bug: 130323000
Test: Test with ./out/host/linux-x86/bin/statsd_testdrive 121
      to ensure log properly
Test: Ensure NetworkStackStatsLog will be generated as expected
Test: atest NetworkStackTest

cherry-picking commit e512b26913.

Change-Id: I8c70503cf1d9f1d06f30a1936d2d88857d0cff53
Merged-In: I1bfe856d771bf56fe33790aea22eceae2001921a
2019-04-18 09:28:01 +08:00
Chiachang Wang
8b2a8821a9 Move Setting constants for NetworkStack
From mainline perspective, we should use android flag api
instead of using Settings. Thus, move the definitions into
NetworkStack and apply new flag design.

Bug: 123167629
Test: atest NetworkStackTests
Change-Id: I9602263f0bff5d8e942bd652de69ccfcb3034a2f
2019-04-17 17:00:54 +08:00
Chalard Jean
896245a1e2 Move TrafficStats tags for the network stack constants
As per API council feedback, these constants should live in
a place that is private to the network stack, only with a
range defined in system API.

Bug: 129433383
Test: m
Change-Id: I84a90f84a9af6fef4667ee4d512ebd0413222086
Merged-In: I4882686a86e7c6d42f4b0619b921d02619ed6d4c
Merged-In: I9b648ed6c687d56db61a54570c7880c51c1bae51
2019-04-17 05:45:40 +00:00
Remi NGUYEN VAN
08d4a537ec Merge "Change the validation URL for Chinese SIMs" 2019-04-12 01:18:12 +00:00
Treehugger Robot
7db7b331ef Merge "provide a resource overlay to configure customized DNS Server." 2019-04-11 11:06:51 +00:00
Chiachang Wang
076317a01f Merge "Address nit in NetworkStackUtils" 2019-04-11 10:48:58 +00:00
Remi NGUYEN VAN
de568f7289 Change the validation URL for Chinese SIMs
The default HTTPS and fallback validation URLs are not accessible from
China, so users in China never get a validated network on WiFi with the
default AOSP settings. OEMs selling devices targeting China typically
change the check URLs for that reason.

When the device uses a Chinese SIM card, change the default validation
URLs to URLs accessible accessible from China as of now.

Test: inserted China SIM, WiFi off/on, dumpsys network_stack shows new
      URL used
Bug: 111819230
Change-Id: Ib7f41f470ef1a9c7712f2477ebfab44e915cf1b9
2019-04-11 17:23:35 +09:00
Xiao Ma
a4d0122048 provide a resource overlay to configure customized DNS Server.
Bug: 122621524
Test:  atest FrameworksNetTests NetworkStackTests
Change-Id: I123b3d4516cc6ba6d17629eb74daf448ba7121eb
2019-04-11 15:30:23 +09:00
Chiachang Wang
b805040fef Address nit in NetworkStackUtils
Follow up commit to fix nit in aosp/937891

Bug: 120013793
Test: Build
Change-Id: I61a6306d3c439a2d72323ab56e2b47771cc60d48
2019-04-11 11:10:51 +08:00
Remi NGUYEN VAN
eb8d81ca14 Merge "Freeze netd AIDL interface (framework)" 2019-04-11 00:13:29 +00:00
Lorenzo Colitti
047940eff0 Merge "Add lifecycle tests to NetworkMonitorTest" 2019-04-10 09:30:03 +00:00
Chiachang Wang
e9a39ceb6b Merge "Move data stall definitions out from Setting" 2019-04-10 03:27:19 +00:00
Chiachang Wang
2449e583d8 Move data stall definitions out from Setting
From mainline perspective, we should use android flag api
instead of using Settings. Thus, move the definitions into
NetworkStack.

Bug:120013793
Test: atest NetworkStackTests SettingsBackupTest
Change-Id: I8e1fb5b47fff3bf624131ba1f5732daabd991e6d
Merged-In: I8e1fb5b47fff3bf624131ba1f5732daabd991e6d
Merged-In: I0a2a1e5d3de14ea86556ca471e26064df3481412
2019-04-10 02:37:57 +00:00
Remi NGUYEN VAN
eec0ed4056 Freeze netd AIDL interface (framework)
This freezes the interface as of the latest beta build, although it has
not changed since then.
This change adds the necessary implementations for getInterfaceVersion.

Test: flashed, WiFi working
Bug: 128803828
Change-Id: I43a6a38685d5fbc669cd573c4d7e7f99bd596952
2019-04-10 11:26:25 +09:00
Lorenzo Colitti
cdef556adf Add lifecycle tests to NetworkMonitorTest
- Ensure that NetworkMonitor quits when notifyNetworkDisconnected
  is called.
- Ensure that BroadcastReceivers are registered when a captive
  portal is detected and unregistered when the network validates
  or when NetworkMonitor quits.

Bug: 122164725
Test: atest FrameworksNetTests NetworkStackTests
Test: atest --generate-new-metrics 10 NetworkStackTests:com.android.server.connectivity.NetworkMonitorTest
Test: test fails if "Don't leak captive portal broadcast receivers." change reverted
Change-Id: I1202626face33cc1e1ec02016b95da487b3335c8
2019-04-09 23:12:33 +09:00
Remi NGUYEN VAN
7bb487a582 Merge "Expose captive portal urls for configuration" 2019-04-09 04:37:48 +00:00
Niklas Lindgren
afc5f9bd3d Expose captive portal urls for configuration
Carriers in Mainland China need to customize certain captive portal
urls. The main issue is that google servers are not accessible in
Mainland China.

Added the following captive portal resources to be targeted for overlay.
- config_captive_portal_http_url
- config_captive_portal_https_url
- config_captive_portal_fallback_urls (string-array)
- config_captive_portal_fallback_probe_specs (string-array)

These values can be customized for e g diffent countries

Bug: 111819230
Test: atest FrameworksNetTests NetworkStackTests
Test: Add a product RRO that targets a specific country code,
insert a SIM card that matches that country code and check the log
what URL is used.
Change-Id: I38a294a5e14417f65e96e76235ea153c53c4d7cc
2019-04-09 10:23:53 +09:00
Lorenzo Colitti
e35374386b Don't leak captive portal broadcast receivers.
Since aosp/937885, mLaunchCaptivePortalAppBroadcastReceiver is
nulled out, but not unregistered, when exiting MaybeNotifyState.
This causes the BroadcastReceiver to be leaked because it is no
longer unregistered when processing CMD_NETWORK_DISCONNECTED.

Fix this by unregistering the receiver in MaybeNotifyState#exit.
Also remove the unregister call in CMD_NETWORK_DISCONNECTED: it
is no longer necessary, because StateMachine, before quitting,
will call the exit method of the current state and all its
parent states.

Bug: 122164725
Test: atest FrameworksNetTests NetworkStackTests
Change-Id: I447b3cfd3821dda19482ed962dd59ec61fc5fc9b
2019-04-08 21:14:23 +09:00
Lucas Lin
83152b1e5f Merge "Prevent SIGN_IN notification pop up several times" 2019-04-08 04:37:47 +00:00
lucaslin
04e50f8608 Prevent SIGN_IN notification pop up several times
SIGN_IN notification may pop up several times before user
logged in the network if someone trigger
ConnectivityService#reportNetworkConnectivity().
Add a boolean to make sure SIGN_IN notification will only pop up
once to user before user logged in.

Bug: b/122164725
Test: Build pass.
Change-Id: I9c7f1d47fde8e5dfadd6646497023b05f3b0ed88
2019-04-08 10:52:46 +08:00
Remi NGUYEN VAN
35487f959a Add NetworkStackTests dependency on libdl_android
This fixes tests that were failing because of the unsatisfied
dependency.

Test: atest NetworkStackTests
Bug: 129387775
Change-Id: Ie0c1bc2b292ad7172d144d9e7ad9edeecd2232b7
(cherry picked from commit 329c4dadbe)
2019-04-06 11:20:38 +02:00
Remi NGUYEN VAN
66d744ba74 Merge "Add a mechanism to pass the L2Key and group hint to IpClient" 2019-04-05 07:30:02 +00:00
Remi NGUYEN VAN
1ddf974859 Merge "Move attach*Filter() and addArpEntry() methods to NetworkStack" 2019-04-05 06:38:08 +00:00
Chalard Jean
3cab290648 Add a mechanism to pass the L2Key and group hint to IpClient
Test: IpClientTest
Change-Id: I399b20ce29a385a74971b7a7248a48cb4d66deb6
2019-04-05 12:51:04 +09:00
Yifan Hong
e4d640b3a8 Merge "Fix NetworkStackTests." 2019-04-04 01:21:34 +00:00
Yifan Hong
0e5459731f Fix NetworkStackTests.
NetworkStackTests dlopens library which indirectly
uses libcgrouprc. Add it to jni_libs.

Test: atest
Fixes: 129902619
Change-Id: I0d60d7a317fa60607d6fdaea15f61b458aefd2f0
2019-04-03 18:15:22 -07:00
paulhu
931cdd273f Move attach*Filter() and addArpEntry() methods to NetworkStack
The SocketUtils.attach*Filter and SocketUtils.addArpEntry methods
were added there because they could not be added as JNI inside
the NetworkStack. This was not possible because on Go devices,
the NetworkStack was a jar library. But now, Go also uses an APK.
Hence, move these methods to the NetworkStack.

Change-Id: I1d88a0f0be23f2b15d5103fa092b9bf982329d7c
Fix: 129433183
Test: atest NetworkStackTests FrameworksNetTests
2019-04-03 17:49:36 +08:00
paulhu
b0f53b84cc Make CaptivePortalProbeSpec and CaptivePortalProbeResult as a library
These two classes were added to @SystemApi because they are used
both by NetworkMonitor and CaptivePortalLogin. However it turns
out they are not needed in the framework, so having them as a
library sounds better.

Change-Id: Iadf77ec5952b6da8812dc6d006a39bd4e93d2bd9
Fix: 129433264
Test: atest NetworkStackTests FrameworksNetTests
2019-04-02 17:55:42 +08:00
Paul Hu
7f10bb1c11 Merge "[IPMS] Implement regular maintenance" 2019-04-02 01:39:38 +00:00
Remi NGUYEN VAN
073e73a0c1 Merge "Rename NetworkStackPermissionStub" 2019-04-02 01:31:51 +00:00
Remi NGUYEN VAN
fc6b247d35 Rename NetworkStackPermissionStub
Use NetworkStackPermissionConfig instead.

Bug: 129317412
Test: Flashed, booted, WiFi working
Merged-In: I7bdc058dddfa483823074055ad5c9d7d2efd37b9
Change-Id: I45299c12598cd3b33bfd78ae8698d98b77b18dc0
2019-04-02 00:14:05 +00:00