diff options
author | Amit Mahajan <amitmahajan@google.com> | 2019-10-07 17:41:26 -0700 |
---|---|---|
committer | Amit Mahajan <amitmahajan@google.com> | 2019-10-07 17:41:26 -0700 |
commit | 6237a6b35cd127cc39973b640e25d198466229a7 (patch) | |
tree | 1b13d79b1ebfe3a58937c0966894ffd13622d5e9 /mms | |
parent | 505e17417637dd02c12dd468b54e86f1c9c1ffe9 (diff) | |
download | base-6237a6b35cd127cc39973b640e25d198466229a7.tar.gz |
Move MmsManager and IMms to frameworks/base/mms
Test: basic sanity
Bug: 140763963
Change-Id: Ib2cffce98f62913c3e50c59b63012c39d595d9ce
Diffstat (limited to 'mms')
-rw-r--r-- | mms/OWNERS | 14 | ||||
-rw-r--r-- | mms/java/android/telephony/MmsManager.java | 118 | ||||
-rw-r--r-- | mms/java/com/android/internal/telephony/IMms.aidl | 198 |
3 files changed, 330 insertions, 0 deletions
diff --git a/mms/OWNERS b/mms/OWNERS new file mode 100644 index 000000000000..ba00d5d75010 --- /dev/null +++ b/mms/OWNERS @@ -0,0 +1,14 @@ +set noparent + +tgunn@google.com +breadley@google.com +hallliu@google.com +rgreenwalt@google.com +amitmahajan@google.com +fionaxu@google.com +jackyu@google.com +jminjie@google.com +satk@google.com +shuoq@google.com +refuhoo@google.com +nazaninb@google.com diff --git a/mms/java/android/telephony/MmsManager.java b/mms/java/android/telephony/MmsManager.java new file mode 100644 index 000000000000..4bcf04691652 --- /dev/null +++ b/mms/java/android/telephony/MmsManager.java @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telephony; + +import android.app.ActivityThread; +import android.app.PendingIntent; +import android.net.Uri; +import android.os.Bundle; +import android.os.RemoteException; +import android.os.ServiceManager; + +import com.android.internal.telephony.IMms; + +/** + * Manages MMS operations such as sending multimedia messages. + * Get this object by calling the static method {@link #getInstance()}. + * @hide + */ +public class MmsManager { + private static final String TAG = "MmsManager"; + + /** Singleton object constructed during class initialization. */ + private static final MmsManager sInstance = new MmsManager(); + + /** + * Get the MmsManager singleton instance. + * + * @return the {@link MmsManager} singleton instance. + */ + public static MmsManager getInstance() { + return sInstance; + } + + /** + * Send an MMS message + * + * @param subId the subscription id + * @param contentUri the content Uri from which the message pdu will be read + * @param locationUrl the optional location url where message should be sent to + * @param configOverrides the carrier-specific messaging configuration values to override for + * sending the message. + * @param sentIntent if not NULL this <code>PendingIntent</code> is broadcast when the message + * is successfully sent, or failed + */ + public void sendMultimediaMessage(int subId, Uri contentUri, String locationUrl, + Bundle configOverrides, PendingIntent sentIntent) { + try { + final IMms iMms = IMms.Stub.asInterface(ServiceManager.getService("imms")); + if (iMms == null) { + return; + } + + iMms.sendMessage(subId, ActivityThread.currentPackageName(), contentUri, + locationUrl, configOverrides, sentIntent); + } catch (RemoteException e) { + // Ignore it + } + } + + /** + * Download an MMS message from carrier by a given location URL + * + * @param subId the subscription id + * @param locationUrl the location URL of the MMS message to be downloaded, usually obtained + * from the MMS WAP push notification + * @param contentUri the content uri to which the downloaded pdu will be written + * @param configOverrides the carrier-specific messaging configuration values to override for + * downloading the message. + * @param downloadedIntent if not NULL this <code>PendingIntent</code> is + * broadcast when the message is downloaded, or the download is failed + * @throws IllegalArgumentException if locationUrl or contentUri is empty + */ + public void downloadMultimediaMessage(int subId, String locationUrl, Uri contentUri, + Bundle configOverrides, PendingIntent downloadedIntent) { + try { + final IMms iMms = IMms.Stub.asInterface(ServiceManager.getService("imms")); + if (iMms == null) { + return; + } + iMms.downloadMessage(subId, ActivityThread.currentPackageName(), + locationUrl, contentUri, configOverrides, downloadedIntent); + } catch (RemoteException e) { + // Ignore it + } + } + + /** + * Get carrier-dependent configuration values. + * + * @param subId the subscription id + * @return bundle key/values pairs of configuration values + */ + public Bundle getCarrierConfigValues(int subId) { + try { + IMms iMms = IMms.Stub.asInterface(ServiceManager.getService("imms")); + if (iMms != null) { + return iMms.getCarrierConfigValues(subId); + } + } catch (RemoteException ex) { + // ignore it + } + return null; + } +} diff --git a/mms/java/com/android/internal/telephony/IMms.aidl b/mms/java/com/android/internal/telephony/IMms.aidl new file mode 100644 index 000000000000..fa5073ef1c7e --- /dev/null +++ b/mms/java/com/android/internal/telephony/IMms.aidl @@ -0,0 +1,198 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.telephony; + +import android.app.PendingIntent; +import android.content.ContentValues; +import android.net.Uri; +import android.os.Bundle; + +/** + * Service interface to handle MMS API requests + */ +interface IMms { + /** + * Send an MMS message + * + * @param subId the SIM id + * @param callingPkg the package name of the calling app + * @param contentUri the content uri from which to read MMS message encoded in standard MMS + * PDU format + * @param locationUrl the optional location url for where this message should be sent to + * @param configOverrides the carrier-specific messaging configuration values to override for + * sending the message. See {@link android.telephony.SmsManager} for the value names and types. + * @param sentIntent if not NULL this <code>PendingIntent</code> is + * broadcast when the message is successfully sent, or failed + */ + void sendMessage(int subId, String callingPkg, in Uri contentUri, + String locationUrl, in Bundle configOverrides, in PendingIntent sentIntent); + + /** + * Download an MMS message using known location and transaction id + * + * @param subId the SIM id + * @param callingPkg the package name of the calling app + * @param locationUrl the location URL of the MMS message to be downloaded, usually obtained + * from the MMS WAP push notification + * @param contentUri a contentUri to which the downloaded MMS message will be written + * @param configOverrides the carrier-specific messaging configuration values to override for + * downloading the message. See {@link android.telephony.SmsManager} for the value names and + * types. + * @param downloadedIntent if not NULL this <code>PendingIntent</code> is + * broadcast when the message is downloaded, or the download is failed + */ + void downloadMessage(int subId, String callingPkg, String locationUrl, + in Uri contentUri, in Bundle configOverrides, + in PendingIntent downloadedIntent); + + /** + * Get carrier-dependent configuration values. + * + * @param subId the SIM id + */ + Bundle getCarrierConfigValues(int subId); + + /** + * Import a text message into system's SMS store + * + * @param callingPkg the calling app's package name + * @param address the destination address of the message + * @param type the type of the message + * @param text the message text + * @param timestampMillis the message timestamp in milliseconds + * @param seen if the message is seen + * @param read if the message is read + * @return the message URI, null if failed + */ + Uri importTextMessage(String callingPkg, String address, int type, String text, + long timestampMillis, boolean seen, boolean read); + + /** + * Import a multimedia message into system's MMS store + * + * @param callingPkg the package name of the calling app + * @param contentUri the content uri from which to read PDU of the message to import + * @param messageId the optional message id + * @param timestampSecs the message timestamp in seconds + * @param seen if the message is seen + * @param read if the message is read + * @return the message URI, null if failed + */ + Uri importMultimediaMessage(String callingPkg, in Uri contentUri, String messageId, + long timestampSecs, boolean seen, boolean read); + + /** + * Delete a system stored SMS or MMS message + * + * @param callingPkg the package name of the calling app + * @param messageUri the URI of the stored message + * @return true if deletion is successful, false otherwise + */ + boolean deleteStoredMessage(String callingPkg, in Uri messageUri); + + /** + * Delete a system stored SMS or MMS thread + * + * @param callingPkg the package name of the calling app + * @param conversationId the ID of the message conversation + * @return true if deletion is successful, false otherwise + */ + boolean deleteStoredConversation(String callingPkg, long conversationId); + + /** + * Update the status properties of a system stored SMS or MMS message, e.g. + * the read status of a message, etc. + * + * @param callingPkg the package name of the calling app + * @param messageUri the URI of the stored message + * @param statusValues a list of status properties in key-value pairs to update + * @return true if deletion is successful, false otherwise + */ + boolean updateStoredMessageStatus(String callingPkg, in Uri messageUri, + in ContentValues statusValues); + + /** + * Archive or unarchive a stored conversation + * + * @param callingPkg the package name of the calling app + * @param conversationId the ID of the message conversation + * @param archived true to archive the conversation, false otherwise + * @return true if update is successful, false otherwise + */ + boolean archiveStoredConversation(String callingPkg, long conversationId, boolean archived); + + /** + * Add a text message draft to system SMS store + * + * @param callingPkg the package name of the calling app + * @param address the destination address of message + * @param text the body of the message to send + * @return the URI of the stored draft message + */ + Uri addTextMessageDraft(String callingPkg, String address, String text); + + /** + * Add a multimedia message draft to system MMS store + * + * @param callingPkg the package name of the calling app + * @param contentUri the content Uri from which to read PDU data of the draft MMS + * @return the URI of the stored draft message + */ + Uri addMultimediaMessageDraft(String callingPkg, in Uri contentUri); + + /** + * Send a system stored MMS message + * + * This is used for sending a previously sent, but failed-to-send, message or + * for sending a text message that has been stored as a draft. + * + * @param subId the SIM id + * @param callingPkg the package name of the calling app + * @param messageUri the URI of the stored message + * @param configOverrides the carrier-specific messaging configuration values to override for + * sending the message. See {@link android.telephony.SmsManager} for the value names and types. + * @param sentIntent if not NULL this <code>PendingIntent</code> is + * broadcast when the message is successfully sent, or failed + */ + void sendStoredMessage(int subId, String callingPkg, in Uri messageUri, + in Bundle configOverrides, in PendingIntent sentIntent); + + /** + * Turns on/off the flag to automatically write sent/received SMS/MMS messages into system + * + * When this flag is on, all SMS/MMS sent/received are stored by system automatically + * When this flag is off, only SMS/MMS sent by non-default SMS apps are stored by system + * automatically + * + * This flag can only be changed by default SMS apps + * + * @param callingPkg the name of the calling app package + * @param enabled Whether to enable message auto persisting + */ + void setAutoPersisting(String callingPkg, boolean enabled); + + /** + * Get the value of the flag to automatically write sent/received SMS/MMS messages into system + * + * When this flag is on, all SMS/MMS sent/received are stored by system automatically + * When this flag is off, only SMS/MMS sent by non-default SMS apps are stored by system + * automatically + * + * @return the current value of the auto persist flag + */ + boolean getAutoPersisting(); +} |