Change ILongConsumer to Consumer<Long> for onSatelliteDatagramReceived

api.

Bug: 275270448
Test: atest SatelliteManagerTest
Change-Id: I421addbf261a788afbbed6cd3731776b75cc2288
This commit is contained in:
Aishwarya Mallampati
2023-03-28 20:25:35 +00:00
parent 866414aadc
commit 1a757e02bf
4 changed files with 51 additions and 14 deletions

View File

@@ -18,7 +18,7 @@ package android.telephony.satellite;
import android.telephony.satellite.SatelliteDatagram;
import com.android.internal.telephony.ILongConsumer;
import com.android.internal.telephony.IVoidConsumer;
/**
* Interface for satellite datagrams callback.
@@ -31,10 +31,10 @@ oneway interface ISatelliteDatagramCallback {
* @param datagramId An id that uniquely identifies incoming datagram.
* @param datagram Datagram received from satellite.
* @param pendingCount Number of datagrams yet to be received from satellite.
* @param callback This callback will be used by datagram receiver app to send received
* datagramId to Telephony. If the callback is not received within five minutes,
* Telephony will resend the datagram.
* @param callback This callback will be used by datagram receiver app to to inform
* Telephony that datagram is received. If the callback is not received
* within five minutes, Telephony will resend the datagram.
*/
void onSatelliteDatagramReceived(long datagramId, in SatelliteDatagram datagram,
int pendingCount, ILongConsumer callback);
int pendingCount, IVoidConsumer callback);
}

View File

@@ -19,7 +19,7 @@ package android.telephony.satellite;
import android.annotation.NonNull;
import android.compat.annotation.UnsupportedAppUsage;
import com.android.internal.telephony.ILongConsumer;
import java.util.function.Consumer;
/**
* A callback class for listening to satellite datagrams.
@@ -33,11 +33,11 @@ public interface SatelliteDatagramCallback {
* @param datagramId An id that uniquely identifies incoming datagram.
* @param datagram Datagram to be received over satellite.
* @param pendingCount Number of datagrams yet to be received by the app.
* @param callback This callback will be used by datagram receiver app to send received
* datagramId to Telephony. If the callback is not received within five minutes,
* Telephony will resend the datagram.
* @param callback This callback will be used by datagram receiver app to inform Telephony
* that they received the datagram. If the callback is not received within
* five minutes, Telephony will resend the datagram.
*/
@UnsupportedAppUsage
void onSatelliteDatagramReceived(long datagramId, @NonNull SatelliteDatagram datagram,
int pendingCount, @NonNull ILongConsumer callback);
int pendingCount, @NonNull Consumer<Void> callback);
}

View File

@@ -37,7 +37,7 @@ import android.telephony.SubscriptionManager;
import android.telephony.TelephonyFrameworkInitializer;
import com.android.internal.telephony.IIntegerConsumer;
import com.android.internal.telephony.ILongConsumer;
import com.android.internal.telephony.IVoidConsumer;
import com.android.internal.telephony.ITelephony;
import com.android.telephony.Rlog;
@@ -1186,10 +1186,22 @@ public class SatelliteManager {
@Override
public void onSatelliteDatagramReceived(long datagramId,
@NonNull SatelliteDatagram datagram, int pendingCount,
@NonNull ILongConsumer ack) {
@NonNull IVoidConsumer internalAck) {
Consumer<Void> externalAck = new Consumer<Void>() {
@Override
public void accept(Void result) {
try {
internalAck.accept();
} catch (RemoteException e) {
logd("onSatelliteDatagramReceived "
+ "RemoteException: " + e);
}
}
};
executor.execute(() -> Binder.withCleanCallingIdentity(
() -> callback.onSatelliteDatagramReceived(
datagramId, datagram, pendingCount, ack)));
datagramId, datagram, pendingCount, externalAck)));
}
};
sSatelliteDatagramCallbackMap.put(callback, internalCallback);
@@ -1244,7 +1256,7 @@ public class SatelliteManager {
* This method requests modem to check if there are any pending datagrams to be received over
* satellite. If there are any incoming datagrams, they will be received via
* {@link SatelliteDatagramCallback#onSatelliteDatagramReceived(long, SatelliteDatagram, int,
* ILongConsumer)}
* Consumer)} )}
*
* @param executor The executor on which the result listener will be called.
* @param resultListener Listener for the {@link SatelliteError} result of the operation.

View File

@@ -0,0 +1,25 @@
/*
* Copyright 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.internal.telephony;
/**
* Copies consumer pattern for an operation that requires void result from another process to
* finish.
*/
oneway interface IVoidConsumer {
void accept();
}