Implement RemoteVvmTaskService
RemoteVvmTaskService manages the connection to the
VisualVoicemailService in the default dialer, notifying it service
connected, incoming VVM SMS and SIM removed events. It will held
resources for the dialer until it is signaled all events has been
processed.
Test: CTS / CTS verifier test
Change-Id: I713ace11c526a5ed838b6a85932c2588649cc14e
Merged-in: I713ace11c526a5ed838b6a85932c2588649cc14e
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 38bfa50..d3f1776 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -18,8 +18,10 @@
import static com.android.internal.telephony.PhoneConstants.SUBSCRIPTION_KEY;
+import android.Manifest.permission;
import android.app.ActivityManager;
import android.app.AppOpsManager;
+import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -53,6 +55,7 @@
import android.telephony.NeighboringCellInfo;
import android.telephony.RadioAccessFamily;
import android.telephony.ServiceState;
+import android.telephony.SmsManager;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyHistogram;
@@ -63,6 +66,7 @@
import android.util.Log;
import android.util.Pair;
import android.util.Slog;
+
import com.android.ims.ImsManager;
import com.android.ims.internal.IImsServiceController;
import com.android.ims.internal.IImsServiceFeatureListener;
@@ -90,8 +94,11 @@
import com.android.internal.util.HexDump;
import com.android.phone.settings.VisualVoicemailSettingsUtil;
import com.android.phone.settings.VoicemailNotificationSettingsUtil;
+
import java.io.FileDescriptor;
import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -2026,11 +2033,33 @@
}
@Override
- public VisualVoicemailSmsFilterSettings getSystemVisualVoicemailSmsFilterSettings(
- String packageName, int subId) {
+ public VisualVoicemailSmsFilterSettings getActiveVisualVoicemailSmsFilterSettings(int subId) {
enforceReadPrivilegedPermission();
return VisualVoicemailSmsFilterConfig
- .getVisualVoicemailSmsFilterSettings(mPhone.getContext(), packageName, subId);
+ .getActiveVisualVoicemailSmsFilterSettings(mPhone.getContext(), subId);
+ }
+
+ @Override
+ public void sendVisualVoicemailSmsForSubscriber(String callingPackage, int subId,
+ String number, int port, String text, PendingIntent sentIntent) {
+ mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
+ enforceDefaultDialer(callingPackage);
+ enforceSendSmsPermission();
+ // Make the calls as the phone process.
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(subId);
+ if (port == 0) {
+ smsManager.sendTextMessageWithSelfPermissions(number, null, text,
+ sentIntent, null, false);
+ } else {
+ byte[] data = text.getBytes(StandardCharsets.UTF_8);
+ smsManager.sendDataMessageWithSelfPermissions(number, null,
+ (short) port, data, sentIntent, null);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
}
/**
* Sets the voice activation state of a given subId.
@@ -3357,6 +3386,28 @@
}
/**
+ * Make sure either called from same process as self (phone) or IPC caller has send SMS
+ * permission.
+ *
+ * @throws SecurityException if the caller does not have the required permission
+ */
+ private void enforceSendSmsPermission() {
+ mApp.enforceCallingOrSelfPermission(permission.SEND_SMS, null);
+ }
+
+ /**
+ * Make sure called from the default dialer
+ *
+ * @throws SecurityException if the caller is not the default dialer
+ */
+ private void enforceDefaultDialer(String callingPackage) {
+ TelecomManager telecomManager = mPhone.getContext().getSystemService(TelecomManager.class);
+ if (!callingPackage.equals(telecomManager.getDefaultDialerPackage())) {
+ throw new SecurityException("Caller not default dialer.");
+ }
+ }
+
+ /**
* Return the application ID for the app type.
*
* @param subId the subscription ID that this request applies to.