Merge "Added send satellite datagram."

This commit is contained in:
Sarah Chin
2023-02-14 07:56:48 +00:00
committed by Android (Google) Code Review
2 changed files with 53 additions and 0 deletions

View File

@@ -1070,6 +1070,45 @@ public class SatelliteManager {
return SATELLITE_REQUEST_FAILED;
}
/**
* Send datagram over satellite.
* @param datagramType - type of datagram
* @param datagram - datagram to send over satellite
* @param executor - The executor on which the result listener will be called.
* @param resultListener - Listener that will be called with the result of the operation.
*
* @throws SecurityException if the caller doesn't have required permission.
* @throws IllegalStateException if the Telephony process is not currently available.
*/
@RequiresPermission(Manifest.permission.SATELLITE_COMMUNICATION)
public void sendSatelliteDatagram(@DatagramType int datagramType,
@NonNull SatelliteDatagram datagram, @NonNull @CallbackExecutor Executor executor,
@SatelliteError @NonNull Consumer<Integer> resultListener) {
Objects.requireNonNull(datagram);
Objects.requireNonNull(executor);
Objects.requireNonNull(resultListener);
try {
ITelephony telephony = getITelephony();
if (telephony != null) {
IIntegerConsumer internalCallback = new IIntegerConsumer.Stub() {
@Override
public void accept(int result) {
executor.execute(() -> Binder.withCleanCallingIdentity(
() -> resultListener.accept(result)));
}
};
telephony.sendSatelliteDatagram(mSubId, datagramType, datagram,
internalCallback);
} else {
throw new IllegalStateException("telephony service is null.");
}
} catch (RemoteException ex) {
loge("sendSatelliteDatagram() RemoteException:" + ex);
ex.rethrowFromSystemServer();
}
}
private static ITelephony getITelephony() {
ITelephony binder = ITelephony.Stub.asInterface(TelephonyFrameworkInitializer
.getTelephonyServiceManager()

View File

@@ -69,6 +69,7 @@ import android.telephony.ims.aidl.IImsRegistrationCallback;
import android.telephony.ims.aidl.IRcsConfigCallback;
import android.telephony.satellite.ISatelliteStateListener;
import android.telephony.satellite.SatelliteCapabilities;
import android.telephony.satellite.SatelliteDatagram;
import com.android.ims.internal.IImsServiceFeatureCallback;
import com.android.internal.telephony.CellNetworkScanResult;
import com.android.internal.telephony.IBooleanConsumer;
@@ -2894,4 +2895,17 @@ interface ITelephony {
@JavaPassthrough(annotation="@android.annotation.RequiresPermission("
+ "android.Manifest.permission.SATELLITE_COMMUNICATION)")
int pollPendingSatelliteDatagrams(int subId);
/**
* Send datagram over satellite.
*
* @param subId - The subId of the subscription used for receiving datagrams.
* @param datagramType - type of datagram
* @param datagram - datagram to send over satellite
* @param callback - The callback to get the error code of the request.
*/
@JavaPassthrough(annotation="@android.annotation.RequiresPermission("
+ "android.Manifest.permission.SATELLITE_COMMUNICATION)")
void sendSatelliteDatagram(int subId, int datagramType, in SatelliteDatagram datagram,
IIntegerConsumer callback);
}