Merge "Add log for manual network select settings" into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
02a54a0150
@@ -34,6 +34,7 @@ import android.util.Log;
|
|||||||
import com.android.internal.telephony.OperatorInfo;
|
import com.android.internal.telephony.OperatorInfo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add static Utility functions to get information from the CellInfo object.
|
* Add static Utility functions to get information from the CellInfo object.
|
||||||
@@ -161,4 +162,21 @@ public final class CellInfoUtil {
|
|||||||
String plmn = CellInfoUtil.getOperatorInfoFromCellInfo(cellInfo).getOperatorNumeric();
|
String plmn = CellInfoUtil.getOperatorInfoFromCellInfo(cellInfo).getOperatorNumeric();
|
||||||
return forbiddenPlmns != null && forbiddenPlmns.contains(plmn);
|
return forbiddenPlmns != null && forbiddenPlmns.contains(plmn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Convert a list of cellInfos to readable string without sensitive info. */
|
||||||
|
public static String cellInfoListToString(List<CellInfo> cellInfos) {
|
||||||
|
return cellInfos.stream()
|
||||||
|
.map(cellInfo -> cellInfoToString(cellInfo))
|
||||||
|
.collect(Collectors.joining(", "));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Convert {@code cellInfo} to a readable string without sensitive info. */
|
||||||
|
public static String cellInfoToString(CellInfo cellInfo) {
|
||||||
|
String cellType = cellInfo.getClass().getSimpleName();
|
||||||
|
CellIdentity cid = cellInfo.getCellIdentity();
|
||||||
|
return String.format(
|
||||||
|
"{CellType = %s, isRegistered = %b, mcc = %s, mnc = %s, alphaL = %s, alphaS = %s}",
|
||||||
|
cellType, cellInfo.isRegistered(), cid.getMccString(), cid.getMncString(),
|
||||||
|
cid.getOperatorAlphaLong(), cid.getOperatorAlphaShort());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,7 +45,6 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
public class NetworkScanHelper {
|
public class NetworkScanHelper {
|
||||||
public static final String TAG = "NetworkScanHelper";
|
public static final String TAG = "NetworkScanHelper";
|
||||||
private static final boolean DBG = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callbacks interface to inform the network scan results.
|
* Callbacks interface to inform the network scan results.
|
||||||
@@ -184,7 +183,6 @@ public class NetworkScanHelper {
|
|||||||
mExecutor.execute(new NetworkScanSyncTask(
|
mExecutor.execute(new NetworkScanSyncTask(
|
||||||
mTelephonyManager, (SettableFuture) mNetworkScanFuture));
|
mTelephonyManager, (SettableFuture) mNetworkScanFuture));
|
||||||
} else if (type == NETWORK_SCAN_TYPE_INCREMENTAL_RESULTS) {
|
} else if (type == NETWORK_SCAN_TYPE_INCREMENTAL_RESULTS) {
|
||||||
if (DBG) Log.d(TAG, "start network scan async");
|
|
||||||
mNetworkScanRequester = mTelephonyManager.requestNetworkScan(
|
mNetworkScanRequester = mTelephonyManager.requestNetworkScan(
|
||||||
NETWORK_SCAN_REQUEST,
|
NETWORK_SCAN_REQUEST,
|
||||||
mExecutor,
|
mExecutor,
|
||||||
@@ -240,17 +238,18 @@ public class NetworkScanHelper {
|
|||||||
|
|
||||||
private final class NetworkScanCallbackImpl extends TelephonyScanManager.NetworkScanCallback {
|
private final class NetworkScanCallbackImpl extends TelephonyScanManager.NetworkScanCallback {
|
||||||
public void onResults(List<CellInfo> results) {
|
public void onResults(List<CellInfo> results) {
|
||||||
if (DBG) Log.d(TAG, "async scan onResults() results = " + results);
|
Log.d(TAG, "Async scan onResults() results = "
|
||||||
|
+ CellInfoUtil.cellInfoListToString(results));
|
||||||
NetworkScanHelper.this.onResults(results);
|
NetworkScanHelper.this.onResults(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
if (DBG) Log.d(TAG, "async scan onComplete()");
|
Log.d(TAG, "async scan onComplete()");
|
||||||
NetworkScanHelper.this.onComplete();
|
NetworkScanHelper.this.onComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onError(@NetworkScan.ScanErrorCode int errCode) {
|
public void onError(@NetworkScan.ScanErrorCode int errCode) {
|
||||||
if (DBG) Log.d(TAG, "async scan onError() errorCode = " + errCode);
|
Log.d(TAG, "async scan onError() errorCode = " + errCode);
|
||||||
NetworkScanHelper.this.onError(errCode);
|
NetworkScanHelper.this.onError(errCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -267,19 +266,21 @@ public class NetworkScanHelper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (DBG) Log.d(TAG, "sync scan start");
|
final CellNetworkScanResult result = mTelephonyManager.getAvailableNetworks();
|
||||||
CellNetworkScanResult result = mTelephonyManager.getAvailableNetworks();
|
|
||||||
if (result.getStatus() == CellNetworkScanResult.STATUS_SUCCESS) {
|
if (result.getStatus() == CellNetworkScanResult.STATUS_SUCCESS) {
|
||||||
List<CellInfo> cellInfos = result.getOperators()
|
final List<CellInfo> cellInfos = result.getOperators()
|
||||||
.stream()
|
.stream()
|
||||||
.map(operatorInfo
|
.map(operatorInfo
|
||||||
-> CellInfoUtil.convertOperatorInfoToCellInfo(operatorInfo))
|
-> CellInfoUtil.convertOperatorInfoToCellInfo(operatorInfo))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
if (DBG) Log.d(TAG, "sync scan complete");
|
Log.d(TAG, "Sync network scan completed, cellInfos = "
|
||||||
|
+ CellInfoUtil.cellInfoListToString(cellInfos));
|
||||||
mCallback.set(cellInfos);
|
mCallback.set(cellInfos);
|
||||||
} else {
|
} else {
|
||||||
mCallback.setException(new Throwable(
|
final Throwable error = new Throwable(
|
||||||
Integer.toString(convertToScanErrorCode(result.getStatus()))));
|
Integer.toString(convertToScanErrorCode(result.getStatus())));
|
||||||
|
mCallback.setException(error);
|
||||||
|
Log.d(TAG, "Sync network scan error, ex = " + error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,7 @@ import android.telephony.NetworkRegistrationInfo;
|
|||||||
import android.telephony.ServiceState;
|
import android.telephony.ServiceState;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
@@ -230,6 +231,8 @@ public class NetworkSelectSettings extends DashboardFragment {
|
|||||||
break;
|
break;
|
||||||
case EVENT_NETWORK_SCAN_RESULTS:
|
case EVENT_NETWORK_SCAN_RESULTS:
|
||||||
List<CellInfo> results = aggregateCellInfoList((List<CellInfo>) msg.obj);
|
List<CellInfo> results = aggregateCellInfoList((List<CellInfo>) msg.obj);
|
||||||
|
Log.d(TAG, "CellInfoList after aggregation: "
|
||||||
|
+ CellInfoUtil.cellInfoListToString(results));
|
||||||
mCellInfoList = new ArrayList<>(results);
|
mCellInfoList = new ArrayList<>(results);
|
||||||
if (mCellInfoList != null && mCellInfoList.size() != 0) {
|
if (mCellInfoList != null && mCellInfoList.size() != 0) {
|
||||||
updateAllPreferenceCategory();
|
updateAllPreferenceCategory();
|
||||||
|
Reference in New Issue
Block a user