Avoid SIM card on/off dialog pop-up if satellite is enabled am: f2ed0ec752
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/26847152 Change-Id: Ifb4f85972f29370d51a8c6363fa8efd63e6dead5 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -29,9 +29,14 @@ import android.util.Log;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
import com.android.settings.network.SatelliteManagerUtil;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/** The receiver when the slot status changes. */
|
||||
public class SimSlotChangeReceiver extends BroadcastReceiver {
|
||||
@@ -51,7 +56,25 @@ public class SimSlotChangeReceiver extends BroadcastReceiver {
|
||||
|
||||
public static void runOnBackgroundThread(Context context) {
|
||||
if (shouldHandleSlotChange(context)) {
|
||||
SimSlotChangeHandler.get().onSlotsStatusChange(context.getApplicationContext());
|
||||
Log.d(TAG, "Checking satellite enabled status");
|
||||
Executor executor = Executors.newSingleThreadExecutor();
|
||||
ListenableFuture<Boolean> satelliteEnabledFuture = SatelliteManagerUtil
|
||||
.requestIsEnabled(context, executor);
|
||||
satelliteEnabledFuture.addListener(() -> {
|
||||
boolean isSatelliteEnabled = false;
|
||||
try {
|
||||
isSatelliteEnabled = satelliteEnabledFuture.get();
|
||||
} catch (ExecutionException | InterruptedException e) {
|
||||
Log.w(TAG, "Can't get satellite enabled status", e);
|
||||
}
|
||||
|
||||
if (isSatelliteEnabled) {
|
||||
Log.i(TAG, "Satellite is enabled. Unable to handle SIM slot changes");
|
||||
} else {
|
||||
Log.i(TAG, "Satellite is disabled. Handle slot changes");
|
||||
SimSlotChangeHandler.get().onSlotsStatusChange(context.getApplicationContext());
|
||||
}
|
||||
}, executor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user