Commit Graph

1000 Commits

Author SHA1 Message Date
Hugo Benichi
84e0cbf218 Merge "ConnectivityManager: fix style issue" am: e74f3adba5
am: ec54a40339

Change-Id: I5a420534268a0daec19f1f0677dcfe7abd8faf73
2017-06-22 08:03:46 +00:00
Hugo Benichi
3ff91f42c1 Merge "Better errors from unregisterNetworkCallback" am: 04e89ad631
am: ca6ebb0f39

Change-Id: Ib380ee7c3fc85db353682ee7abfe97842eaeeb29
2017-06-20 05:19:46 +00:00
Hugo Benichi
7ab07a36c9 ConnectivityManager: fix style issue
Simple style fix flagged by linter.

Test: no functional change.
Change-Id: I2cb19912cba149eeaffdd157616d210259d42959
2017-06-20 14:11:57 +09:00
Hugo Benichi
bee30fe597 Better errors from unregisterNetworkCallback
This patch changes the validation of unregisterNetworkCallback in
ConnectivityManager so that the caller can better distinguish the case
of a callback that was never registered from the case of a callback that
has already been unregistered.

Bug: 62497809
Test: runtest frameworks-net passes
Change-Id: I58eda22725dd4e67dc4b64207e38cf482032df10
2017-06-19 22:11:50 +09:00
Jeff Sharkey
53d8c2b663 Merge "Annotate @SystemApi with required permissions." into oc-dev
am: c1406978a4

Change-Id: I305967cad945a807c3f8234efabaad0ef8b591d1
2017-06-05 22:28:21 +00:00
Jeff Sharkey
9b39e9abdb 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
Hugo Benichi
0b379f7f69 Merge "ConnectivityManager: simplify callback handler" am: 5e6af581e4 am: 7bce658dd6
am: a67fb638fa

Change-Id: I3934666df4a02101351993f7f83fb0a42124a2f5
2017-05-23 06:37:24 +00:00
Hugo Benichi
ea0c83ccb7 Merge "ConnectivityManager: improve argument validation" am: 3ca6c89b37 am: 0187514f74
am: b800e8520e

Change-Id: Idfc0938025c633c89f5bfddd88b3721876d085ef
2017-05-23 03:41:52 +00:00
Hugo Benichi
b6c2406c4c ConnectivityManager: simplify callback handler
Bug: 36701874
Test: $ runtest frameworks-net
Change-Id: I4d5f08903a54f8dced7cb6ae86703847b908b784
2017-05-23 10:39:46 +09:00
Hugo Benichi
bc1104b465 ConnectivityManager: improve argument validation
Using Preconditions and dedicated static methods for checking arguments
to improve error stack traces without error messages.

Test: covered by previously added unit test
Bug: 36701874
Change-Id: Id872b2c887a4bca43a8c3644622add1c2ee57c6d
2017-05-23 10:39:45 +09:00
Hugo Benichi
85c5572cc2 Merge "Address ConnectivityManager API comments." am: 37c09c96b9 am: b57db6ef97
am: 08ab9ea526

Change-Id: I8e5e44043bb7efde3e21650e7edf3f121aff1e6e
2017-05-19 23:36:09 +00:00
Hugo Benichi
37c09c96b9 Merge "Address ConnectivityManager API comments." 2017-05-19 23:05:57 +00:00
Lorenzo Colitti
de1e515306 Add a method to start the captive portal login app.
Bug: 36203355
Bug: 36656914
Test: ConnectivityServiceTest (including new test) passes
Change-Id: Ide82858af67024623560ab79beea27c201b63447
Merged-In: I82a9a9a8da47870ba3f1bbef5941b37e970c844f

(cherry picked from commit 500dbae1b5)
2017-05-19 00:58:41 +00:00
Hugo Benichi
5ac64c51f5 Address ConnectivityManager API comments.
This patch is a cherry pick of the two following commits:
  - 139a48c83c which addresses several
    issues in the public api of ConnectivityManager.
  - 4c11db0fdd which fixes the documentation
    of several methods in ConnectivityManager public api.

Because the first commit change the public api that is referenced in
the documentation fixed by the second commit, it is not possible to one
without the other. In both cases trying to cherry pick only one of them
results in a build error.

The first commit was submitted successfully on an internal branch before
the checks done in the built got stricter.

Bug: 36370941
Test: marlin builds and boots
Change-Id: I86dcf056e6b165e527c3ee88dbabc2764ac09a08
Merged-In: I693ee5270bf186c88c7c5056293519f7237504ff

(cherry picked from commit 139a48c83c)
2017-05-17 21:48:05 +09:00
Hugo Benichi
216aae5188 Merge "Remove unused import in ConnectivityManager" am: db6fc1afe8 am: fe098f8207
am: e13c192d0f

Change-Id: Ib8368c5a8538914cba2723368c03618401ac159f
2017-05-16 13:25:09 +00:00
Hugo Benichi
5d426da614 Remove unused import in ConnectivityManager
This makes the pre-upload verification pass.

Test: no functional change.
Change-Id: I6beccea10ccfcb39d975cb8f6f34fc9d79f1e170
2017-05-16 11:39:08 +09:00
Hugo Benichi
39294ce0cd Merge changes Ie762ce75,I611fd791 am: 21a57f263f am: cc9f695ba0
am: 164854bde2

Change-Id: I1495249f1ced84438dbd5dd0ad6678e2ee4062cb
2017-05-11 14:28:23 +00:00
Hugo Benichi
a590ab8373 ConnectivityManager: uses service error codes and exceptions
This patch introduces between ConnectivityManager and
ConnectivityService a mechanism for propagating back to clients
informative errors in the form of error codes and associated custom
runtime exceptions.

Without error code, the service can only throw a limited number of
different exceptions over Binder. Furthermore the throw site stack
traces are always loss. Although for individual instances of a throw,
the error message can be inspected, aggregations of stack traces from
app crashes sanitize error messages and only leaves the stack traces.

This makes debugging dificult for some service calls such as
requestNetwork that can have a variety of failure modes.

In this patch only one failure mode is codified. More can be added later
at a light cost by: 1) defining an error code, 2) defining an
associated exception, 3) mapping the code to the exception. This patch
can serves as a template for doing so.

Test: $ runtest frameworks-net,
      #testNetworkRequestMaximum() detects the new exception type.
Bug:  36556809, 36701874
Change-Id: I611fd7915575c9e418f7149fcdc8a879d2a3716d
2017-05-11 14:15:15 +09:00
Lorenzo Colitti
f7ffa460e4 Move some NetworkStats tests to tests/net.
This groups them together with the rest of the networking unit
tests. It also speeds up compile/test cycles ("runtest -x" of one
file goes from 1m15s to 30s).

Bug: 33681750
Test: runtest frameworks-net passes on internal tree
Merged-In: I53cb0c51355fe4b4b30e451fa09fbbf58da39efd
Change-Id: I5ae5dbf74c94feb0fe3759681e5e6d6fba62fa32

(cherry picked from commit c86013be936f36c61fa0cdfad95141f6de3c6ef7)
2017-05-08 08:38:08 +00:00
Lorenzo Colitti
d388cbb9e4 Merge "Add a method to start the captive portal login app." into oc-dev
am: 5555b1e3d1

Change-Id: Ic7c14bd3dfd07f97c04901f043ed1cd3b1eee6e4
2017-05-02 04:44:31 +00:00
Lorenzo Colitti
500dbae1b5 Add a method to start the captive portal login app.
Bug: 36203355
Bug: 36656914
Test: ConnectivityServiceTest (including new test) passes
Change-Id: I82a9a9a8da47870ba3f1bbef5941b37e970c844f
2017-05-01 16:01:15 +09:00
Lorenzo Colitti
a75dc7e122 Merge "Address ConnectivityManager API comments." into oc-dev
am: 2121eeec48

Change-Id: I7024b4fe23ab12760fb452a59929df886912b104
2017-04-28 04:04:21 +00:00
Lorenzo Colitti
139a48c83c Address ConnectivityManager API comments.
Bug: 36370941
Test: marlin builds and boots
Change-Id: I693ee5270bf186c88c7c5056293519f7237504ff
2017-04-28 00:58:00 +09:00
Hugo Benichi
8e8532c8f3 NetworkCapabilities: remove duplicated TRANSPORT_NAMES
Due to multi-branch automerging issue, TRANSPORT_NAMES got inserted
twice into NetworkCapabilities both by commits 45670bb37d and
21665ac809. This patch deletes one of the copy.

Test: no functionality change. Build is fixed.
Change-Id: I2adec1a9cb1ee6f1d61dfeec2d0b92b8141eed88
2017-04-25 16:31:06 +09:00
Jeff Sharkey
1ee1487e29 Merge "Even more auto-doc work." into oc-dev
am: 880f4f4cc2

Change-Id: I78199f8366fbda65a4b4917675291d946e29285c
2017-04-24 21:38:03 +00:00
Jeff Sharkey
656584aa8d Even more auto-doc work.
Update docs based on what new lint detector found.  Add new @IntDef
to parameters or methods returning constants or flags, and add
@RequiresPermission to methods mentioning permissions.

Test: make -j32 offline-sdk-docs
Bug: 37526420
Change-Id: I7f640f7883fcb66b911a52ae93b83f77306571ec
2017-04-24 13:20:46 -06:00
Hugo Benichi
b22a842978 Merge "Add BitUtils bit packing methods (Connectivity metrics: add transports pretty printing)" am: 10b5024d5e am: 23d41ee68e
am: 876ebaa8e1

Change-Id: I0dfcea2b92287115c385f1b7678034f643d5daba
2017-04-24 19:06:20 +00:00
Hugo Benichi
21665ac809 Add BitUtils bit packing methods (Connectivity metrics: add transports pretty printing)
This patch is a partial cherry-pick from commit
cf83a3f4da for the BitUtils and
NetworkCapabilities classes.

Bug: 34901696
Test: none

(cherry picked from commit cf83a3f4da)

Merged-In: Id04f9080e7f75608deeb49306aec34941e71794c
Change-Id: I64eae49f646365b7cd1683a689315fe03bf0bdd9
2017-04-22 09:58:42 +09:00
Treehugger Robot
a6a4f5589c Merge "Mark Restricted APN connections as restricted." 2017-04-21 23:12:52 +00:00
Robert Greenwalt
1f4578fa86 Mark Restricted APN connections as restricted.
If anything unrestricted is bundled in the whole thing has to be
unrestricted (we can't restrict based on destination or intent)
but the NOT_METERED flag wasn't taken into account.

This wasn't a problem before because telephony set that statically
and late, but a change caused it to be marked NOT_METERED earlier
which exposed this bug.

bug: 37208956
Merged-In: I7b7a1c38621ce0ecde8cf041e82b1ebb7a9c6f15
Test: new NetworkCapabilitiesTest.  Fails without fix, works with.
Change-Id: I86c1b2854413a94662aa53e697d32380695ab9ac
2017-04-21 22:00:17 +00:00
Erik Kline
5dbf59c901 Add local-only hotspot info into tether state change broadcast
Test: as follows
    - build
    - flashed
    - booted
    - "runtest frameworks-net" passes
    - manually starting tethering shows Settings and icon updates
Bug: 31466854
Bug: 32163131

Change-Id: I938074587dfeec221c5cdb43a392802ad3fc3589
2017-04-21 13:26:04 +09:00
Erik Kline
015d03a4d1 Merge "Add local-only hotspot info into tether state change broadcast" am: 21a081bf34 am: 6af3dd0fc3
am: 3fa8908370

Change-Id: If3851c3f15314e3c0d357e154049aaa2b8b5c8e7
2017-04-20 14:02:24 +00:00
Hugo Benichi
6fa7889bd8 Merge "ConnectivityManager: remove obsolete callback types" am: afeeac07e2 am: 23ee1621c7
am: b51307e12e

Change-Id: I2f5fad0b559b972e82ecacdfcdd3805f0fbb2655
2017-04-20 13:59:32 +00:00
Erik Kline
278c771b04 Merge "Make tetherChangePermission to be secured for AppOps permission" am: d721dd8ebb am: 0d1f04384f
am: d9bfb83d96

Change-Id: I6dd418684b1a40292cd496ead3613cf938577c09
2017-04-20 13:52:35 +00:00
Hugo Benichi
981ee3f2c3 resolve merge conflicts of 7bbd03be361f to oc-dev-plus-aosp
Conflits were:
  - static import section of ConnectivityService
  - code deleted in commit 8d96292e08

Test: built.
Change-Id: I0e026522558f39d8ae6812b62a30f2501923ab86
2017-04-20 22:26:50 +09:00
Treehugger Robot
21a081bf34 Merge "Add local-only hotspot info into tether state change broadcast" 2017-04-20 12:47:55 +00:00
Hugo Benichi
afeeac07e2 Merge "ConnectivityManager: remove obsolete callback types" 2017-04-20 12:38:29 +00:00
Erik Kline
762fa8eb96 Add local-only hotspot info into tether state change broadcast
Test: as follows
    - build
    - flashed
    - booted
    - "runtest frameworks-net" passes
    - manually starting tethering shows Settings and icon updates
Bug: 31466854
Bug: 32163131

Change-Id: I938074587dfeec221c5cdb43a392802ad3fc3589
2017-04-20 19:44:01 +09:00
Erik Kline
d721dd8ebb Merge "Make tetherChangePermission to be secured for AppOps permission" 2017-04-20 04:28:53 +00:00
Hugo Benichi
f8a0f9f873 ConnectivityManager: remove obsolete callback types
This patch also:
  - suppresses callback triggers from ConnectivityService for these
    obsolete callback types.
  - marginally refactors callCallbackForRequest().

Test: runtest frameworks-net
Change-Id: Idfb75640732943c599de4975f252f706d21ad594
2017-04-20 10:42:38 +09:00
Hugo Benichi
8d96292e08 ConnectivityManager: unify prety printing of callback types.
And also remove some small code duplication (checkNotNull).

Test: built, flashed, runtest frameworks-net
Change-Id: Id6c13bca9d12f70b88806032e0a4fa198efbedc6
2017-04-20 10:42:38 +09:00
Robert Greenwalt
c2a92c30ea Merge commit 'd6c9efa3323f3f5ae44abe312ae5a1e6ef3816ce' into manual_merge_d6c9efa3323f
Change-Id: I86d5e87cc3884d8fc3eb326a92b8871ef0926aa6
2017-04-19 11:24:03 -07:00
Tetsutoki Shiozawa
b47da283e7 Make tetherChangePermission to be secured for AppOps permission
Symptom:
AppOps verified the incorrect package of calling tether state
changing API.
It threw SecurityException by mistake.

Solution:
Pass the correct package name to enforceTetherChangePermission.

Bug: 32931147
Change-Id: Ia1167f26f556678b189a24a4a716f1a7e5cb12eb
2017-04-19 16:50:33 +09:00
Robert Greenwalt
7316f068a7 Mark Restricted APN connections as restricted.
If anything unrestricted is bundled in the whole thing has to be
unrestricted (we can't restrict based on destination or intent)
but the NOT_METERED flag wasn't taken into account.

This wasn't a problem before because telephony set that statically
and late, but a change caused it to be marked NOT_METERED earlier
which exposed this bug.

bug: 37208956
Test: new NetworkCapabilitiesTest.  Fails without fix, works with.
Change-Id: I7b7a1c38621ce0ecde8cf041e82b1ebb7a9c6f15
2017-04-18 11:29:20 -07:00
Hugo Benichi
82ed0de810 Merge "ConnectivityManager: release all requests mapping to a callback." am: 1a8f04b1b2 am: 4d80366762
am: e505b37ec5

Change-Id: I99267e14ab04ce62c5c2385f24f5865e791a24a0
2017-04-14 15:36:10 +00:00
Hugo Benichi
2aa65af966 ConnectivityManager: release all requests mapping to a callback.
This patch changes how callback unregistration works in order to be
consistent with undocumented use cases currently de-facto supported
by the API (although in a buggy way):
  - callback recycling: releasing then reregistering a callback again.
  - multiple request registrations with the same callback.

The second use case is not desirable but needs to be taken into account
for now for the purpose of correctly releasing NetworkRequests
registered in ConnectivityService.

In order to support request release in both use cases with minimal
amount of complexity for the time being the following changes are done:
  - request to callback unmapping is done synchronously at callback
    release time.
  - all requests associated to a callback are unmapped at callback
    release time.

This fixes the following issues:
  - a callback stops being triggered as soon as it is released.
    Otherwise when recycling the callback immediately, it is possible
    the previous request associated with it triggers it, confusing the
    app.
  - when a callback is registered multiple times, the requests are not
    leaked.
  - when a callback is registered multiple times and then released, the
    N-1 first registrations do not trigger the callback anymore.

In the future it would be desirable to enforce the intended 1:1 mapping
between callbacks and requests at registration time.

Bug: 35921499, 35955593, 20701525
Test: - added new tests in ConnectivityManagerTest to test releasing,
      recycling, and a disabled test for no multiple regristration.
      - new tests catch regression causing b/35921499, b/35955593.
Change-Id: Ia0917ac322fc049f76adb4743bc745989fed6d26
2017-04-14 22:17:21 +09:00
Etan Cohen
fedaf00fa3 [CM] Unhide the NetworkSpecifier as object API
API visibility change: unhide allowing NetworkSpecifier
to be an arbitrary object.

Bug: 27533960
Bug: 36053921
Bug: 36275276
Test: builds and runs
Change-Id: I1d1705cca7ece077ef8d7c674c62d5369fedbb03
Merged-In: I7535495681da8f168c46d6d95e13925cffecc99b
Merged-In: I6500639ae839ee9ad5af34d1292d1539c943e2ad
2017-04-14 18:23:45 +09:00
Etan Cohen
6c2ab24a4c Make the NetworkSpecifier a class instead of a string.
Bug: 27533960
Bug: 36053921
Bug: 36275276
Test: connectivity, wifi, telephony unit tests
Change-Id: Idd9b10a8418c53c8cf386d9ff8252226b076bbf9
Merged-In: I7535495681da8f168c46d6d95e13925cffecc99b
Merged-In: I6500639ae839ee9ad5af34d1292d1539c943e2ad
2017-04-14 18:22:10 +09:00
Lorenzo Colitti
dfa91739a6 resolve merge conflicts of 4db137b0599a to oc-dev-plus-aosp
Test: builds
Change-Id: I786ece9b82e47691855c8549e174345080964b91
2017-04-14 11:37:12 +09:00
Hugo Benichi
45670bb37d Connectivity metrics: add transports pretty printing
This patch also
  - partially reverts commit 7f818778a8
    that exposed a getTransports method on NetworkCapabilities.
  - moves enumerateBits to BitUtils (as unpackBits), and adds the
    reverse packBit method.

Bug: 34901696
Test: manually looked at $ adb shell dumpsys connmetrics list
Change-Id: I1650daf8fc9c1b6e0d986d2285f81e888be8847f
Merged-In: Id04f9080e7f75608deeb49306aec34941e71794c

(cherry picked from commit df456e13a1127e3c8594b1d22ea4a9b3dca67a4b)
2017-04-13 22:17:50 +00:00