Commit Graph

770 Commits

Author SHA1 Message Date
Nathan Harold
37b4cf3ecb Cosmetic Cleanups for IpSecService
This is a follow-up CL to address comments
on aosp/466677
-Rename ManagedResourceArray.get()
-Comment cleanup

Bug: 38397094
Test: runtest frameworks-net
Change-Id: I6fbdd89c4a864fe1d8a19c68947f582d7b1f0f21
2017-10-04 13:04:55 -07:00
Nathan Harold
727fe3e941 Add equals() for IpSecAlgorithm and IpSecConfig
Add equality testing methods to support tests
for parceling and un-parceling IpSecConfig.

Bug: 38397094
Test: runtest -x IpSecConfigTest.java
Change-Id: I31e318334d39ed6e9daf5ec8f3be7dcec75e12ad
2017-10-03 19:45:58 -07:00
Nathan Harold
19b99d998a Input Validation for IpSecService
All of the input to IpSecService over the Binder
interface needs to be validated both for sanity
and for safety.

-Sanity check all the parameters coming from binder.
-Added setters for IpSecConfig to decouple the test
 from the IpSecManager. This was needed because the
 input validation caused the tests to fail due to a
 null parameter that was previously un-tested.
-Added the mode flag to the IpSecConfig bundle this
 oversight was found during testing.
-Expose the getResourceId() methods for testing in
 UdpEncapsulationSocket, SecurityParameterIndex, and
 IpSecTransform classes.
-Remove the unneeded getIpSecConfig() from
 IpSecTransform: unneeded now that we can synthesize
 configs.

Bug: 38397094
Test: runtest frameworks-net
Change-Id: I5241fc7fbfa9816d54219acd8d81a9f7eef10dd4
2017-10-03 19:45:55 -07:00
nharold
59872858db Merge changes from topic "re-enable-ipsec" am: 61cf7b284e am: 5a77657433
am: 80107540bb

Change-Id: I13a7134864a648aff9338fda044b3bffd653119e
2017-09-26 22:39:01 +00:00
Nathan Harold
8a243c7ae2 Re-Enable Starting of the IpSecService am: 81f54633f0 am: a246237c74
am: 686a8282bb

Change-Id: Ia24348d585b2f1050dafd161eafcdadf0edd82c0
2017-09-26 22:37:44 +00:00
nharold
5a77657433 Merge changes from topic "re-enable-ipsec"
am: 61cf7b284e

Change-Id: Ia1d1f3981a9dd1eb8f60631d318211daf135d575
2017-09-26 22:13:20 +00:00
Nathan Harold
a246237c74 Re-Enable Starting of the IpSecService
am: 81f54633f0

Change-Id: I1f64aa2fdf1cce6dea91427eda65c4b8ee6f6b02
2017-09-26 22:11:58 +00:00
Nathan Harold
69cb0af0a8 Re-Expose IpSecService API Surface
Note, This reverts commit 7194bb9bf9.

Bug: 64800246
Test: compilation
Change-Id: I709d4c476647cfe9f6b982fc373f8d76018b3922
2017-09-12 19:25:13 -07:00
Nathan Harold
81f54633f0 Re-Enable Starting of the IpSecService
This reverts commit 41004ff4113dc9175c993638a47af602af6d8a98.

Bug: 64800246
Test: compilation
Change-Id: I4f5e3cd23001b9d94b3f6dc9fcfe731a90650e6e
2017-09-12 19:25:09 -07:00
Hugo Benichi
624e54f225 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
Bug: 65439160
Test: runtest frameworks-net
Merged-In: I16e97e73f600225f80e0ce517e80c07c6f399196
Merged-In: I2ac0bc3914cb65ae8ee27921856d698dc59624b2
Merged-In: I67d5dc4b52b254748ff17fe1e16c2eeb1d03c30d
Merged-In: Ib488fb034f72c92f19916490981342a3ef2eb33b

(cherry picked from commit d78311f267)

Change-Id: Ic86b65a65a2517c871221f8784088ec1de18f534
2017-09-08 13:39:44 +09:00
Hugo Benichi
619ce0a8f4 Merge "Network Service Discovery test: properly release resources" am: c9d24d203d am: 3a2e98b3ce
am: f467db29f9

Change-Id: Id9be284a16112f999d752751a7972fd735573cda
2017-09-04 12:42:56 +00:00
Hugo Benichi
3a2e98b3ce Merge "Network Service Discovery test: properly release resources"
am: c9d24d203d

Change-Id: If34b3770a5c0fef65d124201e0ca1374cc6b1eca
2017-09-04 12:14:11 +00:00
Hugo Benichi
fa8a0bb61f Network Service Discovery test: properly release resources
Bug: 32561414
Bug: 62918393
Bug: 62044295
Test: runtest frameworks-net
Change-Id: If23993b5e391947ecbdc01677f0a643144794b2b
2017-09-02 14:54:29 +09:00
Jeff Sharkey
488cf28ae9 Merge "Augment network stats based on SubscriptionPlan." into oc-mr1-dev
am: f31cf45e82

Change-Id: Ia6c6d5893d841f21d181363dc01f77efa6579a8f
2017-08-30 19:14:21 +00:00
Jeff Sharkey
2f0f8f418f Augment network stats based on SubscriptionPlan.
When a carrier provides an "anchor" of data usage at a specific
moment in time, augment the network statistics used by warning/limit
thresholds and Settings UI.  For example, if the OS measured 500MB
of usage, but the carrier says only 400MB has been used, we "squish"
down the OS measured usage to match that anchor.

Callers using the hidden API will have their data augmented by
default, and the public API offers a way to opt-into augmentation.

Thorough testing to verify behavior.

Test: bit FrameworksNetTests:android.net.,com.android.server.net.
Test: cts-tradefed run commandAndExit cts-dev -m CtsUsageStatsTestCases -t android.app.usage.cts.NetworkUsageStatsTest
Bug: 64534190
Change-Id: Id3d4d7625bbf04f57643e51dbf376e3fa0ea8eca
2017-08-30 10:01:10 -06:00
Lorenzo Colitti
4187540d39 Merge changes I325b13d5,I89719fe7 am: 31cb4583e5 am: d1800f3e6f
am: 4fa0187015

Change-Id: Ib980879b0e50ffe1c8209339df22da4a50d5b74e
2017-08-19 03:38:10 +00:00
Lorenzo Colitti
d1800f3e6f Merge changes I325b13d5,I89719fe7
am: 31cb4583e5

Change-Id: Iaced543ab17ea87c8f701975764d957bc1b17fc7
2017-08-19 03:15:08 +00:00
Lorenzo Colitti
c2f8a8dda3 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.

(cherry picked from commit f31c942e89)

Bug: 29337859
Bug: 32163131
Test: runtest frameworks-net
Test: runtest frameworks-telephony
Change-Id: I325b13d50e88841dfb0db4c35e7e27f163ee72fe
Merged-In: I4e8e923d68dce1a4a68608dbd6c75a91165aa4ee
2017-08-19 10:12:05 +09:00
Lorenzo Colitti
45ab5640ef Merge "Add tether offload traffic to interface stats as well." into oc-mr1-dev
am: 21bc3a39a4

Change-Id: I4e8e923d68dce1a4a68608dbd6c75a91165aa4ee
2017-08-19 01:02:33 +00:00
Lorenzo Colitti
f31c942e89 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
Jeff Sharkey
b050a094a0 Merge "Rename API to match StorageStats." into oc-mr1-dev
am: 74f7a1425f

Change-Id: I87815da4f2f96c476fcdfdb3361d0f43b895e909
2017-08-12 00:45:19 +00:00
Jeff Sharkey
b1f97acf19 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
Hugo Benichi
ae3ee131d2 Merge "NetworkStats: more robust subtraction for deltas" into oc-dr1-dev am: 5e24152e33
am: b9d28344e0

Change-Id: I67d5dc4b52b254748ff17fe1e16c2eeb1d03c30d
2017-08-08 16:10:52 +00:00
Hugo Benichi
f062d08360 Merge "NetworkStats: more robust subtraction for deltas" into oc-dr1-dev
am: 5e24152e33

Change-Id: Id6040a899653c585d298b7be7208f5cba997f665
2017-08-08 16:01:10 +00:00
Hugo Benichi
b9d28344e0 Merge "NetworkStats: more robust subtraction for deltas" into oc-dr1-dev
am: 5e24152e33

Change-Id: I2ac0bc3914cb65ae8ee27921856d698dc59624b2
2017-08-08 16:01:07 +00:00
Hugo Benichi
d78311f267 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
37d178c71e NsdManager: remove duplicated argument validation
am: 38e4783a60

Change-Id: I3cad605d34cd9612b6073e689dc4af04b1717413
2017-08-03 07:28:16 +00:00
Hugo Benichi
38e4783a60 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: 37013369

(cherry picked from commit f2c64f8725)

Change-Id: Icf047532aa551fbe0a70721cfb95507eaa84d51e
2017-08-03 14:19:43 +09:00
Hugo Benichi
e71cc98cb1 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 f2c64f8725)

Change-Id: I5e6a1ecc6b98069ef0089bbceecf73f7692df227
2017-08-01 02:45:23 +00:00
ludi
2e438582ba Merge "Add dump info to IpSecService" am: ec5fc4872e am: b47cb8b03c am: c628b22fe5
am: 16853ff14c

Change-Id: Idbc0a6f0c88a023c3954b25cc66c8c65c70085c9
2017-07-25 03:36:41 +00:00
ludi
16853ff14c Merge "Add dump info to IpSecService" am: ec5fc4872e am: b47cb8b03c
am: c628b22fe5

Change-Id: I1a5d4c424a3c9e1638d86d177cbf98f0d1bce05d
2017-07-25 03:26:23 +00:00
ludi
b47cb8b03c Merge "Add dump info to IpSecService"
am: ec5fc4872e

Change-Id: Idd4c051e4536d32504718fdfd201c7effdeb62e3
2017-07-25 03:07:00 +00:00
ludi
89194d6e45 Add dump info to IpSecService
Bug:38350824

Test: runtest frameworks-net

Change-Id: Ifa11d55e9d337016ad865baada627db3aa8c2db3
2017-07-24 16:03:33 -07:00
Di Lu
48e3c86ea7 Merge "Add unit test for IpSecService" am: 9e3f886dca am: 8cdceb2fed am: 345db82674
am: cfb337087c

Change-Id: I788e4e8466a76f80d1f15330e6d3b91b73be1d32
2017-07-20 08:42:27 +00:00
Di Lu
cfb337087c Merge "Add unit test for IpSecService" am: 9e3f886dca am: 8cdceb2fed
am: 345db82674

Change-Id: Ia4d85bcf5c42774d7b48cb1cd648754b6dd16b69
2017-07-20 07:50:21 +00:00
Di Lu
8cdceb2fed Merge "Add unit test for IpSecService"
am: 9e3f886dca

Change-Id: I16fb89239e641ac39a8a7adeafd72b7fe03935ed
2017-07-20 07:36:19 +00:00
ludi
5e623eaa02 Add unit test for IpSecService
Test: runtest frameworks-net

Bug:38259578
Change-Id: I4a049d5fdec79e36692e3b12306bd0758c19ad75
2017-07-20 04:26:24 +00:00
Steven Moreland
ba133a202d Merge "frameworks/base: use proper nativehelper headers" am: 826eafd958 am: 4f846495a4 am: c840945a78
am: c79573c26d

Change-Id: Ibe321dd4a8aae9342c76da0780edf94b90e8cd3a
2017-07-20 03:11:00 +00:00
Steven Moreland
c79573c26d Merge "frameworks/base: use proper nativehelper headers" am: 826eafd958 am: 4f846495a4
am: c840945a78

Change-Id: I654e14f0d1b495450db81592a2e564e308746350
2017-07-20 03:05:02 +00:00
Steven Moreland
4f846495a4 Merge "frameworks/base: use proper nativehelper headers"
am: 826eafd958

Change-Id: I36f10ff4d963284a313f1cc5b368f82549a4adb2
2017-07-20 02:50:53 +00:00
Steven Moreland
881296fa45 frameworks/base: use proper nativehelper headers
libnativehelper exports headers under nativehelper. These were
available before incorrectly as global headers in order to give
access to jni.h.

Test: modules using frameworks/base find headers
Bug: 63762847
Change-Id: I0f9f231acdebe460f279135462f43d3e32eff64d
2017-07-19 10:06:40 -07:00
Jeff Sharkey
65501f8094 Only require that system UIDs tag their sockets.
Apps with a normal UID are typically isolated enough to not require
socket tagging; we're mostly interested in tracking down internal
UIDs that have lots of code sharing the same UID.

Also fix up everyone doing manual string checks of Build.TYPE, since
we now have first-class fields for those.

Bug: 38126076
Test: builds, boots
Change-Id: I3a40348196bd8459289f2b9355d9783a07f1e7dd
2017-06-27 11:11:06 -06:00
Jeff Sharkey
8af5ad1575 Allocate well-known tag for app store updates.
This way an app store can shift blame for update-related network
traffic onto the app that is being updated.

Using a well-known tag makes it easy for developers to identify
that they didn't explicitly request the traffic at runtime, similar
to how backup/restore traffic is handled.

Bug: 38282350
Test: builds, boots
Change-Id: I003dd7c9615d4ab318250f1e44fa5d195ac94d23
2017-06-26 19:50:48 -06:00
Jeff Sharkey
96d9849a0a Merge "Annotate @SystemApi with required permissions." into oc-dev am: c1406978a4
am: 4786aec7cc

Change-Id: Ib629e25dbf047c110feaf03e4ff744b5c6df9aeb
2017-06-06 15:48:24 +00:00
Jeff Sharkey
4786aec7cc Merge "Annotate @SystemApi with required permissions." into oc-dev
am: c1406978a4

Change-Id: I305967cad945a807c3f8234efabaad0ef8b591d1
2017-06-05 22:28:21 +00:00
Jeff Sharkey
ad1cebe58e Annotate @SystemApi with required permissions.
Most @SystemApi methods should be protected with system (or higher)
permissions, so annotate common methods with @RequiresPermission to
make automatic verification easier.

Verification is really only relevant when calling into system
services (where permissions checking can happen on the other side of
a Binder call), so annotate managers with the new @SystemService
annotation, which is now automatically documented.

This is purely a docs change; no logic changes are being made.

Test: make -j32 update-api && make -j32 offline-sdk-docs
Bug: 62263906
Change-Id: I2554227202d84465676aa4ab0dd336b5c45fc651
2017-06-05 13:27:11 -06:00
nharold
8df1bad599 Merge "Add UDP Encap Socket Support to IpSecManager" am: 4f6ec3d11d am: c530c01744 am: 3c1484c715
am: 834637a824

Change-Id: Iafed2773a6d32542b051d944341533b2190aa284
2017-06-03 00:15:53 +00:00
nharold
834637a824 Merge "Add UDP Encap Socket Support to IpSecManager" am: 4f6ec3d11d am: c530c01744
am: 3c1484c715

Change-Id: Idc082c1ab2aac63ad61e5fc74be7fa75cf6e686f
2017-06-03 00:04:41 +00:00
Nathan Harold
8086539071 Add UDP Encap Socket Support to IpSecManager
-Implement the UdpEncapsulationSocket
-Convert all ManagedResources to use resourceIds
-Rework ManagedResource to track resourceIds

Bug: 30984788
Test: cts - IpSecManagerTest#testUdpEncapsulation()

Change-Id: I7b1099c487051a8d951c1485791c4b6cef2deb1d
2017-06-02 03:18:56 +00:00
Hugo Benichi
c52f403933 Merge "NsdServiceInfo: move test to tests/net" am: 48859e01d5 am: 1b0f4bf606 am: e8c2700519
am: ca4c03dbb0

Change-Id: I11af75ab8ebc4081cc90d29b83d8a1742f00a3ab
2017-05-25 01:18:45 +00:00