Source:
private void notifyInterfaceClassActivity(String iface, int powerState, long tsNanos, int uid, boolean fromRadio) { NetworkCapabilities networkCapabilities = new NetworkCapabilities(); final ConnectivityManager cm = ConnectivityManager.from(mContext); if (!TextUtils.isEmpty(iface)) { for (Network network : cm.getAllNetworks()) { final LinkProperties lp = cm.getLinkProperties(network); if (lp != null && iface.equals(lp.getInterfaceName())) { networkCapabilities = cm.getNetworkCapabilities(network); break; } } } final boolean isMobile = networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR); if (isMobile) { if (!fromRadio) { if (mMobileActivityFromRadio) { powerState = mLastPowerStateFromRadio; } } else { mMobileActivityFromRadio = true; } if (mLastPowerStateFromRadio != powerState) { mLastPowerStateFromRadio = powerState; try { getBatteryStats().noteMobileRadioPowerState(powerState, tsNanos, uid); } catch (RemoteException e) { } } } if (networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) { if (mLastPowerStateFromWifi != powerState) { mLastPowerStateFromWifi = powerState; try { getBatteryStats().noteWifiRadioPowerState(powerState, tsNanos, uid); } catch (RemoteException e) { } } } boolean isActive = powerState == DataConnectionRealTimeInfo.DC_POWER_STATE_MEDIUM || powerState == DataConnectionRealTimeInfo.DC_POWER_STATE_HIGH; if (!isMobile || fromRadio || !mMobileActivityFromRadio) { final boolean active = isActive; invokeForAllObservers(o -> o.interfaceClassDataActivityChanged( iface, active, tsNanos)); } boolean report = false; synchronized (mIdleTimerLock) { if (mActiveIdleTimers.isEmpty()) { isActive = true; } if (mNetworkActive != isActive) { mNetworkActive = isActive; report = isActive; } } if (report) { reportNetworkActive(); } }

Target:
private void notifyInterfaceClassActivity(String iface, int powerState, long tsNanos, int uid, boolean fromRadio) { int transport = -1; synchronized (mIdleTimerLock) { final IdleTimerParams params = mActiveIdleTimers.get(iface); if (params != null) { transport = params.transport; } } final boolean isMobile = transport == NetworkCapabilities.TRANSPORT_CELLULAR; if (isMobile) { if (!fromRadio) { if (mMobileActivityFromRadio) { powerState = mLastPowerStateFromRadio; } } else { mMobileActivityFromRadio = true; } if (mLastPowerStateFromRadio != powerState) { mLastPowerStateFromRadio = powerState; try { getBatteryStats().noteMobileRadioPowerState(powerState, tsNanos, uid); } catch (RemoteException e) { } } } if (transport == NetworkCapabilities.TRANSPORT_WIFI) { if (mLastPowerStateFromWifi != powerState) { mLastPowerStateFromWifi = powerState; try { getBatteryStats().noteWifiRadioPowerState(powerState, tsNanos, uid); } catch (RemoteException e) { } } } boolean isActive = powerState == DataConnectionRealTimeInfo.DC_POWER_STATE_MEDIUM || powerState == DataConnectionRealTimeInfo.DC_POWER_STATE_HIGH; if (!isMobile || fromRadio || !mMobileActivityFromRadio) { final boolean active = isActive; invokeForAllObservers(o -> o.interfaceClassDataActivityChanged( iface, active, tsNanos)); } boolean report = false; synchronized (mIdleTimerLock) { if (mActiveIdleTimers.isEmpty()) { isActive = true; } if (mNetworkActive != isActive) { mNetworkActive = isActive; report = isActive; } } if (report) { reportNetworkActive(); } }