From 967c944194be6dc7613e55c0e792f62161133e45 Mon Sep 17 00:00:00 2001 From: Blake Kragten Date: Wed, 29 Apr 2020 15:39:54 -0700 Subject: [PATCH] Report NSA NR As NR Cell Dwell Rate Metric TelephonyManager reports NSA connection as LTE. Thus, cell dwell rate metric will never report that the device is in a 5G state. Changing to specify the network type as NR when NSA connection mode detected. Bug: 154877022 Test: On device on live network Cellular Radio Access Technology: oos 30s 811ms (1.3%) lte 25m 42s 352ms (64.3%) nr 13m 46s 268ms (34.4%) Change-Id: Iacbc5800160cd2a4dd42f6a5520dacc6f47be9a5 --- .../android/server/connectivity/DataConnectionStats.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/services/core/java/com/android/server/connectivity/DataConnectionStats.java b/services/core/java/com/android/server/connectivity/DataConnectionStats.java index 5010e46a74eb1..3e619200d4146 100644 --- a/services/core/java/com/android/server/connectivity/DataConnectionStats.java +++ b/services/core/java/com/android/server/connectivity/DataConnectionStats.java @@ -50,6 +50,7 @@ public class DataConnectionStats extends BroadcastReceiver { private SignalStrength mSignalStrength; private ServiceState mServiceState; private int mDataState = TelephonyManager.DATA_DISCONNECTED; + private int mNrState = NetworkRegistrationInfo.NR_STATE_NONE; public DataConnectionStats(Context context, Handler listenerHandler) { mContext = context; @@ -99,6 +100,11 @@ public class DataConnectionStats extends BroadcastReceiver { mServiceState.getNetworkRegistrationInfo(DOMAIN_PS, TRANSPORT_TYPE_WWAN); int networkType = regInfo == null ? TelephonyManager.NETWORK_TYPE_UNKNOWN : regInfo.getAccessNetworkTechnology(); + // If the device is in NSA NR connection the networkType will report as LTE. + // For cell dwell rate metrics, this should report NR instead. + if (mNrState == NetworkRegistrationInfo.NR_STATE_CONNECTED) { + networkType = TelephonyManager.NETWORK_TYPE_NR; + } if (DEBUG) Log.d(TAG, String.format("Noting data connection for network type %s: %svisible", networkType, visible ? "" : "not ")); try { @@ -153,6 +159,7 @@ public class DataConnectionStats extends BroadcastReceiver { @Override public void onServiceStateChanged(ServiceState state) { mServiceState = state; + mNrState = state.getNrState(); notePhoneDataConnectionState(); }