Commit graph android_packages_modules_Co.../service/src/com/android/server/ConnectivityService.java
Message SHA1
Merge "Remove unnecessary arguments from isTetheringFeatureEnabled" into main am: 656e42e16f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2709175

Change-Id: Ie05295a8a59cf957ac3c3da4ef87a64fe8ffa206
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Motomu Utsumi   authored and   Automerger Merge Worker   commited 2023-09-08 10:09:42 +00:00
97ed1eef10
Remove unnecessary arguments from isTetheringFeatureEnabled
This CL also updates not to use isTetheringFeatureEnabled for
TETHER_FORCE_UPSTREAM_AUTOMATIC_VERSION which is wrongly configured in
Connectivity namespace.

Test: m
Bug: 279108992
Change-Id: If4f3a57c749bbaeb85454c31248c5bc5feaab936

Motomu Utsumi   commited 2023-09-08 16:11:28 +09:00
3e0be398a2
Merge "Delay frozen app sockets close until the cellular modem wakes up" into main am: 4e95ea0740
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2608568

Change-Id: I8d5127f1adf82fa6924175a68efa08692f874fc7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Motomu Utsumi   authored and   Automerger Merge Worker   commited 2023-09-05 09:40:50 +00:00
25bc872fc2
Delay frozen app sockets close until the cellular modem wakes up
Closing TCP sockets sends RST packets. If the cellular modem is idle,
sending RST packets will wake the modem up and consume battery.

This CL adds delay_destroy_frozen_sockets_version flag.
When this flag and destroy_frozen_sockets_version is enabled,
ConnectivityService delays closing socket until the cellular modem wakes up.
Pending frozen sockets are closed also when cellular network becomes no
longer the default network.

This CL also adds flag status and pending uids to the dump.

Bug: 284900338
Test: FrameworksNetTests
Change-Id: I2562568390dda36d02f72afb3a96f824788964c0

Motomu Utsumi   commited 2023-09-04 18:04:31 +09:00
188bfd36da
Merge Android U (ab/10368041)
Bug: 291102124
Merged-In: Iff29b090c0b41d0103997a80788f09c2602df074
Change-Id: I5b03523defc88ffbc3aeab9ac8a29b4ca5a11f57

Xin Li   commited 2023-08-25 13:52:17 -07:00
4a6c653160
Merge "Execute netd callbacks on CS handler thread" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-08-24 08:33:03 +00:00
f180b14d9a
Execute netd callbacks on CS handler thread
Test: TH
Bug: 293965195
Change-Id: I178a9904d2ee090ed1fb487c061226909cbde1d6

Chalard Jean   commited 2023-08-24 15:44:15 +09:00
5d05c4b9d1
Rename to isTetheringFeatureEnabled
DeviceConfigUtils has isFeatureEnabled for NetworkStack and Tethering
which were confusing since the difference was only the arguments.
This CL renames isFeatureEnabled for Tethering module to
isTetheringFeatureEnabled to avoid confusion.

Bug: 279108992
Test: m
Change-Id: I05255bb38619afbe621d29524d7910d206a149f1

Motomu Utsumi   commited 2023-08-17 17:47:19 +09:00
624aeb4274
Merge "Use destroyLiveTcpSocketsByOwnerUids for frozen apps" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-08-09 05:17:14 +00:00
b7d3f3fd77
Revert isDefaultNetworkActive behavior when there is no default network
aosp/2605757 updated isDefaultNetworkActive returns false when there is
no default network.
But this change was not merged to U release branch and this change was
not well tested by dogfooding.
So this CL reverts the isDefaultNetworkActivity behavior change.

Bug: 279380356
Bug: 291870075
Test: atest FrameworksNetTests
Change-Id: Id88662faea9eeaba93d59ab2729f6204a3631ab1

Motomu Utsumi   commited 2023-08-01 12:50:00 +09:00
51e7a60359
Revert onNetworkActive callback behavior on U+
aosp/2605757 changed onNetworkActive callback behavior on U+ but this
change was not merged to U release branch.
This CL reverts the behavior change and keep the current behavior on U+.

Bug: 279380356
Bug: 291870075
Test: atest FrameworksNetTests
Change-Id: I91ccc7ee93f0827986401f316997b4a2df11318f

Motomu Utsumi   commited 2023-07-31 19:33:24 +09:00
1e51a64988
Use destroyLiveTcpSocketsByOwnerUids for frozen apps
Bug: 284900338
Test: FrameworksNetTests
Change-Id: Ia10f3c3b01c42d6ae5ba7b18786b66ca3209b108

Motomu Utsumi   commited 2023-06-29 11:41:06 +09:00
588a64587d
Never create native network immediately.
This patch flags off the functionality added by aosp/2162425
in the wake of b/286649301 where a race in ConnectivityService
breaks WiFi connectivity until reboot.

Bug: 286649301
Test: NetworkAgentTest
      ConnectivityServiceTest
Change-Id: I96d755445f6e1f88bb71a7d32742e87dae185250

Chalard Jean   commited 2023-06-27 20:05:20 +09:00
a16607f421
Revert "Always disconnect agents immediately."
This reverts commit 4bc9fa6b8c.

Reason for revert: b/288450518

Some iterations over mNetworkAgentInfos result in networks being
disconnected, which removes them from mNetworkAgentInfos during
iteration. This crashes with NPE or OOB exceptions.

Bug: 286649301
Bug: 288149251
Bug: 288450518
Change-Id: I6e0b5b614d9e88267db77cb807ae4bf09f88c0f6

Jean Chalard   authored and   Chalard Jean   commited 2023-06-27 19:19:11 +09:00
3160bc0825
Evaluation delay = 8 secs for explicitly selected networks
When a network was explicitly selected, the user just tapped it and
is likely waiting for it to connect. A shorter timeout is therefore
more appropriate for these.

Bug: 281970908
Test: New test in ConnectivityServiceTest
Change-Id: I99a263960cbc9292868fc4bb46a4f3b2f3c71541

Chalard Jean   commited 2023-06-20 18:48:39 +09:00
0f1413395d
Merge "Fixes isDefaultNetworkActive and onNetworkActive unreasonable behavior" am: e0365d45ca am: dd0653ee79 am: 57073a67e1
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2605757

Change-Id: If869b552a4b7c59a088e8eae657683364f7105c3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Motomu Utsumi   authored and   Automerger Merge Worker   commited 2023-06-20 02:59:04 +00:00
e702f985c6
Merge "Remove locks from LegacyNetworkActivityTracker" am: d66e846764 am: 7dd8c0ead3 am: 7380d35aa1
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2606669

Change-Id: I1295ac32f5ad7e0d6b0e623f3bca692f854bc304
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Motomu Utsumi   authored and   Automerger Merge Worker   commited 2023-06-20 02:58:54 +00:00
ec6df2053a
Merge "Add executing thread check in LegacyNetworkActivityTracker" am: 48d4e66542 am: c34a1628ff am: b9ea7b707e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2605754

Change-Id: I99b210050d80d273f6c8420125ff7e020fcd75c0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Motomu Utsumi   authored and   Automerger Merge Worker   commited 2023-06-20 02:58:43 +00:00
a754722358
Merge "Add idleTimer existence check before removing idleTimer" am: 40177cf4cb am: 204765e5e5 am: f0fb1e6e38
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2605753

Change-Id: I4e3c21dcae0ff5d10e9f6e6b44f22a8a7194b47e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Motomu Utsumi   authored and   Automerger Merge Worker   commited 2023-06-20 02:58:32 +00:00
2ea33a84e8
Merge "Move network activity change processing to handler thread" am: df9a2d7e20 am: b3f309ca24 am: 557fbbdf90
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2606673

Change-Id: If88c3e9a4a7022e63d7d8188b4b578a5ffcb6479
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Motomu Utsumi   authored and   Automerger Merge Worker   commited 2023-06-20 02:58:21 +00:00
2affe13aa3
Merge "Fixes isDefaultNetworkActive and onNetworkActive unreasonable behavior"
Motomu Utsumi   authored and   Gerrit Code Review   commited 2023-06-20 01:00:24 +00:00
e0365d45ca
Fixes isDefaultNetworkActive and onNetworkActive unreasonable behavior
This CL changes the behavior as follows.

Before this CL, isDefaultNetworkActive returns true if there is no
default network.
After this CL, isDefaultNetworkActive returns false if there is no
default network on all releases.

Before this CL, LegacyNetworkActivityTracker does not call
onNetworkActive callback for networks that tracker does not add the idle
timer to (e.g.  ethernet, cell network configured with activity tracking
disabled).
After this CL,
On T-, onNetworkActive keeps the current behavior.
On U+, onNetworkActive is called regardless of the idle timer existence. This behavior is consistent with ConnectivityManager#isDefaultNetworkActive, which always returns true for a network that has no activity tracking.

Bug: 267870186
Bug: 279380356
Test: atest FrameworksNetTests
Change-Id: I7b1d493fea0ab028b53a3d640a58a00ebbdcc143

Motomu Utsumi   commited 2023-06-20 00:59:46 +00:00
6225d57b18
Merge "Remove locks from LegacyNetworkActivityTracker"
Motomu Utsumi   authored and   Gerrit Code Review   commited 2023-06-20 00:58:14 +00:00
d66e846764
Merge "Add executing thread check in LegacyNetworkActivityTracker"
Motomu Utsumi   authored and   Gerrit Code Review   commited 2023-06-20 00:57:45 +00:00
48d4e66542
Merge "Add idleTimer existence check before removing idleTimer"
Motomu Utsumi   authored and   Gerrit Code Review   commited 2023-06-20 00:45:03 +00:00
40177cf4cb
Merge "Move network activity change processing to handler thread"
Motomu Utsumi   authored and   Gerrit Code Review   commited 2023-06-20 00:44:47 +00:00
df9a2d7e20
Remove locks from LegacyNetworkActivityTracker
Following CLs update LegacyNetworkActivityTracker to support multiple
network activity tracking on U+ devices.
This CL is a preparation for them.

Reasons for having locks in LegacyNetworkActivityTracker were 1)
mNetworkActive can be updated from non handler thread 2)
isDefaultNetworkActive can be called from non handler thread and this
return boolean based on mNetworkActive and mActiveIdleTimers.

aosp/2606673 moves the activity change processing to handler thread
and resolved the first reason.
This CL updates isDefaultNetworkActive to just return
mNetworkActive and resolved the second reason.

So, now LegacyNetworkActivityTracker doesn't need locks and this CL
removed the locks.

Bug: 267870186
Bug: 279380356
Test: atest FrameworksNetTests
Change-Id: I12e3a00c6f8c4a0c40b45b9461860fe2e82fe22a

Motomu Utsumi   commited 2023-06-19 16:03:29 +09:00
c298cf0c2d
Merge "Always disconnect agents immediately." am: d925df8aa6 am: a89d79e3c7 am: 235cb64505
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2623893

Change-Id: I850e1253735cff84730e36f92cc3ce7763dac00a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2023-06-15 06:31:03 +00:00
7ed3e7d540
Always disconnect agents immediately.
Currently, various codepaths in ConnectivityService disconnect
networks using NetworkAgentInfo#disconnect. This posts a message
to the NetworkAgent to disconnect and also posts a message to
ConnectivityService to call disconnectAndDestroyNetwork, which
performs all cleanup in ConnectivityService. These two messages
race and the order is non-deterministic.

Instead, always disconnect using disconnectAndDestroyNetwork,
and have disconnectAndDestroyNetwork post the message to the
agent to disconnect.

This fixes a bug where if wifi uses unregisterAfterReplacement
twice in quick succession, when the third agent connects it
doesn't work because the interface is still being used by the
second network.

Also remove the import of IllegalArgumentException to keep the
linter happy (java.lang.* never needs to be imported).

Bug: 286649301
Test: covered by existing tests
Change-Id: Ie01f5589d6839ac6db25f0ba98fc929fbb5b0a96

Lorenzo Colitti   commited 2023-06-14 18:03:02 +09:00
4bc9fa6b8c
Merge changes I4994dd8d,I98c1aab4 am: 472d51344c am: fccaf1b299 am: bbfeebace0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2620696

Change-Id: I68db492f0d0e95dda68bcae9198b76292ede0635
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Maciej Żenczykowski   authored and   Automerger Merge Worker   commited 2023-06-09 11:22:48 +00:00
6d45dab095
Merge changes I4994dd8d,I98c1aab4
* changes:
  Annotate ClatCoordinator with RequiresApi(T), part 2
  Annotate ClatCoordinator with RequiresApi(T)

Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2023-06-09 09:06:25 +00:00
472d51344c
Annotate ClatCoordinator with RequiresApi(T), part 2
Test: TreeHugger
Bug: 284253984
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4994dd8d4e5e303bca6c33928d359064632b3c4d

Maciej Żenczykowski   commited 2023-06-09 09:06:19 +00:00
7b05987701
Add executing thread check in LegacyNetworkActivityTracker
One of the reasons for having locks in LegacyNetworkActivityTracker is
mNetworkActive is updated from non handler thread.
aosp/2606673 moves network activity change processing to handler thread.
All the methods that update mNetworkActive and mActiveIdleTimers should
be called from handler thread now.

Bug: 267870186
Bug: 279380356
Test: atest FrameworksNetTests
Change-Id: I5c8cd0b253a77a2740ade3a0145ef80336b3b133

Motomu Utsumi   commited 2023-06-09 17:41:01 +09:00
e0ecaea594
Add idleTimer existence check before removing idleTimer
IdleTimer tracking can be disabled if configured timeout is 0 or
negative value.
In this case, setupDataActivityTracking does not add idleTimer and
removeDataActivityTracking causes NPE.
This did not cause crash since the code to cause NPE is wrapped by try
catch.
This CL adds check to avoid causing NPE.

Bug: 267870186
Bug: 279380356
Test: atest FrameworksNetTests
Change-Id: Id774c5ee3d0318d9736f287c50ccf4c7c5743aef

Motomu Utsumi   commited 2023-06-09 17:28:47 +09:00
00ccb51aa3
Move network activity change processing to handler thread
Following CLs update LegacyNetworkActivityTracker to support multiple
network activity tracking on U+ devices.
This CL is a preparation for them.

Bug: 267870186
Bug: 279380356
Test: atest FrameworksNetTests
Change-Id: I2598feef93ef34e10bf576560f687ff7fc449ab9

Motomu Utsumi   commited 2023-06-09 17:28:47 +09:00
5dfaf4e176
Merge "Remove spurious WTF on pre-U devices." am: c2851d45fd am: 80e186e43d am: a1d077267e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2618590

Change-Id: I74ff8480827d125ec27d8578c135843a93c2fbb0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2023-06-07 10:57:40 +00:00
f071a921c1
Merge "Remove spurious WTF on pre-U devices."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2023-06-07 09:00:13 +00:00
c2851d45fd
Remove spurious WTF on pre-U devices.
aosp/2162425 added a WTF if a NetworkAgent changed state before
its native network has been created. This was intended to apply
only to the new U+ codepath, where networks are always created
immediately as soon as their agents register them. But the WTF is
logged on pre-U devices as well.

Fix this so that the WTF is only logged when the new codepath is
running.

Fix: 285999421
Test: TH
Change-Id: I28bda08a006978ab760fe8891bf5cf15b536201a

Lorenzo Colitti   commited 2023-06-07 11:42:20 +09:00
233f2d1d19
Merge "Fix a bug where the PAC proxy port is not set correctly." am: f2b38772ac am: 19fec43662 am: 9a0b1f2653
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1729153

Change-Id: I1612e3a0360961267264c80ecff16ec49e75f33e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Jean Chalard   authored and   Automerger Merge Worker   commited 2023-06-06 14:23:47 +00:00
78efbdcad1
Merge "Fix a bug where the PAC proxy port is not set correctly."
Jean Chalard   authored and   Gerrit Code Review   commited 2023-06-06 12:22:21 +00:00
f2b38772ac
Fix a bug where the PAC proxy port is not set correctly.
Test: new test for this behavior in the preliminary change
Test: FrameworksNetTests NetworkStackTests
Fixes: 138810051
Fixes: 140610528
Change-Id: I95a979d232fb60ece2e33e972bf5d66d20357a1f

Aaron Huang   authored and   Chalard Jean   commited 2023-06-05 20:24:59 +09:00
9fe47bee09
On U+ require config_networkWakeupPacketMark/Mask to be 0x80000000 am: f310a14d53
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/23560649

Change-Id: I09b9d6caea14179c065ab719c5141a2cc8b27a2c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Maciej Żenczykowski   authored and   Automerger Merge Worker   commited 2023-06-05 10:31:32 +00:00
fb12b4ad40
Merge "On U+ require config_networkWakeupPacketMark/Mask to be 0x80000000"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-06-05 09:34:47 +00:00
c133f6e29c
On U+ require config_networkWakeupPacketMark/Mask to be 0x80000000
See system/netd/include/Fwmark.h which reserves the bottom 21 bits
of skb->mark for netid, etc... so out of necessity these have to be
in the top 11 bits.

In practice the only values that really make sense are either:
  mark == mask == 0 (disabled)
or (mark == mask) being one of the top 11 available bits, for example:
  mark == mask == 0x80000000 (enabled, using top-most bit)
(only a single bit makes sense, as this is really just a boolean signal,
 and only the topmost is known to be used on any real devices)

Let's just force the use of 0x80000000 for ecosystem consistency.

Bug: 284334830
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
(cherry picked from https://android-review.googlesource.com/q/commit:767cf7f1cfc6d612bc8554fef8c354fdd660695b)
Merged-In: I199e9b00de845b3747940426ea6644426ab72e87
Change-Id: I199e9b00de845b3747940426ea6644426ab72e87

Maciej Żenczykowski   commited 2023-06-05 07:44:18 +00:00
f310a14d53
On U+ require config_networkWakeupPacketMark/Mask to be 0x80000000
See system/netd/include/Fwmark.h which reserves the bottom 21 bits
of skb->mark for netid, etc... so out of necessity these have to be
in the top 11 bits.

In practice the only values that really make sense are either:
  mark == mask == 0 (disabled)
or (mark == mask) being one of the top 11 available bits, for example:
  mark == mask == 0x80000000 (enabled, using top-most bit)
(only a single bit makes sense, as this is really just a boolean signal,
 and only the topmost is known to be used on any real devices)

Let's just force the use of 0x80000000 for ecosystem consistency.

Bug: 284334830
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I199e9b00de845b3747940426ea6644426ab72e87

Maciej Żenczykowski   commited 2023-06-05 07:41:00 +00:00
cf41fc877a
Merge "Use netd socketDestroy for VPN in T-" am: d8b852fc06 am: fb2ec37ecd am: d54d71ed34
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2614310

Change-Id: I6871fbdee5896c460ba69781140c78541cb8f974
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Motomu Utsumi   authored and   Automerger Merge Worker   commited 2023-06-05 04:51:11 +00:00
0ddac8acd2
Merge "Use netd socketDestroy for VPN in T-"
Motomu Utsumi   authored and   Gerrit Code Review   commited 2023-06-05 03:04:19 +00:00
d8b852fc06
Use netd socketDestroy for VPN in T-
aosp/2490881 updated to use InetDiagMessage.destroyLiveTcpSocket for all
devices.
But it is possible that netd socketDestory is modified in T- devices.
So this CL revert changes to keep using netd socketDestroy in T-
devices.

Test: atest FrameworksNetTests
Bug: 284253763
Change-Id: I9b61f10e975d2e38e9829a8c01d3af706e2518ef

Motomu Utsumi   commited 2023-06-04 23:12:58 +09:00
1d13726710
Merge "Add tests for PAC proxies." am: 5e76b40973 am: 4155e6ec97 am: 4ae128e7e1
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1729152

Change-Id: Ifc4c685e724de1c3727b560d0213b4257f71da54
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Jean Chalard   authored and   Automerger Merge Worker   commited 2023-06-01 21:59:13 +00:00
cab00afb88
Merge "Add tests for PAC proxies."
Jean Chalard   authored and   Gerrit Code Review   commited 2023-06-01 05:20:37 +00:00
5e76b40973