diff options
| author | 2023-10-26 15:00:10 +0000 | |
|---|---|---|
| committer | 2023-11-10 19:03:14 +0000 | |
| commit | f2f5c5bbe57baf391c091e1e1109f23445a6161c (patch) | |
| tree | 7b625dbe2d2aa203345172a82f54f09e3104f684 | |
| parent | fb1b57bac2733b430568aa89850ad5a4659db9af (diff) | |
Add api for monitoring satellite capabilities changed event
1. Added registerForSatelliteCapabilitiesChanged/unregisterForSatelliteCapabilitiesChanged into SatelliteManager
2. Added onSatelliteCapabilitiesChanged() into ISatelliteListener interface
Bug: 307821402
Test: SatelliteControllerTest SatelliteManagerTest
SatelliteManagerOnMockService
Change-Id: Iee6ab609c75b57e8693d60e9495c6ea486a63a96
6 files changed, 190 insertions, 1 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 8d480e5bc8f4..de07fdde6267 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -16834,6 +16834,10 @@ package android.telephony.satellite { field @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") @NonNull public static final android.os.Parcelable.Creator<android.telephony.satellite.SatelliteCapabilities> CREATOR; } + @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") public interface SatelliteCapabilitiesCallback { + method @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") public void onSatelliteCapabilitiesChanged(@NonNull android.telephony.satellite.SatelliteCapabilities); + } + @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") public final class SatelliteDatagram implements android.os.Parcelable { method @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") public int describeContents(); method @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") @NonNull public byte[] getSatelliteDatagram(); @@ -16852,6 +16856,7 @@ package android.telephony.satellite { method @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public void pollPendingSatelliteDatagrams(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>); method @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public void provisionSatelliteService(@NonNull String, @NonNull byte[], @Nullable android.os.CancellationSignal, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>); method @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public int registerForNtnSignalStrengthChanged(@NonNull java.util.concurrent.Executor, @NonNull android.telephony.satellite.NtnSignalStrengthCallback); + method @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public int registerForSatelliteCapabilitiesChanged(@NonNull java.util.concurrent.Executor, @NonNull android.telephony.satellite.SatelliteCapabilitiesCallback); method @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public int registerForSatelliteDatagram(@NonNull java.util.concurrent.Executor, @NonNull android.telephony.satellite.SatelliteDatagramCallback); method @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public int registerForSatelliteModemStateChanged(@NonNull java.util.concurrent.Executor, @NonNull android.telephony.satellite.SatelliteStateCallback); method @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public int registerForSatelliteProvisionStateChanged(@NonNull java.util.concurrent.Executor, @NonNull android.telephony.satellite.SatelliteProvisionStateCallback); @@ -16872,6 +16877,7 @@ package android.telephony.satellite { method @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public void startSatelliteTransmissionUpdates(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>, @NonNull android.telephony.satellite.SatelliteTransmissionUpdateCallback); method @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public void stopSatelliteTransmissionUpdates(@NonNull android.telephony.satellite.SatelliteTransmissionUpdateCallback, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>); method @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public void unregisterForNtnSignalStrengthChanged(@NonNull android.telephony.satellite.NtnSignalStrengthCallback); + method @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public void unregisterForSatelliteCapabilitiesChanged(@NonNull android.telephony.satellite.SatelliteCapabilitiesCallback); method @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public void unregisterForSatelliteDatagram(@NonNull android.telephony.satellite.SatelliteDatagramCallback); method @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public void unregisterForSatelliteModemStateChanged(@NonNull android.telephony.satellite.SatelliteStateCallback); method @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public void unregisterForSatelliteProvisionStateChanged(@NonNull android.telephony.satellite.SatelliteProvisionStateCallback); diff --git a/telephony/java/android/telephony/satellite/ISatelliteCapabilitiesCallback.aidl b/telephony/java/android/telephony/satellite/ISatelliteCapabilitiesCallback.aidl new file mode 100644 index 000000000000..4c37a6dc3832 --- /dev/null +++ b/telephony/java/android/telephony/satellite/ISatelliteCapabilitiesCallback.aidl @@ -0,0 +1,33 @@ +/* + * 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 android.telephony.satellite; + +import android.telephony.satellite.SatelliteCapabilities; + +/** + * Interface for satellite capabilities change callback. + * @hide + */ +oneway interface ISatelliteCapabilitiesCallback { + /** + * Called when satellite capability has changed. + * + * @param capabilities The new satellite capability. + */ + void onSatelliteCapabilitiesChanged(in SatelliteCapabilities capabilities); +} + diff --git a/telephony/java/android/telephony/satellite/SatelliteCapabilitiesCallback.java b/telephony/java/android/telephony/satellite/SatelliteCapabilitiesCallback.java new file mode 100644 index 000000000000..b68dd5a150ff --- /dev/null +++ b/telephony/java/android/telephony/satellite/SatelliteCapabilitiesCallback.java @@ -0,0 +1,39 @@ +/* + * 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 android.annotation.NonNull; +import android.annotation.SystemApi; + +import com.android.internal.telephony.flags.Flags; + +/** + * A callback class for satellite capabilities change events. + * + * @hide + */ +@SystemApi +@FlaggedApi(Flags.FLAG_OEM_ENABLED_SATELLITE_FLAG) +public interface SatelliteCapabilitiesCallback { + /** + * Called when satellite capability has changed. + * @param capabilities The new satellite capabilities. + */ + @FlaggedApi(Flags.FLAG_OEM_ENABLED_SATELLITE_FLAG) + void onSatelliteCapabilitiesChanged(@NonNull SatelliteCapabilities capabilities); +} diff --git a/telephony/java/android/telephony/satellite/SatelliteManager.java b/telephony/java/android/telephony/satellite/SatelliteManager.java index f18cbeafe752..71786b308937 100644 --- a/telephony/java/android/telephony/satellite/SatelliteManager.java +++ b/telephony/java/android/telephony/satellite/SatelliteManager.java @@ -81,6 +81,9 @@ public final class SatelliteManager { new ConcurrentHashMap<>(); private static final ConcurrentHashMap<NtnSignalStrengthCallback, INtnSignalStrengthCallback> sNtnSignalStrengthCallbackMap = new ConcurrentHashMap<>(); + private static final ConcurrentHashMap<SatelliteCapabilitiesCallback, + ISatelliteCapabilitiesCallback> + sSatelliteCapabilitiesCallbackMap = new ConcurrentHashMap<>(); private final int mSubId; @@ -2018,7 +2021,7 @@ public final class SatelliteManager { * {@link TelephonyManager#unregisterTelephonyCallback(TelephonyCallback)}.. * </p> * - * @param callback The callback that was passed to + * @param callback The callback that was passed to. * {@link #registerForNtnSignalStrengthChanged(Executor, NtnSignalStrengthCallback)}. * * @throws SecurityException if the caller doesn't have required permission. @@ -2046,9 +2049,84 @@ public final class SatelliteManager { loge("unregisterForNtnSignalStrengthChanged() RemoteException: " + ex); ex.rethrowFromSystemServer(); } + } + /** + * Registers for satellite capabilities change event from the satellite service. + * + * @param executor The executor on which the callback will be called. + * @param callback The callback to handle the satellite capabilities changed event. + * + * @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) + @FlaggedApi(Flags.FLAG_OEM_ENABLED_SATELLITE_FLAG) + @SatelliteResult public int registerForSatelliteCapabilitiesChanged( + @NonNull @CallbackExecutor Executor executor, + @NonNull SatelliteCapabilitiesCallback callback) { + Objects.requireNonNull(executor); + Objects.requireNonNull(callback); + + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + ISatelliteCapabilitiesCallback internalCallback = + new ISatelliteCapabilitiesCallback.Stub() { + @Override + public void onSatelliteCapabilitiesChanged( + SatelliteCapabilities capabilities) { + executor.execute(() -> Binder.withCleanCallingIdentity( + () -> callback.onSatelliteCapabilitiesChanged( + capabilities))); + } + }; + sSatelliteCapabilitiesCallbackMap.put(callback, internalCallback); + return telephony.registerForSatelliteCapabilitiesChanged(mSubId, internalCallback); + } else { + throw new IllegalStateException("Telephony service is null."); + } + } catch (RemoteException ex) { + loge("registerForSatelliteCapabilitiesChanged() RemoteException: " + ex); + ex.rethrowFromSystemServer(); + } + return SATELLITE_RESULT_REQUEST_FAILED; } + /** + * Unregisters for satellite capabilities change event from the satellite service. + * If callback was not registered before, the request will be ignored. + * + * @param callback The callback that was passed to. + * {@link #registerForSatelliteCapabilitiesChanged(Executor, SatelliteCapabilitiesCallback)}. + * + * @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) + @FlaggedApi(Flags.FLAG_OEM_ENABLED_SATELLITE_FLAG) + public void unregisterForSatelliteCapabilitiesChanged( + @NonNull SatelliteCapabilitiesCallback callback) { + Objects.requireNonNull(callback); + ISatelliteCapabilitiesCallback internalCallback = + sSatelliteCapabilitiesCallbackMap.remove(callback); + + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + if (internalCallback != null) { + telephony.unregisterForSatelliteCapabilitiesChanged(mSubId, internalCallback); + } else { + loge("unregisterForSatelliteCapabilitiesChanged: No internal callback."); + } + } else { + throw new IllegalStateException("Telephony service is null."); + } + } catch (RemoteException ex) { + loge("unregisterForSatelliteCapabilitiesChanged() RemoteException: " + ex); + ex.rethrowFromSystemServer(); + } + } private static ITelephony getITelephony() { ITelephony binder = ITelephony.Stub.asInterface(TelephonyFrameworkInitializer diff --git a/telephony/java/android/telephony/satellite/stub/ISatelliteListener.aidl b/telephony/java/android/telephony/satellite/stub/ISatelliteListener.aidl index d44ddfa1ee7f..ccca5adba367 100644 --- a/telephony/java/android/telephony/satellite/stub/ISatelliteListener.aidl +++ b/telephony/java/android/telephony/satellite/stub/ISatelliteListener.aidl @@ -19,6 +19,7 @@ package android.telephony.satellite.stub; import android.telephony.satellite.stub.NtnSignalStrength; import android.telephony.satellite.stub.NTRadioTechnology; import android.telephony.satellite.stub.PointingInfo; +import android.telephony.satellite.stub.SatelliteCapabilities; import android.telephony.satellite.stub.SatelliteDatagram; import android.telephony.satellite.stub.SatelliteModemState; @@ -62,7 +63,15 @@ oneway interface ISatelliteListener { /** * Called when NTN signal strength changes. + * * @param ntnSignalStrength The new NTN signal strength. */ void onNtnSignalStrengthChanged(in NtnSignalStrength ntnSignalStrength); + + /** + * Called when satellite capabilities of the satellite service have changed. + * + * @param SatelliteCapabilities The current satellite capabilities. + */ + void onSatelliteCapabilitiesChanged(in SatelliteCapabilities capabilities); } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index c212e3575276..15a20cb91d04 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -68,6 +68,7 @@ import android.telephony.ims.aidl.IImsRegistration; import android.telephony.ims.aidl.IImsRegistrationCallback; import android.telephony.ims.aidl.IRcsConfigCallback; import android.telephony.satellite.INtnSignalStrengthCallback; +import android.telephony.satellite.ISatelliteCapabilitiesCallback; import android.telephony.satellite.ISatelliteDatagramCallback; import android.telephony.satellite.ISatelliteTransmissionUpdateCallback; import android.telephony.satellite.ISatelliteProvisionStateCallback; @@ -3123,4 +3124,27 @@ interface ITelephony { + "android.Manifest.permission.SATELLITE_COMMUNICATION)") void unregisterForNtnSignalStrengthChanged(int subId, in INtnSignalStrengthCallback callback); + + /** + * Registers for satellite capabilities change event from the satellite service. + * + * @param executor The executor on which the callback will be called. + * @param callback The callback to handle the satellite capabilities changed event. + */ + @JavaPassthrough(annotation="@android.annotation.RequiresPermission(" + + "android.Manifest.permission.SATELLITE_COMMUNICATION)") + int registerForSatelliteCapabilitiesChanged(int subId, + in ISatelliteCapabilitiesCallback callback); + + /** + * Unregisters for satellite capabilities change event from the satellite service. + * If callback was not registered before, the request will be ignored. + * + * @param callback The callback that was passed to. + * {@link #registerForSatelliteCapabilitiesChanged(Executor, SatelliteCapabilitiesCallback)}. + */ + @JavaPassthrough(annotation="@android.annotation.RequiresPermission(" + + "android.Manifest.permission.SATELLITE_COMMUNICATION)") + void unregisterForSatelliteCapabilitiesChanged(int subId, + in ISatelliteCapabilitiesCallback callback); } |