1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.internal.telephony;
18 
19 import android.app.PendingIntent;
20 import android.content.ContentValues;
21 import android.net.Uri;
22 import android.os.Bundle;
23 
24 /**
25  * Service interface to handle MMS API requests
26  */
27 interface IMms {
28     /**
29      * Send an MMS message
30      *
31      * @param subId the SIM id
32      * @param callingPkg the package name of the calling app
33      * @param contentUri the content uri from which to read MMS message encoded in standard MMS
34      *  PDU format
35      * @param locationUrl the optional location url for where this message should be sent to
36      * @param configOverrides the carrier-specific messaging configuration values to override for
37      *  sending the message. See {@link android.telephony.SmsManager} for the value names and types.
38      * @param sentIntent if not NULL this <code>PendingIntent</code> is
39      *  broadcast when the message is successfully sent, or failed
40      * @param messageId An id that uniquely identifies the message requested to be sent.
41      */
sendMessage(int subId, String callingPkg, in Uri contentUri, String locationUrl, in Bundle configOverrides, in PendingIntent sentIntent, in long messageId)42     void sendMessage(int subId, String callingPkg, in Uri contentUri,
43             String locationUrl, in Bundle configOverrides, in PendingIntent sentIntent,
44             in long messageId);
45 
46     /**
47      * Download an MMS message using known location and transaction id
48      *
49      * @param subId the SIM id
50      * @param callingPkg the package name of the calling app
51      * @param locationUrl the location URL of the MMS message to be downloaded, usually obtained
52      *  from the MMS WAP push notification
53      * @param contentUri a contentUri to which the downloaded MMS message will be written
54      * @param configOverrides the carrier-specific messaging configuration values to override for
55      *  downloading the message. See {@link android.telephony.SmsManager} for the value names and
56      *  types.
57      * @param downloadedIntent if not NULL this <code>PendingIntent</code> is
58      *  broadcast when the message is downloaded, or the download is failed
59      * @param messageId An id that uniquely identifies the message requested to be downloaded.
60     */
downloadMessage(int subId, String callingPkg, String locationUrl, in Uri contentUri, in Bundle configOverrides, in PendingIntent downloadedIntent, in long messageId)61     void downloadMessage(int subId, String callingPkg, String locationUrl,
62             in Uri contentUri, in Bundle configOverrides,
63             in PendingIntent downloadedIntent, in long messageId);
64 
65     /**
66      * Import a text message into system's SMS store
67      *
68      * @param callingPkg the calling app's package name
69      * @param address the destination address of the message
70      * @param type the type of the message
71      * @param text the message text
72      * @param timestampMillis the message timestamp in milliseconds
73      * @param seen if the message is seen
74      * @param read if the message is read
75      * @return the message URI, null if failed
76      */
importTextMessage(String callingPkg, String address, int type, String text, long timestampMillis, boolean seen, boolean read)77     Uri importTextMessage(String callingPkg, String address, int type, String text,
78             long timestampMillis, boolean seen, boolean read);
79 
80     /**
81       * Import a multimedia message into system's MMS store
82       *
83       * @param callingPkg the package name of the calling app
84       * @param contentUri the content uri from which to read PDU of the message to import
85       * @param messageId the optional message id
86       * @param timestampSecs the message timestamp in seconds
87       * @param seen if the message is seen
88       * @param read if the message is read
89       * @return the message URI, null if failed
90       */
importMultimediaMessage(String callingPkg, in Uri contentUri, String messageId, long timestampSecs, boolean seen, boolean read)91     Uri importMultimediaMessage(String callingPkg, in Uri contentUri, String messageId,
92             long timestampSecs, boolean seen, boolean read);
93 
94     /**
95      * Delete a system stored SMS or MMS message
96      *
97      * @param callingPkg the package name of the calling app
98      * @param messageUri the URI of the stored message
99      * @return true if deletion is successful, false otherwise
100      */
deleteStoredMessage(String callingPkg, in Uri messageUri)101     boolean deleteStoredMessage(String callingPkg, in Uri messageUri);
102 
103     /**
104      * Delete a system stored SMS or MMS thread
105      *
106      * @param callingPkg the package name of the calling app
107      * @param conversationId the ID of the message conversation
108      * @return true if deletion is successful, false otherwise
109      */
deleteStoredConversation(String callingPkg, long conversationId)110     boolean deleteStoredConversation(String callingPkg, long conversationId);
111 
112     /**
113      * Update the status properties of a system stored SMS or MMS message, e.g.
114      * the read status of a message, etc.
115      *
116      * @param callingPkg the package name of the calling app
117      * @param messageUri the URI of the stored message
118      * @param statusValues a list of status properties in key-value pairs to update
119      * @return true if deletion is successful, false otherwise
120      */
updateStoredMessageStatus(String callingPkg, in Uri messageUri, in ContentValues statusValues)121     boolean updateStoredMessageStatus(String callingPkg, in Uri messageUri,
122             in ContentValues statusValues);
123 
124     /**
125      * Archive or unarchive a stored conversation
126      *
127      * @param callingPkg the package name of the calling app
128      * @param conversationId the ID of the message conversation
129      * @param archived true to archive the conversation, false otherwise
130      * @return true if update is successful, false otherwise
131      */
archiveStoredConversation(String callingPkg, long conversationId, boolean archived)132     boolean archiveStoredConversation(String callingPkg, long conversationId, boolean archived);
133 
134     /**
135      * Add a text message draft to system SMS store
136      *
137      * @param callingPkg the package name of the calling app
138      * @param address the destination address of message
139      * @param text the body of the message to send
140      * @return the URI of the stored draft message
141      */
addTextMessageDraft(String callingPkg, String address, String text)142     Uri addTextMessageDraft(String callingPkg, String address, String text);
143 
144     /**
145      * Add a multimedia message draft to system MMS store
146      *
147      * @param callingPkg the package name of the calling app
148      * @param contentUri the content Uri from which to read PDU data of the draft MMS
149      * @return the URI of the stored draft message
150      */
addMultimediaMessageDraft(String callingPkg, in Uri contentUri)151     Uri addMultimediaMessageDraft(String callingPkg, in Uri contentUri);
152 
153     /**
154      * Send a system stored MMS message
155      *
156      * This is used for sending a previously sent, but failed-to-send, message or
157      * for sending a text message that has been stored as a draft.
158      *
159      * @param subId the SIM id
160      * @param callingPkg the package name of the calling app
161      * @param messageUri the URI of the stored message
162      * @param configOverrides the carrier-specific messaging configuration values to override for
163      *  sending the message. See {@link android.telephony.SmsManager} for the value names and types.
164      * @param sentIntent if not NULL this <code>PendingIntent</code> is
165      *  broadcast when the message is successfully sent, or failed
166      */
sendStoredMessage(int subId, String callingPkg, in Uri messageUri, in Bundle configOverrides, in PendingIntent sentIntent)167     void sendStoredMessage(int subId, String callingPkg, in Uri messageUri,
168             in Bundle configOverrides, in PendingIntent sentIntent);
169 
170     /**
171      * Turns on/off the flag to automatically write sent/received SMS/MMS messages into system
172      *
173      * When this flag is on, all SMS/MMS sent/received are stored by system automatically
174      * When this flag is off, only SMS/MMS sent by non-default SMS apps are stored by system
175      * automatically
176      *
177      * This flag can only be changed by default SMS apps
178      *
179      * @param callingPkg the name of the calling app package
180      * @param enabled Whether to enable message auto persisting
181      */
setAutoPersisting(String callingPkg, boolean enabled)182     void setAutoPersisting(String callingPkg, boolean enabled);
183 
184     /**
185      * Get the value of the flag to automatically write sent/received SMS/MMS messages into system
186      *
187      * When this flag is on, all SMS/MMS sent/received are stored by system automatically
188      * When this flag is off, only SMS/MMS sent by non-default SMS apps are stored by system
189      * automatically
190      *
191      * @return the current value of the auto persist flag
192      */
getAutoPersisting()193     boolean getAutoPersisting();
194 }
195