Implement VisualVoicemailService cascading.
This CL determines which VisualVoicemailService should be active.
The order is:
1. Current default dialer
The dialer might disable itself when a carrier VVM package is
installed.
2. The carrier packages
Designated with CarrierConfig using KEY_CARRIER_VVM_PACKAGE_NAME_STRING.
This value is used before solely to disable the system client.
KEY_CARRIER_VVM_PACKAGE_NAME_STRING_ARRAY should be added to allow
multiple clients.
3. The system package.
A device specific package override-able with
R.string.system_visual_voicemail_client
4. The system dialer.
Bug: 34132028
Bug: 32414216
Change-Id: Ifa6d0bbb3033a14757ab99226f28aca245848c0f
Fixes: 34132028
Test: manual test using the dialer and the system package.
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 407d050..fd0f698 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -90,10 +90,10 @@
import com.android.internal.util.HexDump;
import com.android.phone.settings.VisualVoicemailSettingsUtil;
import com.android.phone.settings.VoicemailNotificationSettingsUtil;
+import com.android.phone.vvm.RemoteVvmTaskManager;
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;
@@ -2002,7 +2002,7 @@
public void sendVisualVoicemailSmsForSubscriber(String callingPackage, int subId,
String number, int port, String text, PendingIntent sentIntent) {
mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
- enforceDefaultDialer(callingPackage);
+ enforceVisualVoicemailPackage(callingPackage, subId);
enforceSendSmsPermission();
// Make the calls as the phone process.
final long identity = Binder.clearCallingIdentity();
@@ -3278,14 +3278,16 @@
}
/**
- * Make sure called from the default dialer
+ * Make sure called from the package in charge of visual voicemail.
*
- * @throws SecurityException if the caller is not the default dialer
+ * @throws SecurityException if the caller is not the visual voicemail package.
*/
- private void enforceDefaultDialer(String callingPackage) {
- TelecomManager telecomManager = mPhone.getContext().getSystemService(TelecomManager.class);
- if (!callingPackage.equals(telecomManager.getDefaultDialerPackage())) {
- throw new SecurityException("Caller not default dialer.");
+ private void enforceVisualVoicemailPackage(String callingPackage, int subId) {
+ String vvmPackage = RemoteVvmTaskManager.getRemotePackage(mPhone.getContext(), subId)
+ .getPackageName();
+ if (!callingPackage.equals(vvmPackage)) {
+ throw new SecurityException("Caller not current active visual voicemail package[" +
+ vvmPackage + "]");
}
}