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

Commit 68330d78 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 bc58949f 7fbac806
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ public class DatagramController {
     * @param pointingAppController PointingAppController is used to update PointingApp
     *                              about datagram transfer state changes.
     */
    @VisibleForTesting
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    protected DatagramController(@NonNull Context context, @NonNull Looper  looper,
            @NonNull PointingAppController pointingAppController) {
        mContext = context;
@@ -264,7 +264,8 @@ public class DatagramController {
     * Set variables for {@link DatagramDispatcher} and {@link DatagramReceiver} to run demo mode
     * @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;
        mDatagramDispatcher.setDemoMode(isDemoMode);
        mDatagramReceiver.setDemoMode(isDemoMode);
@@ -275,7 +276,7 @@ public class DatagramController {
    }

    /** Get the last sent datagram for demo mode */
    @VisibleForTesting
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public SatelliteDatagram getDemoModeDatagram() {
        return mDemoModeDatagram;
    }
@@ -285,7 +286,7 @@ public class DatagramController {
     * @param datagramType datagram type, only DATAGRAM_TYPE_SOS_MESSAGE will be saved
     * @param datagram datagram The last datagram saved when sendSatelliteDatagramForDemo is called
     */
    @VisibleForTesting
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    protected void setDemoModeDatagram(@SatelliteManager.DatagramType int datagramType,
            SatelliteDatagram datagram) {
        if (mIsDemoMode &&  datagramType == SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE) {
+16 −5
Original line number 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);
        NfcManager nfcManager = mContext.getSystemService(NfcManager.class);
        NfcAdapter nfcAdapter = null;
@@ -313,6 +314,10 @@ public class SatelliteController extends Handler {
                // Read satellite mode radios from settings
                String satelliteModeRadios = Settings.Global.getString(mContentResolver,
                        Settings.Global.SATELLITE_MODE_RADIOS);
                if (satelliteModeRadios == null) {
                    loge("initializeSatelliteModeRadios: satelliteModeRadios is null");
                    return;
                }
                logd("Radios To be checked when satellite is on: " + satelliteModeRadios);

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

            // Cached states need to be cleared whenever switching satellite vendor services.
            synchronized (mIsSatelliteSupportedLock) {
                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
     * 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()) {
            synchronized (mIsSatelliteSupportedLock) {
                if (mIsSatelliteSupported == null) {
@@ -2186,13 +2194,16 @@ public class SatelliteController extends Handler {

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

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

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

+770 −0

File added.

Preview size limit exceeded, changes collapsed.