Skip to content
Snippets Groups Projects
Commit 1e51a649 authored by Motomu Utsumi's avatar Motomu Utsumi
Browse files

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
parent 81559e71
No related branches found
No related tags found
No related merge requests found
......@@ -1704,8 +1704,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
mUserAllContext.registerReceiver(mPackageIntentReceiver, packageIntentFilter,
null /* broadcastPermission */, mHandler);
 
mNetworkActivityTracker =
new LegacyNetworkActivityTracker(mContext, mNetd, mHandler, mDeps.isAtLeastU());
mNetworkActivityTracker = new LegacyNetworkActivityTracker(mContext, mNetd, mHandler);
 
final NetdCallback netdCallback = new NetdCallback();
try {
......@@ -11141,7 +11140,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
// This needs to be volatile to allow non handler threads to read this value without lock.
private volatile boolean mIsDefaultNetworkActive;
private final ArrayMap<String, IdleTimerParams> mActiveIdleTimers = new ArrayMap<>();
private final boolean mIsAtLeastU;
 
private static class IdleTimerParams {
public final int timeout;
......@@ -11154,11 +11152,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
 
LegacyNetworkActivityTracker(@NonNull Context context, @NonNull INetd netd,
@NonNull Handler handler, boolean isAtLeastU) {
@NonNull Handler handler) {
mContext = context;
mNetd = netd;
mHandler = handler;
mIsAtLeastU = isAtLeastU;
}
 
private void ensureRunningOnConnectivityServiceThread() {
......@@ -11319,8 +11316,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
boolean hasIdleTimer) {
if (defaultNetwork != null) {
mIsDefaultNetworkActive = true;
// On T-, callbacks are called only when the network has the idle timer.
if (mIsAtLeastU || hasIdleTimer) {
// Callbacks are called only when the network has the idle timer.
if (hasIdleTimer) {
reportNetworkActive();
}
} else {
......
......@@ -11318,12 +11318,12 @@ public class ConnectivityServiceTest {
}
 
@Test
public void testOnNetworkActive_NewEthernetConnects_Callback() throws Exception {
// On T-, LegacyNetworkActivityTracker calls onNetworkActive callback only for networks that
public void testOnNetworkActive_NewEthernetConnects_CallbackNotCalled() throws Exception {
// LegacyNetworkActivityTracker calls onNetworkActive callback only for networks that
// tracker adds the idle timer to. And the tracker does not set the idle timer for the
// ethernet network.
// So onNetworkActive is not called when the ethernet becomes the default network
doTestOnNetworkActive_NewNetworkConnects(TRANSPORT_ETHERNET, mDeps.isAtLeastU());
doTestOnNetworkActive_NewNetworkConnects(TRANSPORT_ETHERNET, false /* expectCallback */);
}
 
@Test
......
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