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
am skip reason: Change-Id I015219cbd03626c38fb5156d0cb2991ba7d7def7 with SHA-1 0c30d949df is in history
Change-Id: Icceed0b6b2054b28d8e3ad07728fcbb53b31262d
am skip reason: Change-Id I5109d8da3aeb6c1f6523291d9e2ec92c64b5ad2d with SHA-1 876e5e16a9 is in history
Change-Id: I2193378052b1309503b77023da14917810e48e41
am skip reason: Change-Id I015219cbd03626c38fb5156d0cb2991ba7d7def7 with SHA-1 0c30d949df is in history
Change-Id: Idfd895c4ffb29b3caa15b5a7f86f9ff9758c30de
am skip reason: Change-Id I015219cbd03626c38fb5156d0cb2991ba7d7def7 with SHA-1 165b456d92 is in history
Change-Id: Ifadbf3a7cc72bc3dd0067519571e80e669b010d1
am skip reason: Change-Id I5109d8da3aeb6c1f6523291d9e2ec92c64b5ad2d with SHA-1 876e5e16a9 is in history
Change-Id: If9d19fa5ad7ea5a49c5c0fc8d2fb53ef90283d7b
am skip reason: Change-Id I5109d8da3aeb6c1f6523291d9e2ec92c64b5ad2d with SHA-1 e81f99d532 is in history
Change-Id: I47dbc0ccdf9357ef85f2d9e389e0fe47a774b1bd
am skip reason: Change-Id I015219cbd03626c38fb5156d0cb2991ba7d7def7 with SHA-1 0c30d949df is in history
Change-Id: Ia636dce7ecaba574d55352391d99f88224221a49
am skip reason: Change-Id I5109d8da3aeb6c1f6523291d9e2ec92c64b5ad2d with SHA-1 876e5e16a9 is in history
Change-Id: I7f7417ccca7c9cfac332954a6f6dea5a58a54239
am skip reason: Change-Id I015219cbd03626c38fb5156d0cb2991ba7d7def7 with SHA-1 0c30d949df is in history
Change-Id: I1b6127eb68cb3986726ea460c84352c8b23e1e2e
am skip reason: Change-Id I015219cbd03626c38fb5156d0cb2991ba7d7def7 with SHA-1 165b456d92 is in history
Change-Id: I9760fbf2fb0612ed6403c12c7cba213a2f460c74
am skip reason: Change-Id I5109d8da3aeb6c1f6523291d9e2ec92c64b5ad2d with SHA-1 876e5e16a9 is in history
Change-Id: I53d8a9896257920d4a3db462a7f3a1c8974361fa
am skip reason: Change-Id I5109d8da3aeb6c1f6523291d9e2ec92c64b5ad2d with SHA-1 e81f99d532 is in history
Change-Id: I9cea9b849fff6b292d81b6bd2a1c8338d3d271a1
am skip reason: Change-Id I015219cbd03626c38fb5156d0cb2991ba7d7def7 with SHA-1 0c30d949df is in history
Change-Id: I799d401c9dbb64031ee0601bfbb869588c2843dc
am skip reason: Change-Id I015219cbd03626c38fb5156d0cb2991ba7d7def7 with SHA-1 165b456d92 is in history
Change-Id: I36f91fca0d679a9673b743be953f191e16440330
am skip reason: Change-Id I5109d8da3aeb6c1f6523291d9e2ec92c64b5ad2d with SHA-1 876e5e16a9 is in history
Change-Id: Ie8adbc5239fdf8343a9b0e4cd30eddc28e96caaa
am skip reason: Change-Id I5109d8da3aeb6c1f6523291d9e2ec92c64b5ad2d with SHA-1 e81f99d532 is in history
Change-Id: I53102631b3030ba3307c2ffe04d340c9421fc50b
am skip reason: Change-Id I015219cbd03626c38fb5156d0cb2991ba7d7def7 with SHA-1 165b456d92 is in history
Change-Id: I798052af6ff6704c9088c3e0f2952b1ccc41d94b
am skip reason: Change-Id I5109d8da3aeb6c1f6523291d9e2ec92c64b5ad2d with SHA-1 e81f99d532 is in history
Change-Id: I3adadae13ef96c50e4083b8d826730e0fb4990fd
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)
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)
am skip reason: Change-Id I86eef7a93267f800dbfc8eafd307effa76a344ca with SHA-1 fb336e9296 is in history
Change-Id: Ib13d7bc64e59af32acf7dc3c1d317e7476317226
am skip reason: Change-Id I86eef7a93267f800dbfc8eafd307effa76a344ca with SHA-1 fb336e9296 is in history
Change-Id: I8c8fdeb645449b57102b707cf0bc52abb122038f
am skip reason: Change-Id I86eef7a93267f800dbfc8eafd307effa76a344ca with SHA-1 841195a103 is in history
Change-Id: I14d4b2e69c1a518523c1f37b7e1edeaab3df59f6
am skip reason: Change-Id I86eef7a93267f800dbfc8eafd307effa76a344ca with SHA-1 fb336e9296 is in history
Change-Id: I4562315db7b0d4e933d22aa0872a989fa243e5fb
am skip reason: Change-Id I86eef7a93267f800dbfc8eafd307effa76a344ca with SHA-1 fb336e9296 is in history
Change-Id: Iecf35ecae75b28c4bb529b9baf17121ef7e9dea2