Network selection add NGRAN when device support SA
Bug: 187148937 Test: build pass. atest NetworkScanHelperTest (pass) Change-Id: I1ed3eae3bda39eb702bc135b0c698f8df7c280d7
This commit is contained in:
@@ -21,11 +21,14 @@ import android.telephony.AccessNetworkConstants.AccessNetworkType;
|
||||
import android.telephony.CellInfo;
|
||||
import android.telephony.NetworkScan;
|
||||
import android.telephony.NetworkScanRequest;
|
||||
import android.telephony.PhoneCapability;
|
||||
import android.telephony.RadioAccessSpecifier;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.TelephonyScanManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.internal.telephony.CellNetworkScanResult;
|
||||
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
@@ -37,6 +40,7 @@ import com.google.common.util.concurrent.SettableFuture;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.Executor;
|
||||
@@ -111,10 +115,14 @@ public class NetworkScanHelper {
|
||||
public static final int NETWORK_SCAN_TYPE_INCREMENTAL_RESULTS = 2;
|
||||
|
||||
/** The constants below are used in the async network scan. */
|
||||
private static final boolean INCREMENTAL_RESULTS = true;
|
||||
private static final int SEARCH_PERIODICITY_SEC = 5;
|
||||
private static final int MAX_SEARCH_TIME_SEC = 300;
|
||||
private static final int INCREMENTAL_RESULTS_PERIODICITY_SEC = 3;
|
||||
@VisibleForTesting
|
||||
static final boolean INCREMENTAL_RESULTS = true;
|
||||
@VisibleForTesting
|
||||
static final int SEARCH_PERIODICITY_SEC = 5;
|
||||
@VisibleForTesting
|
||||
static final int MAX_SEARCH_TIME_SEC = 300;
|
||||
@VisibleForTesting
|
||||
static final int INCREMENTAL_RESULTS_PERIODICITY_SEC = 3;
|
||||
|
||||
private final NetworkScanCallback mNetworkScanCallback;
|
||||
private final TelephonyManager mTelephonyManager;
|
||||
@@ -133,7 +141,8 @@ public class NetworkScanHelper {
|
||||
mExecutor = executor;
|
||||
}
|
||||
|
||||
private NetworkScanRequest createNetworkScanForPreferredAccessNetworks() {
|
||||
@VisibleForTesting
|
||||
NetworkScanRequest createNetworkScanForPreferredAccessNetworks() {
|
||||
long networkTypeBitmap3gpp = mTelephonyManager.getPreferredNetworkTypeBitmask()
|
||||
& TelephonyManager.NETWORK_STANDARDS_FAMILY_BITMASK_3GPP;
|
||||
|
||||
@@ -161,14 +170,13 @@ public class NetworkScanHelper {
|
||||
// a 5G network, which means that it shouldn't scan for 5G at the expense of battery as
|
||||
// part of the manual network selection process.
|
||||
//
|
||||
// FIXME(b/151119451): re-enable this code once there is a way to distinguish SA from NSA
|
||||
// support in the modem.
|
||||
//
|
||||
// if (networkTypeBitmap3gpp == 0
|
||||
// || (networkTypeBitmap3gpp & TelephonyManager.NETWORK_CLASS_BITMASK_5G) != 0) {
|
||||
// radioAccessSpecifiers.add(
|
||||
// new RadioAccessSpecifier(AccessNetworkType.NGRAN, null, null));
|
||||
// }
|
||||
if (networkTypeBitmap3gpp == 0
|
||||
|| (hasNrSaCapability()
|
||||
&& (networkTypeBitmap3gpp & TelephonyManager.NETWORK_CLASS_BITMASK_5G) != 0)) {
|
||||
radioAccessSpecifiers.add(
|
||||
new RadioAccessSpecifier(AccessNetworkType.NGRAN, null, null));
|
||||
Log.d(TAG, "radioAccessSpecifiers add NGRAN.");
|
||||
}
|
||||
|
||||
return new NetworkScanRequest(
|
||||
NetworkScanRequest.SCAN_TYPE_ONE_SHOT,
|
||||
@@ -253,6 +261,12 @@ public class NetworkScanHelper {
|
||||
mNetworkScanCallback.onError(errCode);
|
||||
}
|
||||
|
||||
private boolean hasNrSaCapability() {
|
||||
return Arrays.stream(
|
||||
mTelephonyManager.getPhoneCapability().getDeviceNrCapabilities())
|
||||
.anyMatch(i -> i == PhoneCapability.DEVICE_NR_CAPABILITY_SA);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the status code of {@link CellNetworkScanResult} to one of the
|
||||
* {@link NetworkScan.ScanErrorCode}.
|
||||
|
Reference in New Issue
Block a user