Merge "Ignore ACTION_PRIMARY_SUBSCRIPTION_LIST_CHANGED event if satellite session is started" into 24D1-dev am: fea80bf236
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/27071155 Change-Id: Idcbc71555ddbebbd28553530ca8ddd6e364635ae Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -48,13 +48,28 @@ import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.HelpTrampoline;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.network.SatelliteRepository;
|
||||
import com.android.settings.network.SubscriptionUtil;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
public class SimSelectNotification extends BroadcastReceiver {
|
||||
private static final String TAG = "SimSelectNotification";
|
||||
|
||||
private static final int DEFAULT_TIMEOUT_MS = 1000;
|
||||
|
||||
@VisibleForTesting
|
||||
public static final int SIM_SELECT_NOTIFICATION_ID = 1;
|
||||
@VisibleForTesting
|
||||
@@ -89,7 +104,7 @@ public class SimSelectNotification extends BroadcastReceiver {
|
||||
|
||||
switch (action) {
|
||||
case TelephonyManager.ACTION_PRIMARY_SUBSCRIPTION_LIST_CHANGED:
|
||||
onPrimarySubscriptionListChanged(context, intent);
|
||||
PrimarySubscriptionListChangedService.scheduleJob(context, intent);
|
||||
break;
|
||||
case Settings.ACTION_ENABLE_MMS_DATA_REQUEST:
|
||||
onEnableMmsDataRequest(context, intent);
|
||||
@@ -149,12 +164,41 @@ public class SimSelectNotification extends BroadcastReceiver {
|
||||
createEnableMmsNotification(context, notificationTitle, notificationSummary, subId);
|
||||
}
|
||||
|
||||
private void onPrimarySubscriptionListChanged(Context context, Intent intent) {
|
||||
startSimSelectDialogIfNeeded(context, intent);
|
||||
sendSimCombinationWarningIfNeeded(context, intent);
|
||||
/**
|
||||
* Handles changes to the primary subscription list, performing actions only
|
||||
* if the device is not currently in a satellite session. This method is
|
||||
* intended to be executed on a worker thread.
|
||||
*
|
||||
* @param context The application context
|
||||
* @param intent The intent signaling a primary subscription change
|
||||
*/
|
||||
@WorkerThread
|
||||
public static void onPrimarySubscriptionListChanged(@NonNull Context context,
|
||||
@NonNull Intent intent) {
|
||||
Log.d(TAG, "Checking satellite enabled status");
|
||||
Executor executor = Executors.newSingleThreadExecutor();
|
||||
ListenableFuture<Boolean> isSatelliteSessionStartedFuture =
|
||||
new SatelliteRepository(context).requestIsSessionStarted(executor);
|
||||
boolean isSatelliteSessionStarted = false;
|
||||
try {
|
||||
isSatelliteSessionStarted =
|
||||
isSatelliteSessionStartedFuture.get(DEFAULT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
|
||||
} catch (InterruptedException | ExecutionException | TimeoutException e) {
|
||||
Log.w(TAG, "Can't get satellite session status", e);
|
||||
} finally {
|
||||
if (isSatelliteSessionStarted) {
|
||||
Log.i(TAG, "Device is in a satellite session.g Unable to handle primary"
|
||||
+ " subscription list changes");
|
||||
} else {
|
||||
Log.i(TAG, "Device is not in a satellite session. Handle primary"
|
||||
+ " subscription list changes");
|
||||
startSimSelectDialogIfNeeded(context, intent);
|
||||
sendSimCombinationWarningIfNeeded(context, intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void startSimSelectDialogIfNeeded(Context context, Intent intent) {
|
||||
private static void startSimSelectDialogIfNeeded(Context context, Intent intent) {
|
||||
int dialogType = intent.getIntExtra(EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE,
|
||||
EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_NONE);
|
||||
|
||||
@@ -194,7 +238,7 @@ public class SimSelectNotification extends BroadcastReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendSimCombinationWarningIfNeeded(Context context, Intent intent) {
|
||||
private static void sendSimCombinationWarningIfNeeded(Context context, Intent intent) {
|
||||
final int warningType = intent.getIntExtra(EXTRA_SIM_COMBINATION_WARNING_TYPE,
|
||||
EXTRA_SIM_COMBINATION_WARNING_TYPE_NONE);
|
||||
|
||||
@@ -207,7 +251,7 @@ public class SimSelectNotification extends BroadcastReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
private void createSimSelectNotification(Context context){
|
||||
private static void createSimSelectNotification(Context context) {
|
||||
final Resources resources = context.getResources();
|
||||
|
||||
NotificationChannel notificationChannel = new NotificationChannel(
|
||||
@@ -217,11 +261,11 @@ public class SimSelectNotification extends BroadcastReceiver {
|
||||
|
||||
Notification.Builder builder =
|
||||
new Notification.Builder(context, SIM_SELECT_NOTIFICATION_CHANNEL)
|
||||
.setSmallIcon(R.drawable.ic_sim_alert)
|
||||
.setColor(context.getColor(R.color.sim_noitification))
|
||||
.setContentTitle(resources.getText(R.string.sim_notification_title))
|
||||
.setContentText(resources.getText(R.string.sim_notification_summary))
|
||||
.setAutoCancel(true);
|
||||
.setSmallIcon(R.drawable.ic_sim_alert)
|
||||
.setColor(context.getColor(R.color.sim_noitification))
|
||||
.setContentTitle(resources.getText(R.string.sim_notification_title))
|
||||
.setContentText(resources.getText(R.string.sim_notification_summary))
|
||||
.setAutoCancel(true);
|
||||
Intent resultIntent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);
|
||||
resultIntent.setPackage(SETTINGS_PACKAGE_NAME);
|
||||
resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
@@ -279,7 +323,7 @@ public class SimSelectNotification extends BroadcastReceiver {
|
||||
notificationManager.cancel(ENABLE_MMS_NOTIFICATION_ID);
|
||||
}
|
||||
|
||||
private void createSimCombinationWarningNotification(Context context, Intent intent){
|
||||
private static void createSimCombinationWarningNotification(Context context, Intent intent) {
|
||||
final Resources resources = context.getResources();
|
||||
final String simNames = intent.getStringExtra(EXTRA_SIM_COMBINATION_NAMES);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user