Merge "Enforce VisualVoicemailService to require BIND_VISUAL_VOICEMAIL_SERVICE"
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index c2c4e46..7f0b23e 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -3538,8 +3538,12 @@
* @throws SecurityException if the caller is not the visual voicemail package.
*/
private void enforceVisualVoicemailPackage(String callingPackage, int subId) {
- String vvmPackage = RemoteVvmTaskManager.getRemotePackage(mPhone.getContext(), subId)
- .getPackageName();
+ ComponentName componentName =
+ RemoteVvmTaskManager.getRemotePackage(mPhone.getContext(), subId);
+ if(componentName == null) {
+ throw new SecurityException("Caller not current active visual voicemail package[null]");
+ }
+ String vvmPackage = componentName.getPackageName();
if (!callingPackage.equals(vvmPackage)) {
throw new SecurityException("Caller not current active visual voicemail package[" +
vvmPackage + "]");
diff --git a/src/com/android/phone/vvm/RemoteVvmTaskManager.java b/src/com/android/phone/vvm/RemoteVvmTaskManager.java
index f48fc7e..ca971d1 100644
--- a/src/com/android/phone/vvm/RemoteVvmTaskManager.java
+++ b/src/com/android/phone/vvm/RemoteVvmTaskManager.java
@@ -131,9 +131,22 @@
bindIntent.setPackage(packageName);
ResolveInfo info = context.getPackageManager()
.resolveService(bindIntent, PackageManager.MATCH_ALL);
- if (info != null) {
- return info.getComponentInfo().getComponentName();
+ if (info == null) {
+ continue;
}
+ if(info.serviceInfo == null){
+ VvmLog.w(TAG,
+ "Component " + info.getComponentInfo() + " is not a service, ignoring");
+ continue;
+ }
+ if (!android.Manifest.permission.BIND_VISUAL_VOICEMAIL_SERVICE
+ .equals(info.serviceInfo.permission)) {
+ VvmLog.w(TAG, "package " + info.serviceInfo.packageName
+ + " does not enforce BIND_VISUAL_VOICEMAIL_SERVICE, ignoring");
+ continue;
+ }
+
+ return info.getComponentInfo().getComponentName();
}
return null;