Merge "Move appName inside Downloadrequest."
diff --git a/telephony/java/android/telephony/MbmsDownloadManager.java b/telephony/java/android/telephony/MbmsDownloadManager.java
index d9f8fa6..a9ec299 100644
--- a/telephony/java/android/telephony/MbmsDownloadManager.java
+++ b/telephony/java/android/telephony/MbmsDownloadManager.java
@@ -17,9 +17,10 @@
 package android.telephony;
 
 import android.content.Context;
+import android.content.Intent;
 import android.net.Uri;
 import android.os.RemoteException;
-import android.telephony.mbms.DownloadCallback;
+import android.telephony.mbms.IDownloadCallback;
 import android.telephony.mbms.DownloadRequest;
 import android.telephony.mbms.DownloadStatus;
 import android.telephony.mbms.IMbmsDownloadManagerCallback;
@@ -242,8 +243,9 @@
      *
      * Asynchronous errors through the listener include any of the errors
      */
-    public DownloadRequest download(DownloadRequest downloadRequest, DownloadCallback listener) {
-        return null;
+    public DownloadRequest download(DownloadRequest request, IDownloadCallback listener) {
+        request.setAppName(mDownloadAppName);
+        return request;
     }
 
     /**
diff --git a/telephony/java/android/telephony/mbms/DownloadRequest.java b/telephony/java/android/telephony/mbms/DownloadRequest.java
index dbaf10bb..f3ca058 100644
--- a/telephony/java/android/telephony/mbms/DownloadRequest.java
+++ b/telephony/java/android/telephony/mbms/DownloadRequest.java
@@ -21,6 +21,7 @@
 import android.os.Parcel;
 import android.os.Parcelable;
 
+import java.lang.IllegalStateException;
 import java.net.URISyntaxException;
 
 /**
@@ -36,6 +37,7 @@
         private Uri dest;
         private int sub;
         private String appIntent;
+        private String appName;  // not the Android app Name, the embms app Name
 
         public Builder setId(int id) {
             this.id = id;
@@ -68,7 +70,7 @@
         }
 
         public DownloadRequest build() {
-            return new DownloadRequest(id, serviceInfo, source, dest, sub, appIntent);
+            return new DownloadRequest(id, serviceInfo, source, dest, sub, appIntent, appName);
         }
     }
 
@@ -78,16 +80,18 @@
     private final Uri destinationUri;
     private final int subId;
     private final String serializedResultIntentForApp;
+    private String appName; // not the Android app Name, the embms app name
 
     private DownloadRequest(int id, FileServiceInfo serviceInfo,
             Uri source, Uri dest,
-            int sub, String appIntent) {
+            int sub, String appIntent, String name) {
         downloadId = id;
         fileServiceInfo = serviceInfo;
         sourceUri = source;
         destinationUri = dest;
         subId = sub;
         serializedResultIntentForApp = appIntent;
+        appName = name;
     }
 
     public static DownloadRequest copy(DownloadRequest other) {
@@ -101,6 +105,7 @@
         destinationUri = dr.destinationUri;
         subId = dr.subId;
         serializedResultIntentForApp = dr.serializedResultIntentForApp;
+        appName = dr.appName;
     }
 
     private DownloadRequest(Parcel in) {
@@ -110,6 +115,7 @@
         destinationUri = in.readParcelable(getClass().getClassLoader());
         subId = in.readInt();
         serializedResultIntentForApp = in.readString();
+        appName = in.readString();
     }
 
     public int describeContents() {
@@ -123,6 +129,7 @@
         out.writeParcelable(destinationUri, flags);
         out.writeInt(subId);
         out.writeString(serializedResultIntentForApp);
+        out.writeString(appName);
     }
 
     public int getDownloadId() {
@@ -153,6 +160,18 @@
         }
     }
 
+    /** @hide */
+    public synchronized void setAppName(String newAppName) {
+        if (appName != null) {
+            throw new IllegalStateException("Attempting to reset appName");
+        }
+        appName = newAppName;
+    }
+
+    public String getAppName() {
+        return appName;
+    }
+
     public static final Parcelable.Creator<DownloadRequest> CREATOR =
             new Parcelable.Creator<DownloadRequest>() {
         public DownloadRequest createFromParcel(Parcel in) {
@@ -162,5 +181,4 @@
             return new DownloadRequest[size];
         }
     };
-
 }
diff --git a/telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl b/telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl
index 3090e12..6c2b816 100755
--- a/telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl
+++ b/telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl
@@ -50,20 +50,20 @@
     /**
      * should move the params into a DownloadRequest parcelable
      */
-    int download(String appName, in DownloadRequest downloadRequest, IDownloadCallback listener);
+    int download(in DownloadRequest downloadRequest, IDownloadCallback listener);
 
-    List<DownloadRequest> listPendingDownloads(String appName);
+    List<DownloadRequest> listPendingDownloads(String appName, int subscriptionId);
 
-    int cancelDownload(String appName, in DownloadRequest downloadRequest);
+    int cancelDownload(in DownloadRequest downloadRequest);
 
-    DownloadStatus getDownloadStatus(String appName, in DownloadRequest downloadRequest);
+    DownloadStatus getDownloadStatus(in DownloadRequest downloadRequest);
 
     /*
      * named this for 2 reasons:
      *  1 don't want 'State' here as it conflicts with 'Status' of the previous function
      *  2 want to perfect typing 'Knowledge'
      */
-    void resetDownloadKnowledge(String appName, in DownloadRequest downloadRequest);
+    void resetDownloadKnowledge(in DownloadRequest downloadRequest);
 
     /**
      * End of life for this MbmsDownloadManager.
diff --git a/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java b/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java
index 369aef1..505aeae 100644
--- a/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java
+++ b/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java
@@ -43,34 +43,34 @@
     }
 
     @Override
-    public int download(String appName, DownloadRequest downloadRequest, IDownloadCallback listener)
+    public int download(DownloadRequest downloadRequest, IDownloadCallback listener)
             throws RemoteException {
         return 0;
     }
 
     @Override
-    public List<DownloadRequest> listPendingDownloads(String appName) throws RemoteException {
+    public List<DownloadRequest> listPendingDownloads(String appName, int subscriptionId)
+            throws RemoteException {
         return null;
     }
 
     @Override
-    public int cancelDownload(String appName, DownloadRequest downloadRequest)
-            throws RemoteException {
+    public int cancelDownload(DownloadRequest downloadRequest) throws RemoteException {
         return 0;
     }
 
     @Override
-    public DownloadStatus getDownloadStatus(String appName, DownloadRequest downloadRequest)
+    public DownloadStatus getDownloadStatus(DownloadRequest downloadRequest)
             throws RemoteException {
         return null;
     }
 
     @Override
-    public void resetDownloadKnowledge(String appName, DownloadRequest downloadRequest)
+    public void resetDownloadKnowledge(DownloadRequest downloadRequest)
             throws RemoteException {
     }
 
     @Override
-    public void dispose(String appName, int subId) throws RemoteException {
+    public void dispose(String appName, int subscriptionId) throws RemoteException {
     }
 }