Skip to content
Snippets Groups Projects
Commit 9b6420bc authored by Motomu Utsumi's avatar Motomu Utsumi Committed by Gerrit Code Review
Browse files

Merge "Update mActiveIdleTimers to use netId as a key" into main

parents 0b5d7850 473c38d1
No related branches found
No related tags found
No related merge requests found
......@@ -11468,7 +11468,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
// If there is no default network, default network is considered active to keep the existing
// behavior. Initial value is used until first connect to the default network.
private volatile boolean mIsDefaultNetworkActive = true;
private final ArrayMap<String, IdleTimerParams> mActiveIdleTimers = new ArrayMap<>();
// Key is netId. Value is configured idle timer information.
private final SparseArray<IdleTimerParams> mActiveIdleTimers = new SparseArray<>();
 
private static class IdleTimerParams {
public final int timeout;
......@@ -11496,7 +11497,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
 
public void handleReportNetworkActivity(NetworkActivityParams activityParams) {
ensureRunningOnConnectivityServiceThread();
if (mActiveIdleTimers.isEmpty()) {
if (mActiveIdleTimers.size() == 0) {
// This activity change is not for the current default network.
// This can happen if netd callback post activity change event message but
// the default network is lost before processing this message.
......@@ -11572,6 +11573,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
*/
private boolean setupDataActivityTracking(NetworkAgentInfo networkAgent) {
final String iface = networkAgent.linkProperties.getInterfaceName();
final int netId = networkAgent.network().netId;
 
final int timeout;
final int type;
......@@ -11596,7 +11598,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
 
if (timeout > 0 && iface != null) {
try {
mActiveIdleTimers.put(iface, new IdleTimerParams(timeout, type));
mActiveIdleTimers.put(netId, new IdleTimerParams(timeout, type));
mNetd.idletimerAddInterface(iface, timeout, Integer.toString(type));
return true;
} catch (Exception e) {
......@@ -11612,6 +11614,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
*/
private void removeDataActivityTracking(NetworkAgentInfo networkAgent) {
final String iface = networkAgent.linkProperties.getInterfaceName();
final int netId = networkAgent.network().netId;
final NetworkCapabilities caps = networkAgent.networkCapabilities;
 
if (iface == null) return;
......@@ -11627,11 +11630,12 @@ public class ConnectivityService extends IConnectivityManager.Stub
 
try {
updateRadioPowerState(false /* isActive */, type);
final IdleTimerParams params = mActiveIdleTimers.remove(iface);
final IdleTimerParams params = mActiveIdleTimers.get(netId);
if (params == null) {
// IdleTimer is not added if the configured timeout is 0 or negative value
return;
}
mActiveIdleTimers.remove(netId);
// The call fails silently if no idle timer setup for this interface
mNetd.idletimerRemoveInterface(iface, params.timeout,
Integer.toString(params.transportType));
......@@ -11702,9 +11706,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
pw.print("mIsDefaultNetworkActive="); pw.println(mIsDefaultNetworkActive);
pw.println("Idle timers:");
try {
for (Map.Entry<String, IdleTimerParams> ent : mActiveIdleTimers.entrySet()) {
pw.print(" "); pw.print(ent.getKey()); pw.println(":");
final IdleTimerParams params = ent.getValue();
for (int i = 0; i < mActiveIdleTimers.size(); i++) {
pw.print(" "); pw.print(mActiveIdleTimers.keyAt(i)); pw.println(":");
final IdleTimerParams params = mActiveIdleTimers.valueAt(i);
pw.print(" timeout="); pw.print(params.timeout);
pw.print(" type="); pw.println(params.transportType);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment