From 00ccb51aa394a570c63cdec2a45723b17ff2a87c Mon Sep 17 00:00:00 2001 From: Motomu Utsumi Date: Tue, 30 May 2023 18:14:50 +0900 Subject: [PATCH] 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 --- service/src/com/android/server/ConnectivityService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java index c8f614eccb..298c3120d8 100755 --- a/service/src/com/android/server/ConnectivityService.java +++ b/service/src/com/android/server/ConnectivityService.java @@ -11280,6 +11280,10 @@ public class ConnectivityService extends IConnectivityManager.Stub updateRadioPowerState(false /* isActive */, type); synchronized (mActiveIdleTimers) { final IdleTimerParams params = mActiveIdleTimers.remove(iface); + if (params == null) { + // IdleTimer is not added if the configured timeout is 0 or negative value + return; + } // The call fails silently if no idle timer setup for this interface mNetd.idletimerRemoveInterface(iface, params.timeout, Integer.toString(params.transportType));