From 1a757e02bf9f2b8156809b3ea75cc4ef334871b3 Mon Sep 17 00:00:00 2001 From: Aishwarya Mallampati Date: Tue, 28 Mar 2023 20:25:35 +0000 Subject: [PATCH] Change ILongConsumer to Consumer for onSatelliteDatagramReceived api. Bug: 275270448 Test: atest SatelliteManagerTest Change-Id: I421addbf261a788afbbed6cd3731776b75cc2288 --- .../satellite/ISatelliteDatagramCallback.aidl | 10 ++++---- .../satellite/SatelliteDatagramCallback.java | 10 ++++---- .../telephony/satellite/SatelliteManager.java | 20 ++++++++++++--- .../internal/telephony/IVoidConsumer.aidl | 25 +++++++++++++++++++ 4 files changed, 51 insertions(+), 14 deletions(-) create mode 100644 telephony/java/com/android/internal/telephony/IVoidConsumer.aidl diff --git a/telephony/java/android/telephony/satellite/ISatelliteDatagramCallback.aidl b/telephony/java/android/telephony/satellite/ISatelliteDatagramCallback.aidl index 2954c2d5a6d7d..e229f05b1ad3a 100644 --- a/telephony/java/android/telephony/satellite/ISatelliteDatagramCallback.aidl +++ b/telephony/java/android/telephony/satellite/ISatelliteDatagramCallback.aidl @@ -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); } diff --git a/telephony/java/android/telephony/satellite/SatelliteDatagramCallback.java b/telephony/java/android/telephony/satellite/SatelliteDatagramCallback.java index d8a6fafcdd2f3..d0409bf5df490 100644 --- a/telephony/java/android/telephony/satellite/SatelliteDatagramCallback.java +++ b/telephony/java/android/telephony/satellite/SatelliteDatagramCallback.java @@ -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 callback); } diff --git a/telephony/java/android/telephony/satellite/SatelliteManager.java b/telephony/java/android/telephony/satellite/SatelliteManager.java index 7d82fd8d6d69a..8a8a37618bcbf 100644 --- a/telephony/java/android/telephony/satellite/SatelliteManager.java +++ b/telephony/java/android/telephony/satellite/SatelliteManager.java @@ -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 externalAck = new Consumer() { + @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. diff --git a/telephony/java/com/android/internal/telephony/IVoidConsumer.aidl b/telephony/java/com/android/internal/telephony/IVoidConsumer.aidl new file mode 100644 index 0000000000000..b5557fde2a02a --- /dev/null +++ b/telephony/java/com/android/internal/telephony/IVoidConsumer.aidl @@ -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(); + } \ No newline at end of file