Commit Graph

1349 Commits

Author SHA1 Message Date
Hansen Kurli
edbf34a182 Merge "Add unit tests checking MTU of interfaces are set." 2022-12-13 07:01:19 +00:00
Paul Hu
d78cda2ba8 Merge changes Icd842479,I2206a846
* changes:
  Add MdnsInterfaceSocket and MdnsSocketProvider
  Put the Network info in MdnsServiceInfo
2022-12-12 08:16:23 +00:00
Paul Hu
2f1de80315 Add MdnsInterfaceSocket and MdnsSocketProvider
MdnsInterfaceSocket: using for listening the multicast
socket on specific interface.

MdnsSocketProvider: using for creating and managing the
multiple multicast sockets.
- Listen NetworkCallback and TetheringEventCallback to know the
  network connected / disconnected changes. And use the callbacks
  to create / remove the sockets for mdns discovery

Bug: 254166302
Test: atest FrameworksNetTests
Change-Id: Icd8424792e89e71198fa31f9ec92e1ec8172128d
2022-12-12 08:15:38 +00:00
Hansen Kurli
3597deb5e1 Merge "Disconnect network when captive portal returns unwanted." 2022-12-12 06:43:01 +00:00
Paul Hu
9e53b630c5 Put the Network info in MdnsServiceInfo
In Nsd, every request has Network info to assign the specific
network to do the mdns query. But the response MdnsServiceInfo
only has interface index which is not very useful and need to
transfer to a Network every time when using it because most
APIs for apps to use the network are based on Network object.
Thus, put the Network info into MdnsServiceInfo.

Bug: 254166302
Test: atest FrameworksNetTests
Change-Id: I2206a84636981fc7d9aa9deda0f18f60642bc7d7
2022-12-09 14:42:44 +08:00
Hansen Kurli
8d267d8998 Add unit tests checking MTU of interfaces are set.
Unit tests covering the different possible cases of calls to updateMtu.

Bug: 246398088
Test: atest ConnectivityServiceTest
Change-Id: Iced44c00e9dbe944c3a31bbf1da88f8077e4379a
2022-12-08 12:00:35 +00:00
Lucas Lin
dc824e95de Merge "Verify that the underlying network info will be cleared/sent or not" 2022-12-08 05:30:47 +00:00
Lucas Lin
678113ade7 Merge "Correct the test design for network lost case" 2022-12-08 03:25:05 +00:00
lucaslin
d1938dffce Verify that the underlying network info will be cleared/sent or not
Add some checks to verify that the underlying network info will
only be cleared when the underlying network is lost, or will only
be sent when the category is not CATEGORY_EVENT_DEACTIVATED_BY_USER
and CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED.

Bug: 237050331
Test: atest FrameworksNetTests:VpnTest
Change-Id: Ifc66658cf59481c4a9804e6933be1048f758b698
2022-12-07 09:47:38 +00:00
lucaslin
0b915e2012 Correct the test design for network lost case
For network lost case, the process should be triggered by calling
onLost() instead of triggering onClosedWithException() directly.

Bug: 237050331
Test: atest FrameworksNetTests:VpnTest
Change-Id: I32781d4ac96ee8212d1fd7ba23009293f72b442e
2022-12-07 09:42:22 +00:00
Paul Hu
3b1703007e Merge "Add onServiceNameDiscovered/onServiceNameRemoved" 2022-12-07 02:00:33 +00:00
Mark Chien
7e60552183 Merge "Increased the timeout from 5 to 30 seconds" 2022-12-06 14:53:44 +00:00
Paul Hu
0ee75422c9 Add onServiceNameDiscovered/onServiceNameRemoved
Add onServiceNameDiscovered method which is used to listen the
discovery callbacks. It would be called once the service is found
even the response is incomplete. This is different from
onServiceFound which needs to receive a complete response.

onServiceNameRemoved is used for service removal if received
response is incomplete.

Bug: 254166302
Test: atest FramworksNetTests
Change-Id: I03313b045d74bb65f7fe6ac93673f02ce3b2c664
2022-12-06 10:29:26 +00:00
Mark Chien
82eb31b346 Increased the timeout from 5 to 30 seconds
Increase the timeout to deal with the flaky test.

Bug: 260073439
Test: TH

Change-Id: I653d80cfa97256e139f8cf989a085b1133732092
2022-12-06 06:51:03 +00:00
Thiébaud Weksteen
b865214380 Merge "Relocate NetworkManagementServiceTest to framework" 2022-12-06 05:57:00 +00:00
Thiébaud Weksteen
11490a1474 Relocate NetworkManagementServiceTest to framework
Bug: 259341026
Test: TH
Change-Id: Ie06d906fa8bc65d6af3511280bc01b2859edde79
2022-12-05 14:48:44 +11:00
Paul Hu
536cc4d102 Fix empty value problem in the TextEntry
Now, the value in TextEntry would be a zero length byte array if
the text record response doesn't contain the value. The problem
is that the value could either be an empty string ("key="), or
there can be no value ("key"), as per rfc6763 6.4 "If there is
no '=' in a DNS-SD TXT record string, then it is a boolean
attribute, simply identified as being present, with no value.".

Bug: 254166302
Test: atest FramworksNetTests
Change-Id: I4eaa5e593ce9ddaa6b6cb2f069c1aef977910796
2022-12-05 02:18:34 +00:00
Treehugger Robot
841b1f33d5 Merge "Revert consider TEMPORARILY_NOT_METERED as unmetered in data usage" 2022-12-02 11:27:27 +00:00
Aaron Huang
c5a05d1d8f Revert consider TEMPORARILY_NOT_METERED as unmetered in data usage
Currently, NET_CAPABILITY_TEMPORARILY_NOT_METERED traffic is
counted as unmetered data usage, and "mobile data usage"
settings screen shows metered data usage which means it doesn't
include TEMPORARILY_NOT_METERED traffic. However, some carriers
show TEMPORARILY_NOT_METERED data usage in customer's bill which
would be confusing if the data usage in the device shows different
results. Thus, revert the change to avoid confusing.

Bug: 183776809
Test: FrameworksNetTests
Change-Id: I4ef25095462adf30b1ecf82134996739f167930d
2022-12-02 16:04:55 +08:00
Aaron Huang
b4b8198b89 Merge "Make mMatchSubscriberIds as a NonNull variable" 2022-12-02 03:08:14 +00:00
Paul Hu
79e239eacb Merge "Send MdnsServiceInfo on onServiceRemoved callback" 2022-12-02 01:33:40 +00:00
Aaron Huang
859884a48f Make mMatchSubscriberIds as a NonNull variable
In current design, mMatchSubscriberIds can be null which has the
same meaning with empty set, and is not easy to maintain since it
need more checks for this variable when mSubscriberId is null.
Thus make mMatchSubscriberIds NonNull for the maintenance.

Bug: 238843364
Test: build, FrameworksNetTests
Change-Id: I6cfc529b5f4a39ded8598283ff968f2f4d1bc89f
2022-11-30 16:38:24 +00:00
Aaron Huang
a8a6da0db9 Remove unused methods from NetworkTemplate
NetworkTemplate.Builder was introduced in Android T and the callers
outside of Connectivity module should use this Builder to build a
template instead. Thus remove the buildTemplate* methods from
NetworkTemplate class. Also, deprecate the methods which are
annotated with @UnsupportedAppUsage and also use Builder to build
the template.

Bug: 238843364
Test: build, FrameworksNetTests
Change-Id: I3190325f6663e4771edf5c7a19bf5ecc7780bf12
2022-11-30 16:38:19 +00:00
Paul Hu
039d8111e0 Send MdnsServiceInfo on onServiceRemoved callback
Send MdnsServiceInfo on onServiceRemoved callback which include
service name, service type and other info instead of service name
only. These extra info is necessary for service lost callback on
NsdService on the following changes.

Bug: 254166302
Test: atest FrameworksNetTests
Change-Id: Ibacbef4b893209bbc2a37376bf26d713ce41429c
2022-11-29 11:51:16 +08:00
Paul Hu
562cdacfee Merge changes from topic "PermissionMonitorOnHandlerThread"
* changes:
  Add synchronized to UidRange getter and dump methods
  Deal with permission update on handler thread
  Running PermissionMonitor#startMonitoring on handler thread
2022-11-23 02:59:17 +00:00
Paul Hu
51f816be4a Deal with permission update on handler thread
To ensure that permission cannot change while CS is doing works,
scoring networks, sending callbacks, etc. So making all
permission update are running on handler thread.

Bug: 232048835
Test: FrameworksNetTests CtsNetTestCases
Change-Id: I5380ec8ff1282a1056d9063848e0fff8b3a570ec
2022-11-22 07:18:36 +00:00
Remi NGUYEN VAN
a814e9c364 Merge "Wait for launcher is shown after calling pressHome" 2022-11-22 07:06:16 +00:00
Aaron Huang
2c07b827e7 Wait for launcher is shown after calling pressHome
In current code, the test will call pressHome before show
network notification but it does not verify the home screen
is shown. The test might be failed due to the notification
shade is still opened. Thus adding an assertion to verify
the launcher is shown.

Bug: 255643296
Test: FrameworksNetTest:NetworkNotificationManagerTest
Change-Id: Iee3476a26030b9ba72994dee624e0e6974c9369f
2022-11-21 10:47:58 +00:00
Treehugger Robot
adb9c9e83a Merge "Refactor CarrierPrivilegeAuthenticatorTest" 2022-11-18 12:05:53 +00:00
Chiachang Wang
dfea18945c Merge "Move VpnTransportInfoTest to common test" 2022-11-18 05:44:20 +00:00
chiachangwang
91bac1953c Move VpnTransportInfoTest to common test
Move VpnTransportInfoTest to common test to add the cts
coverage.

Annotate @ConnectivityModuleTest so that the test will
not fail with module that is not up-to-date, and use
assertParcelingIsLossless to prevent similar order module
in device case.

Bug: 256775913
Test: atest CtsNetTestCases:android.net.VpnTransportInfoTest
Change-Id: I1c40a4fc42468748d71c3df5c18b2ceb5b3769e1
2022-11-18 02:17:33 +00:00
Remi NGUYEN VAN
0f92b69af7 Merge "Add MdnsNsecRecord" 2022-11-17 08:00:15 +00:00
Remi NGUYEN VAN
b683dfcea5 Merge changes I0f8e6590,I61a1bb91
* changes:
  Add MdnsAnyRecord
  Add constructors to MDNS records
2022-11-16 09:12:57 +00:00
Remi NGUYEN VAN
3ce3a4a9ca Add MdnsNsecRecord
NSEC records are included as mDNS negative responses, as per
RFC6762 6.1.

Bug: 241738458
Test: atest
Change-Id: I1546a2c10447ad46321f595b714c7ee7f6dc34c7
2022-11-16 15:57:30 +09:00
Chiachang Wang
b7577c6d42 Merge "Verify bypassability in the VPN network capabilities" 2022-11-16 05:57:00 +00:00
Treehugger Robot
b6f2a3e587 Merge "ethernet: consolidate interface enabling functions in EthernetTracker" 2022-11-16 05:51:42 +00:00
Remi NGUYEN VAN
e8d3e6d58c Add MdnsAnyRecord
The record is useful for mDNS questions in mDNS probes.

Bug: 241738458
Test: atest
Change-Id: I0f8e659048b6e1d7c3ae1640fbd2d57d723ea9b1
2022-11-16 14:40:47 +09:00
Chalard Jean
23890c29c5 Refactor CarrierPrivilegeAuthenticatorTest
Refactor this test to make it easier to test the no-op
refactoring coming as a follow-up

Test: this
Change-Id: I47c81bdec2b8f9575835ba664b61721d5f2c69ff
2022-11-15 19:27:56 +09:00
chiachangwang
d0a2805616 Verify bypassability in the VPN network capabilities
Bug: 256775913
Test: atest FrameworksNetTests
Change-Id: I6600714e5fc7c5d78fa7b8bb29c0c8840ec69637
2022-11-15 05:36:24 +00:00
Chiachang Wang
89d4bda742 Merge "Expose vpn bypassability in VpnTransportInfo" 2022-11-15 05:35:08 +00:00
Junyu Lai
c1294c2584 Merge "Remove unnecessary permission mock for registerSystemDefaultNetwork" 2022-11-15 02:23:39 +00:00
Aaron Huang
ac28a04c6e Merge "Enhance NetworkTemplate test" 2022-11-14 09:38:27 +00:00
Hansen Kurli
553969769d Disconnect network when captive portal returns unwanted.
When the user selects "Do not use this network" in the captive portal
app, it indicates that the user does not want to log in and does not
want to use the network. Thus, the network should be disconnected.

Internally handle the network disconnect in ConnectivityService upon
receiving a captive portal app response of APP_RETURN_UNWANTED.

Test: atest ConnectivityServiceTest
Change-Id: I789ddb663b533a71a77ed435fa91b0c20d3bbfd4
2022-11-14 03:42:32 +00:00
chiachangwang
d12d2011cb Expose vpn bypassability in VpnTransportInfo
Bug: 256775913
Test: m framework-connectivity.stubs.source.system-update-current-api
Test: m lint-check
Test: atest FrameworksNetTests
Change-Id: I6aaad7b4372aa4f91df4bed89caea674031a6367
2022-11-11 08:38:17 +00:00
Treehugger Robot
0448f36d60 Merge "[Feature sync] Resolve class-level nullness suppression" 2022-11-10 13:53:31 +00:00
Treehugger Robot
016269fbb8 Merge "Revert "Partially enforce permission when calling getNetworkInfoForUid"" 2022-11-10 12:13:56 +00:00
Junyu Lai
d0cf7784dc Revert "Partially enforce permission when calling getNetworkInfoForUid"
This reverts commit 163cb98751.

Reason for revert: b/257407201

Change-Id: I412140117d25f4a4b439fff5aaa50785f33b0689
2022-11-10 03:19:06 +00:00
Paul Hu
6c74a13512 [Feature sync] Resolve class-level nullness suppression
This is a chery-picked commit from internal branch which is to
add nullability to reslove the nullness suppression.

Bug: 242631897
Bug: 254155029
Test: atest FrameworksNetTests
Change-Id: I289b0408c0c4ccdefc498d3b6d3f381c2b04132e
2022-11-10 01:57:46 +00:00
Maciej Żenczykowski
82a4e0a42e Merge "ipsec - use ro.vendor.api_level instead of ro.product.first_api_level" 2022-11-09 22:38:36 +00:00
Paul Hu
b800e5903b Merge "[Feature sync] Fix issue where multiple SRV records with same host are not fully resolved" 2022-11-09 06:38:22 +00:00