Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ea8dd75 authored by Nan Wu's avatar Nan Wu Committed by Automerger Merge Worker
Browse files

Merge "Add attribution tag to MMS Service" into tm-dev am: cd33bde6

parents be84f46d cd33bde6
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -70,7 +70,8 @@ public class MmsManager {
            }
            }


            iMms.sendMessage(subId, ActivityThread.currentPackageName(), contentUri,
            iMms.sendMessage(subId, ActivityThread.currentPackageName(), contentUri,
                    locationUrl, configOverrides, sentIntent, messageId);
                    locationUrl, configOverrides, sentIntent, messageId,
                    mContext.getAttributionTag());
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            // Ignore it
            // Ignore it
        }
        }
@@ -102,7 +103,7 @@ public class MmsManager {
            }
            }
            iMms.downloadMessage(subId, ActivityThread.currentPackageName(),
            iMms.downloadMessage(subId, ActivityThread.currentPackageName(),
                    locationUrl, contentUri, configOverrides, downloadedIntent,
                    locationUrl, contentUri, configOverrides, downloadedIntent,
                    messageId);
                    messageId, mContext.getAttributionTag());
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            // Ignore it
            // Ignore it
        }
        }
+5 −3
Original line number Original line Diff line number Diff line
@@ -26,7 +26,7 @@ import android.os.Bundle;
 */
 */
interface IMms {
interface IMms {
    /**
    /**
     * Send an MMS message
     * Send an MMS message with attribution tag.
     *
     *
     * @param subId the SIM id
     * @param subId the SIM id
     * @param callingPkg the package name of the calling app
     * @param callingPkg the package name of the calling app
@@ -38,10 +38,11 @@ interface IMms {
     * @param sentIntent if not NULL this <code>PendingIntent</code> is
     * @param sentIntent if not NULL this <code>PendingIntent</code> is
     *  broadcast when the message is successfully sent, or failed
     *  broadcast when the message is successfully sent, or failed
     * @param messageId An id that uniquely identifies the message requested to be sent.
     * @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,
    void sendMessage(int subId, String callingPkg, in Uri contentUri,
            String locationUrl, in Bundle configOverrides, in PendingIntent sentIntent,
            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
     * Download an MMS message using known location and transaction id
@@ -57,10 +58,11 @@ interface IMms {
     * @param downloadedIntent if not NULL this <code>PendingIntent</code> is
     * @param downloadedIntent if not NULL this <code>PendingIntent</code> is
     *  broadcast when the message is downloaded, or the download is failed
     *  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 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,
    void downloadMessage(int subId, String callingPkg, String locationUrl,
            in Uri contentUri, in Bundle configOverrides,
            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
     * Import a text message into system's SMS store
+20 −20
Original line number Original line Diff line number Diff line
@@ -129,15 +129,15 @@ public class MmsServiceBroker extends SystemService {


        @Override
        @Override
        public void sendMessage(int subId, String callingPkg, Uri contentUri, String locationUrl,
        public void sendMessage(int subId, String callingPkg, Uri contentUri, String locationUrl,
                Bundle configOverrides, PendingIntent sentIntent, long messageId)
                Bundle configOverrides, PendingIntent sentIntent, long messageId,
                throws RemoteException {
                String attributionTag) throws RemoteException {
            returnPendingIntentWithError(sentIntent);
            returnPendingIntentWithError(sentIntent);
        }
        }


        @Override
        @Override
        public void downloadMessage(int subId, String callingPkg, String locationUrl,
        public void downloadMessage(int subId, String callingPkg, String locationUrl,
                Uri contentUri, Bundle configOverrides, PendingIntent downloadedIntent,
                Uri contentUri, Bundle configOverrides, PendingIntent downloadedIntent,
                long messageId)
                long messageId, String attributionTag)
                throws RemoteException {
                throws RemoteException {
            returnPendingIntentWithError(downloadedIntent);
            returnPendingIntentWithError(downloadedIntent);
        }
        }
@@ -333,12 +333,12 @@ public class MmsServiceBroker extends SystemService {
        @Override
        @Override
        public void sendMessage(int subId, String callingPkg, Uri contentUri,
        public void sendMessage(int subId, String callingPkg, Uri contentUri,
                String locationUrl, Bundle configOverrides, PendingIntent sentIntent,
                String locationUrl, Bundle configOverrides, PendingIntent sentIntent,
                long messageId)
                long messageId, String attributionTag)
                throws RemoteException {
                throws RemoteException {
            Slog.d(TAG, "sendMessage() by " + callingPkg);
            Slog.d(TAG, "sendMessage() by " + callingPkg);
            mContext.enforceCallingPermission(Manifest.permission.SEND_SMS, "Send MMS message");
            mContext.enforceCallingPermission(Manifest.permission.SEND_SMS, "Send MMS message");
            if (getAppOpsManager().noteOp(AppOpsManager.OP_SEND_SMS, Binder.getCallingUid(),
            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()");
                Slog.e(TAG, callingPkg + " is not allowed to call sendMessage()");
                return;
                return;
            }
            }
@@ -347,18 +347,18 @@ public class MmsServiceBroker extends SystemService {
                    Intent.FLAG_GRANT_READ_URI_PERMISSION,
                    Intent.FLAG_GRANT_READ_URI_PERMISSION,
                    subId);
                    subId);
            getServiceGuarded().sendMessage(subId, callingPkg, contentUri, locationUrl,
            getServiceGuarded().sendMessage(subId, callingPkg, contentUri, locationUrl,
                    configOverrides, sentIntent, messageId);
                    configOverrides, sentIntent, messageId, attributionTag);
        }
        }


        @Override
        @Override
        public void downloadMessage(int subId, String callingPkg, String locationUrl,
        public void downloadMessage(int subId, String callingPkg, String locationUrl,
                Uri contentUri, Bundle configOverrides,
                Uri contentUri, Bundle configOverrides, PendingIntent downloadedIntent,
                PendingIntent downloadedIntent, long messageId) throws RemoteException {
                long messageId, String attributionTag) throws RemoteException {
            Slog.d(TAG, "downloadMessage() by " + callingPkg);
            Slog.d(TAG, "downloadMessage() by " + callingPkg);
            mContext.enforceCallingPermission(Manifest.permission.RECEIVE_MMS,
            mContext.enforceCallingPermission(Manifest.permission.RECEIVE_MMS,
                    "Download MMS message");
                    "Download MMS message");
            if (getAppOpsManager().noteOp(AppOpsManager.OP_RECEIVE_MMS, Binder.getCallingUid(),
            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()");
                Slog.e(TAG, callingPkg + " is not allowed to call downloadMessage()");
                return;
                return;
            }
            }
@@ -368,14 +368,14 @@ public class MmsServiceBroker extends SystemService {
                    subId);
                    subId);


            getServiceGuarded().downloadMessage(subId, callingPkg, locationUrl, contentUri,
            getServiceGuarded().downloadMessage(subId, callingPkg, locationUrl, contentUri,
                    configOverrides, downloadedIntent, messageId);
                    configOverrides, downloadedIntent, messageId, attributionTag);
        }
        }


        @Override
        @Override
        public Uri importTextMessage(String callingPkg, String address, int type, String text,
        public Uri importTextMessage(String callingPkg, String address, int type, String text,
                long timestampMillis, boolean seen, boolean read) throws RemoteException {
                long timestampMillis, boolean seen, boolean read) throws RemoteException {
            if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
            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
                // Silently fail AppOps failure due to not being the default SMS app
                // while writing the TelephonyProvider
                // while writing the TelephonyProvider
                return FAKE_SMS_SENT_URI;
                return FAKE_SMS_SENT_URI;
@@ -389,7 +389,7 @@ public class MmsServiceBroker extends SystemService {
                String messageId, long timestampSecs, boolean seen, boolean read)
                String messageId, long timestampSecs, boolean seen, boolean read)
                throws RemoteException {
                throws RemoteException {
            if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
            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
                // Silently fail AppOps failure due to not being the default SMS app
                // while writing the TelephonyProvider
                // while writing the TelephonyProvider
                return FAKE_MMS_SENT_URI;
                return FAKE_MMS_SENT_URI;
@@ -402,7 +402,7 @@ public class MmsServiceBroker extends SystemService {
        public boolean deleteStoredMessage(String callingPkg, Uri messageUri)
        public boolean deleteStoredMessage(String callingPkg, Uri messageUri)
                throws RemoteException {
                throws RemoteException {
            if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
            if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
                    callingPkg) != AppOpsManager.MODE_ALLOWED) {
                    callingPkg, null, null) != AppOpsManager.MODE_ALLOWED) {
                return false;
                return false;
            }
            }
            return getServiceGuarded().deleteStoredMessage(callingPkg, messageUri);
            return getServiceGuarded().deleteStoredMessage(callingPkg, messageUri);
@@ -412,7 +412,7 @@ public class MmsServiceBroker extends SystemService {
        public boolean deleteStoredConversation(String callingPkg, long conversationId)
        public boolean deleteStoredConversation(String callingPkg, long conversationId)
                throws RemoteException {
                throws RemoteException {
            if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
            if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
                    callingPkg) != AppOpsManager.MODE_ALLOWED) {
                    callingPkg, null, null) != AppOpsManager.MODE_ALLOWED) {
                return false;
                return false;
            }
            }
            return getServiceGuarded().deleteStoredConversation(callingPkg, conversationId);
            return getServiceGuarded().deleteStoredConversation(callingPkg, conversationId);
@@ -422,7 +422,7 @@ public class MmsServiceBroker extends SystemService {
        public boolean updateStoredMessageStatus(String callingPkg, Uri messageUri,
        public boolean updateStoredMessageStatus(String callingPkg, Uri messageUri,
                ContentValues statusValues) throws RemoteException {
                ContentValues statusValues) throws RemoteException {
            if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
            if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
                    callingPkg) != AppOpsManager.MODE_ALLOWED) {
                    callingPkg, null, null) != AppOpsManager.MODE_ALLOWED) {
                return false;
                return false;
            }
            }
            return getServiceGuarded()
            return getServiceGuarded()
@@ -433,7 +433,7 @@ public class MmsServiceBroker extends SystemService {
        public boolean archiveStoredConversation(String callingPkg, long conversationId,
        public boolean archiveStoredConversation(String callingPkg, long conversationId,
                boolean archived) throws RemoteException {
                boolean archived) throws RemoteException {
            if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
            if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
                    callingPkg) != AppOpsManager.MODE_ALLOWED) {
                    callingPkg, null, null) != AppOpsManager.MODE_ALLOWED) {
                return false;
                return false;
            }
            }
            return getServiceGuarded()
            return getServiceGuarded()
@@ -444,7 +444,7 @@ public class MmsServiceBroker extends SystemService {
        public Uri addTextMessageDraft(String callingPkg, String address, String text)
        public Uri addTextMessageDraft(String callingPkg, String address, String text)
                throws RemoteException {
                throws RemoteException {
            if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
            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
                // Silently fail AppOps failure due to not being the default SMS app
                // while writing the TelephonyProvider
                // while writing the TelephonyProvider
                return FAKE_SMS_DRAFT_URI;
                return FAKE_SMS_DRAFT_URI;
@@ -456,7 +456,7 @@ public class MmsServiceBroker extends SystemService {
        public Uri addMultimediaMessageDraft(String callingPkg, Uri contentUri)
        public Uri addMultimediaMessageDraft(String callingPkg, Uri contentUri)
                throws RemoteException {
                throws RemoteException {
            if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
            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
                // Silently fail AppOps failure due to not being the default SMS app
                // while writing the TelephonyProvider
                // while writing the TelephonyProvider
                return FAKE_MMS_DRAFT_URI;
                return FAKE_MMS_DRAFT_URI;
@@ -468,7 +468,7 @@ public class MmsServiceBroker extends SystemService {
        public void sendStoredMessage(int subId, String callingPkg, Uri messageUri,
        public void sendStoredMessage(int subId, String callingPkg, Uri messageUri,
                Bundle configOverrides, PendingIntent sentIntent) throws RemoteException {
                Bundle configOverrides, PendingIntent sentIntent) throws RemoteException {
            if (getAppOpsManager().noteOp(AppOpsManager.OP_SEND_SMS, Binder.getCallingUid(),
            if (getAppOpsManager().noteOp(AppOpsManager.OP_SEND_SMS, Binder.getCallingUid(),
                    callingPkg) != AppOpsManager.MODE_ALLOWED) {
                    callingPkg, null, null) != AppOpsManager.MODE_ALLOWED) {
                return;
                return;
            }
            }
            getServiceGuarded().sendStoredMessage(subId, callingPkg, messageUri, configOverrides,
            getServiceGuarded().sendStoredMessage(subId, callingPkg, messageUri, configOverrides,
@@ -478,7 +478,7 @@ public class MmsServiceBroker extends SystemService {
        @Override
        @Override
        public void setAutoPersisting(String callingPkg, boolean enabled) throws RemoteException {
        public void setAutoPersisting(String callingPkg, boolean enabled) throws RemoteException {
            if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
            if (getAppOpsManager().noteOp(AppOpsManager.OP_WRITE_SMS, Binder.getCallingUid(),
                    callingPkg) != AppOpsManager.MODE_ALLOWED) {
                    callingPkg, null, null) != AppOpsManager.MODE_ALLOWED) {
                return;
                return;
            }
            }
            getServiceGuarded().setAutoPersisting(callingPkg, enabled);
            getServiceGuarded().setAutoPersisting(callingPkg, enabled);