Commit Graph

8311 Commits

Author SHA1 Message Date
Mohammad Samiul Islam
28829eb116 Merge changes from topic "fail-validation" into rvc-qpr-dev
* changes:
  Delete orphaned staging directories for staged session on reboot
  Clean up staged session data on validation failure
2020-12-07 16:31:22 +00:00
Lais Andrade
f9d9f7796b Add FakeSettingsProviderRule class
Bug: 166581675
Change-Id: Idf081e662aa218e93a38cd3262a1357e2e3faf0d
Merged-In: Idf081e662aa218e93a38cd3262a1357e2e3faf0d
2020-12-01 19:30:17 +08:00
Mohammad Samiul Islam
37daf1ba80 Delete orphaned staging directories for staged session on reboot
Bug: 173132101
Test: StagedInstallInternalTest#testOrphanedStagingDirectoryGetsCleanedUpOnReboot
Change-Id: If840f35245c2d049401d0d2f6539fe8c4625151e
Merged-In: If840f35245c2d049401d0d2f6539fe8c4625151e
(cherry picked from commit bfbf960801)
2020-11-16 15:20:24 +00:00
Mohammad Samiul Islam
f54412183a Clean up staged session data on validation failure
Bug: 173132101
Test: atest StagedInstallInternalTest#testStagedInstallationShouldCleanUpOnValidationFailure
Test: atest StagedInstallInternalTest#testStagedInstallationShouldCleanUpOnValidationFailureMultiPackage
Change-Id: Idd6597cd0d2dda34a8a7626b585401eeee39c31f
Merged-In: Idd6597cd0d2dda34a8a7626b585401eeee39c31f
(cherry picked from commit b6dde00d03)
2020-11-16 14:58:09 +00:00
Benedict Wong
360eba971e 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 0be82d4f4c)
2020-09-25 19:38:39 +00:00
JW Wang
3239fc9e93 Pass correct install user when creating sessions
This CL passes the correct install user when creating sessions in
StagingManager and effectively reverts ag/6901350.

Add a test to ensure b/129397974 is not regressed as described in
b/158222747#comment11.

(Cherry-picked from 838dea54ca)

Fix: 129744602
Fix: 158222747
Test: atest MultiUserRollbackTest#testStagedRollback
Merged-In: I718992240aa76898ff9e4220ea6a769ee8cd61f5
Change-Id: I718992240aa76898ff9e4220ea6a769ee8cd61f5
2020-09-16 07:17:47 +00:00
junyulai
6afd939ba5 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
Chalard Jean
002944f78e 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 8ab570d9c9)
2020-08-07 06:43:22 +00:00
Chalard Jean
c9e026f4e9 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 dece7f3f74)
2020-08-07 05:11:43 +00:00
junyulai
232afa51d9 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
JW Wang
f3a85cdee9 findNetworkStackApk returns an array of files (2/n)
This change handles the case of split APKs. All files starting with
"NetworkStack" will be returned as split APKs.

See b/159978937#comment6. NetworkStack is changed from a single APK to
split APKs. We need this change for install to succeed.

Bug: 159978937
Test: atest NetworkStagedRollbackTest
Change-Id: I20f5fee08ea208ba4dc7711d82a1718239c647c2
2020-06-29 16:16:10 +08:00
Winson
db6d1df791 Fix PackageManagerServiceHostTests disk usage
It seems adb shell stop/start has a bug with taking up disk
space. For now, use a full reboot of the device for each
test step.

This will double the already extremely long test time, so the
entire PackageManagerServiceHostTests module has been moved
to postsubmit, except for tests annotated @Presubmit, of which
there are none as of this change.

Bug: 159540015
Bug: 159256824

Test: atest PackageManagerServiceHostTests

Change-Id: I67da61cb02baa572fc298e6f617d6e53ec2c4724
2020-06-25 10:19:51 -07:00
Sudheer Shanka
74e4018f8b Merge "Correct the blobstore Session.openWrite() API usage in tests." into rvc-dev 2020-06-22 21:40:50 +00:00
TreeHugger Robot
9cf5156fed Merge "Verify staged session remain unchanged on system server reboot" into rvc-dev 2020-06-22 15:51:43 +00:00
TreeHugger Robot
ee9ca628ca Merge "Update DnsManagerTest for AIDL interface change" into rvc-dev 2020-06-22 15:09:54 +00:00
Mohammad Samiul Islam
f75619ecaf Verify staged session remain unchanged on system server reboot
Since rebooting system server requires root, we had to create a new
internal test suite with root access.

Bug: 158283778
Test: StagedInstallInternalTest#
      testSystemServerRestartDoesNotEffectStagedSessions
Change-Id: Id37111c0e63025aabe58cc9c8ab39b0362f1aed4
2020-06-22 15:12:11 +01:00
Ken Chen
125db20ee5 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
Mike Yu
1a5e45e37d 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
Sudheer Shanka
a2c2087f94 Correct the blobstore Session.openWrite() API usage in tests.
Fixes: 157204810
Test: atest --test-mapping apex/blobstore
Change-Id: Ic587da72c4018b15902b2b65307b112edc1c119e
2020-06-21 22:47:50 -07:00
Remi NGUYEN VAN
6555756e90 Merge "Move Inet[4]AddressUtils to libs/net" into rvc-dev 2020-06-19 00:49:29 +00:00
Lorenzo Colitti
db056d4043 Merge "Move DnsPacket to libs net" into rvc-dev 2020-06-18 10:14:47 +00:00
Luke Huang
c1a52b82c9 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
7144459282 Merge "Disable sockets and DNS if process lacks INTERNET permission." into rvc-dev 2020-06-18 03:03:06 +00:00
Luke Huang
6f214e8ebe Disable sockets and DNS if process lacks INTERNET permission.
This is a Client-only solution.
  - Add to NetdClient a per-process std::atomic_boolean
    similar to netIdForProcess and netIdForResolv.
  - The boolean says whether the process should be
    allowed Internet connectivity.
  - Add an @hide method to NetUtils.java to set the boolean;
    call it from the initialization code of the new
    process just after forking from zygote.
  - Make netdClientSocket and dnsOpenProxy check the
    boolean. If the boolean is false, return EPERM from
    socket calls.

Bug: 150028556
Test: atest NetworkUtilsTest
Test: atest CtsAppSecurityHostTestCases:UseProcessTest
Change-Id: If002280fbad493dfc2db3d9d505c0257d49a9056
Exempt-From-Owner-Approval: OWNERS already approved identical patchset 5
2020-06-18 03:02:06 +00:00
Treehugger Robot
2f2dab0158 Treat RouteInfo with different interfaces as different routes
On Android different interfaces usually use different routing tables.
As a result, a change in interface should not be treated as route
update, but rather a remove and an add.

This change fixes a bug in VPN seamless handover where routes
failed to be updated when a new tunnel interface replaces the existing
one within the same network.

Bug: 158696878
Test: atest com.android.cts.net.HostsideVpnTests
Test: atest NetworkStackTests
Test: atest CtsNetTestCases
Test: atest FrameworksNetTests
Original-Change: https://android-review.googlesource.com/1331916
Merged-In: I57987233d42a0253eaee2e1ca5f28728c2354620
Change-Id: I57987233d42a0253eaee2e1ca5f28728c2354620
2020-06-17 13:34:11 +00:00
Chiachang Wang
4d2791b1a6 Test extra info sent to NetworkMonitor
Test extra info sent to NetworkMonitor correctly if network
agent is created through new NetworkAgent constructor without
legacy network info taken as parameter.

Bug: 156173829
Test: atest FrameworkNetTests
Merged-In: I4f827664c528bea30cc957a0a617dd37693f4460
Change-Id: I4f827664c528bea30cc957a0a617dd37693f4460
2020-06-16 01:57:46 +00:00
Remi NGUYEN VAN
eee629f4c7 Move Inet[4]AddressUtils to libs/net
The classes should not be picked up from frameworks/base, as they are
part of several mainline modules.

Also refine comments in DhcpResults following feedback in previous
change.

Bug: 151052811
Test: m; manual: flashed, wifi and telephony working
Test: atest NetworkStackCoverageTests
Change-Id: I7074651c6a2a7a6b11bcf13cc4bb03833d7d655f
2020-06-12 17:04:06 +09:00
Aaron Huang
32f8a56636 Merge "Add unit test for NetworkStatsSubscriptionsMonitor" into rvc-dev 2020-06-12 01:58:59 +00:00
TreeHugger Robot
ab6c4a7685 Merge "Fix original-package support" into rvc-dev 2020-06-10 20:51:39 +00:00
Winson
af8399a682 Fix original-package support
This broke in P. Basic support was broken by a simple negation
issue with the logic that checks for the original package.

That, along with the suggestion in the bug to fix the renamed
package association means this should now work as expected,
carrying data over from a previous installed, differently named
package.

Bug: 131355130
Bug: 132749720
Bug: 111967720

Test: atest PackageManagerServiceHostTests

Change-Id: Ifc4c7af47c4b633cd27ba4a40b6baa0e27960d71
2020-06-10 10:34:43 -07:00
Lorenzo Colitti
50440f899e Merge "Update extra info before registering" into rvc-dev 2020-06-10 15:17:38 +00:00
Aaron Huang
e4e86e1cad Add unit test for NetworkStatsSubscriptionsMonitor
Bug: 154080205
Test: atest FrameworksNetTests:com.android.server.net.NetworkStatsSubscriptionsMonitorTest
Change-Id: I4ef3f1ab2e5ea1322133edd80db3ccd0022e9c91
2020-06-09 00:40:36 +08:00
Chiachang Wang
be7265d261 Update extra info before registering
The extra info is taken into NetworkMonitor from while creating
it. The NetworkMonitor is created when a new agent is registered
but the extra info is not available at that time. Make sure the
field is set in the NetworkInfo when registering.

Bug: 156173829
Test: adb shell dumpsys network and check the apn in the extra
      info shown correctly
Test: atest FrameworkNetTests
Merged-In: Ieaad8cbf1a28af3b97c7f98f74358e417fcad661
Change-Id: Ieaad8cbf1a28af3b97c7f98f74358e417fcad661
2020-06-05 01:46:06 +00:00
JW Wang
864d59ed70 Clean up rollbacks and test apps
See comment#6.

Clean up rollbacks and test apps before and after running tests.
This ensure we are in a good and expected condition when running tests.

Bug: 154080003
Test: atest RollbackTest
Test: atest MultiUserRollbackTest
Test: atest NetworkStagedRollbackTest
Test: atest StagedRollbackTest

Change-Id: If10fc8865e644611f1cf6a9db9d6dca6c7f11aee
2020-06-04 14:45:11 +08:00
Gavin Corkery
ac7b17b98d Unbind explicit health check controller when possible
Ensure that calls to sync requests with the explicit health
check controller are always sent if the list of packages
pending health checks is empty, so that the controller can
unbind. This will allow extservices to be killed by lmkd
on low memory devices.

Test: atest PackageWatchdogTest
Test: atest NetworkStagedRollbackTest
Test: check logcat to see that the service is unbound
Bug: 156323728
Change-Id: If615a337760b2057b962284bde8565b593d82a50
2020-06-01 23:11:07 +01:00
JW Wang
be052c6abe Merge "Add tests for snapshot-deletion (2/n)" into rvc-dev 2020-05-30 13:17:56 +00:00
Benedict Wong
c5401ef015 Merge "Add RequiresFeature annotations for IKEv2 VPN profiles" into rvc-dev 2020-05-29 17:17:10 +00:00
Gavin Corkery
4f5af837be Merge "Revert "Ensure that health check controller is unbound correctly"" into rvc-dev 2020-05-29 12:02:55 +00:00
Gavin Corkery
64201f9d9c Revert "Ensure that health check controller is unbound correctly"
This reverts commit 553c94bcab.

Reason for revert: Breaks NetworkStagedRollbackTest. Will re-submit change once I have a fix for that issue
Bug: 157662759
Change-Id: If81c01c597f37ff01924c8b038cbd38f77e7fa06
2020-05-29 10:25:35 +00:00
JW Wang
e90db5aba3 Add tests for snapshot-deletion (2/n)
1. Document behavior changes due to ag/11475396
2. Test snapshots are deleted after restoration

See go/rollbackmanager-snapshot-deletion for more details.

Bug: 151805360
Test: atest StagedRollbackTest

Change-Id: Ia8993f82073a145889243bcefc74b6336bf71749
2020-05-29 15:49:54 +08:00
Automerger Merge Worker
891ee84b99 Adjust tests for renaming groupHint to cluster.
Bug: 146460486
Test: atest android.net.IpMemoryStoreTest
Test: atest com.android.server.connectivity.ipmemorystore.IpMemoryStoreServiceTest
Change-Id: Ia9797bb93aa4ff89147a77823d342dc22aec6a25
Merged-In: I69f7a2971cc5985d0f0078aecc39d4d6a6130033
(cherry-picked from aosp/1311654)
2020-05-29 02:28:59 +00:00
Benedict Wong
29d6412115 Add RequiresFeature annotations for IKEv2 VPN profiles
This change adds the @RequiresFeature annotation to Ikev2VpnProfile
Builder methods, and checks before provisioning VPN profiles.

Bug: 156681625
Test: New tests added, passing.
Change-Id: I125d8fbe5d67fb877ad7d0636c007cb3e1a9f59b
Merged-In: I125d8fbe5d67fb877ad7d0636c007cb3e1a9f59b
(cherry picked from commit e84a17dd17)
2020-05-28 19:07:29 -07:00
Maciej Żenczykowski
b2603a3193 NetworkStats: apply464xlatAdjustments - don't remove CLAT_UID
This should no longer be needed after all the cleanups.

Test: atest NetworkStatsTest NetworkStatsFactoryTest
Bug: 150738490
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I289d935f84b616ed857ef4c5a7427d57c282d00c
Merged-In: I289d935f84b616ed857ef4c5a7427d57c282d00c
2020-05-28 02:44:20 -07:00
Maciej Żenczykowski
d09cef39c5 NetworkStats: apply464xlatAdjustments - remove useBpfStats parameter.
Test: atest NetworkStatsTest NetworkStatsFactoryTest
Bug: 150738490
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0121a4ac7ee824adc5930bab786d550b2f00b05b
Merged-In: I0121a4ac7ee824adc5930bab786d550b2f00b05b
2020-05-28 02:44:10 -07:00
Maciej Żenczykowski
e07aa4a466 fix com.android.server.net.NetworkStatsFactoryTest#testDoubleClatAccounting100MBDownload
No clat app uid 0 rx stats on base iface due to ip6tables raw prerouting drop

(so just copy over the rx stats from the before file)

Test: atest NetworkStatsTest NetworkStatsFactoryTest
Bug: 150738490
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie73ba0586dafde67bc2726db26e07f7268c18be3
Merged-In: Ie73ba0586dafde67bc2726db26e07f7268c18be3
2020-05-28 02:44:02 -07:00
Maciej Żenczykowski
c9e6605320 fix com.android.server.net.NetworkStatsFactoryTest#testDoubleClatAccounting
No clat app uid 0 rx stats on base iface due to ip6tables raw prerouting drop

Test: atest NetworkStatsFactoryTest
Bug: 150738490
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4393afcbe8e1bb886ecf4f5c1573f6ac8a0e29f5
Merged-In: I4393afcbe8e1bb886ecf4f5c1573f6ac8a0e29f5
2020-05-28 02:43:53 -07:00
Maciej Żenczykowski
68d998de26 fix com.android.server.net.NetworkStatsFactoryTest#testDoubleClatAccountingSimple
No clat app uid 0 rx stats on base iface due to ip6tables raw prerouting drop

Test: atest NetworkStatsFactoryTest
Bug: 150738490
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ifebd946e06b5fa2eeb7ff4fc0b1c423097021692
Merged-In: Ifebd946e06b5fa2eeb7ff4fc0b1c423097021692
2020-05-28 02:43:44 -07:00
Maciej Żenczykowski
6affb9bb01 fix android.net.NetworkStatsTest#testApply464xlatAdjustments
Test: atest NetworkStatsTest
Bug: 150738490
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib12ee88295eb502f6da13d212b4fd6298dea380f
Merged-In: Ib12ee88295eb502f6da13d212b4fd6298dea380f
2020-05-28 02:43:33 -07:00
Sudheer Shanka
7e24d133d0 Merge "Don't allow expired blobs to be accessed." into rvc-dev 2020-05-27 20:10:04 +00:00
Sudheer Shanka
8992c0514f Don't allow expired blobs to be accessed.
Bug: 147722548
Test: atest --test-mapping apex/blobstore
Change-Id: I7294124ba5ce3dcf42a0e7e9858311b1604ae185
2020-05-27 11:41:34 -07:00