Loading AndroidManifest.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,7 @@ <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" /> <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" /> <uses-permission android:name="android.permission.NETWORK_STACK" /> <uses-permission android:name="android.permission.NETWORK_STACK" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" /> <application <application android:label="NetworkStack" android:label="NetworkStack" android:defaultToDeviceProtectedStorage="true" android:defaultToDeviceProtectedStorage="true" Loading src/com/android/server/connectivity/NetworkMonitor.java +19 −43 Original line number Original line Diff line number Diff line Loading @@ -67,15 +67,9 @@ import android.os.RemoteException; import android.os.SystemClock; import android.os.SystemClock; import android.os.UserHandle; import android.os.UserHandle; import android.provider.Settings; import android.provider.Settings; import android.telephony.CellIdentityCdma; import android.telephony.AccessNetworkConstants; import android.telephony.CellIdentityGsm; import android.telephony.NetworkRegistrationState; import android.telephony.CellIdentityLte; import android.telephony.ServiceState; import android.telephony.CellIdentityWcdma; import android.telephony.CellInfo; import android.telephony.CellInfoCdma; import android.telephony.CellInfoGsm; import android.telephony.CellInfoLte; import android.telephony.CellInfoWcdma; import android.telephony.TelephonyManager; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.text.TextUtils; import android.util.Log; import android.util.Log; Loading Loading @@ -1486,10 +1480,6 @@ public class NetworkMonitor extends StateMachine { */ */ private void sendNetworkConditionsBroadcast(boolean responseReceived, boolean isCaptivePortal, private void sendNetworkConditionsBroadcast(boolean responseReceived, boolean isCaptivePortal, long requestTimestampMs, long responseTimestampMs) { long requestTimestampMs, long responseTimestampMs) { if (!mWifiManager.isScanAlwaysAvailable()) { return; } if (!mSystemReady) { if (!mSystemReady) { return; return; } } Loading @@ -1497,6 +1487,10 @@ public class NetworkMonitor extends StateMachine { Intent latencyBroadcast = Intent latencyBroadcast = new Intent(NetworkMonitorUtils.ACTION_NETWORK_CONDITIONS_MEASURED); new Intent(NetworkMonitorUtils.ACTION_NETWORK_CONDITIONS_MEASURED); if (mNetworkCapabilities.hasTransport(TRANSPORT_WIFI)) { if (mNetworkCapabilities.hasTransport(TRANSPORT_WIFI)) { if (!mWifiManager.isScanAlwaysAvailable()) { return; } WifiInfo currentWifiInfo = mWifiManager.getConnectionInfo(); WifiInfo currentWifiInfo = mWifiManager.getConnectionInfo(); if (currentWifiInfo != null) { if (currentWifiInfo != null) { // NOTE: getSSID()'s behavior changed in API 17; before that, SSIDs were not // NOTE: getSSID()'s behavior changed in API 17; before that, SSIDs were not Loading @@ -1516,39 +1510,21 @@ public class NetworkMonitor extends StateMachine { } } latencyBroadcast.putExtra(NetworkMonitorUtils.EXTRA_CONNECTIVITY_TYPE, TYPE_WIFI); latencyBroadcast.putExtra(NetworkMonitorUtils.EXTRA_CONNECTIVITY_TYPE, TYPE_WIFI); } else if (mNetworkCapabilities.hasTransport(TRANSPORT_CELLULAR)) { } else if (mNetworkCapabilities.hasTransport(TRANSPORT_CELLULAR)) { // TODO(b/123893112): Support multi-sim. latencyBroadcast.putExtra(NetworkMonitorUtils.EXTRA_NETWORK_TYPE, latencyBroadcast.putExtra(NetworkMonitorUtils.EXTRA_NETWORK_TYPE, mTelephonyManager.getNetworkType()); mTelephonyManager.getNetworkType()); List<CellInfo> info = mTelephonyManager.getAllCellInfo(); final ServiceState dataSs = mTelephonyManager.getServiceState(); if (info == null) return; if (dataSs == null) { int numRegisteredCellInfo = 0; logw("failed to retrieve ServiceState"); for (CellInfo cellInfo : info) { if (cellInfo.isRegistered()) { numRegisteredCellInfo++; if (numRegisteredCellInfo > 1) { if (VDBG) { logw("more than one registered CellInfo." + " Can't tell which is active. Bailing."); } return; return; } } if (cellInfo instanceof CellInfoCdma) { // See if the data sub is registered for PS services on cell. CellIdentityCdma cellId = ((CellInfoCdma) cellInfo).getCellIdentity(); final NetworkRegistrationState nrs = dataSs.getNetworkRegistrationState( latencyBroadcast.putExtra(NetworkMonitorUtils.EXTRA_CELL_ID, cellId); NetworkRegistrationState.DOMAIN_PS, } else if (cellInfo instanceof CellInfoGsm) { AccessNetworkConstants.TransportType.WWAN); CellIdentityGsm cellId = ((CellInfoGsm) cellInfo).getCellIdentity(); latencyBroadcast.putExtra( latencyBroadcast.putExtra(NetworkMonitorUtils.EXTRA_CELL_ID, cellId); NetworkMonitorUtils.EXTRA_CELL_ID, } else if (cellInfo instanceof CellInfoLte) { nrs == null ? null : nrs.getCellIdentity()); CellIdentityLte cellId = ((CellInfoLte) cellInfo).getCellIdentity(); latencyBroadcast.putExtra(NetworkMonitorUtils.EXTRA_CELL_ID, cellId); } else if (cellInfo instanceof CellInfoWcdma) { CellIdentityWcdma cellId = ((CellInfoWcdma) cellInfo).getCellIdentity(); latencyBroadcast.putExtra(NetworkMonitorUtils.EXTRA_CELL_ID, cellId); } else { if (VDBG) logw("Registered cellinfo is unrecognized"); return; } } } latencyBroadcast.putExtra(NetworkMonitorUtils.EXTRA_CONNECTIVITY_TYPE, TYPE_MOBILE); latencyBroadcast.putExtra(NetworkMonitorUtils.EXTRA_CONNECTIVITY_TYPE, TYPE_MOBILE); } else { } else { return; return; Loading Loading
AndroidManifest.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,7 @@ <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" /> <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" /> <uses-permission android:name="android.permission.NETWORK_STACK" /> <uses-permission android:name="android.permission.NETWORK_STACK" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" /> <application <application android:label="NetworkStack" android:label="NetworkStack" android:defaultToDeviceProtectedStorage="true" android:defaultToDeviceProtectedStorage="true" Loading
src/com/android/server/connectivity/NetworkMonitor.java +19 −43 Original line number Original line Diff line number Diff line Loading @@ -67,15 +67,9 @@ import android.os.RemoteException; import android.os.SystemClock; import android.os.SystemClock; import android.os.UserHandle; import android.os.UserHandle; import android.provider.Settings; import android.provider.Settings; import android.telephony.CellIdentityCdma; import android.telephony.AccessNetworkConstants; import android.telephony.CellIdentityGsm; import android.telephony.NetworkRegistrationState; import android.telephony.CellIdentityLte; import android.telephony.ServiceState; import android.telephony.CellIdentityWcdma; import android.telephony.CellInfo; import android.telephony.CellInfoCdma; import android.telephony.CellInfoGsm; import android.telephony.CellInfoLte; import android.telephony.CellInfoWcdma; import android.telephony.TelephonyManager; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.text.TextUtils; import android.util.Log; import android.util.Log; Loading Loading @@ -1486,10 +1480,6 @@ public class NetworkMonitor extends StateMachine { */ */ private void sendNetworkConditionsBroadcast(boolean responseReceived, boolean isCaptivePortal, private void sendNetworkConditionsBroadcast(boolean responseReceived, boolean isCaptivePortal, long requestTimestampMs, long responseTimestampMs) { long requestTimestampMs, long responseTimestampMs) { if (!mWifiManager.isScanAlwaysAvailable()) { return; } if (!mSystemReady) { if (!mSystemReady) { return; return; } } Loading @@ -1497,6 +1487,10 @@ public class NetworkMonitor extends StateMachine { Intent latencyBroadcast = Intent latencyBroadcast = new Intent(NetworkMonitorUtils.ACTION_NETWORK_CONDITIONS_MEASURED); new Intent(NetworkMonitorUtils.ACTION_NETWORK_CONDITIONS_MEASURED); if (mNetworkCapabilities.hasTransport(TRANSPORT_WIFI)) { if (mNetworkCapabilities.hasTransport(TRANSPORT_WIFI)) { if (!mWifiManager.isScanAlwaysAvailable()) { return; } WifiInfo currentWifiInfo = mWifiManager.getConnectionInfo(); WifiInfo currentWifiInfo = mWifiManager.getConnectionInfo(); if (currentWifiInfo != null) { if (currentWifiInfo != null) { // NOTE: getSSID()'s behavior changed in API 17; before that, SSIDs were not // NOTE: getSSID()'s behavior changed in API 17; before that, SSIDs were not Loading @@ -1516,39 +1510,21 @@ public class NetworkMonitor extends StateMachine { } } latencyBroadcast.putExtra(NetworkMonitorUtils.EXTRA_CONNECTIVITY_TYPE, TYPE_WIFI); latencyBroadcast.putExtra(NetworkMonitorUtils.EXTRA_CONNECTIVITY_TYPE, TYPE_WIFI); } else if (mNetworkCapabilities.hasTransport(TRANSPORT_CELLULAR)) { } else if (mNetworkCapabilities.hasTransport(TRANSPORT_CELLULAR)) { // TODO(b/123893112): Support multi-sim. latencyBroadcast.putExtra(NetworkMonitorUtils.EXTRA_NETWORK_TYPE, latencyBroadcast.putExtra(NetworkMonitorUtils.EXTRA_NETWORK_TYPE, mTelephonyManager.getNetworkType()); mTelephonyManager.getNetworkType()); List<CellInfo> info = mTelephonyManager.getAllCellInfo(); final ServiceState dataSs = mTelephonyManager.getServiceState(); if (info == null) return; if (dataSs == null) { int numRegisteredCellInfo = 0; logw("failed to retrieve ServiceState"); for (CellInfo cellInfo : info) { if (cellInfo.isRegistered()) { numRegisteredCellInfo++; if (numRegisteredCellInfo > 1) { if (VDBG) { logw("more than one registered CellInfo." + " Can't tell which is active. Bailing."); } return; return; } } if (cellInfo instanceof CellInfoCdma) { // See if the data sub is registered for PS services on cell. CellIdentityCdma cellId = ((CellInfoCdma) cellInfo).getCellIdentity(); final NetworkRegistrationState nrs = dataSs.getNetworkRegistrationState( latencyBroadcast.putExtra(NetworkMonitorUtils.EXTRA_CELL_ID, cellId); NetworkRegistrationState.DOMAIN_PS, } else if (cellInfo instanceof CellInfoGsm) { AccessNetworkConstants.TransportType.WWAN); CellIdentityGsm cellId = ((CellInfoGsm) cellInfo).getCellIdentity(); latencyBroadcast.putExtra( latencyBroadcast.putExtra(NetworkMonitorUtils.EXTRA_CELL_ID, cellId); NetworkMonitorUtils.EXTRA_CELL_ID, } else if (cellInfo instanceof CellInfoLte) { nrs == null ? null : nrs.getCellIdentity()); CellIdentityLte cellId = ((CellInfoLte) cellInfo).getCellIdentity(); latencyBroadcast.putExtra(NetworkMonitorUtils.EXTRA_CELL_ID, cellId); } else if (cellInfo instanceof CellInfoWcdma) { CellIdentityWcdma cellId = ((CellInfoWcdma) cellInfo).getCellIdentity(); latencyBroadcast.putExtra(NetworkMonitorUtils.EXTRA_CELL_ID, cellId); } else { if (VDBG) logw("Registered cellinfo is unrecognized"); return; } } } latencyBroadcast.putExtra(NetworkMonitorUtils.EXTRA_CONNECTIVITY_TYPE, TYPE_MOBILE); latencyBroadcast.putExtra(NetworkMonitorUtils.EXTRA_CONNECTIVITY_TYPE, TYPE_MOBILE); } else { } else { return; return; Loading