Commit Graph

2844 Commits

Author SHA1 Message Date
Etan Cohen
896c574bde [CS] Allow network factory implementations to re-evaluate requests
Change the evalRequests() API to protected to allow network factory
implementations to call the API.

A use-case of the API change is for factories temporarily reject a
request since they cannot fullfill it immediately but retry it at a
later time if/when conditions change.

Bug: 63866251
Test: integration tests
Change-Id: Idc50ce0799c67634b7b2fdbad78a26e443caf2e4
2017-08-24 06:47:55 -07:00
Lorenzo Colitti
21bc3a39a4 Merge "Add tether offload traffic to interface stats as well." into oc-mr1-dev 2017-08-19 00:54:59 +00:00
Lorenzo Colitti
5356a35c3b Add tether offload traffic to interface stats as well.
Currently, we only count add tethering traffic to per-UID
stats, but not to total data usage (i.e., dev and XT stats). This
is correct for software tethering, because all software forwarded
packets are already included in interface counters, but it is
incorrect for hardware offload, because such packets do not
increment interface counters.

To fix this:
1. Add an argument to ITetheringStatsProvider#getTetherStats to
   indicate whether per-UID stats are requested. For clarity,
   define integer constants STATS_PER_IFACE and STATS_PER_UID
   to represent these operations.
2. Make NetdTetheringStatsProvider return stats only if per-UID
   stats are requested. (Otherwise tethering traffic would be
   double-counted).
3. Make OffloadController's stats provider return the same
   stats regardless of whether per-UID stats were requested or
   not.
4. Make NetworkStatsService add non-per-UID tethering stats to
   the dev and XT snapshots. The per-UID snapshots were already
   correctly adding in per-UID stats.

Bug: 29337859
Bug: 32163131
Test: runtest frameworks-net
Test: runtest frameworks-telephony
Change-Id: I7a4d04ab47694d754874136179f8edad71099638
2017-08-19 00:21:56 +09:00
Hugo Benichi
fde112a2eb Merge "Allow NetworkAgent "immutable updates" to NetworkCapabilities" into oc-mr1-dev 2017-08-18 11:46:22 +00:00
Hugo Benichi
322df2899b Merge "Add convenience methods to IpPrefix and LinkAddress" into oc-mr1-dev 2017-08-17 22:31:59 +00:00
Charles He
8b2513e439 Merge "Opt-out for always-on VPN: rename API." into oc-mr1-dev 2017-08-17 07:54:05 +00:00
Hugo Benichi
6e833f27aa Add convenience methods to IpPrefix and LinkAddress
Also moving relevant test files into tests/net as part of runtest
framworks-net.

Also removes testHashCode in LinkAddress() because this test relies on
the assumption that hashCode() is stable across releases or jdk
versions, which is absolutely not true.

This creates maintenance work for little benefit since hashCode is
already tested as part of the equality test.

For instance this test is now broken because hashing for InetAddress
changed.

Bug: 62988545
Bug: 62918393
Test: runtest frameworks-net, added coverage in tests
Merged-In: I695bc3f0e801bf13bc4fc0706565758f12b775b4
Merged-In: I6d3f3c50eaec44e3a0787e849ab28e89f6f4a72d
Merged-In: Iddfec82a08f845e728adadfa6ec58a60a078d6af
Merged-In: I8d6dd5efd226a8b1c4b05d1e1102362b58e094a1
Merged-In: Ied0cc53ac34c7c5f5539507b1979cbf9c215262e
Merged-In: I3b2b7dcb1a9a194fc08643b27bbb5a0e84e01412

(cherry picked from commit 1dfb6b6755)

Change-Id: I9a17094bfdc54b9dec671306618e132a4beb59fc
2017-08-17 11:03:24 +09:00
Hugo Benichi
86fc53aa7a Allow NetworkAgent "immutable updates" to NetworkCapabilities
This patch loosens the validation checks when a NetworkAgent updates it
NetworkCapabilities: instead of checking that capabilities labeled as
"immutable" stay identical across updates, it is now accepted to change
immutable capabilities in a way that the new NetworkCapabilities
satisfies the old NetworkCapabilities.

This allows a NetworkAgent to update itself in order to match more
requests, but will still catch NetworkAgents that sends degradation
updates causing potentially requests to not match anymore.

Bug: 64125969
Test: runtest frameworks-net
Merged-In: I2a1b3f9c0be6415e40edc989d0c1b03b5631f7b1
Merged-In: I0ab76de59e87c46a6961229399ff7200bce49838
Merged-In: Ied592bf6112574399a1e808da337004e1c35f244
Merged-In: I01e287b4df82a53a522566d33b3166f7801badca
Merged-In: I7ee60daa9c4266e9b9179032815dd7267e06377f
Merged-In: I31ef741eb83d64c476e5930d5762514b5d4cb16f

(cherry picked from commit bae105a5cc)

Change-Id: I9d630d63336f4db69f3eb52faa8483f1b1e35d16
2017-08-17 10:48:41 +09:00
Charles He
c57a01c166 Opt-out for always-on VPN: rename API.
Rename the opt-out flag in AndroidManifest to
SERVICE_META_DATA_SUPPORTS_ALWAYS_ON
as directed by the API Council.

Bug: 64331776
Bug: 36650087
Test: runtest --path java/com/android/server/connectivity/VpnTest.java
Change-Id: I24326fad7a89083a2409134640bda81ee0359d08
2017-08-15 15:52:39 +01:00
Lorenzo Colitti
4faae82855 Merge changes Ifbd1e8d9,I1e017b6f into oc-mr1-dev
* changes:
  Pass data usage limits to tethering offload code.
  Don't time out when fetching tether offload stats.
2017-08-15 06:47:24 +00:00
Lorenzo Colitti
62801ec2b7 Pass data usage limits to tethering offload code.
(cherry picked from commit 50b60fc34d)

Bug: 29337859
Bug: 32163131
Test: builds
Test: OffloadControllerTest passes
Change-Id: Ifbd1e8d9057aa12b956e3b4501c32aa6bcf420bd
2017-08-15 12:12:04 +09:00
TreeHugger Robot
66042e0caf Merge "Add permission checks to getActiveScorerPackage()." into oc-mr1-dev 2017-08-14 16:50:50 +00:00
Jeff Sharkey
d62e3cb5d6 Rename API to match StorageStats.
Since they're both measuring app code (APKs), name this API
consistently with StorageStats.getAppBytes().

Bug: 64331226
Test: builds, boots
Change-Id: I1b00427b619a78c043b1b5fac2d0e6406b51d454
2017-08-11 15:10:38 -06:00
Sudheer Shanka
06668b5f73 Merge "Update ConnOnActivityStartTest to be hermetic." into oc-mr1-dev 2017-08-10 22:52:40 +00:00
Sudheer Shanka
b8f2316fb4 Update ConnOnActivityStartTest to be hermetic.
Bug: 38432755
Test: runtest -x services/tests/servicestests/src/com/android/server/net/ConnOnActivityStartTest.java
Change-Id: Ie847ec0a202021a2b2cf16bb2d720650c9ee847d
2017-08-08 22:34:46 -07:00
Hugo Benichi
de3b32c277 Merge "NetworkStats: more robust subtraction for deltas" into oc-dr1-dev
am: 5e24152e33

Change-Id: Id6040a899653c585d298b7be7208f5cba997f665
2017-08-08 16:01:10 +00:00
TreeHugger Robot
5e24152e33 Merge "NetworkStats: more robust subtraction for deltas" into oc-dr1-dev 2017-08-08 15:52:39 +00:00
Hugo Benichi
ad5e2827ea NetworkStats: more robust subtraction for deltas
This patch ensures that subtract() between two NetworkStats object will
return a delta with no negative entries in all cases.

When the stats delta contains some negative values, there are clamped to
0. Some logging is added when this happens.

This is what's expected by NetworkStatsHistory#recordData().

Bug: 64365917
Test: runtest frameworks-net
Change-Id: I16e97e73f600225f80e0ce517e80c07c6f399196
2017-08-08 09:19:05 +09:00
Hugo Benichi
85808c8293 Merge "NetworkCapabilities: fix describeImmutableDifferences" into oc-dr1-dev
am: 1b3877a965

Change-Id: I50748aa0c9332787797f91265afccf82ceabf332
2017-08-07 05:49:25 +00:00
Hugo Benichi
8a3a012a1c NetworkCapabilities: fix describeImmutableDifferences
This patch fixes the mask used in describeImmutableDifferences which did
not correctly turn NET_CAPABILITY_NOT_METERED into bit flag.

Bug: 63326103
Test: added unit tests, runtest frameworks-net
Merged-In: Ib6b390b1daef5912859302692af7dcd6cfd3e39a
Merged-In: If38efacdeec8476880835657938e435f9b598525
Merged-In: Ieccad46fcffcaf748f5644b04617e9a82527000e
Merged-In: I533ef8fe369cec19d283ff2950314fce6e28cffd
Merged-In: I12636c6699ff60487a28570208e819ea0b66fa2e
Merged-In: Ie5df14e0ea1c12e0cfabe87978ac6c9b744353b2

(cherry picked from commit 2ecb9408f4)

Change-Id: I74ecf34a2c079c74152d00caea2c220e9c6d1fa5
2017-08-05 11:37:10 +09:00
Jeremy Joslin
2d55b18635 Add permission checks to getActiveScorerPackage().
Added and documented checks for REQUEST_NETWORK_SCORES
and SCORE_NETWORKS.

Bug: 62347124
Test: runtest frameworks-services -c com.android.server.NetworkScoreServiceTest
Test: gts-tradefed run gts -m GtsGmscoreHostTestCases -t com.google.android.gts.netrec.NetRecHostTest
Change-Id: Ibeba7079b3d4a75e11aa0ede6ad2be1c7d48324f
2017-08-02 16:32:08 -07:00
Jeremy Joslin
59502ebcfd NetworkRecommendationProviders require the location permission.
Any NetworkRecommendationProvider bound to by the system must have
access to location (i.e. it holds the location permission and
location is enabled on the device).

If the location permission is revoked then the binding will be
disconnected and the system will revert to the default network
recommendation provider (if set and valid). If location access
is disabled on the device then the binding will be disconnected
but the system won't fall back to the default provider (because
it won't have location either), instead the current provider will
be re-enabled when location access is enabled again.

BUG:62263953
Test: runtest frameworks-services -c com.android.server.NetworkScoreServiceTest
Test: runtest frameworks-services -c com.android.server.NetworkScorerAppManagerTest
Change-Id: I93c37eeda47840d92f3ca52767e878dc19b46740
(cherry picked from commit d816abe97b)
2017-08-02 21:34:26 +00:00
Hugo Benichi
4aa743c343 NsdManager: remove duplicated argument validation
This patch simplifies argument validation in NsdManager public api and
regroup duplicated validation into common methods.

This makes stack traces more actionable as now specific errors will
cause the api to throw exception from specific methods, whereas before
IllegalArgumentException would be thrown from inside the same api method
for different reasons.

This patch also includes a couple of other small cleanups.

Test: $ runtest -x frameworks/base/tests/net/../NsdManagerTest.java
Bug: 35362108
Bug: 37013369
Bug: 62044295
Bug: 63826516
Merged-In: Iaad13e13976e9bf8f508d7188f823f8184ac414b

(cherry pick from commit ff3e6ccca1)

Change-Id: I5e6a1ecc6b98069ef0089bbceecf73f7692df227
2017-08-01 02:45:23 +00:00
Hugo Benichi
6992f4edb3 Merge "Logging improvements when NetworkCapabilities change" into oc-dr1-dev
am: 6e269ec6fe

Change-Id: I4f6cbc0adb461cef6610460daeba72ca38b8f10c
2017-07-28 23:54:03 +00:00
Hugo Benichi
683ea489d3 Logging improvements when NetworkCapabilities change
This patch improves the wtf() logging in updateCapabilities to
better distinguish between the cases of a changed specifiers, changed
transports, or changed capabilities. The case of NOT_METERED being added
or removed is ignored.

Bug: 63326103
Test: runtest frameworks-net, runtest frameworks-wifi
Change-Id: I05c6e78891e1eac658f1cf883223af520a9a4f8f
2017-07-28 15:25:54 +09:00
Jeff Sharkey
17bebd2fd7 Expose SubscriptionPlan API.
Clean up SubscriptionPlan, add docs, and expose as public API.

Deprecate older constants in CarrierConfigManager, and point users
towards new API.  (The goal of CarrierConfigManager is to express
key/value pairs that are identical for all users on a particular
carrier, not to configure details that vary between users.)

Since a CarrierService may itself not have access to the plan
details, allow them to "delegate" the capability to configure plans
to another package name.

Factor out new RecurrenceRule class which is used by both
NetworkPolicy and SubscriptionPlan internally.  Polish it to support
arbitrary periods, and continue to test it through NPMST.

Bug: 63391323
Test: bit FrameworksCoreTests:android.util.RecurrenceRuleTest
Test: bit FrameworksServicesTests:com.android.server.NetworkPolicyManagerServiceTest
Exempt-From-Owner-Approval: Bug 63673347
Change-Id: I93fae4a43e58e9e4c32f8bf345a257dcd607f088
2017-07-20 14:55:57 -06:00
The Android Automerger
af11a49d8c Manually merge commit '530b93aae428'
* commit '530b93aae428':
  NetworkCapabilities: Unhide TRANSPORT_LOWPAN

BUG:31038431
2017-07-19 00:27:08 +00:00
Robert Quattlebaum
4b90b5f884 Merge "NetworkCapabilities: Unhide TRANSPORT_LOWPAN" am: 777c408a22 am: 6b0e6946c3
am: dbc78509ae

Change-Id: I017036f8c63ea1e9c1934daad55ef087b3a83012
2017-07-18 23:51:04 +00:00
Robert Quattlebaum
dbc78509ae Merge "NetworkCapabilities: Unhide TRANSPORT_LOWPAN" am: 777c408a22
am: 6b0e6946c3

Change-Id: Ia6ceafa40c73589d516ca0d50168ba217b6af2c8
2017-07-18 23:43:46 +00:00
Lorenzo Colitti
6a5fe34edf resolve merge conflicts of a1d67fb38e to stage-aosp-master
am: 8228eb3446

Change-Id: Ic9ba31da8e5281c9dbc8fa7ff56a63956a495b72
2017-07-18 23:37:57 +00:00
Robert Quattlebaum
6b0e6946c3 Merge "NetworkCapabilities: Unhide TRANSPORT_LOWPAN"
am: 777c408a22

Change-Id: I3ae9566ca52b9dae87cace18b1e97897eb8de0ad
2017-07-18 23:33:08 +00:00
Treehugger Robot
777c408a22 Merge "NetworkCapabilities: Unhide TRANSPORT_LOWPAN" 2017-07-18 23:09:58 +00:00
Lorenzo Colitti
8228eb3446 resolve merge conflicts of a1d67fb38e to stage-aosp-master
Test: make -j64 services
Change-Id: I3955b01189993f3051c608bc5d07a87e4e3b5f0b
Merged-In: Ic1e799c17b4bb0272cf85e03d5ad14981a55defa
2017-07-19 07:35:31 +09:00
Lorenzo Colitti
07f1304cfe Allow more than one source of tethering statistics.
Currently, netd is the only source of tethering statistics.
In order to support multiple sources, define a new
ITetheringStatsProvider interface that can be registered with
NetworkManagmentService. Convert the existing code into the
first ITetheringStatsProvider.

(cherry picked from commit ef7b2a13ce)

Bug: 29337859
Bug: 32163131
Test: builds, boots
Test: tethering stats continue to be collected
Change-Id: Ie1b5a5e47ae4bf5af922365b09fa241e834236e4
Merged-In: Ie1b5a5e47ae4bf5af922365b09fa241e834236e4
2017-07-19 00:54:54 +09:00
Charles He
3673863f3b Opt-out for always-on VPN
Always-on VPN is a feature introduced in N. Since then, all VPN apps
targeting N+ are assumed to support the feature, and the user or the DPC
can turn on / off always-on for any such VPN app. However, a few VPN
apps are not designed to support the always-on feature. Enabling
always-on for these apps will result in undefined behavior and confusing
"Always-on VPN disconnected" notification.

This feature provides a new manifest meta-data field through which a VPN
app can opt out of the always-on feature explicitly. This will stop the
always-on feature from being enabled for the app, both by the user and
by the DPC, and will clear its existing always-on state.

A @hide API is provided to check whether an app supports always-on VPN.
Documentation is updated to reflect the behavior change.

Bug: 36650087
Test: runtest --path java/com/android/server/connectivity/VpnTest.java
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedDeviceOwnerTest#testAlwaysOnVpnUnsupportedPackage'
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedDeviceOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced'
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackage'
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced'
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackage'
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced'

Change-Id: I477897a29175e3994d4ecf8ec546e26043c90f13
2017-07-18 00:55:38 +01:00
Benjamin Miller
401d176f95 Merge "Docs: VPNs under Android O should promote to the foreground" into oc-dev am: ca007e525b am: 3082216de2
am: 105c3b1df4

Change-Id: Ic23b650fdd29739f312bf62fbab52196429c3f2e
2017-07-17 14:41:07 +00:00
Benjamin Miller
105c3b1df4 Merge "Docs: VPNs under Android O should promote to the foreground" into oc-dev am: ca007e525b
am: 3082216de2

Change-Id: Id9720c51f6192831ede99fd0af0451b43026e663
2017-07-17 14:32:30 +00:00
Benjamin Miller
2ecc198877 Merge "Docs: VPNs under Android O should promote to the foreground" into oc-dev
am: ca007e525b

Change-Id: If2a06d8e8e5fe2034e22c86dabf68bf7d3f79bb0
2017-07-17 14:23:25 +00:00
Benjamin Miller
3082216de2 Merge "Docs: VPNs under Android O should promote to the foreground" into oc-dev
am: ca007e525b

Change-Id: Ife96d44a6c8687be49616562f1834c1e2cc17b7d
2017-07-17 14:22:24 +00:00
TreeHugger Robot
42b4446b0e Merge "Iterate NetworkPolicy towards SubscriptionPlan." 2017-07-15 19:57:08 +00:00
Jeff Sharkey
53313d7e81 Iterate NetworkPolicy towards SubscriptionPlan.
Add new SubscriptionPlan API to describe the various types of carrier
data plans.  Internally the OS will only use the first plan for
driving policy, but it will blindly plumb through the details for
Settings to display any secondary plans.

As part of getting Settings ready to roll towards SubscriptionPlan,
reduce references to NetworkPolicy internal fields.  All usage cycle
details are now obtained from an Iterator which converts to
SubscriptionPlan under the hood.

Replace all data usage cycle calculation with new SubscriptionPlan
implementation, and retrofit large suite of existing tests to
exercise and verify the new logic.

Offer a debugging property that can be used to return "fake" plan
examples for testing.

Bug: 63391323
Test: bit FrameworksServicesTests:com.android.server.NetworkPolicyManagerServiceTest
Exempt-From-Owner-Approval: Bug 63673347
Change-Id: I889c653980eeb7887abdfa4f5b6986f35855ee6d
2017-07-14 16:18:40 -06:00
Jeff Sharkey
845dae5cdb Merge "Move "metered" persistence to WifiConfiguration." 2017-07-14 17:48:02 +00:00
Jeff Sharkey
43d2a1700b Move "metered" persistence to WifiConfiguration.
For a long time we've had a nasty tangled dependency between Wi-Fi
and NPMS, since they both persisted different details for configured
networks.  As part of preparing for new carrier data plan APIs, move
the tracking of meteredness over to WifiConfiguration.

This also cleans up how meteredness is communicated through
NetworkAgents to rely completely on NET_CAPABILITY_NOT_METERED by
removing the metered flag on NetworkInfo, which has caused confusion
and staleness.

Migrates any existing user-configured metered networks over to
WifiConfiguration once the device finishes booting.

Remove support for NetworkQuotaInfo, since this information can no
longer be made available to apps.  Frustratingly, some apps are
using it, so keep the object around returning stub values, and shame
them in the logs.

Bug: 63391323
Test: builds, boots, Wi-Fi policy is upgraded
Exempt-From-Owner-Approval: Bug 63673347
Change-Id: I64f865ddeb65cfcd330f8d2a847368abdf960a07
2017-07-14 11:46:31 -06:00
Benjamin Miller
28a3e85903 Docs: VPNs under Android O should promote to the foreground
Add note for VPN developers that VPN apps started in the background must transition to the foreground in Android O to avoid the system stopping them.

Staged at: go/dac-stage/reference/android/net/VpnService.html

Test: make ds-docs
Bug: 38023983
Change-Id: I33c7ca1717c332ffab495eb51c4c6b9c5c304cef
2017-07-14 17:22:47 +02:00
Lorenzo Colitti
f7a008ff69 Merge changes Icc5aa605,If744f2e0,Ie1b5a5e4 into oc-dr1-dev am: 3756636ad6
am: 041111ff7e

Change-Id: I538f7faef85bbb13499dec2125e0f82b3175396f
2017-07-14 01:06:56 +00:00
Lorenzo Colitti
041111ff7e Merge changes Icc5aa605,If744f2e0,Ie1b5a5e4 into oc-dr1-dev
am: 3756636ad6

Change-Id: Ic1e799c17b4bb0272cf85e03d5ad14981a55defa
2017-07-14 01:01:29 +00:00
Hugo Benichi
a30cb89dfa resolve merge conflicts of 4f2a0fe213 to stage-aosp-master am: a428392c1d
am: 164ff8a2ed

Change-Id: I08195e119f866acc9fe1795b892fe45cea3c7f47
2017-07-14 00:46:49 +00:00
Hugo Benichi
a428392c1d resolve merge conflicts of 4f2a0fe213 to stage-aosp-master
Test: I solemnly swear I tested this conflict resolution.
Change-Id: I61cfb2d4798350f28f1bb36aed67ee8f18895031
2017-07-14 07:25:51 +09:00
Hugo Benichi
fd31b9d46e IpManager: define InitialConfiguration
This patch adds a InitialConfiguration class to IpManager for specifying
IP information in IpManager ProvisioningConfiguration at IpManager
startup.

At the moment this InitialConfiguration is not used, but is validated in
startProvsiioning if ProvisioningConfiguration includes one. It will be
integrated into IpManager IP provisioning logic in follow-up patches.

This patch also includes an example of data driven unit tests using a
table of test case. The highlights of this methodology are:
  1) easy extensibility for new test case,
  2) rich and informative error messages,
Unfortunately Java support for inlined data structure literals is poor
and some companion static methods for data generation are required for
enabling this methodology.

Bug: 62988545
Test: added new test in FrameworksNetTests,
      $ runtest frameworks-net
      $ runtest frameworks-wifi
Merged-In: I060b02603af7d73a6407df89344bf0c000574af2

(cherry pick of commit 2757fcf3a1)

Change-Id: I48dbf89232d7758f1b07ed4d76ce93281e5c6b53
2017-07-14 04:26:42 +09:00
Lorenzo Colitti
ef7b2a13ce Allow more than one source of tethering statistics.
Currently, netd is the only source of tethering statistics.
In order to support multiple sources, define a new
ITetheringStatsProvider interface that can be registered with
NetworkManagmentService. Convert the existing code into the
first ITetheringStatsProvider.

Bug: 29337859
Bug: 32163131
Test: builds, boots
Test: tethering stats continue to be collected
Change-Id: Ie1b5a5e47ae4bf5af922365b09fa241e834236e4
2017-07-13 23:34:25 +09:00