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

Commit a5a865f1 authored by Hakjun Choi's avatar Hakjun Choi Committed by Automerger Merge Worker
Browse files

Merge "Remove requestIsSatelliteCommunicationAllowedForCurrentLocation from...

Merge "Remove requestIsSatelliteCommunicationAllowedForCurrentLocation from vendor implementation" into 24D1-dev am: da4964f5

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/26619385



Change-Id: Ibf2732be36fac772135ec2f4ce704e656a9be614
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 407142cd da4964f5
Loading
Loading
Loading
Loading
+0 −55
Original line number Diff line number Diff line
@@ -175,8 +175,6 @@ public class SatelliteController extends Handler {
    private static final int EVENT_IS_SATELLITE_SUPPORTED_DONE = 16;
    private static final int CMD_GET_SATELLITE_CAPABILITIES = 17;
    private static final int EVENT_GET_SATELLITE_CAPABILITIES_DONE = 18;
    private static final int CMD_IS_SATELLITE_COMMUNICATION_ALLOWED = 19;
    private static final int EVENT_IS_SATELLITE_COMMUNICATION_ALLOWED_DONE = 20;
    private static final int CMD_GET_TIME_SATELLITE_NEXT_VISIBLE = 21;
    private static final int EVENT_GET_TIME_SATELLITE_NEXT_VISIBLE_DONE = 22;
    private static final int EVENT_RADIO_STATE_CHANGED = 23;
@@ -1073,39 +1071,6 @@ public class SatelliteController extends Handler {
                break;
            }

            case CMD_IS_SATELLITE_COMMUNICATION_ALLOWED: {
                request = (SatelliteControllerHandlerRequest) msg.obj;
                onCompleted =
                        obtainMessage(EVENT_IS_SATELLITE_COMMUNICATION_ALLOWED_DONE, request);
                mSatelliteModemInterface
                        .requestIsSatelliteCommunicationAllowedForCurrentLocation(onCompleted);
                break;
            }

            case EVENT_IS_SATELLITE_COMMUNICATION_ALLOWED_DONE: {
                ar = (AsyncResult) msg.obj;
                request = (SatelliteControllerHandlerRequest) ar.userObj;
                int error =  SatelliteServiceUtils.getSatelliteError(ar,
                        "isSatelliteCommunicationAllowedForCurrentLocation");
                Bundle bundle = new Bundle();
                if (error == SATELLITE_RESULT_SUCCESS) {
                    if (ar.result == null) {
                        loge("isSatelliteCommunicationAllowedForCurrentLocation: result is null");
                        error = SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE;
                    } else {
                        boolean communicationAllowed = (boolean) ar.result;
                        if (DBG) {
                            logd("isSatelliteCommunicationAllowedForCurrentLocation: "
                                    + communicationAllowed);
                        }
                        bundle.putBoolean(SatelliteManager.KEY_SATELLITE_COMMUNICATION_ALLOWED,
                                communicationAllowed);
                    }
                }
                ((ResultReceiver) request.argument).send(error, bundle);
                break;
            }

            case CMD_GET_TIME_SATELLITE_NEXT_VISIBLE: {
                request = (SatelliteControllerHandlerRequest) msg.obj;
                onCompleted = obtainMessage(EVENT_GET_TIME_SATELLITE_NEXT_VISIBLE_DONE,
@@ -1954,26 +1919,6 @@ public class SatelliteController extends Handler {
                needFullScreenPointingUI, result);
    }

    /**
     * Request to get whether satellite communication is allowed for the current location.
     *
     * @param subId The subId of the subscription to check whether satellite communication is
     *              allowed for the current location for.
     * @param result The result receiver that returns whether satellite communication is allowed
     *               for the current location if the request is successful or an error code
     *               if the request failed.
     */
    public void requestIsSatelliteCommunicationAllowedForCurrentLocation(int subId,
            @NonNull ResultReceiver result) {
        int error = evaluateOemSatelliteRequestAllowed(false);
        if (error != SATELLITE_RESULT_SUCCESS) {
            result.send(error, null);
            return;
        }

        sendRequestAsync(CMD_IS_SATELLITE_COMMUNICATION_ALLOWED, result, null);
    }

    /**
     * Request to get the time after which the satellite will be visible.
     *
+0 −42
Original line number Diff line number Diff line
@@ -1008,48 +1008,6 @@ public class SatelliteModemInterface {
        }
    }

    /**
     * Request to get whether satellite communication is allowed for the current location.
     *
     * @param message The Message to send to result of the operation to.
     */
    public void requestIsSatelliteCommunicationAllowedForCurrentLocation(@NonNull Message message) {
        if (mSatelliteService != null) {
            try {
                mSatelliteService.requestIsSatelliteCommunicationAllowedForCurrentLocation(
                        new IIntegerConsumer.Stub() {
                            @Override
                            public void accept(int result) {
                                int error = SatelliteServiceUtils.fromSatelliteError(result);
                                logd("requestIsCommunicationAllowedForCurrentLocation: "
                                        + error);
                                Binder.withCleanCallingIdentity(() ->
                                        sendMessageWithResult(message, null, error));
                            }
                        }, new IBooleanConsumer.Stub() {
                            @Override
                            public void accept(boolean result) {
                                logd("requestIsCommunicationAllowedForCurrentLocation: "
                                        + result);
                                Binder.withCleanCallingIdentity(() -> sendMessageWithResult(
                                        message, result,
                                        SatelliteManager.SATELLITE_RESULT_SUCCESS));
                            }
                        });
            } catch (RemoteException e) {
                loge("requestIsCommunicationAllowedForCurrentLocation: RemoteException "
                        + e);
                sendMessageWithResult(message, null,
                        SatelliteManager.SATELLITE_RESULT_SERVICE_ERROR);
            }
        } else {
            loge("requestIsCommunicationAllowedForCurrentLocation: "
                    + "Satellite service is unavailable.");
            sendMessageWithResult(message, null,
                    SatelliteManager.SATELLITE_RESULT_RADIO_NOT_AVAILABLE);
        }
    }

    /**
     * Request to get the time after which the satellite will be visible. This is an int
     * representing the duration in seconds after which the satellite will be visible.
+0 −96
Original line number Diff line number Diff line
@@ -556,58 +556,6 @@ public class SatelliteControllerTest extends TelephonyTest {
        super.tearDown();
    }

    @Test
    public void testRequestIsSatelliteCommunicationAllowedForCurrentLocation() {
        mSatelliteAllowedSemaphore.drainPermits();
        setUpResponseForRequestIsSatelliteSupported(false, SATELLITE_RESULT_SUCCESS);
        verifySatelliteSupported(false, SATELLITE_RESULT_SUCCESS);
        mSatelliteControllerUT.requestIsSatelliteCommunicationAllowedForCurrentLocation(SUB_ID,
                mSatelliteAllowedReceiver);
        processAllMessages();
        assertTrue(waitForRequestIsSatelliteAllowedForCurrentLocationResult(1));
        assertEquals(SATELLITE_RESULT_NOT_SUPPORTED, mQueriedSatelliteAllowedResultCode);

        resetSatelliteControllerUT();
        mSatelliteControllerUT.requestIsSatelliteCommunicationAllowedForCurrentLocation(SUB_ID,
                mSatelliteAllowedReceiver);
        processAllMessages();
        assertTrue(waitForRequestIsSatelliteAllowedForCurrentLocationResult(1));
        assertEquals(SATELLITE_RESULT_INVALID_TELEPHONY_STATE, mQueriedSatelliteAllowedResultCode);

        resetSatelliteControllerUT();
        setUpResponseForRequestIsSatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
        verifySatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
        setUpResponseForRequestIsSatelliteAllowedForCurrentLocation(true,
                SATELLITE_RESULT_SUCCESS);
        mSatelliteControllerUT.requestIsSatelliteCommunicationAllowedForCurrentLocation(SUB_ID,
                mSatelliteAllowedReceiver);
        processAllMessages();
        assertTrue(waitForRequestIsSatelliteAllowedForCurrentLocationResult(1));
        assertEquals(SATELLITE_RESULT_SUCCESS, mQueriedSatelliteAllowedResultCode);
        assertTrue(mQueriedSatelliteAllowed);

        resetSatelliteControllerUT();
        setUpResponseForRequestIsSatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
        verifySatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
        setUpNullResponseForRequestIsSatelliteAllowedForCurrentLocation(SATELLITE_RESULT_SUCCESS);
        mSatelliteControllerUT.requestIsSatelliteCommunicationAllowedForCurrentLocation(SUB_ID,
                mSatelliteAllowedReceiver);
        processAllMessages();
        assertTrue(waitForRequestIsSatelliteAllowedForCurrentLocationResult(1));
        assertEquals(SATELLITE_RESULT_INVALID_TELEPHONY_STATE, mQueriedSatelliteAllowedResultCode);

        resetSatelliteControllerUT();
        setUpResponseForRequestIsSatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
        verifySatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
        setUpNullResponseForRequestIsSatelliteAllowedForCurrentLocation(
                SATELLITE_RESULT_INVALID_MODEM_STATE);
        mSatelliteControllerUT.requestIsSatelliteCommunicationAllowedForCurrentLocation(SUB_ID,
                mSatelliteAllowedReceiver);
        processAllMessages();
        assertTrue(waitForRequestIsSatelliteAllowedForCurrentLocationResult(1));
        assertEquals(SATELLITE_RESULT_INVALID_MODEM_STATE, mQueriedSatelliteAllowedResultCode);
    }

    @Test
    public void testRequestTimeForNextSatelliteVisibility() {
        mSatelliteVisibilityTimeSemaphore.drainPermits();
@@ -3332,32 +3280,6 @@ public class SatelliteControllerTest extends TelephonyTest {
        }).when(mMockSatelliteModemInterface).requestIsSatelliteSupported(any(Message.class));
    }

    private void setUpResponseForRequestIsSatelliteAllowedForCurrentLocation(
            boolean isSatelliteAllowed, @SatelliteManager.SatelliteResult int error) {
        SatelliteException exception = (error == SATELLITE_RESULT_SUCCESS)
                ? null : new SatelliteException(error);
        doAnswer(invocation -> {
            Message message = (Message) invocation.getArguments()[0];
            AsyncResult.forMessage(message, isSatelliteAllowed, exception);
            message.sendToTarget();
            return null;
        }).when(mMockSatelliteModemInterface)
                .requestIsSatelliteCommunicationAllowedForCurrentLocation(any(Message.class));
    }

    private void setUpNullResponseForRequestIsSatelliteAllowedForCurrentLocation(
            @SatelliteManager.SatelliteResult int error) {
        SatelliteException exception = (error == SATELLITE_RESULT_SUCCESS)
                ? null : new SatelliteException(error);
        doAnswer(invocation -> {
            Message message = (Message) invocation.getArguments()[0];
            AsyncResult.forMessage(message, null, exception);
            message.sendToTarget();
            return null;
        }).when(mMockSatelliteModemInterface)
                .requestIsSatelliteCommunicationAllowedForCurrentLocation(any(Message.class));
    }

    private void setUpResponseForRequestTimeForNextSatelliteVisibility(
            int satelliteVisibilityTime, @SatelliteManager.SatelliteResult int error) {
        SatelliteException exception = (error == SATELLITE_RESULT_SUCCESS)
@@ -3581,24 +3503,6 @@ public class SatelliteControllerTest extends TelephonyTest {
        return true;
    }

    private boolean waitForRequestIsSatelliteAllowedForCurrentLocationResult(
            int expectedNumberOfEvents) {
        for (int i = 0; i < expectedNumberOfEvents; i++) {
            try {
                if (!mSatelliteAllowedSemaphore.tryAcquire(TIMEOUT, TimeUnit.MILLISECONDS)) {
                    loge("Timeout to receive "
                            + "requestIsCommunicationAllowedForCurrentLocation()"
                            + " callback");
                    return false;
                }
            } catch (Exception ex) {
                loge("waitForRequestIsSatelliteSupportedResult: Got exception=" + ex);
                return false;
            }
        }
        return true;
    }

    private boolean waitForRequestTimeForNextSatelliteVisibilityResult(
            int expectedNumberOfEvents) {
        for (int i = 0; i < expectedNumberOfEvents; i++) {