Loading src/com/android/settings/bluetooth/BluetoothEnabler.java +1 −1 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ public final class BluetoothEnabler implements SwitchWidgetController.OnSwitchCh new Thread(() -> { try { mIsSatelliteOn.set(mSatelliteRepository.requestIsEnabled( mIsSatelliteOn.set(mSatelliteRepository.requestIsSessionStarted( Executors.newSingleThreadExecutor()).get(3000, TimeUnit.MILLISECONDS)); } catch (InterruptedException | ExecutionException | TimeoutException e) { Log.e(TAG, "Error to get satellite status : " + e); Loading src/com/android/settings/bluetooth/BluetoothPairingDetail.java +1 −1 Original line number Diff line number Diff line Loading @@ -79,7 +79,7 @@ public class BluetoothPairingDetail extends BluetoothDevicePairingDetailBase imp boolean isSatelliteOn = true; try { isSatelliteOn = satelliteRepository.requestIsEnabled( satelliteRepository.requestIsSessionStarted( Executors.newSingleThreadExecutor()).get(3000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { Log.e(TAG, "Error to get satellite status : " + e); Loading src/com/android/settings/network/AirplaneModePreferenceController.java +2 −1 Original line number Diff line number Diff line Loading @@ -162,7 +162,8 @@ public class AirplaneModePreferenceController extends TogglePreferenceController public void onResume() { try { mIsSatelliteOn.set( mSatelliteRepository.requestIsEnabled(Executors.newSingleThreadExecutor()) mSatelliteRepository .requestIsSessionStarted(Executors.newSingleThreadExecutor()) .get(2000, TimeUnit.MILLISECONDS)); } catch (ExecutionException | TimeoutException | InterruptedException e) { Log.e(TAG, "Error to get satellite status : " + e); Loading src/com/android/settings/network/SatelliteRepository.kt +51 −26 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import androidx.annotation.VisibleForTesting import androidx.concurrent.futures.CallbackToFutureAdapter import com.google.common.util.concurrent.Futures.immediateFuture import com.google.common.util.concurrent.ListenableFuture import java.util.concurrent.Executor import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.asExecutor Loading @@ -32,7 +33,6 @@ import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.flow.flowOf import java.util.concurrent.Executor import kotlinx.coroutines.flow.flowOn /** Loading @@ -58,6 +58,7 @@ class SatelliteRepository( } return CallbackToFutureAdapter.getFuture { completer -> try { satelliteManager.requestIsEnabled(executor, object : OutcomeReceiver<Boolean, SatelliteManager.SatelliteException> { override fun onResult(result: Boolean) { Loading @@ -72,6 +73,11 @@ class SatelliteRepository( } }) "requestIsEnabled" } catch (e: IllegalStateException) { Log.w(TAG, "IllegalStateException $e") completer.set(false) } } } Loading @@ -96,14 +102,21 @@ class SatelliteRepository( val callback = object : SatelliteModemStateCallback { override fun onSatelliteModemStateChanged(state: Int) { val isSessionStarted = isSatelliteSessionStarted(state) Log.i(TAG, "Satellite modem state changed: state=$state" + ", isSessionStarted=$isSessionStarted") Log.i( TAG, "Satellite modem state changed: state=$state" + ", isSessionStarted=$isSessionStarted" ) completer.set(isSessionStarted) satelliteManager.unregisterForModemStateChanged(this) } } val registerResult = satelliteManager.registerForModemStateChanged(executor, callback) var registerResult = SatelliteManager.SATELLITE_MODEM_STATE_UNKNOWN try { registerResult = satelliteManager.registerForModemStateChanged(executor, callback) } catch (e: IllegalStateException) { Log.w(TAG, "IllegalStateException $e") } if (registerResult != SatelliteManager.SATELLITE_RESULT_SUCCESS) { Log.w(TAG, "Failed to register for satellite modem state change: $registerResult") completer.set(false) Loading Loading @@ -132,15 +145,21 @@ class SatelliteRepository( return callbackFlow { val callback = SatelliteModemStateCallback { state -> val isSessionStarted = isSatelliteSessionStarted(state) Log.i(TAG, "Satellite modem state changed: state=$state" + ", isSessionStarted=$isSessionStarted") Log.i( TAG, "Satellite modem state changed: state=$state" + ", isSessionStarted=$isSessionStarted" ) trySend(isSessionStarted) } val registerResult = satelliteManager.registerForModemStateChanged( var registerResult: Int = SatelliteManager.SATELLITE_RESULT_ERROR try { registerResult = satelliteManager.registerForModemStateChanged( defaultDispatcher.asExecutor(), callback ) } catch (e: IllegalStateException) { Log.w(TAG, "IllegalStateException $e") } if (registerResult != SatelliteManager.SATELLITE_RESULT_SUCCESS) { // If the registration failed (e.g., device doesn't support satellite), Loading @@ -150,7 +169,13 @@ class SatelliteRepository( trySend(false) } awaitClose { satelliteManager.unregisterForModemStateChanged(callback) } awaitClose { try { satelliteManager.unregisterForModemStateChanged(callback) } catch (e: IllegalStateException) { Log.w(TAG, "IllegalStateException $e") } } }.flowOn(Dispatchers.Default) } Loading src/com/android/settings/wifi/WifiEnabler.java +2 −1 Original line number Diff line number Diff line Loading @@ -139,7 +139,8 @@ public class WifiEnabler implements SwitchWidgetController.OnSwitchChangeListene // Refresh satellite mode status. try { mIsSatelliteOn.set( mSatelliteRepository.requestIsEnabled(Executors.newSingleThreadExecutor()) mSatelliteRepository .requestIsSessionStarted(Executors.newSingleThreadExecutor()) .get(2000, TimeUnit.MILLISECONDS)); } catch (ExecutionException | TimeoutException | InterruptedException e) { Log.e(TAG, "Error to get satellite status : " + e); Loading Loading
src/com/android/settings/bluetooth/BluetoothEnabler.java +1 −1 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ public final class BluetoothEnabler implements SwitchWidgetController.OnSwitchCh new Thread(() -> { try { mIsSatelliteOn.set(mSatelliteRepository.requestIsEnabled( mIsSatelliteOn.set(mSatelliteRepository.requestIsSessionStarted( Executors.newSingleThreadExecutor()).get(3000, TimeUnit.MILLISECONDS)); } catch (InterruptedException | ExecutionException | TimeoutException e) { Log.e(TAG, "Error to get satellite status : " + e); Loading
src/com/android/settings/bluetooth/BluetoothPairingDetail.java +1 −1 Original line number Diff line number Diff line Loading @@ -79,7 +79,7 @@ public class BluetoothPairingDetail extends BluetoothDevicePairingDetailBase imp boolean isSatelliteOn = true; try { isSatelliteOn = satelliteRepository.requestIsEnabled( satelliteRepository.requestIsSessionStarted( Executors.newSingleThreadExecutor()).get(3000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { Log.e(TAG, "Error to get satellite status : " + e); Loading
src/com/android/settings/network/AirplaneModePreferenceController.java +2 −1 Original line number Diff line number Diff line Loading @@ -162,7 +162,8 @@ public class AirplaneModePreferenceController extends TogglePreferenceController public void onResume() { try { mIsSatelliteOn.set( mSatelliteRepository.requestIsEnabled(Executors.newSingleThreadExecutor()) mSatelliteRepository .requestIsSessionStarted(Executors.newSingleThreadExecutor()) .get(2000, TimeUnit.MILLISECONDS)); } catch (ExecutionException | TimeoutException | InterruptedException e) { Log.e(TAG, "Error to get satellite status : " + e); Loading
src/com/android/settings/network/SatelliteRepository.kt +51 −26 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import androidx.annotation.VisibleForTesting import androidx.concurrent.futures.CallbackToFutureAdapter import com.google.common.util.concurrent.Futures.immediateFuture import com.google.common.util.concurrent.ListenableFuture import java.util.concurrent.Executor import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.asExecutor Loading @@ -32,7 +33,6 @@ import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.flow.flowOf import java.util.concurrent.Executor import kotlinx.coroutines.flow.flowOn /** Loading @@ -58,6 +58,7 @@ class SatelliteRepository( } return CallbackToFutureAdapter.getFuture { completer -> try { satelliteManager.requestIsEnabled(executor, object : OutcomeReceiver<Boolean, SatelliteManager.SatelliteException> { override fun onResult(result: Boolean) { Loading @@ -72,6 +73,11 @@ class SatelliteRepository( } }) "requestIsEnabled" } catch (e: IllegalStateException) { Log.w(TAG, "IllegalStateException $e") completer.set(false) } } } Loading @@ -96,14 +102,21 @@ class SatelliteRepository( val callback = object : SatelliteModemStateCallback { override fun onSatelliteModemStateChanged(state: Int) { val isSessionStarted = isSatelliteSessionStarted(state) Log.i(TAG, "Satellite modem state changed: state=$state" + ", isSessionStarted=$isSessionStarted") Log.i( TAG, "Satellite modem state changed: state=$state" + ", isSessionStarted=$isSessionStarted" ) completer.set(isSessionStarted) satelliteManager.unregisterForModemStateChanged(this) } } val registerResult = satelliteManager.registerForModemStateChanged(executor, callback) var registerResult = SatelliteManager.SATELLITE_MODEM_STATE_UNKNOWN try { registerResult = satelliteManager.registerForModemStateChanged(executor, callback) } catch (e: IllegalStateException) { Log.w(TAG, "IllegalStateException $e") } if (registerResult != SatelliteManager.SATELLITE_RESULT_SUCCESS) { Log.w(TAG, "Failed to register for satellite modem state change: $registerResult") completer.set(false) Loading Loading @@ -132,15 +145,21 @@ class SatelliteRepository( return callbackFlow { val callback = SatelliteModemStateCallback { state -> val isSessionStarted = isSatelliteSessionStarted(state) Log.i(TAG, "Satellite modem state changed: state=$state" + ", isSessionStarted=$isSessionStarted") Log.i( TAG, "Satellite modem state changed: state=$state" + ", isSessionStarted=$isSessionStarted" ) trySend(isSessionStarted) } val registerResult = satelliteManager.registerForModemStateChanged( var registerResult: Int = SatelliteManager.SATELLITE_RESULT_ERROR try { registerResult = satelliteManager.registerForModemStateChanged( defaultDispatcher.asExecutor(), callback ) } catch (e: IllegalStateException) { Log.w(TAG, "IllegalStateException $e") } if (registerResult != SatelliteManager.SATELLITE_RESULT_SUCCESS) { // If the registration failed (e.g., device doesn't support satellite), Loading @@ -150,7 +169,13 @@ class SatelliteRepository( trySend(false) } awaitClose { satelliteManager.unregisterForModemStateChanged(callback) } awaitClose { try { satelliteManager.unregisterForModemStateChanged(callback) } catch (e: IllegalStateException) { Log.w(TAG, "IllegalStateException $e") } } }.flowOn(Dispatchers.Default) } Loading
src/com/android/settings/wifi/WifiEnabler.java +2 −1 Original line number Diff line number Diff line Loading @@ -139,7 +139,8 @@ public class WifiEnabler implements SwitchWidgetController.OnSwitchChangeListene // Refresh satellite mode status. try { mIsSatelliteOn.set( mSatelliteRepository.requestIsEnabled(Executors.newSingleThreadExecutor()) mSatelliteRepository .requestIsSessionStarted(Executors.newSingleThreadExecutor()) .get(2000, TimeUnit.MILLISECONDS)); } catch (ExecutionException | TimeoutException | InterruptedException e) { Log.e(TAG, "Error to get satellite status : " + e); Loading