Merge "Remove requestIsSatelliteCommunicationAllowedForCurrentLocation from vendor implementation" into 24D1-dev am: da4964f5fe
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/26619385
Change-Id: Ibf2732be36fac772135ec2f4ce704e656a9be614
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteController.java b/src/java/com/android/internal/telephony/satellite/SatelliteController.java
index da7f30b..287f839 100644
--- a/src/java/com/android/internal/telephony/satellite/SatelliteController.java
+++ b/src/java/com/android/internal/telephony/satellite/SatelliteController.java
@@ -175,8 +175,6 @@
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 @@
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,
@@ -1955,26 +1920,6 @@
}
/**
- * 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.
*
* @param subId The subId to get the time after which the satellite will be visible for.
diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteModemInterface.java b/src/java/com/android/internal/telephony/satellite/SatelliteModemInterface.java
index 2f86eea..e51042f 100644
--- a/src/java/com/android/internal/telephony/satellite/SatelliteModemInterface.java
+++ b/src/java/com/android/internal/telephony/satellite/SatelliteModemInterface.java
@@ -1009,48 +1009,6 @@
}
/**
- * 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.
* This will return 0 if the satellite is currently visible.
diff --git a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java
index 22737b2..0f77e31 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java
@@ -557,58 +557,6 @@
}
@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();
setUpResponseForRequestIsSatelliteSupported(false, SATELLITE_RESULT_SUCCESS);
@@ -3332,32 +3280,6 @@
}).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 @@
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++) {