Commit Graph

8990 Commits

Author SHA1 Message Date
Lorenzo Colitti
58dfa8b72e Fix legacy APIs when VPN switches to suspended underlying network.
Currently, when the VPN underlying network changes from a
network that is not suspended to one that is suspended (or vice
versa), some of the legacy APIs return incorrect results.

This is because the VPN's NetworkInfo can get into SUSPENDED
state even though the capabilities have the NOT_SUSPENDED
capability. This happens because the code in updateCapabilities
that checks for changes in NOT_SUSPENDED and NOT_ROAMING (which
are the capabilities that can affect the NetworkInfo state) is
only run when the capabilities change in a certain way.

Fix this by always checking for changes in these capabilities,
regardless of what else has changed.

This results in sending a lot more SUSPENDED and RESUMED
callbacks than the code sent previously. This should hopefully
not impact apps because those callback methods have never been
public API, though because they're just callbacks, it's possible
that apps found out via code inspection that the callbacks
existed and implemented them.

Bug: 172870110
Test: changes to existing tests in ConnectivityServiceTest
Change-Id: I6ec246a6a4e61f634956a165797fbb80296efd6a
Merged-In: I6ec246a6a4e61f634956a165797fbb80296efd6a
(cherry picked from commit 5b90ebaf4d9edefcd9648b46cd0226f882169476)
2021-02-09 20:19:23 +00:00
Lorenzo Colitti
5aa7b53d66 Backport test coverage from aosp/1547496.
This test coverage is necessary to fix an upcoming bug in R.
Backport it from the change that added it. The non-test portion
of that change is not necessary in R because it fixes a
bug that was introduced in S.

Bug: 172870110
Test: accompanying unit test shows lots of bugs removed
Change-Id: If7eb8857474d8b4f774f5fa5db2a3112e85c9cae
Merged-In: Ibf376a6fa4b34d1c96f8506fa8abbb7595a8c272
(cherry picked from commit 55229beb747b9e7b8a0f392d855a1b3342df8646)
2021-02-09 20:19:11 +00:00
Lorenzo Colitti
3536dc7df7 Backport some helpers in ConnectivityServiceTest.
These were added in aosp/1527378, which is impractical to
backport.

Bug: 172870110
Test: test-only change
Change-Id: Id3d12b23034b284c8f7dffb5167244e1e43987e2
Merged-In: I827543751dbf5e626a24ec02cd6f50b423f5f761
(cherry picked from commit 4c36cb764a6ffbc81acdbf2297cde010a7396f8b)
2021-02-09 20:19:04 +00:00
Lorenzo Colitti
e76c4083f9 Test for bugs with suspended VPN underlying networks.
Bug: 172870110
Test: atest --rerun-until-failure 100 ConnectivityServiceTest#testVpnSwitchFromSuspendedToNonSuspended
Change-Id: Ia52f9cafef3f49ae70ad135d017e207eb57fddfe
Merged-In: Ia52f9cafef3f49ae70ad135d017e207eb57fddfe
(cherry picked from commit 27ecde937319012a3fc07783e1133e14111da788)
2021-02-09 20:18:58 +00:00
Lorenzo Colitti
a2a1c03906 Add a test for getDefaultNetworkCapabilitiesForUser.
Bug: 172870110
Test: test-only change
Test: new test passes 100 times in a row
Change-Id: I210284578e38cd25b8b95235d3390d5bd66a5a70
Merged-In: I210284578e38cd25b8b95235d3390d5bd66a5a70
(cherry picked from commit a9aca9744745b7fc8b3d2a1235096982ad8ec8b6)
2021-02-09 20:18:53 +00:00
Lorenzo Colitti
205e37a71f Improve testing of CONNECTIVITY_ACTION broadcasts.
We currently test CONNECTIVITY_ACTION broadcasts by directly
registering BroadcastReceivers with BroadcastInterceptingContext,
and making the receivers unregister themselves when all the
broadcasts they expect have been received.

This works for current test cases, but does not work if anything
registers another receiver for CONNECTIVITY_ACTION. In that case,
when we unregister the receiver in the receiver's onReceive
method, BroadcastInterceptingContext will throw a
ConcurrentModificationException because the list of receivers is
being modified during iteration.

Fix this by adding an ExpectedBroadcast class that stores the
receiver and unregisters the receiver only when the test checks
that the broadcast was received, which happens after the receiver
runs. This is easier to use and also guarantees that the receiver
is unregistered even if the test is expecting that the broadcast
is never fired. Accordingly, remove mRegisteredReceivers and the
code that uses it; it's no longer necessary now that
ExpectedBroadcast always unregisters its receivers.

Also add a convenience expectConnectivityAction method to expect
a CONNECTIVITY_ACTION broadcast with specific contents. This
makes the test easier to read and more detailed. Convert some
existing tests to this method.

While I'm at it, fix a test that was using "mCellNetworkAgent" to
represent a wifi network.

R backport notes: added import for NetworkInfo.DetailedState.
That was added in aosp/1527378, which is impractical to backport.

Bug: 172870110
Test: test-only change
Change-Id: Ibada8b4215625e1016d9fd170526206920af76f5
Merged-In: Ibada8b4215625e1016d9fd170526206920af76f5
(cherry picked from commit d39cfb8de7ce7a789afd2c9e8ac3ca18fb8186ba)
2021-02-09 20:18:46 +00:00
Lorenzo Colitti
9dc492b106 Test passing an underlying network array with null network in it.
Current code treats these nulls as if they weren't there.

Bug: 172870110
Test: test-only change
Change-Id: Id4632e1b004c09910b4b7613f7233d2c19e2f0ac
Merged-In: Id4632e1b004c09910b4b7613f7233d2c19e2f0ac
(cherry picked from commit eccd26239024ca2a401e354fb16b855fa72f9923)
2021-02-09 20:18:39 +00:00
Lorenzo Colitti
9dd9bd720d Make testVpnNetworkActive more deterministic.
This test is a bit brittle because it sets the underlying
networks while the VPN is undergoing validation by
NetworkMonitor. The test does attempt to disable validation,
but that's not actually possible - the only thing that's possible
is to tell NetworkMonitor to validate immediately without sending
any probes. So the underlying network change races with the
validation. I'm not sure why the test isn't flaky. It might be
because both the network change and the validation result in a
capabilities change, and the test expects "a capabilities change"
without expressing what change that should be.

Make this a bit more predictable by ensuring that the network
validates before the underlying networks are set.

This is useful because an upcoming CL will change the way
underlying network capabilities are propagated. With this test
CL, both the old and the new code pass.

Bug: 172870110
Test: test-only change
Change-Id: I319858228e8d097c0b60a107029f296385f91269
Merged-In: I319858228e8d097c0b60a107029f296385f91269
(cherry picked from commit 0b53357c1a74300319a61890201e56916864309c)
2021-02-09 20:18:35 +00:00
Lorenzo Colitti
2481a6713a Make MockVpn more realistic and easier to use.
MockVpn is very difficult to use because it requires the test
caller keeping track of both the MockVpn object and an
accompanying TestNetworkAgentWrapper.

It's also not very realistic: for example, connect() doesn't
actually connect anything, it just makes it so that if
ConnectivityService tries to update the capabilities, the attempt
will not be ignored. Also, unlike the real code in Vpn, it
connects with empty NetworkCapabilities (in particular, with
empty UID ranges).

Make this easier to use and a bit more realistic by:
- Allowing TestNetworkAgentWrapper to take a "NetworkCapabilities
  template" that will form the initial capabilities sent when the
  agent registers with ConnectivityService. This allows the VPN
  to register its agent with its UID ranges already set, like the
  production code does.
- Providing separate methods to register the NetworkAgent and
  mark it connected for cases where the test needs to make
  changes to the NetworkAgent before connecting (e.g., poking
  NetworkMonitor).
- Putting the TestNetworkAgentWrapper inside MockVpn and driving
  it through MockVpn's methods. In order not to have too many
  wrapper functions (and because we can't delegate like in
  Kotlin), there's still an agent() method that returns the
  TestNetworkAgentWrapper.

Bug: 172870110
Test: test-only change
Change-Id: I749ff325bc13ac96f512270b86d1f67686eec378
Merged-In: I749ff325bc13ac96f512270b86d1f67686eec378
(cherry picked from commit a083cb1ffed7a851f2748463a31904fc4c6b625d)
2021-02-09 20:18:25 +00:00
Lorenzo Colitti
a9e6a86f1d Increase test coverage for VPN info sent to NetworkStatsService.
Bug: 172870110
Test: test-only change
Change-Id: I3711b362f31cb92b759e9f5c9d244fb88d9bd5e7
Merged-In: I3711b362f31cb92b759e9f5c9d244fb88d9bd5e7
(cherry picked from commit 04314f147d00660fc5d32613bc06ede3d9ec3b9d)
2021-02-09 20:18:17 +00:00
Lorenzo Colitti
7f3cec7c0e Simplify MockVpn.
This CL removes four methods in MockVpn by slightly changing the
test code to leverage the actual methods implemented by the
(production) Vpn superclass.

This works because setting mInterface results in
isRunningLocked() returning true, which makes a number of methods
behave as if the VPN is connected (which is what the test
expects).

The more realistic behaviour exposes a minor bug in the treatment
of underlying networks. Add a TODO to fix it.

Bug: 172870110
Test: test-only change
Change-Id: I49421183538ba61ca790af71e309ece36b653bf9
Merged-In: I49421183538ba61ca790af71e309ece36b653bf9
(cherry picked from commit 9ededd8476680d40b0b0d5b21e3a4bc0d743adae)
2021-02-09 20:18:10 +00:00
Lorenzo Colitti
1c22131799 Test a VPN with an underlying network that does not yet exist.
This test checks that if a VPN declares an underlying network
that does not exist, the capabilities of that network are applied
to the VPN as soon as the network starts to exist.

Bug: 172870110
Test: test-only change
Change-Id: Icc0701cb4cea7d91f7738c1e426e94cd26686b74
Merged-In: Icc0701cb4cea7d91f7738c1e426e94cd26686b74
(cherry picked from commit a21b2252e0b0eccd482b3b69e67b8911b94dba73)
2021-02-09 20:18:02 +00:00
Sarah Chin
6a9bff92ae Move phone ID to extra for action provision
Previously, the phone ID was appended to the broadcast in DCT and sent
to ConnectivityManager. Instead of sending both as an action, send the
phone ID as an extra instead to make the action a protected broadcast.

Test: manually verify a SecurityException when action provision is sent
Test: atest DcTrackerTest
Bug: 172459128
Change-Id: Ic4129def86949d7191d15056852718dadbd72fba
Merged-In: Ic4129def86949d7191d15056852718dadbd72fba
2020-12-15 01:10:27 -08:00
Cody Kesting
8744c5c999 Allow the System UID to unregister ConnDiags CBs.
This CL updates ConnectivityService to allow the System's UID to
unregister ConnectivityDiagnostics callbacks. Preivously, only the
registrant was allowed to unregister them - this caused problems for
callbacks that were attempted to be unregistered via binderDied() when
the registrant app dies.

Bug: 159912975
Bug: 174713659
Test: manually verified
Change-Id: I20d0cad5f902708d366aa703c2893b0ea3e55052
Merged-In: I20d0cad5f902708d366aa703c2893b0ea3e55052
(cherry picked from commit 4787c9bc59556ffb62d3b9d6c894af017d985280)
2020-12-04 20:46:52 +00:00
Benedict Wong
6cdf2a4ab6 Provide more feedback to Settings when sessions fail
This change updates the VPN state when IKEv2 sessions fail, and when
configuration errors occur.

Bug: 162289824
Test: Manual testing with IKEv2/PSK
Change-Id: I2e8c6f421d2898f97b0ac422b2276edf9ef923f1
Merged-In: I2e8c6f421d2898f97b0ac422b2276edf9ef923f1
(cherry picked from commit 0be82d4f4cb215e05ca62df80f6a9e652d1d1aa9)
2020-09-25 19:38:39 +00:00
TreeHugger Robot
589e62d691 [automerger skipped] Merge "[CS] Add an option to block sensitive network specifier" into pi-dev am: 9c70259e2b -s ours am: 7eb675f03d -s ours am: f39a6803e1 -s ours am: 7e3ce21887 -s ours
am skip reason: Change-Id If08d312ff814bdde1147518f923199e6349503d5 with SHA-1 107ae95001 is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12321778

Change-Id: Ie0d62c79853bc017102ad95acc1a5190182a92c7
2020-09-10 01:43:19 +00:00
TreeHugger Robot
7e3ce21887 [automerger skipped] Merge "[CS] Add an option to block sensitive network specifier" into pi-dev am: 9c70259e2b -s ours am: 7eb675f03d -s ours am: f39a6803e1 -s ours
am skip reason: Change-Id If08d312ff814bdde1147518f923199e6349503d5 with SHA-1 107ae95001 is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12321778

Change-Id: I553eead2b24367b09f4888ea8a687c48cd2bf9da
2020-09-10 01:14:38 +00:00
TreeHugger Robot
f39a6803e1 [automerger skipped] Merge "[CS] Add an option to block sensitive network specifier" into pi-dev am: 9c70259e2b -s ours am: 7eb675f03d -s ours
am skip reason: Change-Id If08d312ff814bdde1147518f923199e6349503d5 with SHA-1 107ae95001 is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12321778

Change-Id: I90bb0d837e4ac6c3acc834653bc1f758d62e1a08
2020-09-10 00:46:56 +00:00
TreeHugger Robot
7eb675f03d [automerger skipped] Merge "[CS] Add an option to block sensitive network specifier" into pi-dev am: 9c70259e2b -s ours
am skip reason: Change-Id If08d312ff814bdde1147518f923199e6349503d5 with SHA-1 107ae95001 is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12321778

Change-Id: I58327bb904244e5f962c27b7c8facdfeae8a758d
2020-09-10 00:27:47 +00:00
Etan Cohen
3a0aaa681f [CS] Add an option to block sensitive network specifier
Network specifiers are used for 2 purposes:

- As part of network requests to specify more information on the type
  of requested networks.
- On network agents to specify information about their networks.

The network specifiers of the requests and agents are matched to each
other. However, the agent network specifier may contain sensitive
information which we do not want forwarded to any app.

This CL adds an option to strip out this agent network specifier before
the network capabilities are forwarded to the app.

Bug: 161853197
Bug: 161370134
Test: atest ConnectivityServiceTest (frameworks/base/tests/net)
Test: atest frameworks/base/tests/net
Test: atest frameworks/opt/net/wifi/tests/wifitests
Test: atest frameworks/opt/telephony/tests/telephonytests
Test: atest frameworks/opt/net/ethernet/tests
Test: atest android.net.cts - some flakiness!
Test: act.py ThroughputTest
Test: act.py DataPathTest
Test: atest SingleDeviceTest (cts)
Change-Id: I38ed3ff88532ef522ab167c88d87e6e82295ffc5
Merged-In: If08d312ff814bdde1147518f923199e6349503d5
2020-09-07 00:37:33 +00:00
junyulai
a57040886b Skip RAT type listener registration if IMSI is not available
Currently, if SIM is inserted but IMSI is not available, such
as SIM PIN locked state. Information of such SIM will still
be available but IMSI is not. Which makes
NetworkStatsSubscriptionMonitor failed to store IMSI locally
for later RAT type query. Hence, NETWORK_TYPE_UNKNOWN is
always returned for such SIM.

Skip the registration until the IMSI is available. This is safe
since there will be another onSubscriptionsChanged event when
that happens.

Test: enable SIM PIN and manually test
Test: atest NetworkStatsSubscriptionsMonitorTest#testSubscriberIdUnavailable
Test: ./out/host/linux-x86/bin/statsd_testdrive 10082
Bug: 160941101
Merged-In: I408379b3c432d9e62e0837d6b4f6551cc7838e29
Change-Id: I408379b3c432d9e62e0837d6b4f6551cc7838e29
(cherry-picked from ag/12400327)
2020-08-19 09:53:20 +00:00
Lorenzo Colitti
f5c38386a6 Fix fd leak in KeepaliveTracker.
The semantics of FileDescriptor in AIDL are that the callee must close
the file descriptor it receives manually.

Fix: 157789860
Bug: 155136951
Test: treehugger
Change-Id: Ice9fc9abe2959a84ad138a95c900dff676653665
Merged-In: Ice9fc9abe2959a84ad138a95c900dff676653665
(cherry picked from commit db8ae41da255caad7640fc2c1b58d16aafb0e62b)
2020-08-11 04:46:09 +00:00
Chalard Jean
75d9e28a07 Resolve the endpoint in legacy VPN
This adds code to resolve the endpoint in the legacy VPN
runner if it was specified as a hostname, and enables the
previously added test that was disabled because this was
broken until this patch. See the linked bug for details.

This patch uses the async DNS API to do the resolution.
This lets the resolution be fully cancellable, though the
code is more complex than with the non-interruptible
getByName.

Test: VpnTest and in particular VpnTest#testStartRacoon
      Fixes the test meant to test this
      Also manual testing that resolution of a real
      hostname works as expected, that failure to resolve
      returns correctly, and that cancellation/interruption
      will unblock the thread and terminate immediately.
Bug: 158974172
Change-Id: I90bec6d85706fa9b2f9a01f81701138a54347005
Merged-In: I96691f6091c43377f23a00621242ed034fcb0444
(cherry picked from commit 8ab570d9c9eb5e52b2c038818e3e4d1d3b98fda0)
2020-08-07 06:43:22 +00:00
Chalard Jean
3103a6ee03 Add a test for starting the legacy VPN.
The legacy VPN has, among many parameters, a host to connect to.
This host can be specified as a numeric address, or as a hostname.
When it's a name, resolution is required. Currently, name
resolution is performed by the native VPN daemons racoon and
mtpd. When a hostname is used, the framework does not know the
IP address of the VPN server and does not add a throw route for
the VPN server IP address. On older kernels this does not matter
because the legacy PPP kernel code binds the PPP socket to the
right network, but on newer devices that use the upstream PPP
code, this does not work. See b/133797637.

This patch instruments the legacy VPN code so that it can be
run in tests, and uses this instrumentation to simulate passing
a configuration that contains a host, and verifies that the
arguments passed to the mptd and racoon daemons receive the
expected server address, and that the expected throw route is
correctly installed.
It then adds two tests : one specifying the server as a numeric
address, and one as a hostname. As the resolution is currently
broken, the latter of these tests is added disabled, and the
followup fix to the issue enables it.

This test is basic and very targeted, but it's what we need right
now. Also there are plans to remove this entire code path in S, so
the test being ad-hoc is not much of a problem.

Test: this
Bug: 158974172
Change-Id: I96f4bbb9b109e3e5813d083bed1989d88fb156b8
Merged-In: I3c4a94181bd71df68121fa0f71669fa4fa588bdd
(cherry picked from commit dece7f3f74cb67f2a046f3a2a9757b559abc2aac)
2020-08-07 05:11:43 +00:00
Lorenzo Colitti
7309c46403 Set the NetworkInfo subtype to 0. am: fd43392b25
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12246826

Change-Id: If570350574c5113763bb86943a27b9330db6b9ad
2020-07-28 18:05:12 +00:00
Lorenzo Colitti
fd43392b25 Set the NetworkInfo subtype to 0.
For non-telephony networks, this was always set to 0 before R.
In R, it is currently set to the same value as the network type.
This is incorrect because the two have different namespaces.
or example, currently, any network of type WIFI (==1) will have
a subtype of NETWORK_TYPE_GPRS (==1). Similarly, all ETHERNET
networks will have subtype NETWORK_TYPE_1XRTT, all VPN networks
will have a subtype of NETWORK_TYPE_TD_SCDMA, etd.

Bug: 161653721
Test: builds, boots
Change-Id: I07e111c1762e0021c931cefc27f193f78578748b
2020-07-28 09:20:19 +00:00
junyulai
478dc7584e Attribute data usage to virtual RAT type for 5G non-standalone mode am: 2774832382
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12166464

Change-Id: I77a3455318db44cf28ca4cfddf86a9767efe6302
2020-07-17 04:03:07 +00:00
junyulai
2774832382 Attribute data usage to virtual RAT type for 5G non-standalone mode
Test: atest NetworkStatsSubscriptionsMonitorTest#test5g
Bug: 160727498
Change-Id: I8753e68140c0993773017c9a49bd8a666a364071
Merged-In: I8753e68140c0993773017c9a49bd8a666a364071
(cherry-picked from ag/12167624)
2020-07-16 15:33:35 +08:00
Chalard Jean
8b0411b4f6 Merge "Add some more public doc for MacAddress" into rvc-dev am: 2ddb47fa19
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12107302

Change-Id: I2dedf3b86e1ecdb36ebfe67397de9664057fc786
2020-07-10 05:00:54 +00:00
Chalard Jean
9aa3127449 Add some more public doc for MacAddress
Bug: 140807677
Test: doc-only change
Original-Change: https://android-review.googlesource.com/1354447
Merged-In: I0f6e59eda42fd92ec34db0e9bc2d26d2e83d41d0
Change-Id: I0f6e59eda42fd92ec34db0e9bc2d26d2e83d41d0
2020-07-08 09:38:37 +00:00
Lorenzo Colitti
76c6bc4a0d Merge "Send ConnDiags event before revalidating network in CS." into rvc-dev am: 874dec6ba8
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12004847

Change-Id: I1562abb163e5ddf8a84bbac17d140d4fa1e54adf
2020-06-26 15:21:45 +00:00
Lorenzo Colitti
b9128f36a5 Send ConnDiags event before revalidating network in CS.
This change updates ConnectivityService to notify the
ConnectivityDiagnosticsHandler of app-reported connectivity before
attempting to revalidate the network. This change forces an ordering on
Connectivity Diagnostics events in the case that the reported
connectivity does not match the known connectivity for the network -
this leads to the network being revalidated and the
ConnectivityDiagnostics event onConnectivityReportAvailable. Passing the
onNetworkConnectivityReported event to the
ConnectivityDiagnosticsHandler first ensures that it is passed to
callbacks before any potential ConnectivityReports are.

Bug: 159718782
Test: android.net.cts.ConnectivityDiagnosticsManagerTest
Original-Change: https://android-review.googlesource.com/1350662
Merged-In: Ic7bc7138c54c47bbfdf56af5811709fde66f8606
Change-Id: Ic7bc7138c54c47bbfdf56af5811709fde66f8606
2020-06-26 07:59:04 +00:00
TreeHugger Robot
bfad35f93d Merge "Update DnsManagerTest for AIDL interface change" into rvc-dev am: 6ef23fb8f3
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11954238

Change-Id: I42c1a772b91c72c420a73e83d41f6f7769a1f972
2020-06-22 15:18:54 +00:00
TreeHugger Robot
6ef23fb8f3 Merge "Update DnsManagerTest for AIDL interface change" into rvc-dev 2020-06-22 15:09:54 +00:00
TreeHugger Robot
e6f13e706f Merge "Support DNS-over-TLS probes in NetworkDiagnostics" into rvc-dev am: 56e7d278a8
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11940428

Change-Id: Icb40fc91833cdcfb3c79303e4f08cabd60343242
2020-06-22 14:27:54 +00:00
TreeHugger Robot
56e7d278a8 Merge "Support DNS-over-TLS probes in NetworkDiagnostics" into rvc-dev 2020-06-22 14:15:40 +00:00
Ken Chen
8fb860bfe1 Update DnsManagerTest for AIDL interface change
Check one more parameter enforceDnsUid in ResolverOptionsParcel in
DnsManagerTest.

Bug: 159587277
Test: atest
com.android.server.connectivity.DnsManagerTest#testSendDnsConfiguration

Change-Id: Ic53f42b968626294c851dac252a70769846ba427
2020-06-22 21:44:07 +08:00
Lorenzo Colitti
643fbc8e47 Merge "Make PendingIntent immutable and correct Settings package name" into rvc-dev am: 1b7f9ca7d0
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11881938

Change-Id: Ibdf37115a43d5ebbc4e34b5668351916ee5671d1
2020-06-22 09:13:55 +00:00
Lorenzo Colitti
1b7f9ca7d0 Merge "Make PendingIntent immutable and correct Settings package name" into rvc-dev 2020-06-22 09:00:25 +00:00
Mike Yu
b6b7e0c2be Support DNS-over-TLS probes in NetworkDiagnostics
Probe DNS servers to see they support DNS-over-TLS. Use system
CAs to verify whether the certificates sent by DNS servers are
trusted or not. An error is thrown to cause the probe failed if
DNS servers send untrusted certificates.

Unlike the DnsResolver which doesn't verify the certificates
in opportunistic mode, all of the DoT probes from NetworkDiagnostics
check certificates.

DoT probes apply to the DNS servers gotten from LinkProperties
and the DoT servers gotten from PrivateDnsConfig whatever private
DNS mode is.

A common example in DNS strict mode:
.  DNS TLS dst{8.8.8.8} hostname{dns.google} src{192.168.43.2:48436} qtype{1} qname{815149-android-ds.metric.gstatic.com}: SUCCEEDED: 1/1 NOERROR (432ms)
F  DNS TLS dst{192.168.43.144} hostname{}: FAILED: java.net.ConnectException: failed to connect to /192.168.43.144 (port 853) from /192.168.43.2 (port 41770) after 2500ms: isConnected failed: ECONNREFUSED (Connection refused) (172ms)
.  DNS TLS dst{8.8.4.4} hostname{dns.google} src{192.168.43.2:37598} qtype{1} qname{759312-android-ds.metric.gstatic.com}: SUCCEEDED: 1/1 NOERROR (427ms)

An example when the CA is not trusted:
F  DNS TLS dst{8.8.8.8} hostname{dns.google}: FAILED: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. (16ms)

An example when TCP/TLS handshake timeout:
F  DNS TLS dst{8.8.8.8} hostname{dns.google}: FAILED: java.net.SocketTimeoutException: failed to connect to /8.8.8.8 (port 853) from /192.168.2.108 (port 45680) after 2500ms (2514ms)

Bug: 132925257
Bug: 118369977
Test: atest FrameworksNetTests
Original-Change: https://android-review.googlesource.com/1011670
Merged-In: I1b54abed0e931ca4b8a97149459cde54da1c3d6f
Change-Id: I1b54abed0e931ca4b8a97149459cde54da1c3d6f
2020-06-22 08:57:49 +00:00
paulhu
f2db66615d Make PendingIntent immutable and correct Settings package name
ConnectivityService puts up some notifications with pending
intents, but these pending intents are mutable that content can
be changed by someone. So make these pending intents to be
immutable.

Some OEMs have their own Settings package. Thus, need to get the
current using Settings package name instead of just use default
name "com.android.settings".

Bug: 154928507
Test: atest FrameworksNetTests
Change-Id: I02e3277358623400aa03dc8996af3d7c46a8ce76
2020-06-22 15:32:01 +08:00
Remi NGUYEN VAN
2b7046ac9b Merge "Move Inet[4]AddressUtils to libs/net" into rvc-dev am: 6e5b6b612d
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11846903

Change-Id: Ia5028f7dfeadbcf928efb9862b481c82e2849e18
2020-06-19 01:08:47 +00:00
Remi NGUYEN VAN
6e5b6b612d Merge "Move Inet[4]AddressUtils to libs/net" into rvc-dev 2020-06-19 00:49:29 +00:00
Lorenzo Colitti
5409cf46b5 Merge "Move DnsPacket to libs net" into rvc-dev am: 81f0fe48d2
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11862407

Change-Id: I74cac5c415d8b3447b57cda7cba1caa215e84ea2
2020-06-18 14:58:19 +00:00
Luke Huang
854adb51eb Merge "Disable sockets and DNS if process lacks INTERNET permission." into rvc-dev am: bbcd3b326b
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11881939

Change-Id: I10202dc784bafa044a04546d0a765370331223dc
2020-06-18 14:46:02 +00:00
TreeHugger Robot
9a0218f958 Merge "Set correct owner UID for VPN agentConnect()" into rvc-dev am: 65efcc84a0
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11869883

Change-Id: I84b0010488024aa9867ad4af7a4013854cdeeaa1
2020-06-18 14:34:45 +00:00
TreeHugger Robot
b3a9f82988 Merge "Treat RouteInfo with different interfaces as different routes" into rvc-dev am: 70e3f56147
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11882397

Change-Id: I4c96f81ba9118b545b69eb507333f09ea634bdf8
2020-06-18 14:29:52 +00:00
Lorenzo Colitti
81f0fe48d2 Merge "Move DnsPacket to libs net" into rvc-dev 2020-06-18 10:14:47 +00:00
Luke Huang
51221efa45 Move DnsPacket to libs net
This class might be used by some mainline modules.

Bug: 151052811
Test: atest DnsPacketTest
Test: atest DnsResolverTest
Change-Id: I8841d91456952ded5efbf8ea221289aecc7746ad
2020-06-18 16:17:04 +08:00
Luke Huang
bbcd3b326b Merge "Disable sockets and DNS if process lacks INTERNET permission." into rvc-dev 2020-06-18 03:03:06 +00:00