Loading services/core/java/com/android/server/NetworkManagementService.java +7 −23 Original line number Original line Diff line number Diff line Loading @@ -396,22 +396,12 @@ public class NetworkManagementService extends INetworkManagementService.Stub { * Notify our observers of a change in the data activity state of the interface * Notify our observers of a change in the data activity state of the interface */ */ private void notifyInterfaceClassActivity(int type, boolean isActive, long tsNanos, private void notifyInterfaceClassActivity(int type, boolean isActive, long tsNanos, int uid, boolean fromRadio) { int uid) { final boolean isMobile = ConnectivityManager.isNetworkTypeMobile(type); final boolean isMobile = ConnectivityManager.isNetworkTypeMobile(type); int powerState = isActive int powerState = isActive ? DataConnectionRealTimeInfo.DC_POWER_STATE_HIGH ? DataConnectionRealTimeInfo.DC_POWER_STATE_HIGH : DataConnectionRealTimeInfo.DC_POWER_STATE_LOW; : DataConnectionRealTimeInfo.DC_POWER_STATE_LOW; if (isMobile) { if (isMobile) { if (!fromRadio) { if (mMobileActivityFromRadio) { // If this call is not coming from a report from the radio itself, but we // have previously received reports from the radio, then we will take the // power state to just be whatever the radio last reported. powerState = mLastPowerStateFromRadio; } } else { mMobileActivityFromRadio = true; } if (mLastPowerStateFromRadio != powerState) { if (mLastPowerStateFromRadio != powerState) { mLastPowerStateFromRadio = powerState; mLastPowerStateFromRadio = powerState; try { try { Loading @@ -431,15 +421,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub { } } } } if (!isMobile || fromRadio || !mMobileActivityFromRadio) { // Report the change in data activity. We don't do this if this is a change // on the mobile network, that is not coming from the radio itself, and we // have previously seen change reports from the radio. In that case only // the radio is the authority for the current state. final boolean active = isActive; final boolean active = isActive; invokeForAllObservers(o -> o.interfaceClassDataActivityChanged( invokeForAllObservers(o -> o.interfaceClassDataActivityChanged( Integer.toString(type), active, tsNanos, uid)); Integer.toString(type), active, tsNanos, uid)); } boolean report = false; boolean report = false; synchronized (mIdleTimerLock) { synchronized (mIdleTimerLock) { Loading Loading @@ -671,7 +655,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub { timestampNanos = timestamp; timestampNanos = timestamp; } } mDaemonHandler.post(() -> mDaemonHandler.post(() -> notifyInterfaceClassActivity(label, isActive, timestampNanos, uid, false)); notifyInterfaceClassActivity(label, isActive, timestampNanos, uid)); } } @Override @Override Loading Loading @@ -1157,7 +1141,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub { mNetworkActive = false; mNetworkActive = false; } } mDaemonHandler.post(() -> notifyInterfaceClassActivity(type, true, mDaemonHandler.post(() -> notifyInterfaceClassActivity(type, true, SystemClock.elapsedRealtimeNanos(), -1, false)); SystemClock.elapsedRealtimeNanos(), -1)); } } } } Loading @@ -1181,7 +1165,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub { } } mActiveIdleTimers.remove(iface); mActiveIdleTimers.remove(iface); mDaemonHandler.post(() -> notifyInterfaceClassActivity(params.type, false, mDaemonHandler.post(() -> notifyInterfaceClassActivity(params.type, false, SystemClock.elapsedRealtimeNanos(), -1, false)); SystemClock.elapsedRealtimeNanos(), -1)); } } } } Loading Loading
services/core/java/com/android/server/NetworkManagementService.java +7 −23 Original line number Original line Diff line number Diff line Loading @@ -396,22 +396,12 @@ public class NetworkManagementService extends INetworkManagementService.Stub { * Notify our observers of a change in the data activity state of the interface * Notify our observers of a change in the data activity state of the interface */ */ private void notifyInterfaceClassActivity(int type, boolean isActive, long tsNanos, private void notifyInterfaceClassActivity(int type, boolean isActive, long tsNanos, int uid, boolean fromRadio) { int uid) { final boolean isMobile = ConnectivityManager.isNetworkTypeMobile(type); final boolean isMobile = ConnectivityManager.isNetworkTypeMobile(type); int powerState = isActive int powerState = isActive ? DataConnectionRealTimeInfo.DC_POWER_STATE_HIGH ? DataConnectionRealTimeInfo.DC_POWER_STATE_HIGH : DataConnectionRealTimeInfo.DC_POWER_STATE_LOW; : DataConnectionRealTimeInfo.DC_POWER_STATE_LOW; if (isMobile) { if (isMobile) { if (!fromRadio) { if (mMobileActivityFromRadio) { // If this call is not coming from a report from the radio itself, but we // have previously received reports from the radio, then we will take the // power state to just be whatever the radio last reported. powerState = mLastPowerStateFromRadio; } } else { mMobileActivityFromRadio = true; } if (mLastPowerStateFromRadio != powerState) { if (mLastPowerStateFromRadio != powerState) { mLastPowerStateFromRadio = powerState; mLastPowerStateFromRadio = powerState; try { try { Loading @@ -431,15 +421,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub { } } } } if (!isMobile || fromRadio || !mMobileActivityFromRadio) { // Report the change in data activity. We don't do this if this is a change // on the mobile network, that is not coming from the radio itself, and we // have previously seen change reports from the radio. In that case only // the radio is the authority for the current state. final boolean active = isActive; final boolean active = isActive; invokeForAllObservers(o -> o.interfaceClassDataActivityChanged( invokeForAllObservers(o -> o.interfaceClassDataActivityChanged( Integer.toString(type), active, tsNanos, uid)); Integer.toString(type), active, tsNanos, uid)); } boolean report = false; boolean report = false; synchronized (mIdleTimerLock) { synchronized (mIdleTimerLock) { Loading Loading @@ -671,7 +655,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub { timestampNanos = timestamp; timestampNanos = timestamp; } } mDaemonHandler.post(() -> mDaemonHandler.post(() -> notifyInterfaceClassActivity(label, isActive, timestampNanos, uid, false)); notifyInterfaceClassActivity(label, isActive, timestampNanos, uid)); } } @Override @Override Loading Loading @@ -1157,7 +1141,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub { mNetworkActive = false; mNetworkActive = false; } } mDaemonHandler.post(() -> notifyInterfaceClassActivity(type, true, mDaemonHandler.post(() -> notifyInterfaceClassActivity(type, true, SystemClock.elapsedRealtimeNanos(), -1, false)); SystemClock.elapsedRealtimeNanos(), -1)); } } } } Loading @@ -1181,7 +1165,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub { } } mActiveIdleTimers.remove(iface); mActiveIdleTimers.remove(iface); mDaemonHandler.post(() -> notifyInterfaceClassActivity(params.type, false, mDaemonHandler.post(() -> notifyInterfaceClassActivity(params.type, false, SystemClock.elapsedRealtimeNanos(), -1, false)); SystemClock.elapsedRealtimeNanos(), -1)); } } } } Loading