Add callback into vendor interface to receive modem state change event
Added a callback into vendor interface to receive the satellite supported state changed event.
Bug: 327652782
Test: SatelliteControllerTest, cts/SatelliteManagerTest, cts/SatelliteManagerTestOnMockService
manual basic call/sms/mms test includes regression test cases
manual end to end test to check reporting works as intended, register/unregister works well, whether there is any regression while reporting / registering / unregistering with the latest test application.
For the latest test application, please refer to ag/26742085
Change-Id: I5aae485ed824c3eb8c6142c9350a88f95449e066
diff --git a/telephony/java/android/telephony/satellite/ISatelliteSupportedStateCallback.aidl b/telephony/java/android/telephony/satellite/ISatelliteSupportedStateCallback.aidl
new file mode 100644
index 0000000..0455090
--- /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 4a61114..20b24b9 100644
--- a/telephony/java/android/telephony/satellite/SatelliteManager.java
+++ b/telephony/java/android/telephony/satellite/SatelliteManager.java
@@ -87,6 +87,9 @@
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 @@
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 0000000..7e19bd1
--- /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 ccca5ad..5b9dfc6 100644
--- a/telephony/java/android/telephony/satellite/stub/ISatelliteListener.aidl
+++ b/telephony/java/android/telephony/satellite/stub/ISatelliteListener.aidl
@@ -74,4 +74,11 @@
* @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 ff2ee27..f25fc36 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.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 @@
@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);
}