Commit Graph

7389 Commits

Author SHA1 Message Date
Chalard Jean
f01b2efc13 [NS A13] Move legacy broadcast handling after rematch.
As opposed to other patches in this series, there is a logic change
here. This will send all necessary legacy broadcasts after all
matches have been done.

This should be fine because the callbacks and the broadcasts are
unordered anyway, and the broadcasts are still sent in the same
order as before ; there should not be an observable change from
apps besides some jitter.

Bug: 113554781
Test: ConnectivityServiceTest
Change-Id: Ibeab8d0a9106c5198228888ac33084238c0a4a1a
2019-11-29 16:59:31 +09:00
Chalard Jean
61c79256b1 [NS A12] Move some legacy type tracker handling to a function
It's fine to do this out of the if() clause because :
• If the network newly satisfies a request it is sure to have
  it in the list of requests it satisfies
• If it does not newly satisfy a request and there is still
  a request with a legacy type that it satisfies, then it
  is already remembered by LegacyTypeTracker

As for the VPN, the code always enters the condition anyway.

Test: ConnectivityServiceTest
Change-Id: I8bd668ad27043d6a5036b1b3c52fa5a3146abcfa
2019-11-29 16:59:31 +09:00
Chalard Jean
0a2a20054d Add tests for ConnectivityService → BatteryStats messages
Test: ConnectivityServiceTest
Bug: 113554781
Change-Id: I7d3a16be76f606872f8edb84647b9ef94f36cba1
2019-11-29 16:59:30 +09:00
Aaron Huang
2193b07c21 Merge "Add IpConfiguration parcelable interface implementation to system API" 2019-11-28 09:56:58 +00:00
Aaron Huang
4c1dd06339 Add IpConfiguration parcelable interface implementation to system API
API lint robot warnings that parcelable requires writeToParcel
and describeContents.

Bug: 139268426
Bug: 135998869
Test: atest android.net.cts
      atest android.net.wifi.cts
      atest FrameworksNetTests
      ./frameworks/opt/net/wifi/tests/wifitests/runtests.sh

Change-Id: I7acf000c468788c3fdcb47f8601762e7804ab940
2019-11-28 07:25:40 +00:00
Treehugger Robot
cd46b46d51 Merge "BitUtils: support packing/unpacking negative long values" 2019-11-27 15:34:46 +00:00
Hugo Benichi
31270734a2 BitUtils: support packing/unpacking negative long values
Bug: None
Test: Compiled. New unit tests.
Change-Id: Ia543285e206b0bbc7d64458da10e68a951f9eec1
2019-11-27 11:00:32 +09:00
Chiachang Wang
4a41fe8072 Merge "Refactor based on new NetworkMonitor" 2019-11-26 10:52:33 +00:00
Chiachang Wang
bfb1ab4b02 Refactor based on new NetworkMonitor
Bug: 130325409
Test: atest NetworkStackIntegrationTests
Change-Id: I4426be339cb9990c05b3f4fb5666bd70bcd0f78e
2019-11-26 09:10:45 +08:00
Chalard Jean
a8e2afde61 Merge "[NS A11] Small refactor" 2019-11-25 08:55:19 +00:00
Paul Hu
0a6f03873a Merge "Fix hasUseBackgroundNetworksPermission issue." 2019-11-25 08:41:05 +00:00
Lucas Lin
fc8c834040 Merge "Fix title of PRIVATE_DNS_BROKEN notification when connecting VPN" 2019-11-25 08:14:09 +00:00
Treehugger Robot
5d6da8de07 Merge "Adjust PermissionMonitor#startMonitoring in ConnectivityService" 2019-11-24 15:21:43 +00:00
paulhu
9b2c01a7f0 Fix hasUseBackgroundNetworksPermission issue.
PermissionMonitor#hasUseBackgroundNetworksPermission only uses
the first package name of the uid for checking permission.
This is incorrect since each package declared different
permissions. So using the mApps which already checked both
network and using restricted network permissions. If uid is in
the mApps list that means uid has one of permission at least.

Bug: 135897744
Test: atest FrameworksNetTests
Change-Id: I3500a03ce06b5b822311ad0c67b606ce4039216a
2019-11-24 22:27:32 +08:00
Chalard Jean
3d59a27d1c Merge changes I195d894e,I7069c111
* changes:
  [NS A10] Cleanup
  [NS A09] Always rematch all networks to requests
2019-11-22 14:08:09 +00:00
Aaron Huang
c2df0b68c4 Merge "Expose IpConfiguration and ProxyInfo APIs" 2019-11-22 09:25:16 +00:00
lucaslin
784ca66669 Fix title of PRIVATE_DNS_BROKEN notification when connecting VPN
NetworkNotificationManager will only get the first transport
type from the NetworkCapabilities of network, and if the device
connects to a VPN and its underlying network is wifi, then the
first finding transport type will be TRANSPORT_WIFI. So, if the
private DNS is broken when device connected to VPN,
NetworkNotificationManager will try to get the SSID for the
title of notification but failed. For this kind of case, the
title of PRIVATE_DNS_BROKEN notification will show
"null has no internet access".

Bug: 143340533
Test: 1. Build pass.
      2. Connect to VPN and let private DNS to be broken, check
      title of PRIVATE_DNS_BROKEN notification.
      3. atest FrameworksNetTests

Change-Id: I1ed018cc8774d4fce4b94854f8e8703a28818463
2019-11-22 12:46:32 +08:00
Chalard Jean
f1df59afe3 Merge "Cut the dependency to APN constants" 2019-11-21 12:37:33 +00:00
Chalard Jean
3701fcd817 Merge changes I52f70756,Icc621f0a
* changes:
  [NS A08] Tiny refactoring
  [NS A07] Move the last side effects out of the decision loop.
2019-11-21 08:32:35 +00:00
Chalard Jean
afaed1a5e0 Cut the dependency to APN constants
With Telephony moving to Mainline these constants are not accessible
any more, and should not be made public. As they are only used by
a deprecated method that can only be called by apps with a target
SDK < M and only for one of the features it used to handle, copying
the constants until this method is completely removed is the simplest
way to go.

Test: FrameworksNetTests
Bug: 144454341
Change-Id: Iea18c8d2f2c8a40f04db9383d3f74b917267ba25
2019-11-21 14:48:00 +09:00
Meng Wang
138728da9a Merge "Use TelephonyManager instead of ITelephony Binder" 2019-11-21 04:36:10 +00:00
Meng Wang
ed6f441315 Use TelephonyManager instead of ITelephony Binder
Bug: 140908357
Test: make
Change-Id: If3be915329cc27c560af3fd71a903984a626aca8
2019-11-20 10:05:33 -08:00
Aaron Huang
fb8581aac0 Expose IpConfiguration and ProxyInfo APIs
Moving IpConfiguration methods to system API
for mainline support.

Public copy constructors of ProxyInfo and add
buildPacProxy(Uri, int) to create a new proxy
properties.

Bug: 139268426
Bug: 135998869
Test: atest android.net.cts
      atest android.net.wifi.cts
      atest FrameworksNetTests
      ./frameworks/opt/net/wifi/tests/wifitests/runtests.sh

Change-Id: I07bcd2a34a222ea2b3cf0d8b497f051011c41c2c
2019-11-20 20:07:05 +08:00
Chalard Jean
f5ff770f70 [NS A11] Small refactor
Test: ConnectivityServiceTest
Change-Id: I9c4247e0ed67c76d10575bd1a8fb5ff7780a1206
2019-11-20 20:42:41 +09:00
Chalard Jean
0a8afdae5d [NS A10] Cleanup
Reap networks after all networks have been rematched.

Bug: 113554781
Test: ConnectivityServiceTest
Change-Id: I195d894e702f1c738ea25596704ea73a3ae55031
2019-11-20 20:42:41 +09:00
Chalard Jean
b0b3bc6d3d [NS A09] Always rematch all networks to requests
This is a regression in performance but it is necessary for
the sake of refactoring ; when the refactoring is over, the
performance will be improved back.

Test: ConnectivityServiceTest
Change-Id: I7069c11193dccb7dce6af65cfb731c0f4ad93629
2019-11-20 20:42:40 +09:00
Chalard Jean
f728b7c91b [NS A08] Tiny refactoring
Test: ConnectivityServiceTest
Change-Id: I52f70756003cef61b450e9c1e9e57dc70f3091d5
2019-11-20 20:32:57 +09:00
Chalard Jean
ed295c52b2 [NS A06] Move more side effects out of the decision loop
This is a no-op.

Bug: 113554781
Test: ConnectivityServiceTest
Change-Id: I493b969c278097a289a1ef689ca268606227ae79
2019-11-20 20:32:57 +09:00
Chalard Jean
d56c485af9 [NS A07] Move the last side effects out of the decision loop.
This is a no-op. Reviewers : please scrutinize this for behavior
changes.

Test: ConnectivityServiceTest
Change-Id: Icc621f0a64a72dae0192843e6b6587ec4e31ea4d
2019-11-20 20:32:57 +09:00
Chalard Jean
1c75c2309a [NS A05] Move some side effects out of the network decision loop
This moves the side effects done by the decision loop when a
network stops satisfying a request to outside the decision loop.

Bug: 113554781
Test: ConnectivityServiceTest
Change-Id: I7b7594250d5c04362c699e065d30a1181effed09
2019-11-20 20:32:57 +09:00
Chalard Jean
a97b9c8fec [NS A04] Store changes in rematchNetworkAndRequests in a map
This is a preliminary change to move the code that chooses what
network gets assigned to what request out of ConnectivityService.

By storing the list of changes first, it becomes possible to move
the changes with side-effects to a later part of the code, after
the decisions have been made. This move is implemented in a later
change.

Bug: 113554781
Test: ConnectivityServiceTest
Change-Id: I60fe318a8eabf13d1c07b144367ca92cf07e734e
2019-11-20 20:32:56 +09:00
Chalard Jean
ef365c70c9 [NS A03] Remove mNetworkForRequestId
The goal of doing this is to remove the locks. Locking imposes
an ordering that is parallel to the program sequence ; often
it is what is needed, but the refactoring in progress needs to
change the traversal order of the requests without having
observable side-effects (or at least, very controlled ones).
The order is difficult enough to maintain when there is
only one. In this case, it is easy to remove the locks, and it
will simplify vastly the complexity of the refactoring by
removing the parallel ordering that would have to be maintained.

Bug: 113554781
Test: ConnectivityServiceTest
Change-Id: Ie4ae6a97053559e6cbac8230f2db3d35000b35a9
2019-11-20 20:32:45 +09:00
Chalard Jean
7c10ed5e9b Rename waitForConnectivityBroadcast
This doesn't wait, so it was ill-named.
Test: ConnectivityServiceTest

Change-Id: I15e5083f961e415b1d2d870e49c177fc84f0312c
2019-11-19 22:41:09 +09:00
Chalard Jean
dd8adb9866 [NS A02] Move the contents of mNetworkForRequestId to NRIs
The member will be removed in a subsequent change

Bug: 113554781
Test: ConnectivityServiceTest
Change-Id: I2379e47b1a97fb939b8558c01547d3d704f0f628
2019-11-19 22:41:09 +09:00
Chalard Jean
2c8b3e302f [NS A01] Add checks for the handler thread
This is a preliminary step to removing mNetworkForRequestId, whose
role could be better managed by storing the network inside the NRI.
This serves two purposes :
1. It is a sanity check. Those functions should never be called out
of the handler thread, and if they are it's a bug.
2. It will serve to prove the followup changes are correct.

Bug: 113554781
Test: ConnectivityServiceTest
Change-Id: If29066839ad640121d33f231abdd4f37d0ad3fd5
2019-11-19 22:41:09 +09:00
Chalard Jean
48127ba387 Merge "Add tests for the legacy broadcast" 2019-11-19 13:32:17 +00:00
Chalard Jean
4aa9d9d859 Add tests for the legacy broadcast
Test: this
Change-Id: I0777bf443f65d894eaab9b800db40c1caf6520fe
2019-11-19 21:08:44 +09:00
paulhu
c62d3c22df Adjust PermissionMonitor#startMonitoring in ConnectivityService
Let PermissionMonitor#startMonitoring() running in the beginning
of the ConnectivityService#systemReady() before
MultipathPolicyTracker.start(). Since mApps in PermissionMonitor
needs to be populated first to ensure that listening network
request which is sent by MultipathPolicyTracker won't be added
NET_CAPABILITY_FOREGROUND capability.

Bug: 135897744
Test: atest FrameworksNetTests
Change-Id: Ibef8e7b0017a77384630d34c9edc6c40875f773e
2019-11-19 17:55:31 +08:00
Roshan Pius
90a81fedc5 Merge "StaticIpConfiguration: Couple of minor fixes" 2019-11-18 15:05:31 +00:00
Jayachandran C
2092850198 Remove usage of Telephonymanager getDefault() and from() hidden APIs
This CL replaces with getSystemService(TelephonyManager.class)

Bug: 140768340
Test: atest frameworks/base/tests/net
Change-Id: I0f14cc5440fa85c81ab90f3199e9e91c1b00f5e1
2019-11-15 19:26:33 -08:00
Roshan Pius
32b898bb6d StaticIpConfiguration: Couple of minor fixes
a) Ensure the Builder.build() does not crash if setDnsServers() is not
invoked.
b) Add a checkNotNull on setDnsServers() since it is marked @NonNull.

Bug: 144487020
Test: Compiles
Change-Id: I2b9f990efa0583c0f067c25e23d8c944ffbdf6a5
(cherry-picked from d0348339c50eeae0fe137c62476f6a01542f4163)
2019-11-14 18:13:26 -08:00
Artur Satayev
96639a6e4e Add @UnsupportedAppUsage to test apis that are known to be used by apps.
go/testapi-enforcement

Bug: 133832325
Test: m
Change-Id: Ifc8db120640a1554dcbf1722e61e09c7ddc65dd6
Merged-In: Ifc8db120640a1554dcbf1722e61e09c7ddc65dd6
2019-11-13 15:05:56 +00:00
Remi NGUYEN VAN
732d7f96f3 Merge "Add permissions to NetIntegrationTests manifest" 2019-11-12 05:31:19 +00:00
Treehugger Robot
d57628bf9f Merge "Add @UnsupportedAppUsage annotations for greylist." 2019-11-11 14:27:47 +00:00
Treehugger Robot
f2016651b6 Merge "Add @UnsupportedAppUsage annotations for max-p." 2019-11-08 17:26:36 +00:00
Artur Satayev
56cb6bb2a9 Add @UnsupportedAppUsage annotations for greylist.
go/cleanup-greylist-txt

These have already been greylisted, however due to bugs/omissions in the tooling have been kept in go/greylist-txt instead of being annotated in the code.

Bug: 137350495
Test: m

Change-Id: Id6c1f5e403a0e66edb1102ee45f3bf19f244fb09
Merged-In: Id6c1f5e403a0e66edb1102ee45f3bf19f244fb09
2019-11-08 16:17:13 +00:00
Artur Satayev
8124713528 Add @UnsupportedAppUsage annotations for max-p.
See go/UnsupportedAppUsage for more details.

These have already been greylisted, however due to bugs/omissions in the tooling have been kept in go/greylist-txt instead of being annotated in the code.

Bug: 137350495
Test: m
Change-Id: I5aa29a49b193db47aaee4d3a756c17f48cc9f0b1
Merged-In: I5aa29a49b193db47aaee4d3a756c17f48cc9f0b1
2019-11-08 16:17:13 +00:00
Lucas Lin
bd692519f4 Merge "[NS01] Create NetworkScore" 2019-11-08 00:47:22 +00:00
lucaslin
17e9c67315 [NS01] Create NetworkScore
It's the first patch for refounding network selection. The new
network selection will try to compare the networks by more
factors, and will try to choose the best network after doing
the evaluation of trade-off.
Create the object that will serve to represent network quality
for more comprehensive ranking.

Bug: 143676287
Test: 1. Build pass.
      2. atest FrameworksNetTests

Change-Id: I4b6071d14365aa84d06be9802516fedf527e70f7
2019-11-07 16:47:56 +08:00
Remi NGUYEN VAN
c598529450 Add permissions to NetIntegrationTests manifest
As the TestNetworkStack target is updated not to use the complete
NetworkStackManifest to avoid including priv-app permissions and actual
service names, the missing permissions must be added to the
FrameworksNetIntegrationTests manifest.

Add the permissions and attributes that are necessary for the test, and
used to be merged from the TestNetworkStack library manifest.

Test: atest FrameworksNetIntegrationTests
Change-Id: I8b434e67f3a6c9141da71c6dfab1be77aa0f8411
2019-10-30 18:30:03 +09:00