make sure to update session controller to power off state
Currently, SatelliteSessionController never update the isSatelliteSupported state after it is created.
Therefore, in case SatelliteSessionController is created when isSatelliteSupported state has been reported as false from modem,
it'll never be updated to supported state until reboot.
Bug: 341971624
Test: atest SatelliteSessionControllerTest
manually enable Skylo service to reproduce the issue
Change-Id: I58ccdfee425217d6ed172b476ec7dd35cb7d6fa9
diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteController.java b/src/java/com/android/internal/telephony/satellite/SatelliteController.java
index c0917fe..020a605 100644
--- a/src/java/com/android/internal/telephony/satellite/SatelliteController.java
+++ b/src/java/com/android/internal/telephony/satellite/SatelliteController.java
@@ -218,7 +218,8 @@
@NonNull private static SatelliteController sInstance;
@NonNull private final Context mContext;
@NonNull private final SatelliteModemInterface mSatelliteModemInterface;
- @NonNull private SatelliteSessionController mSatelliteSessionController;
+ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
+ @NonNull protected SatelliteSessionController mSatelliteSessionController;
@NonNull private final PointingAppController mPointingAppController;
@NonNull private final DatagramController mDatagramController;
@NonNull private final ControllerMetricsStats mControllerMetricsStats;
@@ -3242,6 +3243,9 @@
}
mSatelliteSessionController = SatelliteSessionController.make(
mContext, getLooper(), supported);
+ logd("create a new SatelliteSessionController due to isSatelliteSupported state has "
+ + "changed to " + supported);
+
if (supported) {
registerForSatelliteProvisionStateChanged();
registerForPendingDatagramCount();
@@ -3502,6 +3506,10 @@
}
}
mIsSatelliteSupported = supported;
+ mSatelliteSessionController = SatelliteSessionController.make(
+ mContext, getLooper(), supported);
+ logd("create a new SatelliteSessionController due to isSatelliteSupported state has "
+ + "changed to " + supported);
}
List<ISatelliteSupportedStateCallback> deadCallersList = new ArrayList<>();
diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteSessionController.java b/src/java/com/android/internal/telephony/satellite/SatelliteSessionController.java
index dc0cf47..dcf9bb0 100644
--- a/src/java/com/android/internal/telephony/satellite/SatelliteSessionController.java
+++ b/src/java/com/android/internal/telephony/satellite/SatelliteSessionController.java
@@ -39,7 +39,6 @@
import android.os.Message;
import android.os.RemoteException;
import android.os.SystemProperties;
-import android.telephony.Rlog;
import android.telephony.satellite.ISatelliteModemStateCallback;
import android.telephony.satellite.SatelliteManager;
import android.telephony.satellite.stub.ISatelliteGateway;
@@ -163,15 +162,9 @@
*/
public static SatelliteSessionController make(
@NonNull Context context, @NonNull Looper looper, boolean isSatelliteSupported) {
- if (sInstance == null) {
+ if (sInstance == null || isSatelliteSupported != sInstance.mIsSatelliteSupported) {
sInstance = new SatelliteSessionController(context, looper, isSatelliteSupported,
SatelliteModemInterface.getInstance());
- } else {
- if (isSatelliteSupported != sInstance.mIsSatelliteSupported) {
- Rlog.e(TAG, "New satellite support state " + isSatelliteSupported
- + " is different from existing state " + sInstance.mIsSatelliteSupported
- + ". Ignore the new state.");
- }
}
return sInstance;
}
diff --git a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java
index 1484b47..f8656bf 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java
@@ -202,6 +202,7 @@
@Mock private TelephonyConfigUpdateInstallReceiver mMockTelephonyConfigUpdateInstallReceiver;
@Mock private SatelliteConfigParser mMockConfigParser;
@Mock private SatelliteConfig mMockConfig;
+ @Mock private DemoSimulator mMockDemoSimulator;
private Semaphore mIIntegerConsumerSemaphore = new Semaphore(0);
private IIntegerConsumer mIIntegerConsumer = new IIntegerConsumer.Stub() {
@@ -475,6 +476,7 @@
replaceInstance(PhoneFactory.class, "sPhones", null, new Phone[]{mPhone, mPhone2});
replaceInstance(TelephonyConfigUpdateInstallReceiver.class, "sReceiverAdaptorInstance",
null, mMockTelephonyConfigUpdateInstallReceiver);
+ replaceInstance(DemoSimulator.class, "sInstance", null, mMockDemoSimulator);
mServiceState2 = Mockito.mock(ServiceState.class);
when(mPhone.getServiceState()).thenReturn(mServiceState);
@@ -785,6 +787,7 @@
setUpResponseForRequestSatelliteEnabled(true, false, false, SATELLITE_RESULT_SUCCESS);
mSatelliteControllerUT.requestSatelliteEnabled(SUB_ID, true, false, false,
mIIntegerConsumer);
+ mSatelliteControllerUT.setSatelliteSessionController(mMockSatelliteSessionController);
processAllMessages();
assertTrue(waitForIIntegerConsumerResult(1));
assertEquals(SATELLITE_RESULT_SUCCESS, (long) mIIntegerConsumerResults.get(0));
@@ -1304,6 +1307,7 @@
.registerForSatelliteModemStateChanged(callback);
resetSatelliteControllerUTToSupportedAndProvisionedState();
+ mSatelliteControllerUT.setSatelliteSessionController(mMockSatelliteSessionController);
errorCode = mSatelliteControllerUT.registerForSatelliteModemStateChanged(
SUB_ID, callback);
@@ -1324,7 +1328,7 @@
.unregisterForSatelliteModemStateChanged(callback);
resetSatelliteControllerUTToSupportedAndProvisionedState();
-
+ mSatelliteControllerUT.setSatelliteSessionController(mMockSatelliteSessionController);
mSatelliteControllerUT.unregisterForModemStateChanged(SUB_ID, callback);
verify(mMockSatelliteSessionController).unregisterForSatelliteModemStateChanged(callback);
}
@@ -2250,6 +2254,7 @@
SATELLITE_MODEM_STATE_CONNECTED);
resetSatelliteControllerUTToSupportedAndProvisionedState();
+ mSatelliteControllerUT.setSatelliteSessionController(mMockSatelliteSessionController);
clearInvocations(mMockSatelliteSessionController);
clearInvocations(mMockDatagramController);
sendSatelliteModemStateChangedEvent(SATELLITE_MODEM_STATE_UNAVAILABLE, null);
@@ -4502,5 +4507,9 @@
protected long getElapsedRealtime() {
return elapsedRealtime;
}
+
+ void setSatelliteSessionController(SatelliteSessionController satelliteSessionController) {
+ mSatelliteSessionController = satelliteSessionController;
+ }
}
}