Stop network scan before manual select network
Otherwise device could not connect to network. Bug: 339226604 Test: manual - Choose network Change-Id: Ia7e52ad94d5406cab42bd8e7b25ba7e4e13c67fc
This commit is contained in:
@@ -56,6 +56,8 @@ import com.google.common.collect.ImmutableList;
|
|||||||
|
|
||||||
import kotlin.Unit;
|
import kotlin.Unit;
|
||||||
|
|
||||||
|
import kotlinx.coroutines.Job;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -96,6 +98,8 @@ public class NetworkSelectSettings extends DashboardFragment {
|
|||||||
private AtomicBoolean mShouldFilterOutSatellitePlmn = new AtomicBoolean();
|
private AtomicBoolean mShouldFilterOutSatellitePlmn = new AtomicBoolean();
|
||||||
|
|
||||||
private NetworkScanRepository mNetworkScanRepository;
|
private NetworkScanRepository mNetworkScanRepository;
|
||||||
|
@Nullable
|
||||||
|
private Job mNetworkScanJob = null;
|
||||||
|
|
||||||
private NetworkSelectRepository mNetworkSelectRepository;
|
private NetworkSelectRepository mNetworkSelectRepository;
|
||||||
|
|
||||||
@@ -213,13 +217,14 @@ public class NetworkSelectSettings extends DashboardFragment {
|
|||||||
|
|
||||||
private void launchNetworkScan() {
|
private void launchNetworkScan() {
|
||||||
setProgressBarVisible(true);
|
setProgressBarVisible(true);
|
||||||
mNetworkScanRepository.launchNetworkScan(getViewLifecycleOwner(), (networkScanResult) -> {
|
mNetworkScanJob = mNetworkScanRepository.launchNetworkScan(getViewLifecycleOwner(),
|
||||||
if (isPreferenceScreenEnabled()) {
|
(networkScanResult) -> {
|
||||||
scanResultHandler(networkScanResult);
|
if (isPreferenceScreenEnabled()) {
|
||||||
}
|
scanResultHandler(networkScanResult);
|
||||||
|
}
|
||||||
|
|
||||||
return Unit.INSTANCE;
|
return Unit.INSTANCE;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -245,6 +250,12 @@ public class NetworkSelectSettings extends DashboardFragment {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Need stop network scan before manual select network.
|
||||||
|
if (mNetworkScanJob != null) {
|
||||||
|
mNetworkScanJob.cancel(null);
|
||||||
|
mNetworkScanJob = null;
|
||||||
|
}
|
||||||
|
|
||||||
// Refresh the last selected item in case users reselect network.
|
// Refresh the last selected item in case users reselect network.
|
||||||
clearPreferenceSummary();
|
clearPreferenceSummary();
|
||||||
if (mSelectedPreference != null) {
|
if (mSelectedPreference != null) {
|
||||||
|
@@ -52,9 +52,8 @@ class NetworkScanRepository(private val context: Context, subId: Int) {
|
|||||||
private val telephonyManager = context.telephonyManager(subId)
|
private val telephonyManager = context.telephonyManager(subId)
|
||||||
|
|
||||||
/** TODO: Move this to UI layer, when UI layer migrated to Kotlin. */
|
/** TODO: Move this to UI layer, when UI layer migrated to Kotlin. */
|
||||||
fun launchNetworkScan(lifecycleOwner: LifecycleOwner, onResult: (NetworkScanResult) -> Unit) {
|
fun launchNetworkScan(lifecycleOwner: LifecycleOwner, onResult: (NetworkScanResult) -> Unit) =
|
||||||
networkScanFlow().collectLatestWithLifecycle(lifecycleOwner, action = onResult)
|
networkScanFlow().collectLatestWithLifecycle(lifecycleOwner, action = onResult)
|
||||||
}
|
|
||||||
|
|
||||||
data class CellInfoScanKey(
|
data class CellInfoScanKey(
|
||||||
val title: String?,
|
val title: String?,
|
||||||
@@ -101,7 +100,10 @@ class NetworkScanRepository(private val context: Context, subId: Int) {
|
|||||||
callback,
|
callback,
|
||||||
)
|
)
|
||||||
|
|
||||||
awaitClose { networkScan.stopScan() }
|
awaitClose {
|
||||||
|
networkScan.stopScan()
|
||||||
|
Log.d(TAG, "network scan stopped")
|
||||||
|
}
|
||||||
}.conflate().onEach { Log.d(TAG, "networkScanFlow: $it") }.flowOn(Dispatchers.Default)
|
}.conflate().onEach { Log.d(TAG, "networkScanFlow: $it") }.flowOn(Dispatchers.Default)
|
||||||
|
|
||||||
/** Create network scan for allowed network types. */
|
/** Create network scan for allowed network types. */
|
||||||
|
Reference in New Issue
Block a user