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

Commit 3ea9aa58 authored by Thomas Nguyen's avatar Thomas Nguyen Committed by Android (Google) Code Review
Browse files

Merge "Add functionality to update satellite service package" into udc-dev

parents 622abbb0 782c14ed
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -442,6 +442,11 @@ public class DatagramReceiver extends Handler {
                            SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVE_FAILED,
                            mDatagramController.getReceivePendingCount(), error);

                    mDatagramController.updateReceiveStatus(request.subId,
                            SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_IDLE,
                            mDatagramController.getReceivePendingCount(),
                            SatelliteManager.SATELLITE_ERROR_NONE);

                    reportMetrics(null, error);
                    mControllerMetricsStats.reportIncomingDatagramCount(error);
                }
+29 −1
Original line number Diff line number Diff line
@@ -201,7 +201,6 @@ public class SatelliteController extends Handler {

        // Create the SatelliteControllerMetrics to report controller metrics
        // should be called before making DatagramController
        loge("mControllerMetricsStats = ControllerMetricsStats.make(mContext);");
        mControllerMetricsStats = ControllerMetricsStats.make(mContext);
        mProvisionMetricsStats = ProvisionMetricsStats.getOrCreateInstance();

@@ -1407,6 +1406,35 @@ public class SatelliteController extends Handler {
        sendRequestAsync(CMD_GET_TIME_SATELLITE_NEXT_VISIBLE, result, phone);
    }

    /**
     * This API can be used by only CTS to update satellite vendor service package name.
     *
     * @param servicePackageName The package name of the satellite vendor service.
     * @return {@code true} if the satellite vendor service is set successfully,
     * {@code false} otherwise.
     */
    public boolean setSatelliteServicePackageName(@Nullable String servicePackageName) {
        boolean result = mSatelliteModemInterface.setSatelliteServicePackageName(
                servicePackageName);
        if (result && (servicePackageName == null || servicePackageName.equals("null"))) {
            /**
             * mIsSatelliteSupported is set to true when running SatelliteManagerTestOnMockService.
             * We need to set it to the actual state of the device.
             */
            synchronized (mIsSatelliteSupportedLock) {
                mIsSatelliteSupported = null;
            }
            ResultReceiver receiver = new ResultReceiver(this) {
                @Override
                protected void onReceiveResult(int resultCode, Bundle resultData) {
                    logd("requestIsSatelliteSupported: resultCode=" + resultCode);
                }
            };
            requestIsSatelliteSupported(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, receiver);
        }
        return result;
    }

    /**
     * This function is used by {@link SatelliteModemInterface} to notify
     * {@link SatelliteController} that the satellite vendor service was just connected.
+51 −3
Original line number Diff line number Diff line
@@ -24,12 +24,14 @@ import android.content.Intent;
import android.content.ServiceConnection;
import android.os.AsyncResult;
import android.os.Binder;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.RegistrantList;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.telephony.Rlog;
import android.telephony.satellite.SatelliteCapabilities;
import android.telephony.satellite.SatelliteDatagram;
@@ -55,7 +57,8 @@ import java.util.Arrays;
 */
public class SatelliteModemInterface {
    private static final String TAG = "SatelliteModemInterface";

    private static final String ALLOW_MOCK_MODEM_PROPERTY = "persist.radio.allow_mock_modem";
    private static final boolean DEBUG = !"user".equals(Build.TYPE);
    private static final long REBIND_INITIAL_DELAY = 2 * 1000; // 2 seconds
    private static final long REBIND_MAXIMUM_DELAY = 64 * 1000; // 1 minute
    private static final int REBIND_MULTIPLIER = 2;
@@ -69,9 +72,10 @@ public class SatelliteModemInterface {
    /**
     * {@code true} to use the vendor satellite service and {@code false} to use the HAL.
     */
    private final boolean mIsSatelliteServiceSupported;
    private boolean mIsSatelliteServiceSupported;
    @Nullable private ISatellite mSatelliteService;
    @Nullable private SatelliteServiceConnection mSatelliteServiceConnection;
    @NonNull private String mVendorSatellitePackageName = "";
    private boolean mIsBound;
    private boolean mIsBinding;

@@ -133,7 +137,6 @@ public class SatelliteModemInterface {
                    // keep previous state as this could be retrying sending or receiving
                    break;
            }
            // TODO: properly notify the rest of the datagram transfer state changed parameters
            mDatagramTransferStateChangedRegistrants.notifyResult(datagramTransferState);
        }
    };
@@ -206,6 +209,9 @@ public class SatelliteModemInterface {
    }

    @NonNull private String getSatellitePackageName() {
        if (!TextUtils.isEmpty(mVendorSatellitePackageName)) {
            return mVendorSatellitePackageName;
        }
        return TextUtils.emptyIfNull(mContext.getResources().getString(
                R.string.config_satellite_service_package));
    }
@@ -235,6 +241,7 @@ public class SatelliteModemInterface {
        intent.setPackage(packageName);

        mSatelliteServiceConnection = new SatelliteServiceConnection();
        logd("Binding to " + packageName);
        try {
            boolean success = mContext.bindService(
                    intent, mSatelliteServiceConnection, Context.BIND_AUTO_CREATE);
@@ -963,6 +970,43 @@ public class SatelliteModemInterface {
        return mIsSatelliteServiceSupported;
    }

    /**
     * This API can be used by only CTS to update satellite vendor service package name.
     *
     * @param servicePackageName The package name of the satellite vendor service.
     * @return {@code true} if the satellite vendor service is set successfully,
     * {@code false} otherwise.
     */
    boolean setSatelliteServicePackageName(@Nullable String servicePackageName) {
        if (!shouldAllowModifyingSatelliteServicePackageName()) {
            loge("setSatelliteServicePackageName: modifying satellite service package name "
                    + "is not allowed");
            return false;
        }

        logd("setSatelliteServicePackageName: config_satellite_service_package is "
                + "updated, new packageName=" + servicePackageName);
        mExponentialBackoff.stop();
        if (mSatelliteServiceConnection != null) {
            synchronized (mLock) {
                mIsBound = false;
                mIsBinding = false;
            }
            unbindService();
        }

        if (servicePackageName == null || servicePackageName.equals("null")) {
            mVendorSatellitePackageName = "";
        } else {
            mVendorSatellitePackageName = servicePackageName;
        }
        mIsSatelliteServiceSupported = getSatelliteServiceSupport();
        bindService();
        mExponentialBackoff.start();

        return true;
    }

    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    protected static void sendMessageWithResult(@NonNull Message message, @Nullable Object result,
            @SatelliteManager.SatelliteError int error) {
@@ -972,6 +1016,10 @@ public class SatelliteModemInterface {
        message.sendToTarget();
    }

    private boolean shouldAllowModifyingSatelliteServicePackageName() {
        return (DEBUG || SystemProperties.getBoolean(ALLOW_MOCK_MODEM_PROPERTY, false));
    }

    private static void logd(@NonNull String log) {
        Rlog.d(TAG, log);
    }