Merge "Attribute data usage to 5G for 5G non-standalone mode" am: c987a53a93 am: b2cd1cf130 am: d3dda13a8c am: ce0762faa5 am: 45dba047e9

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1359203

Change-Id: Ifde023200e39995411932a44716a3eeb6daea542
This commit is contained in:
Junyu Lai
2020-07-10 03:45:23 +00:00
committed by Automerger Merge Worker

View File

@@ -22,6 +22,7 @@ import android.annotation.NonNull;
import android.content.Context; import android.content.Context;
import android.os.Looper; import android.os.Looper;
import android.telephony.Annotation; import android.telephony.Annotation;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.PhoneStateListener; import android.telephony.PhoneStateListener;
import android.telephony.ServiceState; import android.telephony.ServiceState;
import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager;
@@ -196,7 +197,19 @@ public class NetworkStatsSubscriptionsMonitor extends
@Override @Override
public void onServiceStateChanged(@NonNull ServiceState ss) { public void onServiceStateChanged(@NonNull ServiceState ss) {
final int networkType = ss.getDataNetworkType(); // In 5G SA (Stand Alone) mode, the primary cell itself will be 5G hence telephony
// would report RAT = 5G_NR.
// However, in 5G NSA (Non Stand Alone) mode, the primary cell is still LTE and
// network allocates a secondary 5G cell so telephony reports RAT = LTE along with
// NR state as connected. In such case, attributes the data usage to NR.
// See b/160727498.
final boolean is5GNsa = (ss.getDataNetworkType() == TelephonyManager.NETWORK_TYPE_LTE
|| ss.getDataNetworkType() == TelephonyManager.NETWORK_TYPE_LTE_CA)
&& ss.getNrState() == NetworkRegistrationInfo.NR_STATE_CONNECTED;
final int networkType =
(is5GNsa ? TelephonyManager.NETWORK_TYPE_NR : ss.getDataNetworkType());
final int collapsedRatType = getCollapsedRatType(networkType); final int collapsedRatType = getCollapsedRatType(networkType);
if (collapsedRatType == mLastCollapsedRatType) return; if (collapsedRatType == mLastCollapsedRatType) return;