Disable SIM On/Off operation when device is in a Satellite session

Bug: 330585109
Test: SatelliteManagerTestOnMockService SatelliteSessionControllerTest SatelliteControllerTest
Manual test with demo and real mode

Change-Id: Iade6426981f76a0b9b71828e0c86d3088c3e974e
This commit is contained in:
Thomas Nguyen
2024-04-23 11:26:58 -07:00
parent 58b70959a6
commit c6005fb22a
3 changed files with 113 additions and 14 deletions

View File

@@ -56,22 +56,23 @@ public class SimSlotChangeReceiver extends BroadcastReceiver {
public static void runOnBackgroundThread(Context context) {
if (shouldHandleSlotChange(context)) {
Log.d(TAG, "Checking satellite enabled status");
Log.d(TAG, "Checking satellite session status");
Executor executor = Executors.newSingleThreadExecutor();
ListenableFuture<Boolean> satelliteEnabledFuture = new SatelliteRepository(context)
.requestIsEnabled(executor);
satelliteEnabledFuture.addListener(() -> {
boolean isSatelliteEnabled = false;
ListenableFuture<Boolean> isSatelliteSessionStartedFuture =
new SatelliteRepository(context).requestIsSessionStarted(executor);
isSatelliteSessionStartedFuture.addListener(() -> {
boolean isSatelliteSessionStarted = false;
try {
isSatelliteEnabled = satelliteEnabledFuture.get();
isSatelliteSessionStarted = isSatelliteSessionStartedFuture.get();
} catch (ExecutionException | InterruptedException e) {
Log.w(TAG, "Can't get satellite enabled status", e);
Log.w(TAG, "Can't get satellite session status", e);
}
if (isSatelliteEnabled) {
Log.i(TAG, "Satellite is enabled. Unable to handle SIM slot changes");
if (isSatelliteSessionStarted) {
Log.i(TAG, "Device is in a satellite session. Unable to handle SIM slot"
+ " changes");
} else {
Log.i(TAG, "Satellite is disabled. Handle slot changes");
Log.i(TAG, "Not in a satellite session. Handle slot changes");
SimSlotChangeHandler.get().onSlotsStatusChange(context.getApplicationContext());
}
}, executor);