Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e9a57e0d authored by Hakjun Choi's avatar Hakjun Choi Committed by Android (Google) Code Review
Browse files

Merge "make sure to update session controller to power off state" into 24D1-dev

parents b5b81c00 6b882d4c
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -218,7 +218,8 @@ public class SatelliteController extends Handler {
    @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 @@ public class SatelliteController extends Handler {
        }
        mSatelliteSessionController = SatelliteSessionController.make(
                mContext, getLooper(), supported);
        logd("create a new SatelliteSessionController due to isSatelliteSupported state has "
                + "changed to " + supported);

        if (supported) {
            registerForSatelliteProvisionStateChanged();
            registerForPendingDatagramCount();
@@ -3503,6 +3507,10 @@ public class SatelliteController extends Handler {
                }
            }
            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<>();
+1 −8
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ import android.os.Looper;
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 class SatelliteSessionController extends StateMachine {
     */
    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;
    }
+10 −1
Original line number Diff line number Diff line
@@ -202,6 +202,7 @@ public class SatelliteControllerTest extends TelephonyTest {
    @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 @@ public class SatelliteControllerTest extends TelephonyTest {
        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 @@ public class SatelliteControllerTest extends TelephonyTest {
        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 @@ public class SatelliteControllerTest extends TelephonyTest {
                .registerForSatelliteModemStateChanged(callback);

        resetSatelliteControllerUTToSupportedAndProvisionedState();
        mSatelliteControllerUT.setSatelliteSessionController(mMockSatelliteSessionController);

        errorCode = mSatelliteControllerUT.registerForSatelliteModemStateChanged(
                SUB_ID, callback);
@@ -1324,7 +1328,7 @@ public class SatelliteControllerTest extends TelephonyTest {
                .unregisterForSatelliteModemStateChanged(callback);

        resetSatelliteControllerUTToSupportedAndProvisionedState();

        mSatelliteControllerUT.setSatelliteSessionController(mMockSatelliteSessionController);
        mSatelliteControllerUT.unregisterForModemStateChanged(SUB_ID, callback);
        verify(mMockSatelliteSessionController).unregisterForSatelliteModemStateChanged(callback);
    }
@@ -2250,6 +2254,7 @@ public class SatelliteControllerTest extends TelephonyTest {
                SATELLITE_MODEM_STATE_CONNECTED);

        resetSatelliteControllerUTToSupportedAndProvisionedState();
        mSatelliteControllerUT.setSatelliteSessionController(mMockSatelliteSessionController);
        clearInvocations(mMockSatelliteSessionController);
        clearInvocations(mMockDatagramController);
        sendSatelliteModemStateChangedEvent(SATELLITE_MODEM_STATE_UNAVAILABLE, null);
@@ -4502,5 +4507,9 @@ public class SatelliteControllerTest extends TelephonyTest {
        protected long getElapsedRealtime() {
            return elapsedRealtime;
        }

        void setSatelliteSessionController(SatelliteSessionController satelliteSessionController) {
            mSatelliteSessionController = satelliteSessionController;
        }
    }
}