diff options
| author | 2024-03-30 06:41:10 +0000 | |
|---|---|---|
| committer | 2024-03-30 06:41:10 +0000 | |
| commit | 9891aba78d09d757044c51dfed1e482b3524a970 (patch) | |
| tree | 5899f06ea5fbd3e3f1317ba1539ca1f18a9754dd | |
| parent | 8225fab4c2f0a731edf30ef1bd9b89101a447eb5 (diff) | |
| parent | 1ca93825ee8a3f246fb541dee8cee303c8f90f43 (diff) | |
Merge "Add callback into vendor interface to receive modem state change event" into 24D1-dev am: 1ca93825ee
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/26623705
Change-Id: I5a4b9a4357b365dc03fff3bb9c46ae51b2819f73
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
5 files changed, 189 insertions, 0 deletions
diff --git a/telephony/java/android/telephony/satellite/ISatelliteSupportedStateCallback.aidl b/telephony/java/android/telephony/satellite/ISatelliteSupportedStateCallback.aidl new file mode 100644 index 000000000000..04550906324b --- /dev/null +++ b/telephony/java/android/telephony/satellite/ISatelliteSupportedStateCallback.aidl @@ -0,0 +1,31 @@ +/* + * Copyright 2024 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 android.telephony.satellite; + +/** + * Interface for satellite supported state change callback. + * @hide + */ +oneway interface ISatelliteSupportedStateCallback { + /** + * Called when satellite supported state has changed. + * + * @param supoprted Whether satellite is supported or not. + */ + void onSatelliteSupportedStateChanged(in boolean supported); +} + diff --git a/telephony/java/android/telephony/satellite/SatelliteManager.java b/telephony/java/android/telephony/satellite/SatelliteManager.java index 4a6111444f31..20b24b9db6f4 100644 --- a/telephony/java/android/telephony/satellite/SatelliteManager.java +++ b/telephony/java/android/telephony/satellite/SatelliteManager.java @@ -87,6 +87,9 @@ public final class SatelliteManager { private static final ConcurrentHashMap<SatelliteCapabilitiesCallback, ISatelliteCapabilitiesCallback> sSatelliteCapabilitiesCallbackMap = new ConcurrentHashMap<>(); + private static final ConcurrentHashMap<SatelliteSupportedStateCallback, + ISatelliteSupportedStateCallback> sSatelliteSupportedStateCallbackMap = + new ConcurrentHashMap<>(); private final int mSubId; @@ -2284,6 +2287,88 @@ public final class SatelliteManager { return new ArrayList<>(); } + /** + * Registers for the satellite supported state changed. + * + * @param executor The executor on which the callback will be called. + * @param callback The callback to handle the satellite supoprted state changed event. + * + * @return The {@link SatelliteResult} result of the operation. + * + * @throws SecurityException if the caller doesn't have required permission. + * @throws IllegalStateException if the Telephony process is not currently available. + * + * @hide + */ + @RequiresPermission(Manifest.permission.SATELLITE_COMMUNICATION) + @SatelliteResult public int registerForSupportedStateChanged( + @NonNull @CallbackExecutor Executor executor, + @NonNull SatelliteSupportedStateCallback callback) { + Objects.requireNonNull(executor); + Objects.requireNonNull(callback); + + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + ISatelliteSupportedStateCallback internalCallback = + new ISatelliteSupportedStateCallback.Stub() { + @Override + public void onSatelliteSupportedStateChanged(boolean supported) { + executor.execute(() -> Binder.withCleanCallingIdentity( + () -> callback.onSatelliteSupportedStateChanged( + supported))); + } + }; + sSatelliteSupportedStateCallbackMap.put(callback, internalCallback); + return telephony.registerForSatelliteSupportedStateChanged( + mSubId, internalCallback); + } else { + throw new IllegalStateException("telephony service is null."); + } + } catch (RemoteException ex) { + loge("registerForSupportedStateChanged() RemoteException: " + ex); + ex.rethrowAsRuntimeException(); + } + return SATELLITE_RESULT_REQUEST_FAILED; + } + + /** + * Unregisters for the satellite supported state changed. + * If callback was not registered before, the request will be ignored. + * + * @param callback The callback that was passed to + * {@link #registerForSupportedStateChanged(Executor, SatelliteSupportedStateCallback)} + * + * @throws SecurityException if the caller doesn't have required permission. + * @throws IllegalStateException if the Telephony process is not currently available. + * + * @hide + */ + @RequiresPermission(Manifest.permission.SATELLITE_COMMUNICATION) + @FlaggedApi(Flags.FLAG_OEM_ENABLED_SATELLITE_FLAG) + public void unregisterForSupportedStateChanged( + @NonNull SatelliteSupportedStateCallback callback) { + Objects.requireNonNull(callback); + ISatelliteSupportedStateCallback internalCallback = + sSatelliteSupportedStateCallbackMap.remove(callback); + + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + if (internalCallback != null) { + telephony.unregisterForSatelliteSupportedStateChanged(mSubId, internalCallback); + } else { + loge("unregisterForSupportedStateChanged: No internal callback."); + } + } else { + throw new IllegalStateException("telephony service is null."); + } + } catch (RemoteException ex) { + loge("unregisterForSupportedStateChanged() RemoteException: " + ex); + ex.rethrowAsRuntimeException(); + } + } + @Nullable private static ITelephony getITelephony() { ITelephony binder = ITelephony.Stub.asInterface(TelephonyFrameworkInitializer .getTelephonyServiceManager() diff --git a/telephony/java/android/telephony/satellite/SatelliteSupportedStateCallback.java b/telephony/java/android/telephony/satellite/SatelliteSupportedStateCallback.java new file mode 100644 index 000000000000..7e19bd13140d --- /dev/null +++ b/telephony/java/android/telephony/satellite/SatelliteSupportedStateCallback.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 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 android.telephony.satellite; + +import android.annotation.FlaggedApi; + +import com.android.internal.telephony.flags.Flags; + +/** + * A callback class for monitoring satellite supported state change events. + * + * @hide + */ +@FlaggedApi(Flags.FLAG_OEM_ENABLED_SATELLITE_FLAG) +public interface SatelliteSupportedStateCallback { + /** + * Called when satellite supported state changes. + * + * @param supported The new supported state. {@code true} means satellite is supported, + * {@code false} means satellite is not supported. + * + * @hide + */ + @FlaggedApi(Flags.FLAG_OEM_ENABLED_SATELLITE_FLAG) + void onSatelliteSupportedStateChanged(boolean supported); +} diff --git a/telephony/java/android/telephony/satellite/stub/ISatelliteListener.aidl b/telephony/java/android/telephony/satellite/stub/ISatelliteListener.aidl index ccca5adba367..5b9dfc67c68c 100644 --- a/telephony/java/android/telephony/satellite/stub/ISatelliteListener.aidl +++ b/telephony/java/android/telephony/satellite/stub/ISatelliteListener.aidl @@ -74,4 +74,11 @@ oneway interface ISatelliteListener { * @param SatelliteCapabilities The current satellite capabilities. */ void onSatelliteCapabilitiesChanged(in SatelliteCapabilities capabilities); + + /** + * Called when supported state of satellite has changed + * + * @param supported True means satellite service is supported and false means it is not. + */ + void onSatelliteSupportedStateChanged(in boolean supported); } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index ff2ee27abc60..f25fc362a203 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -72,6 +72,7 @@ import android.telephony.satellite.ISatelliteCapabilitiesCallback; import android.telephony.satellite.ISatelliteDatagramCallback; import android.telephony.satellite.ISatelliteTransmissionUpdateCallback; import android.telephony.satellite.ISatelliteProvisionStateCallback; +import android.telephony.satellite.ISatelliteSupportedStateCallback; import android.telephony.satellite.ISatelliteModemStateCallback; import android.telephony.satellite.NtnSignalStrength; import android.telephony.satellite.SatelliteCapabilities; @@ -3315,4 +3316,29 @@ interface ITelephony { @JavaPassthrough(annotation="@android.annotation.RequiresPermission(" + "android.Manifest.permission.SATELLITE_COMMUNICATION)") List<String> getSatellitePlmnsForCarrier(int subId); + + /** + * Registers for supported state changed from satellite modem. + * + * @param subId The subId of the subscription to register for supported state changed. + * @param callback The callback to handle the satellite supported state changed event. + * + * @return The {@link SatelliteError} result of the operation. + */ + @JavaPassthrough(annotation="@android.annotation.RequiresPermission(" + + "android.Manifest.permission.SATELLITE_COMMUNICATION)") + int registerForSatelliteSupportedStateChanged(int subId, + in ISatelliteSupportedStateCallback callback); + + /** + * Unregisters for supported state changed from satellite modem. + * If callback was not registered before, the request will be ignored. + * + * @param subId The subId of the subscription to unregister for supported state changed. + * @param callback The callback that was passed to registerForSatelliteSupportedStateChanged. + */ + @JavaPassthrough(annotation="@android.annotation.RequiresPermission(" + + "android.Manifest.permission.SATELLITE_COMMUNICATION)") + void unregisterForSatelliteSupportedStateChanged(int subId, + in ISatelliteSupportedStateCallback callback); } |