Revert "Make Satellite UI updatable during receiving callback (P..."

Revert submission 31790253

Reason for revert: DroidMonitor: Potential culprit for http://b/397368653 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Reverted changes: /q/submissionid:31790253

Change-Id: I851046019821fff0d132efb0b00cbff1e3ecbe72
This commit is contained in:
Liana Kazanova (xWF)
2025-02-18 09:35:50 -08:00
parent 196a3120c0
commit 790fa6e00e
2 changed files with 30 additions and 208 deletions

View File

@@ -16,48 +16,35 @@
package com.android.settings.network.telephony; package com.android.settings.network.telephony;
import static android.telephony.CarrierConfigManager.CARRIER_ROAMING_NTN_CONNECT_AUTOMATIC;
import static android.telephony.CarrierConfigManager.KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL; import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ESOS_SUPPORTED_BOOL; import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ESOS_SUPPORTED_BOOL;
import static android.telephony.NetworkRegistrationInfo.SERVICE_TYPE_SMS;
import android.content.Context; import android.content.Context;
import android.os.PersistableBundle; import android.os.PersistableBundle;
import android.telephony.TelephonyCallback;
import android.telephony.TelephonyManager;
import android.telephony.satellite.NtnSignalStrength;
import android.telephony.satellite.SatelliteManager; import android.telephony.satellite.SatelliteManager;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.lifecycle.DefaultLifecycleObserver; import androidx.lifecycle.DefaultLifecycleObserver;
import androidx.lifecycle.LifecycleOwner; import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.flags.Flags; import com.android.settings.flags.Flags;
import com.android.settings.network.CarrierConfigCache; import com.android.settings.network.CarrierConfigCache;
import java.util.Arrays;
import java.util.List;
/** Preference controller for Satellite functions in mobile network settings. */ /** Preference controller for Satellite functions in mobile network settings. */
public class SatelliteSettingsPreferenceCategoryController public class SatelliteSettingsPreferenceCategoryController
extends TelephonyBasePreferenceController implements DefaultLifecycleObserver { extends TelephonyBasePreferenceController implements DefaultLifecycleObserver {
private static final String TAG = "SatelliteSettingsPrefCategoryCon"; private static final String TAG = "SatelliteSettingsPrefCategoryCon";
@VisibleForTesting
final CarrierRoamingNtnModeCallback mCarrierRoamingNtnModeCallback =
new CarrierRoamingNtnModeCallback(this);
private CarrierConfigCache mCarrierConfigCache; private CarrierConfigCache mCarrierConfigCache;
private SatelliteManager mSatelliteManager; private SatelliteManager mSatelliteManager;
private TelephonyManager mTelephonyManager; private PreferenceCategory mPreferenceCategory;
private PreferenceScreen mPreferenceScreen;
public SatelliteSettingsPreferenceCategoryController(Context context, String key) { public SatelliteSettingsPreferenceCategoryController(Context context, String key) {
super(context, key); super(context, key);
mCarrierConfigCache = CarrierConfigCache.getInstance(context);
mSatelliteManager = context.getSystemService(SatelliteManager.class);
} }
/** /**
@@ -68,23 +55,13 @@ public class SatelliteSettingsPreferenceCategoryController
public void init(int subId) { public void init(int subId) {
Log.d(TAG, "init(), subId=" + subId); Log.d(TAG, "init(), subId=" + subId);
mSubId = subId; mSubId = subId;
mCarrierConfigCache = CarrierConfigCache.getInstance(mContext);
mSatelliteManager = mContext.getSystemService(SatelliteManager.class);
mTelephonyManager = mContext.getSystemService(TelephonyManager.class);
} }
@Override @Override
public void displayPreference(PreferenceScreen screen) { public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen); super.displayPreference(screen);
if (mPreferenceScreen != null) { mPreferenceCategory = screen.findPreference(getPreferenceKey());
mPreferenceScreen = screen; mPreferenceCategory.setTitle(R.string.category_title_satellite_connectivity);
}
}
void displayPreference() {
if (mPreferenceScreen != null) {
displayPreference(mPreferenceScreen);
}
} }
@Override @Override
@@ -98,89 +75,15 @@ public class SatelliteSettingsPreferenceCategoryController
} }
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId); final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId);
final boolean isSatelliteAttachSupported = carrierConfig.getBoolean(
KEY_SATELLITE_ATTACH_SUPPORTED_BOOL);
boolean isSatelliteSosSupported = false; boolean isSatelliteSosSupported = false;
if (Flags.satelliteOemSettingsUxMigration()) { if (Flags.satelliteOemSettingsUxMigration()) {
isSatelliteSosSupported = carrierConfig.getBoolean( isSatelliteSosSupported = carrierConfig.getBoolean(
KEY_SATELLITE_ESOS_SUPPORTED_BOOL); KEY_SATELLITE_ESOS_SUPPORTED_BOOL);
} }
if (!carrierConfig.getBoolean(KEY_SATELLITE_ATTACH_SUPPORTED_BOOL)) { return (isSatelliteAttachSupported || isSatelliteSosSupported)
return UNSUPPORTED_ON_DEVICE; ? AVAILABLE_UNSEARCHABLE : UNSUPPORTED_ON_DEVICE;
}
if (isSatelliteSosSupported) {
return AVAILABLE_UNSEARCHABLE;
}
if (CARRIER_ROAMING_NTN_CONNECT_AUTOMATIC == carrierConfig.getInt(
KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT,
CARRIER_ROAMING_NTN_CONNECT_AUTOMATIC)) {
return AVAILABLE_UNSEARCHABLE;
} else {
return mCarrierRoamingNtnModeCallback.isSatelliteSmsAvailable()
? AVAILABLE_UNSEARCHABLE
: CONDITIONALLY_UNAVAILABLE;
}
}
@Override
public void onResume(@NonNull LifecycleOwner owner) {
if (com.android.settings.flags.Flags.satelliteOemSettingsUxMigration()) {
if (mTelephonyManager != null) {
mTelephonyManager.registerTelephonyCallback(mContext.getMainExecutor(),
mCarrierRoamingNtnModeCallback);
}
}
}
@Override
public void onPause(@NonNull LifecycleOwner owner) {
if (com.android.settings.flags.Flags.satelliteOemSettingsUxMigration()) {
if (mTelephonyManager != null) {
mTelephonyManager.unregisterTelephonyCallback(mCarrierRoamingNtnModeCallback);
}
}
}
@VisibleForTesting
static class CarrierRoamingNtnModeCallback extends TelephonyCallback implements
TelephonyCallback.CarrierRoamingNtnListener {
SatelliteSettingsPreferenceCategoryController mController;
private boolean mIsSatelliteSmsAvailable = false;
CarrierRoamingNtnModeCallback(
SatelliteSettingsPreferenceCategoryController controller) {
mController = controller;
}
boolean isSatelliteSmsAvailable() {
return mIsSatelliteSmsAvailable;
}
@Override
public void onCarrierRoamingNtnAvailableServicesChanged(@NonNull int[] availableServices) {
CarrierRoamingNtnListener.super.onCarrierRoamingNtnAvailableServicesChanged(
availableServices);
List<Integer> availableServicesList = Arrays.stream(availableServices).boxed().toList();
mIsSatelliteSmsAvailable = availableServicesList.contains(SERVICE_TYPE_SMS);
Log.d(TAG, "isSmsAvailable : " + mIsSatelliteSmsAvailable);
mController.displayPreference();
}
@Override
public void onCarrierRoamingNtnEligibleStateChanged(boolean eligible) {
// Do nothing
}
@Override
public void onCarrierRoamingNtnModeChanged(boolean active) {
// Do nothing
}
@Override
public void onCarrierRoamingNtnSignalStrengthChanged(
@NonNull NtnSignalStrength ntnSignalStrength) {
// Do nothing
}
} }
} }

View File

@@ -16,38 +16,29 @@
package com.android.settings.network.telephony; package com.android.settings.network.telephony;
import static android.telephony.CarrierConfigManager.CARRIER_ROAMING_NTN_CONNECT_AUTOMATIC;
import static android.telephony.CarrierConfigManager.CARRIER_ROAMING_NTN_CONNECT_MANUAL;
import static android.telephony.CarrierConfigManager.KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ESOS_SUPPORTED_BOOL;
import static android.telephony.NetworkRegistrationInfo.SERVICE_TYPE_SMS;
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE; import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static junit.framework.Assert.assertEquals;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import android.content.Context; import android.content.Context;
import android.os.Looper; import android.os.Looper;
import android.os.PersistableBundle;
import android.platform.test.annotations.EnableFlags;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
import androidx.test.core.app.ApplicationProvider; import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.android.internal.telephony.flags.Flags;
import com.android.settings.network.CarrierConfigCache;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule; import org.mockito.junit.MockitoRule;
@@ -59,12 +50,8 @@ public class SatelliteSettingsPreferenceCategoryControllerTest {
@Rule @Rule
public final MockitoRule mMockitoRule = MockitoJUnit.rule(); public final MockitoRule mMockitoRule = MockitoJUnit.rule();
@Mock
private CarrierConfigCache mCarrierConfigCache;
private Context mContext = null; private Context mContext = null;
private SatelliteSettingsPreferenceCategoryController mController = null; private SatelliteSettingsPreferenceCategoryController mController = null;
private PersistableBundle mPersistableBundle = new PersistableBundle();
@Before @Before
public void setUp() { public void setUp() {
@@ -72,95 +59,27 @@ public class SatelliteSettingsPreferenceCategoryControllerTest {
Looper.prepare(); Looper.prepare();
} }
mContext = spy(ApplicationProvider.getApplicationContext()); mContext = spy(ApplicationProvider.getApplicationContext());
CarrierConfigCache.setTestInstance(mContext, mCarrierConfigCache);
mController = new SatelliteSettingsPreferenceCategoryController(mContext, KEY); mController = new SatelliteSettingsPreferenceCategoryController(mContext, KEY);
when(mCarrierConfigCache.getConfigForSubId(TEST_SUB_ID)).thenReturn(mPersistableBundle);
} }
@Test @Test
public void getAvailabilityStatus_deviceUnsupported_returnUnsupported() { @Ignore("b/382664790")
public void getAvailabilityStatus_default_returnUnsupported() {
int result = mController.getAvailabilityStatus(TEST_SUB_ID); int result = mController.getAvailabilityStatus(TEST_SUB_ID);
assertThat(result).isEqualTo(UNSUPPORTED_ON_DEVICE); assertThat(result).isEqualTo(UNSUPPORTED_ON_DEVICE);
} }
@Test @Test
public void getAvailabilityStatus_carrierNotSupport_returnUnsupported() { @Ignore("b/382664790")
mPersistableBundle.putBoolean(KEY_SATELLITE_ATTACH_SUPPORTED_BOOL, false); public void setPreferenceTitle_hasSmsService_showMessaging() {
mController.init(TEST_SUB_ID); PreferenceManager preferenceManager = new PreferenceManager(mContext);
PreferenceScreen preferenceScreen = preferenceManager.createPreferenceScreen(mContext);
PreferenceCategory preferenceCategory = new PreferenceCategory(mContext);
preferenceCategory.setKey(KEY);
preferenceScreen.addPreference(preferenceCategory);
preferenceCategory.addPreference(new Preference(mContext));
mController.displayPreference(preferenceScreen);
int result = mController.getAvailabilityStatus(TEST_SUB_ID); assertEquals(preferenceCategory.getTitle(), "Satellite connectivity");
assertThat(result).isEqualTo(UNSUPPORTED_ON_DEVICE);
}
@Test
@EnableFlags({
Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG,
com.android.settings.flags.Flags.FLAG_SATELLITE_OEM_SETTINGS_UX_MIGRATION
})
public void getAvailabilityStatus_sosSupported_returnAvailable() {
mPersistableBundle.putBoolean(KEY_SATELLITE_ESOS_SUPPORTED_BOOL, true);
mPersistableBundle.putBoolean(KEY_SATELLITE_ATTACH_SUPPORTED_BOOL, true);
mController.init(TEST_SUB_ID);
int result = mController.getAvailabilityStatus(TEST_SUB_ID);
assertThat(result).isEqualTo(AVAILABLE_UNSEARCHABLE);
}
@Test
@EnableFlags({
Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG,
com.android.settings.flags.Flags.FLAG_SATELLITE_OEM_SETTINGS_UX_MIGRATION
})
public void getAvailabilityStatus_connectTypeAuto_returnAvailable() {
mPersistableBundle.putBoolean(KEY_SATELLITE_ESOS_SUPPORTED_BOOL, false);
mPersistableBundle.putBoolean(KEY_SATELLITE_ATTACH_SUPPORTED_BOOL, true);
mPersistableBundle.putInt(KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT,
CARRIER_ROAMING_NTN_CONNECT_AUTOMATIC);
mController.init(TEST_SUB_ID);
int result = mController.getAvailabilityStatus(TEST_SUB_ID);
assertThat(result).isEqualTo(AVAILABLE_UNSEARCHABLE);
}
@Test
@EnableFlags({
Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG,
com.android.settings.flags.Flags.FLAG_SATELLITE_OEM_SETTINGS_UX_MIGRATION
})
public void getAvailabilityStatus_connectTypeManualAndAvailable_returnAvailable() {
mPersistableBundle.putBoolean(KEY_SATELLITE_ESOS_SUPPORTED_BOOL, false);
mPersistableBundle.putBoolean(KEY_SATELLITE_ATTACH_SUPPORTED_BOOL, true);
mPersistableBundle.putInt(KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT,
CARRIER_ROAMING_NTN_CONNECT_AUTOMATIC);
mController.init(TEST_SUB_ID);
mController.mCarrierRoamingNtnModeCallback.onCarrierRoamingNtnAvailableServicesChanged(
new int[]{SERVICE_TYPE_SMS});
int result = mController.getAvailabilityStatus(TEST_SUB_ID);
assertThat(result).isEqualTo(AVAILABLE_UNSEARCHABLE);
}
@Test
@EnableFlags({
Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG,
com.android.settings.flags.Flags.FLAG_SATELLITE_OEM_SETTINGS_UX_MIGRATION
})
public void getAvailabilityStatus_connectTypeManualAndUnavailable_returnUnavailable() {
mPersistableBundle.putBoolean(KEY_SATELLITE_ESOS_SUPPORTED_BOOL, false);
mPersistableBundle.putBoolean(KEY_SATELLITE_ATTACH_SUPPORTED_BOOL, true);
mPersistableBundle.putInt(KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT,
CARRIER_ROAMING_NTN_CONNECT_MANUAL);
mController.init(TEST_SUB_ID);
mController.mCarrierRoamingNtnModeCallback.onCarrierRoamingNtnAvailableServicesChanged(
new int[]{});
int result = mController.getAvailabilityStatus(TEST_SUB_ID);
assertThat(result).isEqualTo(CONDITIONALLY_UNAVAILABLE);
} }
} }