Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 23b1bd5e authored by Hyosun Kim's avatar Hyosun Kim
Browse files

Add deprovisionSatellite api

Bug: 368435815
Test: atest SatelliteControllerTest
Test: atest SatelliteManagerTestOnMockService
Test: manual test with test apk b/368435815#comment2
Flag: com.android.internal.telephony.flags.carrier_roaming_nb_iot_ntn

Change-Id: I1dbb5cfacfa7e5f162da1c544ced79f63e45aa51
parent c59b0fe5
Loading
Loading
Loading
Loading
+62 −0
Original line number Diff line number Diff line
@@ -248,6 +248,13 @@ public final class SatelliteManager {
     */
    public static final String KEY_PROVISION_SATELLITE_TOKENS = "provision_satellite";

    /**
     * Bundle key to get the response from
     * {@link #deprovisionSatellite(List, Executor, OutcomeReceiver)}.
     * @hide
     */
    public static final String KEY_DEPROVISION_SATELLITE_TOKENS = "deprovision_satellite";

    /**
     * The request was successfully processed.
     */
@@ -2791,6 +2798,61 @@ public final class SatelliteManager {
        }
    }

    /**
     * Deliver the list of deprovisioned satellite subscriber infos.
     *
     * @param list The list of deprovisioned satellite subscriber infos.
     * @param executor The executor on which the callback will be called.
     * @param callback The callback object to which the result will be delivered.
     *
     * @throws SecurityException if the caller doesn't have required permission.
     * @hide
     */
    @RequiresPermission(Manifest.permission.SATELLITE_COMMUNICATION)
    @FlaggedApi(Flags.FLAG_CARRIER_ROAMING_NB_IOT_NTN)
    public void deprovisionSatellite(@NonNull List<SatelliteSubscriberInfo> list,
            @NonNull @CallbackExecutor Executor executor,
            @NonNull OutcomeReceiver<Boolean, SatelliteException> callback) {
        Objects.requireNonNull(executor);
        Objects.requireNonNull(callback);

        try {
            ITelephony telephony = getITelephony();
            if (telephony != null) {
                ResultReceiver receiver = new ResultReceiver(null) {
                    @Override
                    protected void onReceiveResult(int resultCode, Bundle resultData) {
                        if (resultCode == SATELLITE_RESULT_SUCCESS) {
                            if (resultData.containsKey(KEY_DEPROVISION_SATELLITE_TOKENS)) {
                                boolean isUpdated =
                                        resultData.getBoolean(KEY_DEPROVISION_SATELLITE_TOKENS);
                                executor.execute(() -> Binder.withCleanCallingIdentity(() ->
                                        callback.onResult(isUpdated)));
                            } else {
                                loge("KEY_DEPROVISION_SATELLITE_TOKENS does not exist.");
                                executor.execute(() -> Binder.withCleanCallingIdentity(() ->
                                        callback.onError(new SatelliteException(
                                                SATELLITE_RESULT_REQUEST_FAILED))));
                            }
                        } else {
                            executor.execute(() -> Binder.withCleanCallingIdentity(() ->
                                    callback.onError(new SatelliteException(resultCode))));
                        }
                    }
                };
                telephony.deprovisionSatellite(list, receiver);
            } else {
                loge("deprovisionSatellite() invalid telephony");
                executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError(
                        new SatelliteException(SATELLITE_RESULT_ILLEGAL_STATE))));
            }
        } catch (RemoteException ex) {
            loge("deprovisionSatellite() RemoteException: " + ex);
            executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError(
                    new SatelliteException(SATELLITE_RESULT_ILLEGAL_STATE))));
        }
    }

    @Nullable
    private static ITelephony getITelephony() {
        ITelephony binder = ITelephony.Stub.asInterface(TelephonyFrameworkInitializer
+11 −0
Original line number Diff line number Diff line
@@ -3444,4 +3444,15 @@ interface ITelephony {
     */
    boolean overrideCarrierRoamingNtnEligibilityChanged(
            in boolean status, in boolean resetRequired);

    /**
     * Deliver the list of deprovisioned satellite subscriber infos.
     *
     * @param list The list of deprovisioned satellite subscriber infos.
     * @param result The result receiver that returns whether deliver success or fail.
     * @hide
     */
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission("
            + "android.Manifest.permission.SATELLITE_COMMUNICATION)")
    void deprovisionSatellite(in List<SatelliteSubscriberInfo> list, in ResultReceiver result);
}