Commit Graph

307 Commits

Author SHA1 Message Date
Lorenzo Colitti
a9e06c1b90 [automerger skipped] Don't call maybeTrackInterface on the wrong thread. am: 6123533817 -s ours am: 30f9b1dbf8 -s ours
am skip reason: Change-Id Ia2cb265f8d4de96210f1462339c10ad2947eec65 with SHA-1 6123533817 is in history

Change-Id: I6010d72e7e7364142e8dc961dd2f4bea16a0eed5
2020-04-22 08:43:33 +00:00
Lorenzo Colitti
dd1f90eb69 [automerger skipped] Don't call maybeTrackInterface on the wrong thread. am: 6123533817 am: dc3c209dd1 -s ours
am skip reason: Change-Id Ia2cb265f8d4de96210f1462339c10ad2947eec65 with SHA-1 bd66333a24 is in history

Change-Id: Ie311603d95412f9dcd820c0a25b2e7f30476ed94
2020-04-22 08:42:48 +00:00
Lorenzo Colitti
dc3c209dd1 Don't call maybeTrackInterface on the wrong thread. am: 6123533817
Change-Id: Idc00a7e5520ccae2db848d729f0fe80aab724468
2020-04-22 08:32:54 +00:00
Lorenzo Colitti
30f9b1dbf8 [automerger skipped] Don't call maybeTrackInterface on the wrong thread. am: 6123533817 -s ours
am skip reason: Change-Id Ia2cb265f8d4de96210f1462339c10ad2947eec65 with SHA-1 bd66333a24 is in history

Change-Id: If41fd756ec2faa88a4fb2a5cbea5778c72cd48ab
2020-04-22 08:32:18 +00:00
Lorenzo Colitti
6123533817 Don't call maybeTrackInterface on the wrong thread.
Bug: 150644681
Test: atest TetheringIntegrationTests:EthernetTetheringTest --rerun-until-failure 100
Merged-In: Ia2cb265f8d4de96210f1462339c10ad2947eec65
Change-Id: Ia2cb265f8d4de96210f1462339c10ad2947eec65
2020-04-22 06:42:46 +00:00
Chalard Jean
b3f4c82c61 [automerger skipped] Address further API council comments. am: 4b9a7dd13d am: 7608da3e3a -s ours am: 7f49fa7dad -s ours
am skip reason: Change-Id I7c27f76c54a76abeae46dcdcddaeb3ca48afa358 with SHA-1 dff893b275 is in history

Change-Id: Icb83b93cb122f70861d2617ebf2ea7c46b13818d
2020-04-02 07:00:10 +00:00
Chalard Jean
7f49fa7dad [automerger skipped] Address further API council comments. am: 4b9a7dd13d am: 7608da3e3a -s ours
am skip reason: Change-Id I7c27f76c54a76abeae46dcdcddaeb3ca48afa358 with SHA-1 dff893b275 is in history

Change-Id: I73c243ccc7e14b895fdf0ab67493ba471b696f50
2020-04-02 06:37:15 +00:00
Chalard Jean
c86bfb7117 [automerger skipped] Convert the Ethernet factory to the new network agent am: 86aac0daec am: 7f511738e0 -s ours am: 9abd9e2504 -s ours
am skip reason: Change-Id Ie7b70750ef0e17141080f4266dea6155c3601569 with SHA-1 79eb7ba87b is in history

Change-Id: Iba771d95f044ae505cdedf6c2a94ac057c0d05a2
2020-04-01 11:39:41 +00:00
Chalard Jean
9abd9e2504 [automerger skipped] Convert the Ethernet factory to the new network agent am: 86aac0daec am: 7f511738e0 -s ours
am skip reason: Change-Id Ie7b70750ef0e17141080f4266dea6155c3601569 with SHA-1 79eb7ba87b is in history

Change-Id: Id73857a02ed1e4b3b30d5166451af59e7583cd72
2020-04-01 11:19:44 +00:00
Chalard Jean
4b9a7dd13d Address further API council comments.
Test: FrameworksNetTests NetworkStackTests
Bug: 152238712
Copy from ag/10857997
Change-Id: I7c27f76c54a76abeae46dcdcddaeb3ca48afa358
Merged-In: I7c27f76c54a76abeae46dcdcddaeb3ca48afa358
2020-04-01 11:04:18 +00:00
Chalard Jean
86aac0daec Convert the Ethernet factory to the new network agent
This is a combination of ag/10147368 and ag/10438581.
ag/10147368 implemented this conversion together with
using the planned NetworkScore API, while ag/10438581
reverted the parts that had to do with NetworkScore.
This is just a squash of these two patches and it
brings the factory in line with the code in rvc-dev.

Test: FrameworksNetTests NetworkStackTests EthernetTetheringTest
Change-Id: Ib214fbbd042f2c0ebd01cf5b0ec33d922629677e
Merged-In: Ie7b70750ef0e17141080f4266dea6155c3601569
2020-04-01 09:09:32 +00:00
Chalard Jean
7fc8220a53 Merge "Address further API council comments." into rvc-dev am: d3a0721fb5 am: cc9cab6311
Change-Id: Ib995f82ee38a7105b28b5cdccb04d73dc6f43b81
2020-03-27 23:07:02 +00:00
Chalard Jean
d02358a6cc Merge "Address further API council comments." into rvc-dev am: d3a0721fb5 am: bad3318c8e
Change-Id: I8cc1054a4f9c3bde0d3e47f8e1099aaec0609529
2020-03-27 23:02:26 +00:00
Chalard Jean
bad3318c8e Merge "Address further API council comments." into rvc-dev am: d3a0721fb5
Change-Id: I30c12bd1f44911306ba543cd1ad1e78cef35e0c6
2020-03-27 22:58:34 +00:00
Chalard Jean
cc9cab6311 Merge "Address further API council comments." into rvc-dev am: d3a0721fb5
Change-Id: I3baeb9a62722dfc35063dda3c1480cf627ecf237
2020-03-27 22:56:26 +00:00
Chalard Jean
d3a0721fb5 Merge "Address further API council comments." into rvc-dev 2020-03-27 22:50:42 +00:00
Lorenzo Colitti
a33bf42216 [automerger skipped] Fix querying Ethernet availability for unprivileged callers. am: bc7ff5d89f am: 6b4862dfc8 -s ours
am skip reason: Change-Id Idff3b05a193a80c581d80d0e4fe9c2d3fc0d8a25 with SHA-1 bc7ff5d89f is in history

Change-Id: Ib0e588434a8dd04280ef0df1f8f2d3abdfeff7a3
2020-03-27 14:35:52 +00:00
Lorenzo Colitti
2ed1da60c0 [automerger skipped] Fix querying Ethernet availability for unprivileged callers. am: bc7ff5d89f -s ours am: 54e8d7400a -s ours
am skip reason: Change-Id Idff3b05a193a80c581d80d0e4fe9c2d3fc0d8a25 with SHA-1 dd397f58c7 is in history

Change-Id: I535ef517fd18b84e1b4f1823c656ac14bc798f00
2020-03-27 14:35:09 +00:00
Lorenzo Colitti
54e8d7400a [automerger skipped] Fix querying Ethernet availability for unprivileged callers. am: bc7ff5d89f -s ours
am skip reason: Change-Id Idff3b05a193a80c581d80d0e4fe9c2d3fc0d8a25 with SHA-1 dd397f58c7 is in history

Change-Id: I551191401ef145f60ce43992dc1130cda0d62838
2020-03-27 14:17:55 +00:00
Lorenzo Colitti
6b4862dfc8 Fix querying Ethernet availability for unprivileged callers. am: bc7ff5d89f
Change-Id: I7b670de0724e00ee48fe234b2bd193501c7c783c
2020-03-27 14:17:36 +00:00
Lorenzo Colitti
bc7ff5d89f Fix querying Ethernet availability for unprivileged callers.
Both EthernetManager#getAvailableInterfaces() and the no-arg
version of EthernetManager#isAvailable() end up calling
EthernetServiceImpl#getAvailableInterfaces. This method attempts
to filter out restricted interfaces if the caller does not have
the CONNECTIVITY_USE_RESTRICTED_NETWORKS permission.

Unfortunately EthernetNetworkFactory's notion of a restricted
interface is the opposite of what it should be. This means that
while privileged callers can see all interfaces, unprivileged
callers can only see restricted interfaces which they cannot use.

Fix this by correcting NetworkInterfaceState#isRestricted(), so
that unprivileged callers can see only unrestricted interfaces.
Privileged callers are unaffected.

This bug probably went unnoticed because restricted Ethernet
interfaces are rare (likely used only on auto devices) and
because the callers that care about those restricted interfaces
are generally privileged.

Bug: 148824036
Test: atest android.net.EthernetTetheringTest#testPhysicalEthernet
Merged-In: Idff3b05a193a80c581d80d0e4fe9c2d3fc0d8a25
Change-Id: Idff3b05a193a80c581d80d0e4fe9c2d3fc0d8a25
2020-03-27 11:38:33 +00:00
Lorenzo Colitti
1ba2a5d379 Fix querying Ethernet availability for unprivileged callers. am: dd397f58c7 am: 4ff97e70da am: 6b41e255c6
Change-Id: Ib4491ccd852bdb0fa8ad93e031239714239c1a4a
2020-03-27 09:18:12 +00:00
Lorenzo Colitti
6b41e255c6 Fix querying Ethernet availability for unprivileged callers. am: dd397f58c7 am: 4ff97e70da
Change-Id: I125e0f6c3ed7005cba55cefc0872d55262fcd596
2020-03-27 09:06:27 +00:00
Chalard Jean
dff893b275 Address further API council comments.
Test: FrameworksNetTests NetworkStackTests
Bug: 152238712
Change-Id: I7c27f76c54a76abeae46dcdcddaeb3ca48afa358
2020-03-27 15:05:02 +09:00
Lorenzo Colitti
dd397f58c7 Fix querying Ethernet availability for unprivileged callers.
Both EthernetManager#getAvailableInterfaces() and the no-arg
version of EthernetManager#isAvailable() end up calling
EthernetServiceImpl#getAvailableInterfaces. This method attempts
to filter out restricted interfaces if the caller does not have
the CONNECTIVITY_USE_RESTRICTED_NETWORKS permission.

Unfortunately EthernetNetworkFactory's notion of a restricted
interface is the opposite of what it should be. This means that
while privileged callers can see all interfaces, unprivileged
callers can only see restricted interfaces which they cannot use.

Fix this by correcting NetworkInterfaceState#isRestricted(), so
that unprivileged callers can see only unrestricted interfaces.
Privileged callers are unaffected.

This bug probably went unnoticed because restricted Ethernet
interfaces are rare (likely used only on auto devices) and
because the callers that care about those restricted interfaces
are generally privileged.

Bug: 148824036
Test: atest android.net.EthernetTetheringTest#testPhysicalEthernet
Change-Id: Idff3b05a193a80c581d80d0e4fe9c2d3fc0d8a25
2020-03-26 22:53:10 +09:00
Lorenzo Colitti
cbbac4940d Don't call maybeTrackInterface on the wrong thread. am: bd66333a24 am: fbe05a3c1a am: b8327f43aa
Change-Id: Id4e2753b445edd6fe719441b501337ff2df8f23f
2020-03-26 10:24:20 +00:00
Lorenzo Colitti
b8327f43aa Don't call maybeTrackInterface on the wrong thread. am: bd66333a24 am: fbe05a3c1a
Change-Id: Ib032004882f40dcdb8f1614a2b1f0ec97dd153e4
2020-03-26 09:58:55 +00:00
Lorenzo Colitti
bd66333a24 Don't call maybeTrackInterface on the wrong thread.
Bug: 150644681
Test: atest TetheringIntegrationTests:EthernetTetheringTest --rerun-until-failure 100
Change-Id: Ia2cb265f8d4de96210f1462339c10ad2947eec65
2020-03-26 17:02:27 +09:00
Lorenzo Colitti
0f0c14b99b [automerger skipped] Send tethered interface callbacks based on interface existence. am: 0c30d949df -s ours am: b6c727b208 -s ours
am skip reason: Change-Id I015219cbd03626c38fb5156d0cb2991ba7d7def7 with SHA-1 0c30d949df is in history

Change-Id: I799d401c9dbb64031ee0601bfbb869588c2843dc
2020-03-20 01:17:22 +00:00
Lorenzo Colitti
84fea4258b [automerger skipped] Send tethered interface callbacks based on interface existence. am: 0c30d949df am: 32a1f9a35c -s ours
am skip reason: Change-Id I015219cbd03626c38fb5156d0cb2991ba7d7def7 with SHA-1 165b456d92 is in history

Change-Id: I36f91fca0d679a9673b743be953f191e16440330
2020-03-20 01:17:04 +00:00
Lorenzo Colitti
4c80e73bfa [automerger skipped] Support setting the default interface to null again. am: 876e5e16a9 am: 65c1bc7c5d -s ours
am skip reason: Change-Id I5109d8da3aeb6c1f6523291d9e2ec92c64b5ad2d with SHA-1 876e5e16a9 is in history

Change-Id: Ie8adbc5239fdf8343a9b0e4cd30eddc28e96caaa
2020-03-20 01:16:55 +00:00
Lorenzo Colitti
f7bc865d2c [automerger skipped] Support setting the default interface to null again. am: 876e5e16a9 -s ours am: 6fb426f10a -s ours
am skip reason: Change-Id I5109d8da3aeb6c1f6523291d9e2ec92c64b5ad2d with SHA-1 e81f99d532 is in history

Change-Id: I53102631b3030ba3307c2ffe04d340c9421fc50b
2020-03-20 01:09:43 +00:00
Lorenzo Colitti
b6c727b208 [automerger skipped] Send tethered interface callbacks based on interface existence. am: 0c30d949df -s ours
am skip reason: Change-Id I015219cbd03626c38fb5156d0cb2991ba7d7def7 with SHA-1 165b456d92 is in history

Change-Id: I798052af6ff6704c9088c3e0f2952b1ccc41d94b
2020-03-20 00:45:05 +00:00
Lorenzo Colitti
32a1f9a35c Send tethered interface callbacks based on interface existence. am: 0c30d949df
Change-Id: I34e7e1ee8e1cbceb8f3941543dac9299e96a7e27
2020-03-20 00:44:59 +00:00
Lorenzo Colitti
6fb426f10a [automerger skipped] Support setting the default interface to null again. am: 876e5e16a9 -s ours
am skip reason: Change-Id I5109d8da3aeb6c1f6523291d9e2ec92c64b5ad2d with SHA-1 e81f99d532 is in history

Change-Id: I3adadae13ef96c50e4083b8d826730e0fb4990fd
2020-03-20 00:44:57 +00:00
Lorenzo Colitti
65c1bc7c5d Support setting the default interface to null again. am: 876e5e16a9
Change-Id: I88a98acb57b48fb9eedf104ed783a7d27b12e47f
2020-03-20 00:44:42 +00:00
Lorenzo Colitti
4615bbe667 Send tethered interface callbacks based on interface existence. am: 165b456d92 am: cad2e49acb am: 3449a34474
Change-Id: Iac66c95f07fe81d5c9e1b5dfcd42fe676ea2bc70
2020-03-19 16:16:22 +00:00
Lorenzo Colitti
a79245c7f0 Support setting the default interface to null again. am: e81f99d532 am: e19d6a8764 am: 4b10eea44f
Change-Id: I0633a83170f9e9cda8113fe1ccf7b6225f16e794
2020-03-19 16:16:14 +00:00
Lorenzo Colitti
0c30d949df Send tethered interface callbacks based on interface existence.
Currently, callbacks for tethered interface availability are sent
based on interface link state. This is incorrect:

- It is acceptable and expected to be able to enable tethering on
  an interface that does not yet have link up.
- It doesn't seem useful to disable Ethernet tethering if link
  temporarily goes down.

Instead, only base the callbacks on whether an interface exists
or not.

Bug: 150644681
Test: WIP tests in aosp/1260100 pass
Change-Id: I015219cbd03626c38fb5156d0cb2991ba7d7def7
Merged-In: I015219cbd03626c38fb5156d0cb2991ba7d7def7
(cherry picked from commit 64d12ea20ce3cd822518e0f15ed7483a2fb91a50)
2020-03-19 15:54:05 +00:00
Lorenzo Colitti
876e5e16a9 Support setting the default interface to null again.
Currently, the default interface can only ever go from null to
non-null. This is correct for fixed interfaces (because they
don't get unplugged) and it's generally correct for USB
interfaces that use ethX as their device name (because when
they are unplugged and plugged in again, the device name won't
change). But it is not correct if, for example, the default
interface is a test interface. So, allow mDefaultInterface to go
back to null.

This CL also fixes a crash if a tethered interface request is
added and removed when there is no default interface.

Also, make dump() report tethered interface requests.

Also remove an unused variable that I missed in the previous CL.

Bug: 150644681
Test: tested by EthernetTetheringTest in same topic
Change-Id: I5109d8da3aeb6c1f6523291d9e2ec92c64b5ad2d
Merged-In: I5109d8da3aeb6c1f6523291d9e2ec92c64b5ad2d
(cherry picked from commit cc156c2f7793731b2699e194d4b164138ee4cf62)
2020-03-19 15:53:13 +00:00
Lorenzo Colitti
3449a34474 Send tethered interface callbacks based on interface existence. am: 165b456d92 am: cad2e49acb
Change-Id: I4b24ea24ede2856d8c33df3e2331efe9d5825ca6
2020-03-19 15:52:09 +00:00
Lorenzo Colitti
4b10eea44f Support setting the default interface to null again. am: e81f99d532 am: e19d6a8764
Change-Id: I373f51835b48bdb9c7a678c4779f1a9079c7a181
2020-03-19 15:52:03 +00:00
Lorenzo Colitti
8f07511302 [automerger skipped] Make Ethernet interfaces more testable. am: fb336e9296 -s ours am: 523093a1ff -s ours
am skip reason: Change-Id I86eef7a93267f800dbfc8eafd307effa76a344ca with SHA-1 841195a103 is in history

Change-Id: Iec8edbba782a10b8d5c2b8c740d265dc2c11e2a1
2020-03-19 15:00:06 +00:00
Lorenzo Colitti
6910d448e5 [automerger skipped] Make Ethernet interfaces more testable. am: fb336e9296 am: 5cc44b3cdd -s ours
am skip reason: Change-Id I86eef7a93267f800dbfc8eafd307effa76a344ca with SHA-1 841195a103 is in history

Change-Id: Ia96d3fa55a985e8a37c0e8b2b5893dce986b7898
2020-03-19 14:59:45 +00:00
Lorenzo Colitti
523093a1ff [automerger skipped] Make Ethernet interfaces more testable. am: fb336e9296 -s ours
am skip reason: Change-Id I86eef7a93267f800dbfc8eafd307effa76a344ca with SHA-1 841195a103 is in history

Change-Id: I31d44b8c1a538f7c4573cf6fa476529326a9c0bf
2020-03-19 14:44:23 +00:00
Lorenzo Colitti
5cc44b3cdd Make Ethernet interfaces more testable. am: fb336e9296
Change-Id: I99a104ce76bbf3ceaca5497ab22b468d716769e0
2020-03-19 14:44:04 +00:00
Lorenzo Colitti
165b456d92 Send tethered interface callbacks based on interface existence.
Currently, callbacks for tethered interface availability are sent
based on interface link state. This is incorrect:

- It is acceptable and expected to be able to enable tethering on
  an interface that does not yet have link up.
- It doesn't seem useful to disable Ethernet tethering if link
  temporarily goes down.

Instead, only base the callbacks on whether an interface exists
or not.

Bug: 150644681
Test: WIP tests in aosp/1260100 pass
Change-Id: I015219cbd03626c38fb5156d0cb2991ba7d7def7
2020-03-19 22:12:32 +09:00
Lorenzo Colitti
e81f99d532 Support setting the default interface to null again.
Currently, the default interface can only ever go from null to
non-null. This is correct for fixed interfaces (because they
don't get unplugged) and it's generally correct for USB
interfaces that use ethX as their device name (because when
they are unplugged and plugged in again, the device name won't
change). But it is not correct if, for example, the default
interface is a test interface. So, allow mDefaultInterface to go
back to null.

This CL also fixes a crash if a tethered interface request is
added and removed when there is no default interface.

Also, make dump() report tethered interface requests.

Also remove an unused variable that I missed in the previous CL.

Bug: 150644681
Test: tested by EthernetTetheringTest in same topic
Change-Id: I5109d8da3aeb6c1f6523291d9e2ec92c64b5ad2d
2020-03-19 22:04:23 +09:00
Lorenzo Colitti
fb336e9296 Make Ethernet interfaces more testable.
This CL adds a setIncludeTestInterfaces method to EthernetManager
that, when called, causes the Ethernet service to recognize and
manage test interfaces created by TestNetworkManager.

Bug: 150644681
Test: Tested by EthernetTetheringTest in same topic
Change-Id: I86eef7a93267f800dbfc8eafd307effa76a344ca
Merged-In: I86eef7a93267f800dbfc8eafd307effa76a344ca
(cherry picked from commit 4978dbd5fb6592fc4e7be08d02783752245da634)
2020-03-19 12:29:35 +00:00
Lorenzo Colitti
7988bb7cdf Make Ethernet interfaces more testable. am: 841195a103 am: 6d590906f5 am: ee43f745bd
Change-Id: I680a4f7ab3d3b02eb35bfd2477136f87ef514c9f
2020-03-19 11:49:13 +00:00