Add attribution tag to MMS Service
MmsManager picks up client app's attribution tag and send it to MmsServiceBroker.
MmsServiceBroker includes it in the call to noteOp. It then calls MmsService sendMessage and pass it along.
These changes are applied to sendMessage and downloadMessage methods only.
Null entries are passed to noteOp methods in other methods like importTextMessage, etc.
These methods were removed from MmsManager(ag/9431535), but not removed from IMms.
Bug: 224831002
Test: Manually verify multimedia send/receive message.
Change-Id: I83a1b5c4c184747d9a22f672b1dbd4f02950c645
diff --git a/mms/java/android/telephony/MmsManager.java b/mms/java/android/telephony/MmsManager.java
index d541da0..b893b45 100644
--- a/mms/java/android/telephony/MmsManager.java
+++ b/mms/java/android/telephony/MmsManager.java
@@ -70,7 +70,8 @@
}
iMms.sendMessage(subId, ActivityThread.currentPackageName(), contentUri,
- locationUrl, configOverrides, sentIntent, messageId);
+ locationUrl, configOverrides, sentIntent, messageId,
+ mContext.getAttributionTag());
} catch (RemoteException e) {
// Ignore it
}
@@ -102,7 +103,7 @@
}
iMms.downloadMessage(subId, ActivityThread.currentPackageName(),
locationUrl, contentUri, configOverrides, downloadedIntent,
- messageId);
+ messageId, mContext.getAttributionTag());
} catch (RemoteException e) {
// Ignore it
}
diff --git a/mms/java/com/android/internal/telephony/IMms.aidl b/mms/java/com/android/internal/telephony/IMms.aidl
index e0e0a4a..3cdde10 100644
--- a/mms/java/com/android/internal/telephony/IMms.aidl
+++ b/mms/java/com/android/internal/telephony/IMms.aidl
@@ -26,7 +26,7 @@
*/
interface IMms {
/**
- * Send an MMS message
+ * Send an MMS message with attribution tag.
*
* @param subId the SIM id
* @param callingPkg the package name of the calling app
@@ -38,10 +38,11 @@
* @param sentIntent if not NULL this <code>PendingIntent</code> is
* broadcast when the message is successfully sent, or failed
* @param messageId An id that uniquely identifies the message requested to be sent.
+ * @param attributionTag a tag that attributes the call to a client App.
*/
void sendMessage(int subId, String callingPkg, in Uri contentUri,
String locationUrl, in Bundle configOverrides, in PendingIntent sentIntent,
- in long messageId);
+ in long messageId, String attributionTag);
/**
* Download an MMS message using known location and transaction id
@@ -57,10 +58,11 @@
* @param downloadedIntent if not NULL this <code>PendingIntent</code> is
* broadcast when the message is downloaded, or the download is failed
* @param messageId An id that uniquely identifies the message requested to be downloaded.
+ * @param attributionTag a tag that attributes the call to a client App.
*/
void downloadMessage(int subId, String callingPkg, String locationUrl,
in Uri contentUri, in Bundle configOverrides,
- in PendingIntent downloadedIntent, in long messageId);
+ in PendingIntent downloadedIntent, in long messageId, String attributionTag);
/**
* Import a text message into system's SMS store
diff --git a/services/core/java/com/android/server/MmsServiceBroker.java b/services/core/java/com/android/server/MmsServiceBroker.java
index 593c406..59db686 100644
--- a/services/core/java/com/android/server/MmsServiceBroker.java
+++ b/services/core/java/com/android/server/MmsServiceBroker.java
@@ -129,15 +129,15 @@
@Override
public void sendMessage(int subId, String callingPkg, Uri contentUri, String locationUrl,
- Bundle configOverrides, PendingIntent sentIntent, long messageId)
- throws RemoteException {
+ Bundle configOverrides, PendingIntent sentIntent, long messageId,
+ String attributionTag) throws RemoteException {
returnPendingIntentWithError(sentIntent);
}
@Override
public void downloadMessage(int subId, String callingPkg, String locationUrl,
Uri contentUri, Bundle configOverrides, PendingIntent downloadedIntent,
- long messageId)
+ long messageId, String attributionTag)
throws RemoteException {
returnPendingIntentWithError(downloadedIntent);
}
@@ -333,12 +333,12 @@
@Override
public void sendMessage(int subId, String callingPkg, Uri contentUri,
String locationUrl, Bundle configOverrides, PendingIntent sentIntent,
- long messageId)
+ long messageId, String attributionTag)
throws RemoteException {
Slog.d(TAG, "sendMessage() by " + callingPkg);
mContext.enforceCallingPermission(Manifest.permission.SEND_SMS, "Send MMS message");
if (getAppOpsManager().noteOp(AppOpsManager.OP_SEND_SMS, Binder.getCallingUid(),
- callingPkg) != AppOpsManager.MODE_ALLOWED) {
+ callingPkg, attributionTag, null) != AppOpsManager.MODE_ALLOWED) {
Slog.e(TAG, callingPkg + " is not allowed to call sendMessage()");
return;
}
@@ -347,18 +347,18 @@
Intent.FLAG_GRANT_READ_URI_PERMISSION,
subId);
getServiceGuarded().sendMessage(subId, callingPkg, contentUri, locationUrl,
- configOverrides, sentIntent, messageId);
+ configOverrides, sentIntent, messageId, attributionTag);
}
@Override
public void downloadMessage(int subId, String callingPkg, String locationUrl,
- Uri contentUri, Bundle configOverrides,
- PendingIntent downloadedIntent, long messageId) throws RemoteException {
+ Uri contentUri, Bundle configOverrides, PendingIntent downloadedIntent,
+ long messageId, String attributionTag) throws RemoteException {
Slog.d(TAG, "downloadMessage() by " + callingPkg);
mContext.enforceCallingPermission(Manifest.permission.RECEIVE_MMS,
"Download MMS message");
if (getAppOpsManager().noteOp(AppOpsManager.OP_RECEIVE_MMS, Binder.getCallingUid(),
- callingPkg) != AppOpsManager.MODE_ALLOWED) {
+ callingPkg, attributionTag, null) != AppOpsManager.MODE_ALLOWED) {
Slog.e(TAG, callingPkg + " is not allowed to call downloadMessage()");
return;
}
@@ -368,14 +368,14 @@
subId);
getServiceGuarded().downloadMessage(subId, callingPkg, locationUrl, contentUri,
- configOverrides, downloadedIntent, messageId);
+ configOverrides, downloadedIntent, messageId, attributionTag);
}
@Override
public Uri importTextMessage(String callingPkg, String address, int type, String text,
long timestampMillis, boolean seen, boolean read) throws RemoteException {
if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
- callingPkg) != AppOpsManager.MODE_ALLOWED) {
+ callingPkg, null, null) != AppOpsManager.MODE_ALLOWED) {
// Silently fail AppOps failure due to not being the default SMS app
// while writing the TelephonyProvider
return FAKE_SMS_SENT_URI;
@@ -389,7 +389,7 @@
String messageId, long timestampSecs, boolean seen, boolean read)
throws RemoteException {
if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
- callingPkg) != AppOpsManager.MODE_ALLOWED) {
+ callingPkg, null, null) != AppOpsManager.MODE_ALLOWED) {
// Silently fail AppOps failure due to not being the default SMS app
// while writing the TelephonyProvider
return FAKE_MMS_SENT_URI;
@@ -402,7 +402,7 @@
public boolean deleteStoredMessage(String callingPkg, Uri messageUri)
throws RemoteException {
if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
- callingPkg) != AppOpsManager.MODE_ALLOWED) {
+ callingPkg, null, null) != AppOpsManager.MODE_ALLOWED) {
return false;
}
return getServiceGuarded().deleteStoredMessage(callingPkg, messageUri);
@@ -412,7 +412,7 @@
public boolean deleteStoredConversation(String callingPkg, long conversationId)
throws RemoteException {
if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
- callingPkg) != AppOpsManager.MODE_ALLOWED) {
+ callingPkg, null, null) != AppOpsManager.MODE_ALLOWED) {
return false;
}
return getServiceGuarded().deleteStoredConversation(callingPkg, conversationId);
@@ -422,7 +422,7 @@
public boolean updateStoredMessageStatus(String callingPkg, Uri messageUri,
ContentValues statusValues) throws RemoteException {
if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
- callingPkg) != AppOpsManager.MODE_ALLOWED) {
+ callingPkg, null, null) != AppOpsManager.MODE_ALLOWED) {
return false;
}
return getServiceGuarded()
@@ -433,7 +433,7 @@
public boolean archiveStoredConversation(String callingPkg, long conversationId,
boolean archived) throws RemoteException {
if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
- callingPkg) != AppOpsManager.MODE_ALLOWED) {
+ callingPkg, null, null) != AppOpsManager.MODE_ALLOWED) {
return false;
}
return getServiceGuarded()
@@ -444,7 +444,7 @@
public Uri addTextMessageDraft(String callingPkg, String address, String text)
throws RemoteException {
if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
- callingPkg) != AppOpsManager.MODE_ALLOWED) {
+ callingPkg, null, null) != AppOpsManager.MODE_ALLOWED) {
// Silently fail AppOps failure due to not being the default SMS app
// while writing the TelephonyProvider
return FAKE_SMS_DRAFT_URI;
@@ -456,7 +456,7 @@
public Uri addMultimediaMessageDraft(String callingPkg, Uri contentUri)
throws RemoteException {
if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
- callingPkg) != AppOpsManager.MODE_ALLOWED) {
+ callingPkg, null, null) != AppOpsManager.MODE_ALLOWED) {
// Silently fail AppOps failure due to not being the default SMS app
// while writing the TelephonyProvider
return FAKE_MMS_DRAFT_URI;
@@ -468,7 +468,7 @@
public void sendStoredMessage(int subId, String callingPkg, Uri messageUri,
Bundle configOverrides, PendingIntent sentIntent) throws RemoteException {
if (getAppOpsManager().noteOp(AppOpsManager.OP_SEND_SMS, Binder.getCallingUid(),
- callingPkg) != AppOpsManager.MODE_ALLOWED) {
+ callingPkg, null, null) != AppOpsManager.MODE_ALLOWED) {
return;
}
getServiceGuarded().sendStoredMessage(subId, callingPkg, messageUri, configOverrides,
@@ -478,7 +478,7 @@
@Override
public void setAutoPersisting(String callingPkg, boolean enabled) throws RemoteException {
if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
- callingPkg) != AppOpsManager.MODE_ALLOWED) {
+ callingPkg, null, null) != AppOpsManager.MODE_ALLOWED) {
return;
}
getServiceGuarded().setAutoPersisting(callingPkg, enabled);