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

Commit bd5f0607 authored by Thomas Nguyen's avatar Thomas Nguyen Committed by Automerger Merge Worker
Browse files

Merge "Add unit test framework and some tests for SatelliteController" into udc-dev am: 7fbac806

parents dcc55821 7fbac806
Loading
Loading
Loading
Loading
+5 −4
Original line number Original line Diff line number Diff line
@@ -98,7 +98,7 @@ public class DatagramController {
     * @param pointingAppController PointingAppController is used to update PointingApp
     * @param pointingAppController PointingAppController is used to update PointingApp
     *                              about datagram transfer state changes.
     *                              about datagram transfer state changes.
     */
     */
    @VisibleForTesting
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    protected DatagramController(@NonNull Context context, @NonNull Looper  looper,
    protected DatagramController(@NonNull Context context, @NonNull Looper  looper,
            @NonNull PointingAppController pointingAppController) {
            @NonNull PointingAppController pointingAppController) {
        mContext = context;
        mContext = context;
@@ -264,7 +264,8 @@ public class DatagramController {
     * Set variables for {@link DatagramDispatcher} and {@link DatagramReceiver} to run demo mode
     * Set variables for {@link DatagramDispatcher} and {@link DatagramReceiver} to run demo mode
     * @param isDemoMode {@code true} means demo mode is on, {@code false} otherwise.
     * @param isDemoMode {@code true} means demo mode is on, {@code false} otherwise.
     */
     */
    void setDemoMode(boolean isDemoMode) {
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public void setDemoMode(boolean isDemoMode) {
        mIsDemoMode = isDemoMode;
        mIsDemoMode = isDemoMode;
        mDatagramDispatcher.setDemoMode(isDemoMode);
        mDatagramDispatcher.setDemoMode(isDemoMode);
        mDatagramReceiver.setDemoMode(isDemoMode);
        mDatagramReceiver.setDemoMode(isDemoMode);
@@ -275,7 +276,7 @@ public class DatagramController {
    }
    }


    /** Get the last sent datagram for demo mode */
    /** Get the last sent datagram for demo mode */
    @VisibleForTesting
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public SatelliteDatagram getDemoModeDatagram() {
    public SatelliteDatagram getDemoModeDatagram() {
        return mDemoModeDatagram;
        return mDemoModeDatagram;
    }
    }
@@ -285,7 +286,7 @@ public class DatagramController {
     * @param datagramType datagram type, only DATAGRAM_TYPE_SOS_MESSAGE will be saved
     * @param datagramType datagram type, only DATAGRAM_TYPE_SOS_MESSAGE will be saved
     * @param datagram datagram The last datagram saved when sendSatelliteDatagramForDemo is called
     * @param datagram datagram The last datagram saved when sendSatelliteDatagramForDemo is called
     */
     */
    @VisibleForTesting
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    protected void setDemoModeDatagram(@SatelliteManager.DatagramType int datagramType,
    protected void setDemoModeDatagram(@SatelliteManager.DatagramType int datagramType,
            SatelliteDatagram datagram) {
            SatelliteDatagram datagram) {
        if (mIsDemoMode &&  datagramType == SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE) {
        if (mIsDemoMode &&  datagramType == SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE) {
+16 −5
Original line number Original line Diff line number Diff line
@@ -283,7 +283,8 @@ public class SatelliteController extends Handler {
        }
        }
    }
    }


    private void initializeSatelliteModeRadios() {
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    protected void initializeSatelliteModeRadios() {
        UwbManager uwbManager = mContext.getSystemService(UwbManager.class);
        UwbManager uwbManager = mContext.getSystemService(UwbManager.class);
        NfcManager nfcManager = mContext.getSystemService(NfcManager.class);
        NfcManager nfcManager = mContext.getSystemService(NfcManager.class);
        NfcAdapter nfcAdapter = null;
        NfcAdapter nfcAdapter = null;
@@ -313,6 +314,10 @@ public class SatelliteController extends Handler {
                // Read satellite mode radios from settings
                // Read satellite mode radios from settings
                String satelliteModeRadios = Settings.Global.getString(mContentResolver,
                String satelliteModeRadios = Settings.Global.getString(mContentResolver,
                        Settings.Global.SATELLITE_MODE_RADIOS);
                        Settings.Global.SATELLITE_MODE_RADIOS);
                if (satelliteModeRadios == null) {
                    loge("initializeSatelliteModeRadios: satelliteModeRadios is null");
                    return;
                }
                logd("Radios To be checked when satellite is on: " + satelliteModeRadios);
                logd("Radios To be checked when satellite is on: " + satelliteModeRadios);


                if (satelliteModeRadios.contains(Settings.Global.RADIO_BLUETOOTH)
                if (satelliteModeRadios.contains(Settings.Global.RADIO_BLUETOOTH)
@@ -1756,6 +1761,8 @@ public class SatelliteController extends Handler {
        boolean result = mSatelliteModemInterface.setSatelliteServicePackageName(
        boolean result = mSatelliteModemInterface.setSatelliteServicePackageName(
                servicePackageName);
                servicePackageName);
        if (result) {
        if (result) {
            logd("setSatelliteServicePackageName: Resetting cached states");

            // Cached states need to be cleared whenever switching satellite vendor services.
            // Cached states need to be cleared whenever switching satellite vendor services.
            synchronized (mIsSatelliteSupportedLock) {
            synchronized (mIsSatelliteSupportedLock) {
                mIsSatelliteSupported = null;
                mIsSatelliteSupported = null;
@@ -1847,7 +1854,8 @@ public class SatelliteController extends Handler {
     * Because satellite vendor service might have just come back from a crash, we need to disable
     * Because satellite vendor service might have just come back from a crash, we need to disable
     * the satellite modem so that resources will be cleaned up and internal states will be reset.
     * the satellite modem so that resources will be cleaned up and internal states will be reset.
     */
     */
    void onSatelliteServiceConnected() {
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public void onSatelliteServiceConnected() {
        if (mSatelliteModemInterface.isSatelliteServiceSupported()) {
        if (mSatelliteModemInterface.isSatelliteServiceSupported()) {
            synchronized (mIsSatelliteSupportedLock) {
            synchronized (mIsSatelliteSupportedLock) {
                if (mIsSatelliteSupported == null) {
                if (mIsSatelliteSupported == null) {
@@ -2186,13 +2194,16 @@ public class SatelliteController extends Handler {


        mDatagramController.onSatelliteModemStateChanged(state);
        mDatagramController.onSatelliteModemStateChanged(state);
    }
    }
    private void setSettingsKeyForSatelliteMode(int val) {

    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    protected void setSettingsKeyForSatelliteMode(int val) {
        logd("setSettingsKeyForSatelliteMode val: " + val);
        logd("setSettingsKeyForSatelliteMode val: " + val);
        Settings.Global.putInt(mContext.getContentResolver(),
        Settings.Global.putInt(mContext.getContentResolver(),
                    Settings.Global.SATELLITE_MODE_ENABLED, val);
                    Settings.Global.SATELLITE_MODE_ENABLED, val);
    }
    }


    private boolean areAllRadiosDisabled() {
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    protected boolean areAllRadiosDisabled() {
        synchronized (mRadioStateLock) {
        synchronized (mRadioStateLock) {
            if ((mDisableBTOnSatelliteEnabled && mBTStateEnabled)
            if ((mDisableBTOnSatelliteEnabled && mBTStateEnabled)
                    || (mDisableNFCOnSatelliteEnabled && mNfcStateEnabled)
                    || (mDisableNFCOnSatelliteEnabled && mNfcStateEnabled)
+2 −1
Original line number Original line Diff line number Diff line
@@ -1015,7 +1015,8 @@ public class SatelliteModemInterface {
     * @return {@code true} if the satellite vendor service is set successfully,
     * @return {@code true} if the satellite vendor service is set successfully,
     * {@code false} otherwise.
     * {@code false} otherwise.
     */
     */
    boolean setSatelliteServicePackageName(@Nullable String servicePackageName) {
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public boolean setSatelliteServicePackageName(@Nullable String servicePackageName) {
        if (!shouldAllowModifyingSatelliteServicePackageName()) {
        if (!shouldAllowModifyingSatelliteServicePackageName()) {
            loge("setSatelliteServicePackageName: modifying satellite service package name "
            loge("setSatelliteServicePackageName: modifying satellite service package name "
                    + "is not allowed");
                    + "is not allowed");
+2 −1
Original line number Original line Diff line number Diff line
@@ -338,7 +338,8 @@ public class SatelliteSessionController extends StateMachine {
     *                   {@code false} : The listening timeout durations will be restored to
     *                   {@code false} : The listening timeout durations will be restored to
     *                   production mode
     *                   production mode
     */
     */
    void setDemoMode(boolean isDemoMode) {
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public void setDemoMode(boolean isDemoMode) {
        mIsDemoMode = isDemoMode;
        mIsDemoMode = isDemoMode;
    }
    }