Commit Graph

1419 Commits

Author SHA1 Message Date
Cody Kesting
ed459f5f1a Merge "Protect ConnectivityService from SecurityException in permission check." 2020-03-16 14:33:25 +00:00
junyulai
cc38304ad8 [SP24] Rename functions that add Entry unconditionally
Currently, in NetworkStats, there are many methods to manipulate
the records. However, some methods are similar and ambiguous,
such as addEntry, addValues, setValues, addIfaceValues,
combineValues and combineAllValues.

Thus, properly grouping and renaming methods are necessary.
In this change, for methods that add one record unconditionally,
name them insertEntry.
  setIfaceValues -> insertEntry
  addEntry -> insertEntry

Test: atest FrameworksNetTests ImsPhoneCallTrackerTest TetheringTests
Test: m doc-comment-check-docs
Bug: 148895143
Change-Id: I801ddc49e283a254b9586700c9b597c0adb0d459
2020-03-16 14:27:45 +08:00
Junyu Lai
24ab7411ba Merge "[SP21] Address comments for API council review about aosp/1172143" 2020-03-16 02:41:19 +00:00
Automerger Merge Worker
b0b8333e82 Resolve ambiguous argument.
CTS tests don't have access to TestNetworkAgent and therefore
require overloading this method, which means 'null' is ambiguous.

Bug: 139268426
Test: FrameworksNetTests
Change-Id: I5d7deea82d7114fa38f37b90f94fe7e6073bd848
(cherry picked from commit ff83f1d7eea38c4143869cbf10dca5972421f6cd)
2020-03-15 12:56:05 +00:00
Chalard Jean
16cad96e9f Merge "Resolve ambiguous argument." 2020-03-14 03:38:01 +00:00
Cody Kesting
417004a722 Merge "Clear UIDs when sharing NetworkCapabilties for ConnectivityDiagnostics." into rvc-dev 2020-03-13 18:44:50 +00:00
Chalard Jean
a7cc6d8eee Resolve ambiguous argument.
CTS tests don't have access to TestNetworkAgent and therefore
require overloading this method, which means 'null' is ambiguous.

Bug: 139268426
Test: FrameworksNetTests
Change-Id: I9279718bde30bd98eff901921fb3411d22da72e5
2020-03-13 21:17:33 +09:00
Treehugger Robot
62b8d6f24d Merge "Remove redundant connected notification" 2020-03-13 07:10:13 +00:00
Lorenzo Colitti
487b677f3a Ensure that NetworkFactory objects cannot be reused.
NetworkFactory is turning into a one-time object that cannot be
re-used. Check for this in ConnectivityService.

Bug: 148635501
Test: test continues to pass
Change-Id: I793436ee0f4b5d778788ad34b8a2575d2ad0ed80
2020-03-13 15:51:56 +09:00
junyulai
0c88795cb5 [SP21] Address comments for API council review about aosp/1172143
Test: atest FrameworksNetTests ImsPhoneCallTrackerTest
Test: atest TetheringTests NetworkStackTests
Test: m doc-comment-check-docs
Fix: 148552904

Change-Id: I141393f229e772d2eb9f7c156849e379bd71b845
2020-03-12 21:34:17 +08:00
paulhu
27ca44913a Kill ConnectivityManager.CONNECTIVITY_ACTION_SUPL
CONNECTIVITY_ACTION_SUPL is marked as a "temporary hack" and has
never been public. Remove this intent definition since no one is
receiving this intent and should use network callback to know the
connection change.

Bug: 109636544
Test: atest FrameworksNetTests
Change-Id: Ie9e5127742beba04f1c191e894e8a29fe1e704bb
2020-03-11 22:14:11 +08:00
Benedict Wong
b645699cdb Add tests for Tunnel, Transport mode application with released SPIs
This change adds tests to validate that both transport and tunnel mode
transforms continue to work even after the SPI resource has been
released. Specifically, since SPI resources are effectively subsumed by
the creation of a Transform, the SPI resource is still "alive", but
removed from the user-tracking sparse arrays.

Bug: 142072071
Test: Added these new tests. Failing prior to aosp/1133555, passes with.
Change-Id: I37dd459d08b57b14f72f3b28ea80fa231b152f10
2020-03-11 07:12:07 +00:00
Cody Kesting
807ce6621b Clean up unit testing for ConnectivityDiagnostics.
Connectivity Diagnostics included an unnecessary try-catch for verifying
that the permissions check for invoking ConnectivityDiagnosticsCallbacks
doesn't throw when the uid and package name do not match.

Bug: 149119324
Test: atest FrameworksNetTests
Change-Id: Ie302b1f4f437e819fdd15ec28adb0b56750c2c53
2020-03-10 23:27:01 -07:00
Lorenzo Colitti
f25e167d93 Merge "Merge NetworkStatsService handler changes." into rvc-dev 2020-03-11 06:19:18 +00:00
Benedict Wong
feff1cde9a Automatically set IPsec tunnel interface as up
This change makes IPsec tunnel interfaces automatically get brought up
once they are created. Originally this was considered to be an
additional safety check, as they would not be start routing traffic
until explicitly brought up. However, in the intervening time, the
NetworkManagementController now requires the NETWORK_STACK permission to
set an interface as up. Additionally, that call is a hidden API, and
thus not usable for use cases such as IWLAN.

Bug: 149348618
Test: FrameworksNetTests, CtsNetTestCases passing.
Change-Id: I55b63a748463a388e1e2991d2d5d6b3023545e60
2020-03-10 23:08:16 -07:00
Tyler Wear
e4314861e3 mtu: Add MTU parameter to Routes
- Change route to update existing route
- MTU parameter added to AddRoute

Bug: 142892223
Test: unit test
Change-Id: Ie339d0cee5be12c2232a4631fed61219a0facc64
2020-03-11 13:33:10 +08:00
Lucas Lin
ea7800cb54 Merge "Remove redundant connected notification" into rvc-dev 2020-03-10 02:21:07 +00:00
Cody Kesting
a830439b37 Protect ConnectivityService from SecurityException in permission check.
ConnectivityService currently calls
LocationPermissionChecker#checkLocationPermission. This method call
throws a SecurityException if the given package name and UID do not
match. This permission check is made from the ConnectivityService
Thread, so any Exception being thrown will crash the SystemServer. This
is not acceptable, so surround the permission check in a try-catch in
case any SecurityExceptions are thrown.

Bug: 149119324
Test: atest ConnectivityServiceTest
Change-Id: Ibe2874f2a5249432270aa1b9eb7d004bbba35ac2
2020-03-09 11:27:00 -07:00
Cody Kesting
5f3c53a268 Clear UIDs when sharing NetworkCapabilties for ConnectivityDiagnostics.
ConnectivityDiagnostics shares NetworkCapabilities in
ConnectivityReports and DataStallReports. These NetworkCapabilities need
to have their UIDs scrubbed before they are shared with callbacks.

Bug: 148942124
Test: atest FrameworksNetTests
Change-Id: I5bde5a8116f7e36b8f4de49adf4cab8ec45a5aa4
Merged-In: I5bde5a8116f7e36b8f4de49adf4cab8ec45a5aa4
(cherry picked from commit 3de243265558fb5505b4daabe715a5090104450f)
2020-03-09 08:27:10 -07:00
Cody Kesting
42fbfe8826 Merge "Clear UIDs when sharing NetworkCapabilties for ConnectivityDiagnostics." 2020-03-09 15:12:51 +00:00
Automerger Merge Worker
911106c17c Merge NetworkStatsService handler changes.
=====
Remove the need of accessing handler in NSS unit test

Currently, to wait for handler becomes idle, specific message
is used and the test would wait for condition variable to be
open when the message is processed.

However, this is already done in the HandlerUtils. Thus,
there is no need to post such message manually in the handler.

Test: atest FrameworksNetTests
Bug: 150664039

Change-Id: Iab32b2dbab01634ca159dcb90fc9f929d1fed1a2
=====
Remove setHandler in NetworkStatsService

Currently, internal handler is set by setHandler after
constructing NSS object. This was introduced in ag/866187 to
access the handler in the unit test.

However, the design put NSS in a bad situation where all classes
that need handler or executor could not be final and need to be
dynamically allocated in order to get a valid handler.

Thus, since the usage of handler is removed in previous patch,
this change eliminate setHandler by initializing the handler in
the constructor.

Test: atest FrameworksNetTests
Bug: 150664039

Change-Id: I794a24d00b0ca9fdc78091e7b9ab7307e0f034b7
=====

Bug: 150664039
Change-Id: If256ed4437ddcbcc72a6f766cff2f4cc512ee3f7
Merged-In: If256ed4437ddcbcc72a6f766cff2f4cc512ee3f7
(cherry picked from commit 2a6439d7e2a3926e10a0b9a4dc730b1a022d8138)
2020-03-09 07:59:27 +00:00
Chalard Jean
e34d090bce Merge "Remove the NetworkScore class." into rvc-dev 2020-03-09 05:54:30 +00:00
Automerger Merge Worker
e58e7a4d85 Add more assertions to testStackedLinkProperties.
Check all routes that are added and removed instead of just some
of them. This is in preparation of an upcoming change that
switches to adding and creating routes by issuing direct calls to
netd.

Also rename the misleading ipv4Default route variable to
ipv4Subnet, which is what it actually is.

Bug: 142892223
Test: test-only change
Change-Id: I7d111382be215a926a7d7d4701bd3c3e94372b99
Merged-In: I7d111382be215a926a7d7d4701bd3c3e94372b99
(cherry picked from commit dcb35cb9a5d1c250e6564b6e66a4b436dd11c795)
2020-03-09 03:48:15 +00:00
Automerger Merge Worker
76eead56aa Remove the NetworkScore class.
This class is useless at this point and introduces overhead.

Bug: 113554781
Test: FrameworksNetTests
Change-Id: Ib5f540070222865260c16c7182cc13c710a243c2
Merged-In: Ib5f540070222865260c16c7182cc13c710a243c2
(cherry picked from commit c3489ad3a6ce98218ce223cea877586781025b98)
2020-03-09 03:46:34 +00:00
Automerger Merge Worker
13a85611f8 test: ConnectivityService: Validate Route Add/Del
Validate route addition and deletion after linkProperties are
changed.

Bug: 142892223
Test: atest ConnectivityServiceTest#testStackedLinkProperties
Change-Id: I18296b933e856a0f8a4c1dbd75bd35024853bfbb
Merged-In: I18296b933e856a0f8a4c1dbd75bd35024853bfbb
(cherry picked from commit a22a979a0caf3e3533ede410d48127084052aec5)
2020-03-09 03:36:10 +00:00
Treehugger Robot
d88d10a100 Merge "Remove the NetworkScore class." 2020-03-08 04:52:26 +00:00
Chalard Jean
8cdee3a431 Remove the NetworkScore class.
This class is useless at this point and introduces overhead.

Bug: 113554781
Test: FrameworksNetTests
Change-Id: Ib6da6c1c7f2a0b97c847d2e64e5ce16dd821e1e7
2020-03-06 11:57:53 +09:00
lucaslin
444d43aea0 Remove redundant connected notification
Remove the old connected notification since there is a new file
- NetworkStackNotifier.java which will send the connected
notification when captive portal validated.

Bug: 149883761
Test: 1. atest FrameworksNetTests
      2. Sign-in a captive portal and see if there is a redundant
      connected notification.

Change-Id: I4ec9d26623af4bfc65156a28a96b982466aede31
Merged-In: Id11a9b99dd04772a92af8d527104906c47bf64cd
2020-03-05 06:48:48 +00:00
lucaslin
73f992fd80 Remove redundant connected notification
Remove the old connected notification since there is a new file
- NetworkStackNotifier.java which will send the connected
notification when captive portal validated.

Bug: 149883761
Test: 1. atest FrameworksNetTests
      2. Sign-in a captive portal and see if there is a redundant
      connected notification.

Change-Id: Id11a9b99dd04772a92af8d527104906c47bf64cd
Merged-In: Id11a9b99dd04772a92af8d527104906c47bf64cd
2020-03-05 06:48:12 +00:00
Cody Kesting
7febafb11c Clear UIDs when sharing NetworkCapabilties for ConnectivityDiagnostics.
ConnectivityDiagnostics shares NetworkCapabilities in
ConnectivityReports and DataStallReports. These NetworkCapabilities need
to have their UIDs scrubbed before they are shared with callbacks.

Bug: 148942124
Test: atest FrameworksNetTests
Change-Id: I5bde5a8116f7e36b8f4de49adf4cab8ec45a5aa4
2020-03-04 08:40:11 -08:00
Junyu Lai
22d91b660a Merge changes I794a24d0,Iab32b2db
* changes:
  Remove setHandler in NetworkStatsService
  Remove the need of accessing handler in NSS unit test
2020-03-04 13:07:49 +00:00
junyulai
c05d1359b4 Remove setHandler in NetworkStatsService
Currently, internal handler is set by setHandler after
constructing NSS object. This was introduced in ag/866187 to
access the handler in the unit test.

However, the design put NSS in a bad situation where all classes
that need handler or executor could not be final and need to be
dynamically allocated in order to get a valid handler.

Thus, since the usage of handler is removed in previous patch,
this change eliminate setHandler by initializing the handler in
the constructor.

Test: atest FrameworksNetTests
Bug: 150664039

Change-Id: I794a24d00b0ca9fdc78091e7b9ab7307e0f034b7
2020-03-04 16:01:21 +08:00
Lorenzo Colitti
2e6a35ef5e Add more assertions to testStackedLinkProperties.
Check all routes that are added and removed instead of just some
of them. This is in preparation of an upcoming change that
switches to adding and creating routes by issuing direct calls to
netd.

Also rename the misleading ipv4Default route variable to
ipv4Subnet, which is what it actually is.

Bug: 142892223
Test: test-only change
Change-Id: I7d111382be215a926a7d7d4701bd3c3e94372b99
2020-03-03 21:48:18 +09:00
junyulai
3123092fd5 Remove the need of accessing handler in NSS unit test
Currently, to wait for handler becomes idle, specific message
is used and the test would wait for condition variable to be
open when the message is processed.

However, this is already done in the HandlerUtils. Thus,
there is no need to post such message manually in the handler.

Test: atest FrameworksNetTests
Bug: 150664039

Change-Id: Iab32b2dbab01634ca159dcb90fc9f929d1fed1a2
2020-03-03 16:27:03 +08:00
Aaron Huang
5d61bc285d Merge "Move NetworkAgent#register to a new method." 2020-03-03 03:37:07 +00:00
Chalard Jean
fdb872c4ed Revert "Add public fields to NetworkScore and make it @SystemApi"
This reverts commit 511f7e3792.

Bug: 113554781
Test: FrameworksNetTests FrameworksTelephonyTests FrameworksWifiTests
Change-Id: Ie1e84bd2a16f088307b195f924f4e49335cbe367
2020-02-28 06:26:27 +00:00
Lorenzo Colitti
08c82181ad Merge "test: ConnectivityService: Validate Route Add/Del" 2020-02-27 01:00:58 +00:00
Tyler Wear
5668f7198b test: ConnectivityService: Validate Route Add/Del
Validate route addition and deletion after linkProperties are
changed.

Test: atest ConnectivityServiceTest#testStackedLinkProperties
Change-Id: I18296b933e856a0f8a4c1dbd75bd35024853bfbb
2020-02-24 17:23:02 -08:00
TreeHugger Robot
7bcd12e7d2 Merge changes from topic "revert-10338939-YCRBMILGZV"
* changes:
  Revert "[NS D03] Migrate the bad wifi avoidance policy"
  Revert "[NS D04] Implement a simple speed comparison between scores."
2020-02-21 08:51:09 +00:00
TreeHugger Robot
e60c52cb89 Merge changes from topic "revert-10343065-HRWTWGOFZV"
* changes:
  Revert "[NS D05] Rework how to tear down networks"
  Revert "[NS D06] Implement more policies"
  Revert "[NS D07] Use the unmodified legacy score"
2020-02-21 07:53:30 +00:00
Chalard Jean
5863a71547 Move NetworkAgent#register to a new method.
Calling IPC in a constructor is unusual and confusing, and can be
considered bad form. There are multiple reasons for this :
• Users can't obtain an instance of the class without calling the
  constructor, but they can't always afford an IPC where they need
  this, forcing them to know about the implementation detail and
  sometimes design around it.
• On a related but generalized note, constructors should usually
  be fast for the same range of reasons.
• Having a separate method to register the agent simply gives more
  flexibility to the app.
• It's also a lot easier to test.
But also we can't fix it without an update to the API, so here it is.

Another reason for doing this is consistency with the NetworkProvider
API.

Bug: 138306002
Bug: 139268426
Test: atest FrameworksNetTests FrameworksWifiTests FrameworksTelephonyTests
Change-Id: I1ee5c7b1353d581e487c8a8a159009bebd781643
Merged-In: I1ee5c7b1353d581e487c8a8a159009bebd781643
(clean cherry-pick from internal branch)
2020-02-21 14:54:18 +08:00
Chalard Jean
7b6b7ecc19 Revert "[NS D03] Migrate the bad wifi avoidance policy"
Revert submission 10338939

Reason for revert: The feature was punted out of R.
Reverted Changes:
I32c12702c:[NS D04] Implement a simple speed comparison betwe...
I688593cc0:[NS D03] Migrate the bad wifi avoidance policy

Change-Id: I640635a1ed94bed3b53466abe2a988caf0eca2b0
2020-02-21 06:47:35 +00:00
Chalard Jean
b3ce7501b7 Revert "[NS D05] Rework how to tear down networks"
Revert submission 10343065

Reason for revert: This is part of a feature that was punted out of R.
Reverted Changes:
Ic9a3d3363:[NS D05] Rework how to tear down networks
I7d815f873:[NS D06] Implement more policies
I561098476:[NS D07] Use the unmodified legacy score

Change-Id: I8d2696d15999265d79abfc9163e7e5ccad873cfe
2020-02-20 07:32:12 +00:00
Chalard Jean
751e5a1c37 Revert "[NS D06] Implement more policies"
Revert submission 10343065

Reason for revert: This is part of a feature that was punted out of R.
Reverted Changes:
Ic9a3d3363:[NS D05] Rework how to tear down networks
I7d815f873:[NS D06] Implement more policies
I561098476:[NS D07] Use the unmodified legacy score

Change-Id: I378449443f99eb0a7f01f31f53398b8f55ce87f1
2020-02-20 07:32:12 +00:00
Chalard Jean
b104cd7c12 Revert "[NS D07] Use the unmodified legacy score"
Revert submission 10343065

Reason for revert: This is part of a feature that was punted out of R.
Reverted Changes:
Ic9a3d3363:[NS D05] Rework how to tear down networks
I7d815f873:[NS D06] Implement more policies
I561098476:[NS D07] Use the unmodified legacy score

Change-Id: I184817e3aa290afdbe6721a7c36332b940434d3a
2020-02-20 07:32:12 +00:00
Automerger Merge Worker
589d8b524e Merge "Sanitize owner UID iff owning app does not have location permissions." am: 4d95254cb3 am: aba23b3f43 am: a06f220d24
Change-Id: I9b8fb3ff8d907ecda918a8a926edb133b742c8f1
2020-02-20 05:59:35 +00:00
Qingxi Li
4d95254cb3 Merge "Sanitize owner UID iff owning app does not have location permissions." 2020-02-20 05:20:27 +00:00
Qingxi Li
b274810c34 Sanitize owner UID iff owning app does not have location permissions.
This change adds permission checking to ensure that the following
conditions are enforced in order for apps to receive the owner UID:
1. The app must be the owner of the network
2. The app must hold the FINE_LOCATION permission/appop
3. The user must have their location toggle enabled.

Bug: 142072839
Test: atest FrameworksNetTests
Change-Id: I7a981a82f1219828ee89c8c96eb9d2efd153377f
2020-02-20 01:02:42 +00:00
Automerger Merge Worker
fbcdf41d67 Merge changes from topic "settings-vpn" am: 70f90282ef am: 1758c298d0 am: 3d6f91ed37
Change-Id: Idac6e83bab50b818e2776f28da380f08000e2a42
2020-02-19 23:08:32 +00:00
Chalard Jean
4bb5b45830 [NS D07] Use the unmodified legacy score
Ranking used to make use of the various adjustments in
ConnectivityService. These are now implemented in policy.

Test: ConnectivityServiceTest

Change-Id: I56109847678ea5cda1752511123ba652c0f4fe36
2020-02-19 22:17:13 +09:00