Loading src/com/android/settings/network/telephony/NetworkSelectSettings.java +17 −6 Original line number Diff line number Diff line Loading @@ -58,6 +58,8 @@ import com.google.common.collect.ImmutableList; import kotlin.Unit; import kotlinx.coroutines.Job; import java.util.ArrayList; import java.util.Arrays; import java.util.List; Loading Loading @@ -98,6 +100,8 @@ public class NetworkSelectSettings extends DashboardFragment { private AtomicBoolean mShouldFilterOutSatellitePlmn = new AtomicBoolean(); private NetworkScanRepository mNetworkScanRepository; @Nullable private Job mNetworkScanJob = null; @Override public void onCreate(Bundle icicle) { Loading Loading @@ -206,7 +210,8 @@ public class NetworkSelectSettings extends DashboardFragment { private void launchNetworkScan() { setProgressBarVisible(true); mNetworkScanRepository.launchNetworkScan(getViewLifecycleOwner(), (networkScanResult) -> { mNetworkScanJob = mNetworkScanRepository.launchNetworkScan(getViewLifecycleOwner(), (networkScanResult) -> { if (isPreferenceScreenEnabled()) { scanResultHandler(networkScanResult); } Loading Loading @@ -238,6 +243,12 @@ public class NetworkSelectSettings extends DashboardFragment { 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. clearPreferenceSummary(); if (mSelectedPreference != null) { Loading src/com/android/settings/network/telephony/scan/NetworkScanRepository.kt +5 −3 Original line number Diff line number Diff line Loading @@ -52,9 +52,8 @@ class NetworkScanRepository(context: Context, subId: Int) { context.getSystemService(TelephonyManager::class.java)!!.createForSubscriptionId(subId) /** 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) } data class CellInfoScanKey( val title: String?, Loading Loading @@ -101,7 +100,10 @@ class NetworkScanRepository(context: Context, subId: Int) { callback, ) awaitClose { networkScan.stopScan() } awaitClose { networkScan.stopScan() Log.d(TAG, "network scan stopped") } }.conflate().onEach { Log.d(TAG, "networkScanFlow: $it") }.flowOn(Dispatchers.Default) /** Create network scan for allowed network types. */ Loading Loading
src/com/android/settings/network/telephony/NetworkSelectSettings.java +17 −6 Original line number Diff line number Diff line Loading @@ -58,6 +58,8 @@ import com.google.common.collect.ImmutableList; import kotlin.Unit; import kotlinx.coroutines.Job; import java.util.ArrayList; import java.util.Arrays; import java.util.List; Loading Loading @@ -98,6 +100,8 @@ public class NetworkSelectSettings extends DashboardFragment { private AtomicBoolean mShouldFilterOutSatellitePlmn = new AtomicBoolean(); private NetworkScanRepository mNetworkScanRepository; @Nullable private Job mNetworkScanJob = null; @Override public void onCreate(Bundle icicle) { Loading Loading @@ -206,7 +210,8 @@ public class NetworkSelectSettings extends DashboardFragment { private void launchNetworkScan() { setProgressBarVisible(true); mNetworkScanRepository.launchNetworkScan(getViewLifecycleOwner(), (networkScanResult) -> { mNetworkScanJob = mNetworkScanRepository.launchNetworkScan(getViewLifecycleOwner(), (networkScanResult) -> { if (isPreferenceScreenEnabled()) { scanResultHandler(networkScanResult); } Loading Loading @@ -238,6 +243,12 @@ public class NetworkSelectSettings extends DashboardFragment { 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. clearPreferenceSummary(); if (mSelectedPreference != null) { Loading
src/com/android/settings/network/telephony/scan/NetworkScanRepository.kt +5 −3 Original line number Diff line number Diff line Loading @@ -52,9 +52,8 @@ class NetworkScanRepository(context: Context, subId: Int) { context.getSystemService(TelephonyManager::class.java)!!.createForSubscriptionId(subId) /** 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) } data class CellInfoScanKey( val title: String?, Loading Loading @@ -101,7 +100,10 @@ class NetworkScanRepository(context: Context, subId: Int) { callback, ) awaitClose { networkScan.stopScan() } awaitClose { networkScan.stopScan() Log.d(TAG, "network scan stopped") } }.conflate().onEach { Log.d(TAG, "networkScanFlow: $it") }.flowOn(Dispatchers.Default) /** Create network scan for allowed network types. */ Loading