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

Commit 61544e91 authored by Sarah Chin's avatar Sarah Chin Committed by Aishwarya Mallampati
Browse files

Support new and updated satellite APIs

Test: atest SatelliteManagerTest
Bug: 268791334
Change-Id: Ie41a70a4ff6d24336960ec25a615a587ec54a320
parent 59fbd9c4
Loading
Loading
Loading
Loading
+8 −1
Original line number Original line Diff line number Diff line
@@ -3146,7 +3146,14 @@ public interface CommandsInterface {
    default void getMaxCharactersPerSatelliteTextMessage(Message result) {}
    default void getMaxCharactersPerSatelliteTextMessage(Message result) {}


    /**
    /**
     * Get time for next visibility of satellite.
     * Get whether satellite communication is allowed for the current location.
     *
     * @param result Message that will be sent back to the requester.
     */
    default void isSatelliteCommunicationAllowedForCurrentLocation(Message result) {}

    /**
     * Get the time after which the satellite will next be visible.
     *
     *
     * @param result Message that will be sent back to the requester.
     * @param result Message that will be sent back to the requester.
     */
     */
+32 −17
Original line number Original line Diff line number Diff line
@@ -5273,8 +5273,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {


    /**
    /**
     * Get maximum number of characters per text message on satellite.
     * Get maximum number of characters per text message on satellite.
     * @param result - message object which contains maximum characters on success
     * @param result The Message to send the result of the operation to.
     *               and error code on failure.
     */
     */
    public void getMaxCharactersPerSatelliteTextMessage(Message result) {
    public void getMaxCharactersPerSatelliteTextMessage(Message result) {
        mCi.getMaxCharactersPerSatelliteTextMessage(result);
        mCi.getMaxCharactersPerSatelliteTextMessage(result);
@@ -5414,9 +5413,9 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    /**
    /**
     * Registers for satellite state change from satellite modem.
     * Registers for satellite state change from satellite modem.
     *
     *
     * @param h - Handler for notification message.
     * @param h Handler for notification message.
     * @param what - User-defined message code.
     * @param what User-defined message code.
     * @param obj - User object.
     * @param obj User object.
     */
     */
    public void registerForSatelliteModemStateChange(@NonNull Handler h, int what,
    public void registerForSatelliteModemStateChange(@NonNull Handler h, int what,
            @Nullable Object obj) {
            @Nullable Object obj) {
@@ -5426,7 +5425,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    /**
    /**
     * Unregisters for satellite state changes from satellite modem.
     * Unregisters for satellite state changes from satellite modem.
     *
     *
     * @param h - Handler to be removed from registrant list.
     * @param h Handler to be removed from registrant list.
     */
     */
    public void unregisterForSatelliteModemStateChange(@NonNull Handler h) {
    public void unregisterForSatelliteModemStateChange(@NonNull Handler h) {
        mCi.unregisterForSatelliteModeChanged(h);
        mCi.unregisterForSatelliteModeChanged(h);
@@ -5435,9 +5434,9 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    /**
    /**
     * Registers for pending message count info from satellite modem.
     * Registers for pending message count info from satellite modem.
     *
     *
     * @param h - Handler for notification message.
     * @param h Handler for notification message.
     * @param what - User-defined message code.
     * @param what User-defined message code.
     * @param obj - User object.
     * @param obj User object.
     */
     */
    public void registerForPendingMessageCount(@NonNull Handler h, int what, @Nullable Object obj) {
    public void registerForPendingMessageCount(@NonNull Handler h, int what, @Nullable Object obj) {
        mCi.registerForPendingSatelliteMessageCount(h, what, obj);
        mCi.registerForPendingSatelliteMessageCount(h, what, obj);
@@ -5446,7 +5445,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    /**
    /**
     * Unregisters for pending message count info from satellite modem.
     * Unregisters for pending message count info from satellite modem.
     *
     *
     * @param h - Handler to be removed from registrant list.
     * @param h Handler to be removed from registrant list.
     */
     */
    public void unregisterForPendingMessageCount(@NonNull Handler h) {
    public void unregisterForPendingMessageCount(@NonNull Handler h) {
        mCi.unregisterForPendingSatelliteMessageCount(h);
        mCi.unregisterForPendingSatelliteMessageCount(h);
@@ -5455,9 +5454,9 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    /**
    /**
     * Register to receive incoming datagrams over satellite.
     * Register to receive incoming datagrams over satellite.
     *
     *
     * @param h - Handler for notification message.
     * @param h Handler for notification message.
     * @param what - User-defined message code.
     * @param what User-defined message code.
     * @param obj - User object.
     * @param obj User object.
     */
     */
    public void registerForNewSatelliteDatagram(@NonNull Handler h, int what,
    public void registerForNewSatelliteDatagram(@NonNull Handler h, int what,
            @Nullable Object obj) {
            @Nullable Object obj) {
@@ -5468,7 +5467,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    /**
    /**
     * Unregister to stop receiving incoming datagrams over satellite.
     * Unregister to stop receiving incoming datagrams over satellite.
     *
     *
     * @param h - Handler to be removed from registrant list.
     * @param h Handler to be removed from registrant list.
     */
     */
    public void unregisterForNewSatelliteDatagram(@NonNull Handler h) {
    public void unregisterForNewSatelliteDatagram(@NonNull Handler h) {
        //mCi.unregisterForNewSatelliteDatagram(h);
        //mCi.unregisterForNewSatelliteDatagram(h);
@@ -5476,7 +5475,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {


    /**
    /**
     * Poll pending satellite datagrams over satellite.
     * Poll pending satellite datagrams over satellite.
     * @param result - message object which informs if the request is successful or not.
     * @param result The Message to send the result of the operation to.
     */
     */
    public void pollPendingSatelliteDatagrams(Message result) {
    public void pollPendingSatelliteDatagrams(Message result) {
        //mCi.pollPendingSatelliteDatagrams(result);
        //mCi.pollPendingSatelliteDatagrams(result);
@@ -5484,13 +5483,29 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {


    /**
    /**
     * Send datagram over satellite.
     * Send datagram over satellite.
     * @param result - message object which informs if the request is successful or not
     * @param result The Message to send the result of the operation to.
     * @param datagram - datagram to send over satellite
     * @param datagram Datagram to send over satellite.
     */
     */
    public void sendSatelliteDatagram(Message result, SatelliteDatagram datagram) {
    public void sendSatelliteDatagram(Message result, SatelliteDatagram datagram) {
        //mCi.sendSatelliteDatagram(result, datagram, longitude, latitude);
        //mCi.sendSatelliteDatagram(result, datagram, longitude, latitude);
    }
    }


    /**
     * Check whether satellite communication is allowed for the current location.
     * @param result The Message to send the result of the operation to.
     */
    public void isSatelliteCommunicationAllowedForCurrentLocation(Message result) {
        mCi.isSatelliteCommunicationAllowedForCurrentLocation(result);
    }

    /**
     * Get the time after which the satellite will next be visible.
     * @param result The Message to send the result of the operation to.
     */
    public void requestTimeForNextSatelliteVisibility(Message result) {
        mCi.getTimeForNextSatelliteVisibility(result);
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("Phone: subId=" + getSubId());
        pw.println("Phone: subId=" + getSubId());
        pw.println(" mPhoneId=" + mPhoneId);
        pw.println(" mPhoneId=" + mPhoneId);
+19 −0
Original line number Original line Diff line number Diff line
@@ -6308,6 +6308,25 @@ public class RIL extends BaseCommands implements CommandsInterface {
        }
        }
    }
    }


    /**
     * Get whether satellite communication is allowed for the current location
     *
     * @param result Message that will be sent back to the requester.
     */
    @Override
    public void isSatelliteCommunicationAllowedForCurrentLocation(Message result) {
        // TODO: link to HAL implementation
        if (RILJ_LOGD) {
            Rlog.d(RILJ_LOG_TAG,
                    "stopSendingSatellitePointingInfo: REQUEST_NOT_SUPPORTED");
        }
        if (result != null) {
            AsyncResult.forMessage(result, null,
                    CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED));
            result.sendToTarget();
        }
    }

    /**
    /**
     * Get time for next visibility of satellite.
     * Get time for next visibility of satellite.
     *
     *
+1 −41
Original line number Original line Diff line number Diff line
@@ -377,7 +377,6 @@ import android.telephony.ims.stub.ImsRegistrationImplBase.ImsDeregistrationReaso
import android.telephony.satellite.PointingInfo;
import android.telephony.satellite.PointingInfo;
import android.telephony.satellite.SatelliteCapabilities;
import android.telephony.satellite.SatelliteCapabilities;
import android.telephony.satellite.SatelliteManager;
import android.telephony.satellite.SatelliteManager;
import android.telephony.satellite.stub.SatelliteImplBase;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.ArraySet;
import android.util.SparseArray;
import android.util.SparseArray;
@@ -5946,35 +5945,8 @@ public class RILUtils {
                supportedRadioTechnologies.add(technology);
                supportedRadioTechnologies.add(technology);
            }
            }
        }
        }

        Set<Integer> supportedFeatures = new HashSet<>();
        if (capabilities.supportedFeatures != null
                && capabilities.supportedFeatures.length > 0) {
            for (int feature : capabilities.supportedFeatures) {
                supportedFeatures.add(feature);
            }
        }
        return new SatelliteCapabilities(supportedRadioTechnologies, capabilities.isAlwaysOn,
        return new SatelliteCapabilities(supportedRadioTechnologies, capabilities.isAlwaysOn,
                capabilities.needsPointingToSatellite, supportedFeatures,
                capabilities.needsPointingToSatellite, capabilities.needsSeparateSimProfile);
                capabilities.needsSeparateSimProfile);
    }

    /**
     * Convert from android.hardware.radio.satellite.Feature to
     * android.telephony.satellite.stub.SatelliteImplBase.Feature
     */
    public static int convertHalSatelliteFeature(int feature) {
        switch (feature) {
            case android.hardware.radio.satellite.SatelliteFeature.SOS_SMS:
                return SatelliteImplBase.FEATURE_SOS_SMS;
            case android.hardware.radio.satellite.SatelliteFeature.EMERGENCY_SMS:
                return SatelliteImplBase.FEATURE_EMERGENCY_SMS;
            case android.hardware.radio.satellite.SatelliteFeature.SMS:
                return SatelliteImplBase.FEATURE_SMS;
            case android.hardware.radio.satellite.SatelliteFeature.LOCATION_SHARING:
                return SatelliteImplBase.FEATURE_LOCATION_SHARING;
            default: return SatelliteImplBase.FEATURE_UNKNOWN;
        }
    }
    }


    /**
    /**
@@ -5988,18 +5960,6 @@ public class RILUtils {
                pointingInfo.antennaPitchDegrees, pointingInfo.antennaRollDegrees);
                pointingInfo.antennaPitchDegrees, pointingInfo.antennaRollDegrees);
    }
    }


    /**
     * Convert array of android.hardware.radio.satellite.Feature to
     * array of android.telephony.satellite.stub.SatelliteImplBase.Feature
     */
    public static int[] convertHalSatelliteFeatures(int[] features) {
        int[] convertedFeatrures = new int[features.length];
        for (int i = 0; i < features.length; i++) {
            convertedFeatrures[i] = convertHalSatelliteFeature(features[i]);
        }
        return convertedFeatrures;
    }

    /**
    /**
     * Convert from android.telephony.satellite.stub.PointingInfo to
     * Convert from android.telephony.satellite.stub.PointingInfo to
     * android.hardware.radio.satellite.PointingInfo
     * android.hardware.radio.satellite.PointingInfo
+3 −2
Original line number Original line Diff line number Diff line
@@ -167,13 +167,14 @@ public class SatelliteIndication extends IRadioSatelliteIndication.Stub {
     * @param features List of Feature whose provision state has changed.
     * @param features List of Feature whose provision state has changed.
     */
     */
    public void onProvisionStateChanged(int indicationType, boolean provisioned, int[] features) {
    public void onProvisionStateChanged(int indicationType, boolean provisioned, int[] features) {
        // TODO: remove features and update AsyncResult
        mRil.processIndication(HAL_SERVICE_SATELLITE, indicationType);
        mRil.processIndication(HAL_SERVICE_SATELLITE, indicationType);


        if (mRil.isLogOrTrace()) mRil.unsljLog(RIL_UNSOL_SATELLITE_PROVISION_STATE_CHANGED);
        if (mRil.isLogOrTrace()) mRil.unsljLog(RIL_UNSOL_SATELLITE_PROVISION_STATE_CHANGED);


        if (mRil.mSatelliteProvisionStateChangedRegistrants != null) {
        if (mRil.mSatelliteProvisionStateChangedRegistrants != null) {
            mRil.mSatelliteProvisionStateChangedRegistrants.notifyRegistrants(new AsyncResult(
            mRil.mSatelliteProvisionStateChangedRegistrants.notifyRegistrants(
                    provisioned, RILUtils.convertHalSatelliteFeatures(features), null));
                    new AsyncResult(provisioned, null, null));
        }
        }
    }
    }
}
}