summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYe Wen <ywen@google.com>2014-05-15 12:51:25 -0700
committerYe Wen <ywen@google.com>2014-05-19 10:51:52 -0700
commit144df2c53c194ce94e4a99fce1f9ad8c49845189 (patch)
tree81fe529064736fc0a1248a5f962ad7df77c0cf6c
parent64817e848552fd0a429a3e026b7b1562103c56bb (diff)
downloadmms-144df2c53c194ce94e4a99fce1f9ad8c49845189.tar.gz
MMS API: initial API definition and build file change
b/14095333 Change-Id: I2a8849a096cc2ad2adb750ef0d518433deef33e8
-rw-r--r--Android.mk4
-rw-r--r--src/java/android/telephony/MmsManager.java106
-rw-r--r--src/java/com/android/internal/telephony/mms/IMms.aidl50
-rw-r--r--src/java/com/android/internal/telephony/mms/package.html5
4 files changed, 164 insertions, 1 deletions
diff --git a/Android.mk b/Android.mk
index e0da575..1f40869 100644
--- a/Android.mk
+++ b/Android.mk
@@ -16,8 +16,10 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
+LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/src/java
+LOCAL_SRC_FILES := $(call all-java-files-under, src/java) $(call all-Iaidl-files-under, src/java)
+
LOCAL_JAVA_LIBRARIES := telephony-common
-LOCAL_SRC_FILES := $(call all-java-files-under, src/java)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := mms-common
diff --git a/src/java/android/telephony/MmsManager.java b/src/java/android/telephony/MmsManager.java
new file mode 100644
index 0000000..2b9a7f6
--- /dev/null
+++ b/src/java/android/telephony/MmsManager.java
@@ -0,0 +1,106 @@
+/*
+ * 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 android.telephony;
+
+import com.android.internal.telephony.mms.IMms;
+
+import android.app.PendingIntent;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.text.TextUtils;
+import android.util.Log;
+
+/**
+ * Manages MMS operations like sending, downloading MMS messages.
+ * Get instance of this class by calling the static method {@link #getDefault()}
+ *
+ * {@hide}
+ */
+public final class MmsManager {
+ private static final String LOG_TAG = "MmsManager";
+ private static final String SERVICE = "com.android.internal.telephony.mms.IMms";
+
+ private static final MmsManager sInstance = new MmsManager();
+
+ /**
+ * Get the default instance of the MmsManager
+ *
+ * @return the default instance of the MmsManager
+ */
+ public static MmsManager getDefault() {
+ return sInstance;
+ }
+
+ private MmsManager() {
+ // Do nothing
+ }
+
+ /**
+ * Send an MMS message
+ *
+ * @param pdu the MMS message encoded in standard MMS PDU format
+ * @param sentIntent if not NULL this <code>PendingIntent</code> is
+ * broadcast when the message is successfully sent, or failed
+ * @param deliveryIntent if not NULL this <code>PendingIntent</code> is
+ * broadcast when the message is delivered to the recipient
+ * @param readIntent if not NULL this <code>PendingIntent</code> is
+ * broadcast when the message is read by the recipient
+ */
+ public void sendMessage(byte[] pdu, PendingIntent sentIntent, PendingIntent deliveryIntent,
+ PendingIntent readIntent) {
+ if (pdu == null || pdu.length == 0) {
+ throw new IllegalArgumentException("Empty or zero length PDU");
+ }
+ try {
+ final IMms iMms = IMms.Stub.asInterface(ServiceManager.getService(SERVICE));
+ if (iMms == null) {
+ Log.e(LOG_TAG, "Can not find Mms service");
+ return;
+ }
+ iMms.sendMessage(pdu, sentIntent, deliveryIntent, readIntent);
+ } catch (RemoteException e) {
+ // Ignore it
+ }
+ }
+
+ /**
+ * Download an MMS message from carrier by a given location URL
+ *
+ * @param locationUrl the location URL of the MMS message to be downloaded, usually obtained
+ * from the MMS WAP push notification
+ * @param transactionId the transaction ID of the MMS message, usually obtained from the
+ * MMS WAP push notification
+ * @param downloadedIntent if not NULL this <code>PendingIntent</code> is
+ * broadcast when the message is downloaded, or the download is failed
+ */
+ public void downloadMessage(String locationUrl, String transactionId,
+ PendingIntent downloadedIntent) {
+ if (TextUtils.isEmpty(locationUrl)) {
+ throw new IllegalArgumentException("Empty MMS location URL");
+ }
+ try {
+ final IMms iMms = IMms.Stub.asInterface(ServiceManager.getService(SERVICE));
+ if (iMms != null) {
+ Log.e(LOG_TAG, "Can not find Mms service");
+ return;
+ }
+ iMms.downloadMessage(locationUrl, transactionId, downloadedIntent);
+ } catch (RemoteException e) {
+ // Ignore it
+ }
+ }
+}
diff --git a/src/java/com/android/internal/telephony/mms/IMms.aidl b/src/java/com/android/internal/telephony/mms/IMms.aidl
new file mode 100644
index 0000000..6f410c2
--- /dev/null
+++ b/src/java/com/android/internal/telephony/mms/IMms.aidl
@@ -0,0 +1,50 @@
+/*
+ * 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.mms;
+
+import android.app.PendingIntent;
+
+/**
+ * Service interface to handle MMS API requests
+ */
+interface IMms {
+ /**
+ * Send an MMS message
+ *
+ * @param pdu the MMS message encoded in standard MMS PDU format
+ * @param sentIntent if not NULL this <code>PendingIntent</code> is
+ * broadcast when the message is successfully sent, or failed
+ * @param deliveryIntent if not NULL this <code>PendingIntent</code> is
+ * broadcast when the message is delivered to the recipient
+ * @param readIntent if not NULL this <code>PendingIntent</code> is
+ * broadcast when the message is read by the recipient
+ */
+ void sendMessage(in byte[] pdu, in PendingIntent sentIntent, in PendingIntent deliveryIntent,
+ in PendingIntent readIntent);
+
+ /**
+ * Download an MMS message using known location and transaction id
+ *
+ * @param location the location URL of the MMS message to be downloaded, usually obtained
+ * from the MMS WAP push notification
+ * @param transactionId the transaction ID of the MMS message, usually obtained from the
+ * MMS WAP push notification
+ * @param downloadedIntent if not NULL this <code>PendingIntent</code> is
+ * broadcast when the message is downloaded, or the download is failed
+ */
+ void downloadMessage(String location, String transactionId, in PendingIntent downloadedIntent);
+}
diff --git a/src/java/com/android/internal/telephony/mms/package.html b/src/java/com/android/internal/telephony/mms/package.html
new file mode 100644
index 0000000..6377c18
--- /dev/null
+++ b/src/java/com/android/internal/telephony/mms/package.html
@@ -0,0 +1,5 @@
+<html>
+<body>
+{@hide}
+</body>
+</html>