Snap for 12046004 from 26966957190f50fec6f3eea760a3f109702fe9de to mainline-permission-release Change-Id: I8cd24a6cac142ecbcff809c08c2088aa1146d988
diff --git a/satellite_client/src/android/telephony/satellite/wrapper/ProvisionSubscriberIdWrapper.java b/satellite_client/src/android/telephony/satellite/wrapper/ProvisionSubscriberIdWrapper.java new file mode 100644 index 0000000..760fc34 --- /dev/null +++ b/satellite_client/src/android/telephony/satellite/wrapper/ProvisionSubscriberIdWrapper.java
@@ -0,0 +1,68 @@ +/* + * Copyright (C) 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.wrapper; + +import android.annotation.NonNull; + +import java.util.Objects; + +public class ProvisionSubscriberIdWrapper { + @NonNull + private final String subscriberId; + private int carrierId; + + public ProvisionSubscriberIdWrapper(String subscriberId, int carrierId) { + this.subscriberId = subscriberId; + this.carrierId = carrierId; + } + + @NonNull + public String getSubscriberId() { + return subscriberId; + } + + public int getCarrierId() { + return carrierId; + } + + @Override + @NonNull + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("SubscriberId:"); + sb.append(subscriberId); + sb.append(","); + + sb.append("carrierId:"); + sb.append(carrierId); + return sb.toString(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ProvisionSubscriberIdWrapper that = (ProvisionSubscriberIdWrapper) o; + return Objects.equals(subscriberId, that.subscriberId) + && carrierId == that.carrierId; + } + + @Override + public int hashCode() { + return Objects.hash(subscriberId, carrierId); + } +}
diff --git a/satellite_client/src/android/telephony/satellite/wrapper/SatelliteManagerWrapper.java b/satellite_client/src/android/telephony/satellite/wrapper/SatelliteManagerWrapper.java index 59045f6..8bc9e6d 100644 --- a/satellite_client/src/android/telephony/satellite/wrapper/SatelliteManagerWrapper.java +++ b/satellite_client/src/android/telephony/satellite/wrapper/SatelliteManagerWrapper.java
@@ -49,6 +49,7 @@ import android.telephony.satellite.SatelliteProvisionStateCallback; import android.telephony.satellite.SatelliteSessionStats; import android.telephony.satellite.SatelliteSupportedStateCallback; +import android.telephony.satellite.ProvisionSubscriberId; import android.telephony.satellite.SatelliteTransmissionUpdateCallback; import com.android.internal.telephony.flags.Flags; @@ -61,6 +62,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executor; @@ -1368,6 +1370,119 @@ } } + /** + * Wrapper API to provide a way to check if the subscription is capable for non-terrestrial + * networks for the carrier. + * + * @param subId The unique SubscriptionInfo key in database. + * @return {@code true} if it is a non-terrestrial network capable subscription, + * {@code false} otherwise. + * Note: The method returns {@code false} if the parameter is invalid or any other error occurs. + */ + @FlaggedApi(Flags.FLAG_CARRIER_ROAMING_NB_IOT_NTN) + public boolean isSatelliteESOSSupportedSubscription(int subId) { + if (!mSubscriptionManager.isValidSubscriptionId(subId)) { + return false; + } + + List<SubscriptionInfo> subInfoList = mSubscriptionManager.getAvailableSubscriptionInfoList(); + for (SubscriptionInfo subInfo : subInfoList) { + if (subInfo.getSubscriptionId() == subId) { + logd("found matched subscription info"); + return subInfo.isSatelliteESOSSupported(); + } + } + logd("failed to found matched subscription info"); + return false; + } + + /** + * Request to get list of prioritized satellite subscriber ids to be used for provision. + * + * @param executor, The executor on which the callback will be called. + * @param callback, The callback object to which the result will be delivered. + * If successful, the callback returns a list of subscriberIds sorted in ascending priority + * order index 0 has the highest priority. Otherwise, it returns an error with a + * SatelliteException. + */ + @FlaggedApi(Flags.FLAG_CARRIER_ROAMING_NB_IOT_NTN) + public void requestProvisionSubscriberIds(@NonNull @CallbackExecutor Executor executor, + @NonNull OutcomeReceiver<List<ProvisionSubscriberIdWrapper>, + SatelliteExceptionWrapper> callback) { + Objects.requireNonNull(executor); + Objects.requireNonNull(callback); + + OutcomeReceiver internalCallback = + new OutcomeReceiver<List<ProvisionSubscriberId>, SatelliteException>() { + @Override + public void onResult(List<ProvisionSubscriberId> result) { + callback.onResult(result.stream().map(ids -> new ProvisionSubscriberIdWrapper( + ids.getSubscriberId(), ids.getCarrierId())).collect(Collectors.toList())); + } + + @Override + public void onError(SatelliteException exception) { + callback.onError(new SatelliteExceptionWrapper(exception.getErrorCode())); + } + }; + mSatelliteManager.requestProvisionSubscriberIds(executor, internalCallback); + } + + /** + * Request to get provisioned status for given a satellite subscriber id. + * + * @param satelliteSubscriberId Satellite subscriber id requiring provisioned status check. + * @param executor The executor on which the callback will be called. + * @param callback The callback object to which the result will be delivered. + */ + @FlaggedApi(Flags.FLAG_CARRIER_ROAMING_NB_IOT_NTN) + public void requestIsProvisioned(@NonNull String satelliteSubscriberId, + @NonNull @CallbackExecutor Executor executor, + @NonNull OutcomeReceiver<Boolean, SatelliteExceptionWrapper> callback) { + OutcomeReceiver internalCallback = + new OutcomeReceiver<Boolean, SatelliteException>() { + @Override + public void onResult(Boolean result) { + callback.onResult(result); + } + + @Override + public void onError(SatelliteException exception) { + callback.onError(new SatelliteExceptionWrapper(exception.getErrorCode())); + } + }; + mSatelliteManager.requestIsProvisioned(satelliteSubscriberId, executor, internalCallback); + } + + /** + * Deliver the list of provisioned satellite subscriber ids. + * + * @param list List of ProvisionSubscriberId. + * @param executor The executor on which the callback will be called. + * @param callback The callback object to which the result will be delivered. + */ + @FlaggedApi(Flags.FLAG_CARRIER_ROAMING_NB_IOT_NTN) + public void provisionSatellite(@NonNull List<ProvisionSubscriberIdWrapper> list, + @NonNull @CallbackExecutor Executor executor, + @NonNull OutcomeReceiver<Boolean, SatelliteExceptionWrapper> callback) { + OutcomeReceiver internalCallback = + new OutcomeReceiver<Boolean, SatelliteException>() { + @Override + public void onResult(Boolean result) { + callback.onResult(result); + } + + @Override + public void onError(SatelliteException exception) { + callback.onError(new SatelliteExceptionWrapper(exception.getErrorCode())); + } + }; + mSatelliteManager.provisionSatellite(list.stream() + .map(wrapper -> new ProvisionSubscriberId(wrapper.getSubscriberId(), + wrapper.getCarrierId())) + .collect(Collectors.toList()), executor, internalCallback); + } + @Nullable private ServiceState getServiceStateForSubscriptionId(int subId) { if (!mSubscriptionManager.isValidSubscriptionId(subId)) {