Merge "Implement the Telephony API to remove the UCE requests cannot be sent status" am: 06d4fa3d55 am: 64a1f2cd4c am: 6e8e8f6873
Original change: https://android-review.googlesource.com/c/platform/packages/services/Telephony/+/1688293
Change-Id: I1e5402a66a7c509e022bcd9f08bcd704681f5633
diff --git a/src/com/android/phone/ImsRcsController.java b/src/com/android/phone/ImsRcsController.java
index 31059e7..bcc312c 100644
--- a/src/com/android/phone/ImsRcsController.java
+++ b/src/com/android/phone/ImsRcsController.java
@@ -407,6 +407,20 @@
return pidfXml == null ? "none" : pidfXml;
}
+ /**
+ * Remove UCE requests cannot be sent to the network status.
+ * @return true if this command is successful.
+ */
+ // Used for SHELL command only right now.
+ public boolean removeUceRequestDisallowedStatus(int subId) throws ImsException {
+ UceControllerManager uceCtrlManager = getRcsFeatureController(subId).getFeature(
+ UceControllerManager.class);
+ if (uceCtrlManager == null) {
+ return false;
+ }
+ return uceCtrlManager.removeUceRequestDisallowedStatus();
+ }
+
@Override
public void registerUcePublishStateCallback(int subId, IRcsUcePublishStateCallback c) {
enforceReadPrivilegedPermission("registerUcePublishStateCallback");
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index e371354..65b8e1f 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -10475,6 +10475,23 @@
}
}
+ /**
+ * Remove UCE requests cannot be sent to the network status.
+ */
+ // Used for SHELL command only right now.
+ @Override
+ public boolean removeUceRequestDisallowedStatus(int subId) {
+ TelephonyPermissions.enforceShellOnly(Binder.getCallingUid(), "uceRemoveDisallowedStatus");
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ return mApp.imsRcsController.removeUceRequestDisallowedStatus(subId);
+ } catch (ImsException e) {
+ throw new ServiceSpecificException(e.getCode(), e.getMessage());
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
@Override
public void setSignalStrengthUpdateRequest(int subId, SignalStrengthUpdateRequest request,
diff --git a/src/com/android/phone/TelephonyShellCommand.java b/src/com/android/phone/TelephonyShellCommand.java
index 3042aa3..f7fa959 100644
--- a/src/com/android/phone/TelephonyShellCommand.java
+++ b/src/com/android/phone/TelephonyShellCommand.java
@@ -144,6 +144,8 @@
private static final String UCE_SET_DEVICE_ENABLED = "set-device-enabled";
private static final String UCE_OVERRIDE_PUBLISH_CAPS = "override-published-caps";
private static final String UCE_GET_LAST_PIDF_XML = "get-last-publish-pidf";
+ private static final String UCE_REMOVE_REQUEST_DISALLOWED_STATUS =
+ "remove-request-disallowed-status";
// Check if a package has carrier privileges on any SIM, regardless of subId/phoneId.
private static final String HAS_CARRIER_PRIVILEGES_COMMAND = "has-carrier-privileges";
@@ -455,6 +457,8 @@
pw.println(" uce get-last-publish-pidf [-s SLOT_ID]");
pw.println(" Get the PIDF XML included in the last SIP PUBLISH, or \"none\" if no ");
pw.println(" PUBLISH is active");
+ pw.println(" uce remove-request-disallowed-status [-s SLOT_ID]");
+ pw.println(" Remove the UCE is disallowed to execute UCE requests status");
}
private void onHelpNumberVerification() {
@@ -2023,6 +2027,8 @@
return handleUceOverridePublishCaps();
case UCE_GET_LAST_PIDF_XML:
return handleUceGetPidfXml();
+ case UCE_REMOVE_REQUEST_DISALLOWED_STATUS:
+ return handleUceRemoveRequestDisallowedStatus();
}
return -1;
}
@@ -2109,6 +2115,26 @@
return 0;
}
+ private int handleUceRemoveRequestDisallowedStatus() {
+ int subId = getSubId("uce remove-request-disallowed-status");
+ if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ Log.w(LOG_TAG, "uce remove-request-disallowed-status, Invalid subscription ID");
+ return -1;
+ }
+ boolean result;
+ try {
+ result = mInterface.removeUceRequestDisallowedStatus(subId);
+ } catch (RemoteException e) {
+ Log.w(LOG_TAG, "uce remove-request-disallowed-status, error " + e.getMessage());
+ return -1;
+ }
+ if (VDBG) {
+ Log.v(LOG_TAG, "uce remove-request-disallowed-status, returned: " + result);
+ }
+ getOutPrintWriter().println(result);
+ return 0;
+ }
+
private int handleSrcSetTestEnabledCommand() {
String enabledStr = getNextArg();
if (enabledStr == null) {
diff --git a/src/com/android/services/telephony/rcs/UceControllerManager.java b/src/com/android/services/telephony/rcs/UceControllerManager.java
index d62fb5e..fc0087d 100644
--- a/src/com/android/services/telephony/rcs/UceControllerManager.java
+++ b/src/com/android/services/telephony/rcs/UceControllerManager.java
@@ -70,12 +70,13 @@
* Constructor to inject dependencies for testing.
*/
@VisibleForTesting
- public UceControllerManager(Context context, int slotId, int subId, ExecutorService executor) {
+ public UceControllerManager(Context context, int slotId, int subId, ExecutorService executor,
+ UceController uceController) {
mSlotId = slotId;
mSubId = subId;
mContext = context;
mExecutorService = executor;
- mUceController = new UceController(mContext, subId);
+ mUceController = uceController;
}
@Override
@@ -140,11 +141,6 @@
});
}
- @VisibleForTesting
- public void setUceController(UceController uceController) {
- mUceController = uceController;
- }
-
/**
* Request the capabilities for contacts.
*
@@ -328,6 +324,32 @@
}
/**
+ * Remove UCE requests cannot be sent to the network status.
+ * @return true if this command is successful.
+ */
+ public boolean removeUceRequestDisallowedStatus() throws ImsException {
+ Future<Boolean> future = mExecutorService.submit(() -> {
+ if (mUceController == null) {
+ throw new ImsException("UCE controller is null",
+ ImsException.CODE_ERROR_SERVICE_UNAVAILABLE);
+ }
+ mUceController.removeRequestDisallowedStatus();
+ return true;
+ });
+
+ try {
+ return future.get();
+ } catch (ExecutionException | InterruptedException e) {
+ Log.w(LOG_TAG, "removeUceRequestDisallowedStatus exception: " + e);
+ Throwable cause = e.getCause();
+ if (cause instanceof ImsException) {
+ throw (ImsException) cause;
+ }
+ return false;
+ }
+ }
+
+ /**
* Register the Publish state changed callback.
*
* @throws ImsException if the ImsService connected to this controller is currently down.
diff --git a/tests/src/com/android/services/telephony/rcs/UceControllerManagerTest.java b/tests/src/com/android/services/telephony/rcs/UceControllerManagerTest.java
index 82687f8..75ddb96 100644
--- a/tests/src/com/android/services/telephony/rcs/UceControllerManagerTest.java
+++ b/tests/src/com/android/services/telephony/rcs/UceControllerManagerTest.java
@@ -243,8 +243,7 @@
private UceControllerManager getUceControllerManager() {
UceControllerManager manager = new UceControllerManager(mContext, mSlotId, mSubId,
- mExecutorService);
- manager.setUceController(mUceController);
+ mExecutorService, mUceController);
return manager;
}
}