Merge "Support handle the shell command of removing capabilities from EAB"
diff --git a/src/com/android/phone/ImsRcsController.java b/src/com/android/phone/ImsRcsController.java
index 12c8cda..2c87f7c 100644
--- a/src/com/android/phone/ImsRcsController.java
+++ b/src/com/android/phone/ImsRcsController.java
@@ -263,10 +263,6 @@
public void requestCapabilities(int subId, String callingPackage, String callingFeatureId,
List<Uri> contactNumbers, IRcsUceControllerCallback c) {
enforceReadPrivilegedPermission("requestCapabilities");
- if (!isUceSettingEnabled(subId, callingPackage, callingFeatureId)) {
- throw new ServiceSpecificException(ImsException.CODE_ERROR_UNSUPPORTED_OPERATION,
- "The user has not enabled UCE for this subscription.");
- }
final long token = Binder.clearCallingIdentity();
try {
UceControllerManager uceCtrlManager = getRcsFeatureController(subId).getFeature(
@@ -284,13 +280,9 @@
}
@Override
- public void requestNetworkAvailability(int subId, String callingPackage,
+ public void requestAvailability(int subId, String callingPackage,
String callingFeatureId, Uri contactNumber, IRcsUceControllerCallback c) {
- enforceReadPrivilegedPermission("requestNetworkAvailability");
- if (!isUceSettingEnabled(subId, callingPackage, callingFeatureId)) {
- throw new ServiceSpecificException(ImsException.CODE_ERROR_UNSUPPORTED_OPERATION,
- "The user has not enabled UCE for this subscription.");
- }
+ enforceReadPrivilegedPermission("requestAvailability");
final long token = Binder.clearCallingIdentity();
try {
UceControllerManager uceCtrlManager = getRcsFeatureController(subId).getFeature(
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 73fbb4b..10b8bc8 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -130,6 +130,7 @@
import com.android.ims.ImsManager;
import com.android.ims.internal.IImsServiceFeatureCallback;
+import com.android.ims.rcs.uce.eab.EabUtil;
import com.android.internal.telephony.CallForwardInfo;
import com.android.internal.telephony.CallManager;
import com.android.internal.telephony.CallStateException;
@@ -9832,6 +9833,21 @@
}
}
+ /**
+ * Remove the EAB contacts from the EAB database.
+ */
+ @Override
+ public int removeContactFromEab(int subId, String contacts) {
+ TelephonyPermissions.enforceShellOnly(Binder.getCallingUid(), "removeCapabilitiesFromEab");
+ enforceModifyPermission();
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ return EabUtil.removeContactFromEab(subId, contacts, getDefaultPhone().getContext());
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
@Override
public void setSignalStrengthUpdateRequest(int subId, SignalStrengthUpdateRequest request,
String callingPackage) {
diff --git a/src/com/android/phone/TelephonyShellCommand.java b/src/com/android/phone/TelephonyShellCommand.java
index f5bfe10..9cfb804 100644
--- a/src/com/android/phone/TelephonyShellCommand.java
+++ b/src/com/android/phone/TelephonyShellCommand.java
@@ -31,6 +31,7 @@
import android.telephony.SubscriptionManager;
import android.telephony.emergency.EmergencyNumber;
import android.telephony.ims.feature.ImsFeature;
+import android.text.TextUtils;
import android.util.Log;
import com.android.internal.telephony.ITelephony;
@@ -102,6 +103,9 @@
private static final String D2D_SUBCOMMAND = "d2d";
private static final String D2D_SEND = "send";
+ private static final String RCS_UCE_COMMAND = "uce";
+ private static final String UCE_REMOVE_EAB_CONTACT = "remove-eab-contact";
+
// Take advantage of existing methods that already contain permissions checks when possible.
private final ITelephony mInterface;
@@ -171,6 +175,8 @@
case IMS_SUBCOMMAND: {
return handleImsCommand();
}
+ case RCS_UCE_COMMAND:
+ return handleRcsUceCommand();
case NUMBER_VERIFICATION_SUBCOMMAND:
return handleNumberVerificationCommand();
case EMERGENCY_NUMBER_TEST_MODE:
@@ -202,6 +208,8 @@
pw.println(" Print this help text.");
pw.println(" ims");
pw.println(" IMS Commands.");
+ pw.println(" uce");
+ pw.println(" RCS User Capability Exchange Commands.");
pw.println(" emergency-number-test-mode");
pw.println(" Emergency Number Test Mode Commands.");
pw.println(" end-block-suppression");
@@ -215,6 +223,7 @@
pw.println(" src");
pw.println(" RCS VoLTE Single Registration Config Commands.");
onHelpIms();
+ onHelpUce();
onHelpEmergencyNumber();
onHelpEndBlockSupperssion();
onHelpDataTestMode();
@@ -276,6 +285,17 @@
pw.println(" enables or disables handling or network conference event package data.");
}
+ private void onHelpUce() {
+ PrintWriter pw = getOutPrintWriter();
+ pw.println("User Capability Exchange Commands:");
+ pw.println(" uce remove-eab-contact [-s SLOT_ID] [PHONE_NUMBER]");
+ pw.println(" Remove the EAB contacts from the EAB database.");
+ pw.println(" Options are:");
+ pw.println(" -s: The SIM slot ID to read carrier config value for. If no option");
+ pw.println(" is specified, it will choose the default voice SIM slot.");
+ pw.println(" PHONE_NUMBER: The phone numbers to be removed from the EAB databases");
+ }
+
private void onHelpNumberVerification() {
PrintWriter pw = getOutPrintWriter();
pw.println("Number verification commands");
@@ -1562,6 +1582,45 @@
return -1;
}
+ private int handleRcsUceCommand() {
+ String arg = getNextArg();
+ if (arg == null) {
+ Log.w(LOG_TAG, "cannot get uce parameter");
+ return -1;
+ }
+
+ switch (arg) {
+ case UCE_REMOVE_EAB_CONTACT:
+ return handleRemovingEabContactCommand();
+ }
+ return -1;
+ }
+
+ private int handleRemovingEabContactCommand() {
+ int subId = getSubId("uce remove-eab-contact");
+ if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ return -1;
+ }
+
+ String phoneNumber = getNextArgRequired();
+ if (TextUtils.isEmpty(phoneNumber)) {
+ return -1;
+ }
+ int result = 0;
+ try {
+ result = mInterface.removeContactFromEab(subId, phoneNumber);
+ } catch (RemoteException e) {
+ Log.w(LOG_TAG, "uce remove-eab-contact -s " + subId + ", error " + e.getMessage());
+ getErrPrintWriter().println("Exception: " + e.getMessage());
+ return -1;
+ }
+
+ if (VDBG) {
+ Log.v(LOG_TAG, "uce remove-eab-contact -s " + subId + ", result: " + result);
+ }
+ return result;
+ }
+
private int handleSrcSetDeviceEnabledCommand() {
String enabledStr = getNextArg();
if (enabledStr == null) {