Loading src/java/com/android/internal/telephony/satellite/DemoSimulator.java +11 −17 Original line number Original line Diff line number Diff line Loading @@ -28,11 +28,12 @@ import android.telephony.satellite.stub.SatelliteModemState; import android.telephony.satellite.stub.SatelliteResult; import android.telephony.satellite.stub.SatelliteResult; import android.util.Log; import android.util.Log; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.State; import com.android.internal.util.State; import com.android.internal.util.StateMachine; import com.android.internal.util.StateMachine; import java.util.concurrent.atomic.AtomicBoolean; public class DemoSimulator extends StateMachine { public class DemoSimulator extends StateMachine { private static final String TAG = "DemoSimulator"; private static final String TAG = "DemoSimulator"; private static final boolean DBG = true; private static final boolean DBG = true; Loading @@ -50,11 +51,10 @@ public class DemoSimulator extends StateMachine { @NonNull private final PowerOffState mPowerOffState = new PowerOffState(); @NonNull private final PowerOffState mPowerOffState = new PowerOffState(); @NonNull private final NotConnectedState mNotConnectedState = new NotConnectedState(); @NonNull private final NotConnectedState mNotConnectedState = new NotConnectedState(); @NonNull private final ConnectedState mConnectedState = new ConnectedState(); @NonNull private final ConnectedState mConnectedState = new ConnectedState(); @NonNull private final Object mLock = new Object(); @GuardedBy("mLock") private boolean mIsAligned = false; private ISatelliteListener mISatelliteListener; private ISatelliteListener mISatelliteListener; private AtomicBoolean mIsAligned = new AtomicBoolean(false); /** /** * @return The singleton instance of DemoSimulator. * @return The singleton instance of DemoSimulator. */ */ Loading Loading @@ -134,11 +134,9 @@ public class DemoSimulator extends StateMachine { SatelliteModemState.SATELLITE_MODEM_STATE_OUT_OF_SERVICE); SatelliteModemState.SATELLITE_MODEM_STATE_OUT_OF_SERVICE); mISatelliteListener.onNtnSignalStrengthChanged(ntnSignalStrength); mISatelliteListener.onNtnSignalStrengthChanged(ntnSignalStrength); synchronized (mLock) { if (mIsAligned.get()) { if (mIsAligned) { handleEventDeviceAlignedWithSatellite(true); handleEventDeviceAlignedWithSatellite(true); } } } } catch (RemoteException e) { } catch (RemoteException e) { loge("NotConnectedState: RemoteException " + e); loge("NotConnectedState: RemoteException " + e); } } Loading Loading @@ -194,11 +192,9 @@ public class DemoSimulator extends StateMachine { SatelliteModemState.SATELLITE_MODEM_STATE_IN_SERVICE); SatelliteModemState.SATELLITE_MODEM_STATE_IN_SERVICE); mISatelliteListener.onNtnSignalStrengthChanged(ntnSignalStrength); mISatelliteListener.onNtnSignalStrengthChanged(ntnSignalStrength); synchronized (mLock) { if (!mIsAligned.get()) { if (!mIsAligned) { handleEventDeviceAlignedWithSatellite(false); handleEventDeviceAlignedWithSatellite(false); } } } } catch (RemoteException e) { } catch (RemoteException e) { loge("ConnectedState: RemoteException " + e); loge("ConnectedState: RemoteException " + e); } } Loading Loading @@ -319,11 +315,9 @@ public class DemoSimulator extends StateMachine { */ */ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) public void setDeviceAlignedWithSatellite(boolean isAligned) { public void setDeviceAlignedWithSatellite(boolean isAligned) { synchronized (mLock) { if (mSatelliteController.isDemoModeEnabled()) { if (mSatelliteController.isDemoModeEnabled()) { mIsAligned = isAligned; mIsAligned.set(isAligned); sendMessage(EVENT_DEVICE_ALIGNED_WITH_SATELLITE, isAligned); sendMessage(EVENT_DEVICE_ALIGNED_WITH_SATELLITE, isAligned); } } } } } } } tests/telephonytests/src/com/android/internal/telephony/satellite/DemoSimulatorTest.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.mockito.Mockito.when; Loading Loading @@ -73,6 +74,7 @@ public class DemoSimulatorTest extends TelephonyTest { when(mMockSatelliteController.getDemoPointingNotAlignedDurationMillis()).thenReturn( when(mMockSatelliteController.getDemoPointingNotAlignedDurationMillis()).thenReturn( TEST_DEVICE_POINTING_NOT_ALIGNED_DURATION_MILLIS); TEST_DEVICE_POINTING_NOT_ALIGNED_DURATION_MILLIS); doReturn(true).when(mFeatureFlags).satelliteImproveMultiThreadDesign(); mTestDemoSimulator = new TestDemoSimulator(mContext, Looper.myLooper(), mTestDemoSimulator = new TestDemoSimulator(mContext, Looper.myLooper(), mMockSatelliteController); mMockSatelliteController); mTestDemoSimulator.setSatelliteListener(mISatelliteListener); mTestDemoSimulator.setSatelliteListener(mISatelliteListener); Loading Loading
src/java/com/android/internal/telephony/satellite/DemoSimulator.java +11 −17 Original line number Original line Diff line number Diff line Loading @@ -28,11 +28,12 @@ import android.telephony.satellite.stub.SatelliteModemState; import android.telephony.satellite.stub.SatelliteResult; import android.telephony.satellite.stub.SatelliteResult; import android.util.Log; import android.util.Log; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.State; import com.android.internal.util.State; import com.android.internal.util.StateMachine; import com.android.internal.util.StateMachine; import java.util.concurrent.atomic.AtomicBoolean; public class DemoSimulator extends StateMachine { public class DemoSimulator extends StateMachine { private static final String TAG = "DemoSimulator"; private static final String TAG = "DemoSimulator"; private static final boolean DBG = true; private static final boolean DBG = true; Loading @@ -50,11 +51,10 @@ public class DemoSimulator extends StateMachine { @NonNull private final PowerOffState mPowerOffState = new PowerOffState(); @NonNull private final PowerOffState mPowerOffState = new PowerOffState(); @NonNull private final NotConnectedState mNotConnectedState = new NotConnectedState(); @NonNull private final NotConnectedState mNotConnectedState = new NotConnectedState(); @NonNull private final ConnectedState mConnectedState = new ConnectedState(); @NonNull private final ConnectedState mConnectedState = new ConnectedState(); @NonNull private final Object mLock = new Object(); @GuardedBy("mLock") private boolean mIsAligned = false; private ISatelliteListener mISatelliteListener; private ISatelliteListener mISatelliteListener; private AtomicBoolean mIsAligned = new AtomicBoolean(false); /** /** * @return The singleton instance of DemoSimulator. * @return The singleton instance of DemoSimulator. */ */ Loading Loading @@ -134,11 +134,9 @@ public class DemoSimulator extends StateMachine { SatelliteModemState.SATELLITE_MODEM_STATE_OUT_OF_SERVICE); SatelliteModemState.SATELLITE_MODEM_STATE_OUT_OF_SERVICE); mISatelliteListener.onNtnSignalStrengthChanged(ntnSignalStrength); mISatelliteListener.onNtnSignalStrengthChanged(ntnSignalStrength); synchronized (mLock) { if (mIsAligned.get()) { if (mIsAligned) { handleEventDeviceAlignedWithSatellite(true); handleEventDeviceAlignedWithSatellite(true); } } } } catch (RemoteException e) { } catch (RemoteException e) { loge("NotConnectedState: RemoteException " + e); loge("NotConnectedState: RemoteException " + e); } } Loading Loading @@ -194,11 +192,9 @@ public class DemoSimulator extends StateMachine { SatelliteModemState.SATELLITE_MODEM_STATE_IN_SERVICE); SatelliteModemState.SATELLITE_MODEM_STATE_IN_SERVICE); mISatelliteListener.onNtnSignalStrengthChanged(ntnSignalStrength); mISatelliteListener.onNtnSignalStrengthChanged(ntnSignalStrength); synchronized (mLock) { if (!mIsAligned.get()) { if (!mIsAligned) { handleEventDeviceAlignedWithSatellite(false); handleEventDeviceAlignedWithSatellite(false); } } } } catch (RemoteException e) { } catch (RemoteException e) { loge("ConnectedState: RemoteException " + e); loge("ConnectedState: RemoteException " + e); } } Loading Loading @@ -319,11 +315,9 @@ public class DemoSimulator extends StateMachine { */ */ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) public void setDeviceAlignedWithSatellite(boolean isAligned) { public void setDeviceAlignedWithSatellite(boolean isAligned) { synchronized (mLock) { if (mSatelliteController.isDemoModeEnabled()) { if (mSatelliteController.isDemoModeEnabled()) { mIsAligned = isAligned; mIsAligned.set(isAligned); sendMessage(EVENT_DEVICE_ALIGNED_WITH_SATELLITE, isAligned); sendMessage(EVENT_DEVICE_ALIGNED_WITH_SATELLITE, isAligned); } } } } } } }
tests/telephonytests/src/com/android/internal/telephony/satellite/DemoSimulatorTest.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.mockito.Mockito.when; Loading Loading @@ -73,6 +74,7 @@ public class DemoSimulatorTest extends TelephonyTest { when(mMockSatelliteController.getDemoPointingNotAlignedDurationMillis()).thenReturn( when(mMockSatelliteController.getDemoPointingNotAlignedDurationMillis()).thenReturn( TEST_DEVICE_POINTING_NOT_ALIGNED_DURATION_MILLIS); TEST_DEVICE_POINTING_NOT_ALIGNED_DURATION_MILLIS); doReturn(true).when(mFeatureFlags).satelliteImproveMultiThreadDesign(); mTestDemoSimulator = new TestDemoSimulator(mContext, Looper.myLooper(), mTestDemoSimulator = new TestDemoSimulator(mContext, Looper.myLooper(), mMockSatelliteController); mMockSatelliteController); mTestDemoSimulator.setSatelliteListener(mISatelliteListener); mTestDemoSimulator.setSatelliteListener(mISatelliteListener); Loading