Merge "Revert onNetworkActive callback behavior on U+" into main
This commit is contained in:
@@ -1704,8 +1704,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
mUserAllContext.registerReceiver(mPackageIntentReceiver, packageIntentFilter,
|
mUserAllContext.registerReceiver(mPackageIntentReceiver, packageIntentFilter,
|
||||||
null /* broadcastPermission */, mHandler);
|
null /* broadcastPermission */, mHandler);
|
||||||
|
|
||||||
mNetworkActivityTracker =
|
mNetworkActivityTracker = new LegacyNetworkActivityTracker(mContext, mNetd, mHandler);
|
||||||
new LegacyNetworkActivityTracker(mContext, mNetd, mHandler, mDeps.isAtLeastU());
|
|
||||||
|
|
||||||
final NetdCallback netdCallback = new NetdCallback();
|
final NetdCallback netdCallback = new NetdCallback();
|
||||||
try {
|
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.
|
// This needs to be volatile to allow non handler threads to read this value without lock.
|
||||||
private volatile boolean mIsDefaultNetworkActive;
|
private volatile boolean mIsDefaultNetworkActive;
|
||||||
private final ArrayMap<String, IdleTimerParams> mActiveIdleTimers = new ArrayMap<>();
|
private final ArrayMap<String, IdleTimerParams> mActiveIdleTimers = new ArrayMap<>();
|
||||||
private final boolean mIsAtLeastU;
|
|
||||||
|
|
||||||
private static class IdleTimerParams {
|
private static class IdleTimerParams {
|
||||||
public final int timeout;
|
public final int timeout;
|
||||||
@@ -11154,11 +11152,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
LegacyNetworkActivityTracker(@NonNull Context context, @NonNull INetd netd,
|
LegacyNetworkActivityTracker(@NonNull Context context, @NonNull INetd netd,
|
||||||
@NonNull Handler handler, boolean isAtLeastU) {
|
@NonNull Handler handler) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mNetd = netd;
|
mNetd = netd;
|
||||||
mHandler = handler;
|
mHandler = handler;
|
||||||
mIsAtLeastU = isAtLeastU;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureRunningOnConnectivityServiceThread() {
|
private void ensureRunningOnConnectivityServiceThread() {
|
||||||
@@ -11319,8 +11316,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
boolean hasIdleTimer) {
|
boolean hasIdleTimer) {
|
||||||
if (defaultNetwork != null) {
|
if (defaultNetwork != null) {
|
||||||
mIsDefaultNetworkActive = true;
|
mIsDefaultNetworkActive = true;
|
||||||
// On T-, callbacks are called only when the network has the idle timer.
|
// Callbacks are called only when the network has the idle timer.
|
||||||
if (mIsAtLeastU || hasIdleTimer) {
|
if (hasIdleTimer) {
|
||||||
reportNetworkActive();
|
reportNetworkActive();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -11320,12 +11320,12 @@ public class ConnectivityServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOnNetworkActive_NewEthernetConnects_Callback() throws Exception {
|
public void testOnNetworkActive_NewEthernetConnects_CallbackNotCalled() throws Exception {
|
||||||
// On T-, LegacyNetworkActivityTracker calls onNetworkActive callback only for networks that
|
// 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
|
// tracker adds the idle timer to. And the tracker does not set the idle timer for the
|
||||||
// ethernet network.
|
// ethernet network.
|
||||||
// So onNetworkActive is not called when the ethernet becomes the default 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
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user