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

Commit 58101399 authored by Thomas Nguyen's avatar Thomas Nguyen Committed by Android (Google) Code Review
Browse files

Merge "Add deprovisionSatelliteService API"

parents ce1a4bdc ec1f1786
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ import android.telephony.satellite.PointingInfo;
 * @hide
 */
oneway interface ISatelliteStateListener {
    void onSatelliteProvisionStateChanged(in int[] features, in boolean provisioned);
    void onSatelliteProvisionStateChanged(in boolean provisioned);
    void onSatellitePositionUpdate(in PointingInfo pointingInfo);
    void onMessageTransferStateUpdate(in int state);
}
+3 −7
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package android.telephony.satellite;

import android.annotation.NonNull;
import android.os.Binder;
import android.telephony.satellite.stub.SatelliteImplBase;

import java.lang.ref.WeakReference;
import java.util.concurrent.Executor;
@@ -63,12 +62,10 @@ public class SatelliteCallback {
        /**
         * Called when satellite provision state changes.
         *
         * @param features The list of provisioned features.
         * @param provisioned The new provision state. {@code true} means satellite is provisioned
         *                    {@code false} means satellite is not provisioned.
         */
        void onSatelliteProvisionStateChanged(
                @SatelliteImplBase.Feature int[] features, boolean provisioned);
        void onSatelliteProvisionStateChanged(boolean provisioned);
    }

    /**
@@ -100,14 +97,13 @@ public class SatelliteCallback {
            mExecutor = executor;
        }

        public void onSatelliteProvisionStateChanged(
                @SatelliteImplBase.Feature int[] features, boolean provisioned) {
        public void onSatelliteProvisionStateChanged(boolean provisioned) {
            SatelliteProvisionStateListener listener =
                    (SatelliteProvisionStateListener) mSatelliteCallbackWeakRef.get();
            if (listener == null) return;

            Binder.withCleanCallingIdentity(() -> mExecutor.execute(
                    () -> listener.onSatelliteProvisionStateChanged(features, provisioned)));
                    () -> listener.onSatelliteProvisionStateChanged(provisioned)));
        }

        public void onSatellitePositionUpdate(@NonNull PointingInfo pointingInfo) {
+44 −1
Original line number Diff line number Diff line
@@ -638,7 +638,8 @@ public class SatelliteManager {
     * Provision the device with a satellite provider.
     * This is needed if the provider allows dynamic registration.
     *
     * @param token The security token of the device/subscription to be provisioned.
     * @param token The token to be used as a unique identifier for provisioning with satellite
     *              gateway.
     * @param cancellationSignal The optional signal used by the caller to cancel the provision
     *                           request. Even when the cancellation is signaled, Telephony will
     *                           still trigger the callback to return the result of this request.
@@ -681,6 +682,48 @@ public class SatelliteManager {
        }
    }

    /**
     * Deprovision the device with the satellite provider.
     * This is needed if the provider allows dynamic registration. Once deprovisioned,
     * {@link SatelliteCallback.SatelliteProvisionStateListener#onSatelliteProvisionStateChanged}
     * should report as deprovisioned.
     * For provisioning satellite service, refer to
     * {@link #provisionSatelliteService(String, CancellationSignal, Executor, Consumer)}.
     *
     * @param token The token of the device/subscription to be deprovisioned.
     * @param errorCodeListener Listener for the {@link SatelliteError} result of the operation.
     *
     * @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)
    public void deprovisionSatelliteService(@NonNull String token,
            @NonNull @CallbackExecutor Executor executor,
            @SatelliteError @NonNull Consumer<Integer> errorCodeListener) {
        Objects.requireNonNull(token);
        Objects.requireNonNull(executor);
        Objects.requireNonNull(errorCodeListener);

        try {
            ITelephony telephony = getITelephony();
            if (telephony != null) {
                IIntegerConsumer errorCallback = new IIntegerConsumer.Stub() {
                    @Override
                    public void accept(int result) {
                        executor.execute(() -> Binder.withCleanCallingIdentity(
                                () -> errorCodeListener.accept(result)));
                    }
                };
                telephony.deprovisionSatelliteService(mSubId, token, errorCallback);
            } else {
                throw new IllegalStateException("telephony service is null.");
            }
        } catch (RemoteException ex) {
            loge("deprovisionSatelliteService RemoteException=" + ex);
            ex.rethrowFromSystemServer();
        }
    }

    /**
     * Register for the satellite provision state change.
     *
+18 −1
Original line number Diff line number Diff line
@@ -2783,7 +2783,8 @@ interface ITelephony {
     * This is needed to register the subscription if the provider allows dynamic registration.
     *
     * @param subId The subId of the subscription to be provisioned.
     * @param token The security token of the device/subscription to be provisioned.
     * @param token The token to be used as a unique identifier for provisioning with satellite
     *              gateway.
     * @param callback The callback to get the error code of the request.
     *
     * @return The signal transport used by callers to cancel the provision request.
@@ -2793,6 +2794,22 @@ interface ITelephony {
    ICancellationSignal provisionSatelliteService(int subId, in String token,
            in IIntegerConsumer callback);

    /**
     * Unregister the subscription with the satellite provider.
     * This is needed to unregister the subscription if the provider allows dynamic registration.
     * Once deprovisioned,
     * {@link SatelliteCallback.SatelliteProvisionStateListener#onSatelliteProvisionStateChanged}
     * should report as deprovisioned.
     *
     * @param subId The subId of the subscription to be deprovisioned.
     * @param token The token of the device/subscription to be deprovisioned.
     * @param callback The callback to get the error code of the request.
     */
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission("
            + "android.Manifest.permission.SATELLITE_COMMUNICATION)")
    void deprovisionSatelliteService(int subId, in String token, in IIntegerConsumer callback);


    /**
     * Register for the satellite provision state change.
     *