From 563e150c2d806f2c616851d19de8b3d6dbfb699f Mon Sep 17 00:00:00 2001 From: Hall Liu Date: Tue, 25 Apr 2017 15:04:26 -0700 Subject: [PATCH] eMBMS API update Brings eMBMS APIs into alignment with the architecture doc. All APIs are hidden for now. Test: builds Change-Id: I6e692bd363f998d1cd8f80faa72bde71ffe8fd2e --- Android.mk | 8 +- .../telephony/MbmsDownloadManager.java | 202 +++++++++++++++--- .../telephony/MbmsStreamingManager.java | 79 +++++-- ...oadListener.java => DownloadCallback.java} | 2 +- .../telephony/mbms/DownloadRequest.java | 120 +++++++++-- ...adListener.aidl => IDownloadCallback.aidl} | 2 +- ...aidl => IMbmsDownloadManagerCallback.aidl} | 2 +- ...idl => IMbmsStreamingManagerCallback.aidl} | 2 +- ...er.aidl => IStreamingServiceCallback.aidl} | 5 +- ....java => MbmsDownloadManagerCallback.java} | 2 +- .../mbms/MbmsInitializationException.java | 32 +++ ...java => MbmsStreamingManagerCallback.java} | 2 +- .../telephony/mbms/StreamingService.java | 2 +- ...ner.java => StreamingServiceCallback.java} | 4 +- .../android/telephony/mbms/UriPathPair.aidl | 20 ++ .../android/telephony/mbms/UriPathPair.java | 80 +++++++ .../mbms/vendor/IMbmsDownloadService.aidl | 16 +- .../mbms/vendor/IMbmsStreamingService.aidl | 8 +- .../mbms/vendor/MbmsDownloadServiceBase.java | 76 +++++++ .../mbms/vendor/MbmsStreamingServiceBase.java | 82 +++++++ 20 files changed, 649 insertions(+), 97 deletions(-) rename telephony/java/android/telephony/mbms/{DownloadListener.java => DownloadCallback.java} (96%) rename telephony/java/android/telephony/mbms/{IDownloadListener.aidl => IDownloadCallback.aidl} (97%) rename telephony/java/android/telephony/mbms/{IMbmsDownloadManagerListener.aidl => IMbmsDownloadManagerCallback.aidl} (97%) rename telephony/java/android/telephony/mbms/{IMbmsStreamingManagerListener.aidl => IMbmsStreamingManagerCallback.aidl} (97%) rename telephony/java/android/telephony/mbms/{IStreamingServiceListener.aidl => IStreamingServiceCallback.aidl} (84%) rename telephony/java/android/telephony/mbms/{MbmsDownloadManagerListener.java => MbmsDownloadManagerCallback.java} (95%) create mode 100644 telephony/java/android/telephony/mbms/MbmsInitializationException.java rename telephony/java/android/telephony/mbms/{MbmsStreamingManagerListener.java => MbmsStreamingManagerCallback.java} (96%) rename telephony/java/android/telephony/mbms/{StreamingServiceListener.java => StreamingServiceCallback.java} (93%) create mode 100755 telephony/java/android/telephony/mbms/UriPathPair.aidl create mode 100644 telephony/java/android/telephony/mbms/UriPathPair.java create mode 100644 telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java create mode 100644 telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java diff --git a/Android.mk b/Android.mk index 623ceba9c65fb..620b7a51ddded 100644 --- a/Android.mk +++ b/Android.mk @@ -432,10 +432,10 @@ LOCAL_SRC_FILES += \ telecomm/java/com/android/internal/telecom/IInCallService.aidl \ telecomm/java/com/android/internal/telecom/ITelecomService.aidl \ telecomm/java/com/android/internal/telecom/RemoteServiceCallback.aidl \ - telephony/java/android/telephony/mbms/IMbmsDownloadManagerListener.aidl \ - telephony/java/android/telephony/mbms/IMbmsStreamingManagerListener.aidl \ - telephony/java/android/telephony/mbms/IDownloadListener.aidl \ - telephony/java/android/telephony/mbms/IStreamingServiceListener.aidl \ + telephony/java/android/telephony/mbms/IMbmsDownloadManagerCallback.aidl \ + telephony/java/android/telephony/mbms/IMbmsStreamingManagerCallback.aidl \ + telephony/java/android/telephony/mbms/IDownloadCallback.aidl \ + telephony/java/android/telephony/mbms/IStreamingServiceCallback.aidl \ telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl \ telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl \ telephony/java/com/android/ims/internal/IImsCallSession.aidl \ diff --git a/telephony/java/android/telephony/MbmsDownloadManager.java b/telephony/java/android/telephony/MbmsDownloadManager.java index bb4bf1e838fbd..862c91942d601 100644 --- a/telephony/java/android/telephony/MbmsDownloadManager.java +++ b/telephony/java/android/telephony/MbmsDownloadManager.java @@ -16,14 +16,16 @@ package android.telephony; -import android.app.PendingIntent; import android.content.Context; import android.net.Uri; -import android.telephony.mbms.DownloadListener; +import android.os.RemoteException; +import android.telephony.mbms.DownloadCallback; import android.telephony.mbms.DownloadRequest; import android.telephony.mbms.DownloadStatus; -import android.telephony.mbms.FileServiceInfo; -import android.telephony.mbms.IMbmsDownloadManagerListener; +import android.telephony.mbms.IMbmsDownloadManagerCallback; +import android.telephony.mbms.MbmsInitializationException; +import android.telephony.mbms.vendor.IMbmsDownloadService; +import android.util.Log; import java.util.List; @@ -31,9 +33,135 @@ import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID; /** @hide */ public class MbmsDownloadManager { + private static final String LOG_TAG = MbmsDownloadManager.class.getSimpleName(); + + /** + * The MBMS middleware should send this when a download of single file has completed or + * failed. Mandatory extras are + * {@link #EXTRA_RESULT} + * {@link #EXTRA_INFO} + * {@link #EXTRA_REQUEST} + * {@link #EXTRA_TEMP_LIST} + * {@link #EXTRA_FINAL_URI} + * + * TODO: future systemapi + */ + public static final String ACTION_DOWNLOAD_RESULT_INTERNAL = + "android.telephony.mbms.action.DOWNLOAD_RESULT_INTERNAL"; + + /** + * The MBMS middleware should send this when it wishes to request {@code content://} URIs to + * serve as temp files for downloads or when it wishes to resume paused downloads. Mandatory + * extras are + * {@link #EXTRA_REQUEST} + * + * Optional extras are + * {@link #EXTRA_FD_COUNT} (0 if not present) + * {@link #EXTRA_PAUSED_LIST} (empty if not present) + * + * TODO: future systemapi + */ + public static final String ACTION_FILE_DESCRIPTOR_REQUEST = + "android.telephony.mbms.action.FILE_DESCRIPTOR_REQUEST"; + + /** + * The MBMS middleware should send this when it wishes to clean up temp files in the app's + * filesystem. Mandatory extras are: + * {@link #EXTRA_TEMP_FILES_IN_USE} + * + * TODO: future systemapi + */ + public static final String ACTION_CLEANUP = + "android.telephony.mbms.action.CLEANUP"; + + /** + * Integer extra indicating the result code of the download. + * TODO: put in link to error list + * TODO: future systemapi (here and and all extras) + */ + public static final String EXTRA_RESULT = "android.telephony.mbms.extra.RESULT"; + + /** + * Extra containing the {@link android.telephony.mbms.FileInfo} for which the download result + * is for. Must not be null. + */ + public static final String EXTRA_INFO = "android.telephony.mbms.extra.INFO"; + + /** + * Extra containing the {@link DownloadRequest} for which the download result or file + * descriptor request is for. Must not be null. + */ + public static final String EXTRA_REQUEST = "android.telephony.mbms.extra.REQUEST"; + + /** + * Extra containing a {@link List} of {@link Uri}s that were used as temp files for this + * completed file. These {@link Uri}s should have scheme {@code file://}, and the temp + * files will be deleted upon receipt of the intent. + * May be null. + */ + public static final String EXTRA_TEMP_LIST = "android.telephony.mbms.extra.TEMP_LIST"; + + /** + * Extra containing a single {@link Uri} indicating the path to the temp file in which the + * decoded downloaded file resides. Must not be null. + */ + public static final String EXTRA_FINAL_URI = "android.telephony.mbms.extra.FINAL_URI"; + + /** + * Extra containing an integer indicating the number of temp files requested. + */ + public static final String EXTRA_FD_COUNT = "android.telephony.mbms.extra.FD_COUNT"; + + /** + * Extra containing a list of {@link Uri}s that the middleware is requesting access to via + * {@link #ACTION_FILE_DESCRIPTOR_REQUEST} in order to resume downloading. These {@link Uri}s + * should have scheme {@code file://}. + */ + public static final String EXTRA_PAUSED_LIST = "android.telephony.mbms.extra.PAUSED_LIST"; + + /** + * Extra containing a list of {@link android.telephony.mbms.UriPathPair}s, used in the + * response to {@link #ACTION_FILE_DESCRIPTOR_REQUEST}. These are temp files that are meant + * to be used for new file downloads. + */ + public static final String EXTRA_FREE_URI_LIST = "android.telephony.mbms.extra.FREE_URI_LIST"; + + /** + * Extra containing a list of {@link android.telephony.mbms.UriPathPair}s, used in the + * response to {@link #ACTION_FILE_DESCRIPTOR_REQUEST}. These + * {@link android.telephony.mbms.UriPathPair}s contain {@code content://} URIs that provide + * access to previously paused downloads. + */ + public static final String EXTRA_PAUSED_URI_LIST = + "android.telephony.mbms.extra.PAUSED_URI_LIST"; + + /** + * Extra containing a list of {@link Uri}s indicating temp files which the middleware is + * still using. + */ + public static final String EXTRA_TEMP_FILES_IN_USE = + "android.telephony.mbms.extra.TEMP_FILES_IN_USE"; + + public static final int RESULT_SUCCESSFUL = 1; + public static final int RESULT_CANCELLED = 2; + public static final int RESULT_EXPIRED = 3; + // TODO - more results! + private final Context mContext; private int mSubId = INVALID_SUBSCRIPTION_ID; + private IMbmsDownloadService mService; + private final IMbmsDownloadManagerCallback mCallback; + private final String mDownloadAppName; + + private MbmsDownloadManager(Context context, IMbmsDownloadManagerCallback callback, + String downloadAppName, int subId) { + mContext = context; + mCallback = callback; + mDownloadAppName = downloadAppName; + mSubId = subId; + } + /** * Create a new MbmsDownloadManager using the system default data subscription ID. * @@ -42,9 +170,13 @@ public class MbmsDownloadManager { * * @hide */ - public MbmsDownloadManager(Context context, IMbmsDownloadManagerListener listener, - String downloadAppName) { - mContext = context; + public static MbmsDownloadManager createManager(Context context, + IMbmsDownloadManagerCallback listener, String downloadAppName) + throws MbmsInitializationException{ + MbmsDownloadManager mdm = new MbmsDownloadManager(context, listener, downloadAppName, + SubscriptionManager.getDefaultSubscriptionId()); + mdm.bindAndInitialize(); + return mdm; } /** @@ -55,9 +187,23 @@ public class MbmsDownloadManager { * * @hide */ - public MbmsDownloadManager(Context context, IMbmsDownloadManagerListener listener, - String downloadAppName, int subId) { - mContext = context; + + public static MbmsDownloadManager createManager(Context context, + IMbmsDownloadManagerCallback listener, String downloadAppName, int subId) + throws MbmsInitializationException { + MbmsDownloadManager mdm = new MbmsDownloadManager(context, listener, downloadAppName, + subId); + mdm.bindAndInitialize(); + return mdm; + } + + private void bindAndInitialize() throws MbmsInitializationException { + // TODO: bind + try { + mService.initialize(mDownloadAppName, mSubId, mCallback); + } catch (RemoteException e) { + throw new MbmsInitializationException(0); // TODO: proper error code + } } /** @@ -84,31 +230,9 @@ public class MbmsDownloadManager { } - public static final String EXTRA_REQUEST = "extraRequest"; - - public static final int RESULT_SUCCESSFUL = 1; - public static final int RESULT_CANCELLED = 2; - public static final int RESULT_EXPIRED = 3; - // TODO - more results! - - public static final String EXTRA_RESULT = "extraResult"; - public static final String EXTRA_URI = "extraDownloadedUri"; - /** * Requests a future download. * returns a token which may be used to cancel a download. - * fileServiceInfo indicates what FileService to download from - * source indicates which file to download from the given FileService. This is - * an optional field - it may be null or empty to indicate download everything from - * the FileService. - * destination is a file URI for where in the apps accessible storage locations to write - * the content. This URI may be used to store temporary data and should not be - * accessed until the PendingIntent is called indicating success. - * resultIntent is sent when each file is completed and when the request is concluded - * either via TTL expiration, cancel or error. - * This intent is sent with three extras: a {@link DownloadRequest} typed extra called - * {@link #EXTRA_REQUEST}, an Integer called {@link #EXTRA_RESULT} for the result code - * and a {@link Uri} called {@link #EXTRA_URI} to the resulting file (if successful). * downloadListener is an optional callback object which can be used to get progress reports * of a currently occuring download. Note this can only run while the calling app * is running, so future downloads will simply result in resultIntents being sent @@ -118,7 +242,7 @@ public class MbmsDownloadManager { * * Asynchronous errors through the listener include any of the errors */ - public DownloadRequest download(DownloadRequest downloadRequest, DownloadListener listener) { + public DownloadRequest download(DownloadRequest downloadRequest, DownloadCallback listener) { return null; } @@ -168,7 +292,7 @@ public class MbmsDownloadManager { } /** - * Resets middleware knowldge regarding this download request. + * Resets middleware knowledge regarding this download request. * * This state consists of knowledge of what files have already been downloaded. * Normally the middleware won't download files who's hash matches previously downloaded @@ -187,5 +311,15 @@ public class MbmsDownloadManager { } public void dispose() { + try { + if (mService != null) { + mService.dispose(mDownloadAppName, mSubId); + } else { + Log.i(LOG_TAG, "Service already dead"); + } + } catch (RemoteException e) { + // Ignore + Log.i(LOG_TAG, "Remote exception while disposing of service"); + } } } diff --git a/telephony/java/android/telephony/MbmsStreamingManager.java b/telephony/java/android/telephony/MbmsStreamingManager.java index 9a2ba6de93deb..770a04a8881ae 100644 --- a/telephony/java/android/telephony/MbmsStreamingManager.java +++ b/telephony/java/android/telephony/MbmsStreamingManager.java @@ -17,10 +17,13 @@ package android.telephony; import android.content.Context; -import android.telephony.mbms.IMbmsStreamingManagerListener; -import android.telephony.mbms.IStreamingServiceListener; +import android.os.RemoteException; +import android.telephony.mbms.IMbmsStreamingManagerCallback; +import android.telephony.mbms.IStreamingServiceCallback; +import android.telephony.mbms.MbmsInitializationException; import android.telephony.mbms.StreamingService; import android.telephony.mbms.StreamingServiceInfo; +import android.telephony.mbms.vendor.IMbmsStreamingService; import android.util.Log; import java.util.List; @@ -31,19 +34,20 @@ import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID; public class MbmsStreamingManager { private static final String LOG_TAG = "MbmsStreamingManager"; private static final boolean DEBUG = true; + private IMbmsStreamingService mService; + private IMbmsStreamingManagerCallback mCallbackToApp; + private final String mAppName; private final Context mContext; - private int mSubId = INVALID_SUBSCRIPTION_ID; + private int mSubscriptionId = INVALID_SUBSCRIPTION_ID; - /** - * Create a new MbmsStreamingManager using the system default data subscription ID. - * - * Note that this call will bind a remote service and that may take a bit. This - * may throw an IllegalArgumentException or RemoteException. - */ - public MbmsStreamingManager(Context context, IMbmsStreamingManagerListener listener, - String streamingAppName) { + /** @hide */ + private MbmsStreamingManager(Context context, IMbmsStreamingManagerCallback listener, + String streamingAppName, int subscriptionId) { mContext = context; + mAppName = streamingAppName; + mCallbackToApp = listener; + mSubscriptionId = subscriptionId; } /** @@ -51,10 +55,39 @@ public class MbmsStreamingManager { * * Note that this call will bind a remote service and that may take a bit. This * may throw an IllegalArgumentException or RemoteException. + * TODO: document this and add exceptions that can be thrown for synchronous + * initialization/bind errors + * + * @param context + * @param listener + * @param streamingAppName + * @param subscriptionId + * @return */ - public MbmsStreamingManager(Context context, IMbmsStreamingManagerListener listener, - String streamingAppName, int subId) { - mContext = context; + public static MbmsStreamingManager create(Context context, + IMbmsStreamingManagerCallback listener, String streamingAppName, int subscriptionId) + throws MbmsInitializationException { + MbmsStreamingManager manager = new MbmsStreamingManager(context, listener, + streamingAppName, subscriptionId); + manager.bindAndInitialize(); + return manager; + } + + /** + * Create a new MbmsStreamingManager using the system default data subscription ID. + * + * Note that this call will bind a remote service and that may take a bit. This + * may throw an IllegalArgumentException or RemoteException. + */ + public static MbmsStreamingManager create(Context context, + IMbmsStreamingManagerCallback listener, String streamingAppName) + throws MbmsInitializationException { + // TODO: get default sub id + int subId = INVALID_SUBSCRIPTION_ID; + MbmsStreamingManager manager = new MbmsStreamingManager(context, listener, + streamingAppName, subId); + manager.bindAndInitialize(); + return manager; } /** @@ -97,7 +130,7 @@ public class MbmsStreamingManager { * Asynchronous errors through the listener include any of the errors */ public StreamingService startStreaming(StreamingServiceInfo serviceInfo, - IStreamingServiceListener listener) { + IStreamingServiceCallback listener) { return null; } @@ -125,4 +158,20 @@ public class MbmsStreamingManager { private void logd(String str) { Log.d(LOG_TAG, str); } + + private boolean isServiceConnected() { + return mService != null; + } + + private void bindAndInitialize() throws MbmsInitializationException { + // TODO: bind to the service + try { + int returnCode = mService.initialize(mCallbackToApp, mAppName, mSubscriptionId); + if (returnCode != 0) { + throw new MbmsInitializationException(returnCode); + } + } catch (RemoteException e) { + throw new MbmsInitializationException(/* some error */ 0); + } + } } diff --git a/telephony/java/android/telephony/mbms/DownloadListener.java b/telephony/java/android/telephony/mbms/DownloadCallback.java similarity index 96% rename from telephony/java/android/telephony/mbms/DownloadListener.java rename to telephony/java/android/telephony/mbms/DownloadCallback.java index 8d1bd024a5db6..0c6fec4b9c75e 100644 --- a/telephony/java/android/telephony/mbms/DownloadListener.java +++ b/telephony/java/android/telephony/mbms/DownloadCallback.java @@ -20,7 +20,7 @@ package android.telephony.mbms; * A optional listener class used by download clients to track progress. * @hide */ -public class DownloadListener extends IDownloadListener.Stub { +public class DownloadCallback extends IDownloadCallback.Stub { /** * Gives process callbacks for a given DownloadRequest. * request indicates which download is being referenced. diff --git a/telephony/java/android/telephony/mbms/DownloadRequest.java b/telephony/java/android/telephony/mbms/DownloadRequest.java index 42a82da94d316..dbaf10bb68eb5 100644 --- a/telephony/java/android/telephony/mbms/DownloadRequest.java +++ b/telephony/java/android/telephony/mbms/DownloadRequest.java @@ -16,44 +16,101 @@ package android.telephony.mbms; -import android.app.PendingIntent; +import android.content.Intent; import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; +import java.net.URISyntaxException; + /** * A Parcelable class describing a pending Cell-Broadcast download request * @hide */ public class DownloadRequest implements Parcelable { - public DownloadRequest(int id, FileServiceInfo serviceInfo, Uri source, Uri dest, - PendingIntent resultPI, int sub) { + /** @hide */ + public static class Builder { + private int id; + private FileServiceInfo serviceInfo; + private Uri source; + private Uri dest; + private int sub; + private String appIntent; + + public Builder setId(int id) { + this.id = id; + return this; + } + + public Builder setServiceInfo(FileServiceInfo serviceInfo) { + this.serviceInfo = serviceInfo; + return this; + } + + public Builder setSource(Uri source) { + this.source = source; + return this; + } + + public Builder setDest(Uri dest) { + this.dest = dest; + return this; + } + + public Builder setSub(int sub) { + this.sub = sub; + return this; + } + + public Builder setAppIntent(Intent intent) { + this.appIntent = intent.toUri(0); + return this; + } + + public DownloadRequest build() { + return new DownloadRequest(id, serviceInfo, source, dest, sub, appIntent); + } + } + + private final int downloadId; + private final FileServiceInfo fileServiceInfo; + private final Uri sourceUri; + private final Uri destinationUri; + private final int subId; + private final String serializedResultIntentForApp; + + private DownloadRequest(int id, FileServiceInfo serviceInfo, + Uri source, Uri dest, + int sub, String appIntent) { downloadId = id; fileServiceInfo = serviceInfo; sourceUri = source; destinationUri = dest; subId = sub; + serializedResultIntentForApp = appIntent; } - /** @hide */ - public DownloadRequest(DownloadRequest dr, PendingIntent fdRequestPI, PendingIntent cleanupPI) { + public static DownloadRequest copy(DownloadRequest other) { + return new DownloadRequest(other); + } + + private DownloadRequest(DownloadRequest dr) { downloadId = dr.downloadId; fileServiceInfo = dr.fileServiceInfo; sourceUri = dr.sourceUri; destinationUri = dr.destinationUri; subId = dr.subId; - /* - * resultPI = new PI - * fileDescriptorRequstPI = fdRequestPI; - * this.cleanupPI = cleanupPI; - */ + serializedResultIntentForApp = dr.serializedResultIntentForApp; } - public final int downloadId; - public final FileServiceInfo fileServiceInfo; - public final Uri sourceUri; - public final Uri destinationUri; - public final int subId; + private DownloadRequest(Parcel in) { + downloadId = in.readInt(); + fileServiceInfo = in.readParcelable(getClass().getClassLoader()); + sourceUri = in.readParcelable(getClass().getClassLoader()); + destinationUri = in.readParcelable(getClass().getClassLoader()); + subId = in.readInt(); + serializedResultIntentForApp = in.readString(); + } public int describeContents() { return 0; @@ -65,14 +122,35 @@ public class DownloadRequest implements Parcelable { out.writeParcelable(sourceUri, flags); out.writeParcelable(destinationUri, flags); out.writeInt(subId); + out.writeString(serializedResultIntentForApp); } - private DownloadRequest(Parcel in) { - downloadId = in.readInt(); - fileServiceInfo = in.readParcelable(null); - sourceUri = in.readParcelable(null); - destinationUri = in.readParcelable(null); - subId = in.readInt(); + public int getDownloadId() { + return downloadId; + } + + public FileServiceInfo getFileServiceInfo() { + return fileServiceInfo; + } + + public Uri getSourceUri() { + return sourceUri; + } + + public Uri getDestinationUri() { + return destinationUri; + } + + public int getSubId() { + return subId; + } + + public Intent getIntentForApp() { + try { + return Intent.parseUri(serializedResultIntentForApp, 0); + } catch (URISyntaxException e) { + return null; + } } public static final Parcelable.Creator CREATOR = diff --git a/telephony/java/android/telephony/mbms/IDownloadListener.aidl b/telephony/java/android/telephony/mbms/IDownloadCallback.aidl similarity index 97% rename from telephony/java/android/telephony/mbms/IDownloadListener.aidl rename to telephony/java/android/telephony/mbms/IDownloadCallback.aidl index 9838682f2bb84..a6bd7e5f84f9b 100755 --- a/telephony/java/android/telephony/mbms/IDownloadListener.aidl +++ b/telephony/java/android/telephony/mbms/IDownloadCallback.aidl @@ -23,7 +23,7 @@ import android.telephony.mbms.FileInfo; * The optional interface used by download clients to track progress. * @hide */ -interface IDownloadListener +interface IDownloadCallback { /** * Gives progress callbacks for a given DownloadRequest. Includes a FileInfo diff --git a/telephony/java/android/telephony/mbms/IMbmsDownloadManagerListener.aidl b/telephony/java/android/telephony/mbms/IMbmsDownloadManagerCallback.aidl similarity index 97% rename from telephony/java/android/telephony/mbms/IMbmsDownloadManagerListener.aidl rename to telephony/java/android/telephony/mbms/IMbmsDownloadManagerCallback.aidl index 6b5c0217f1fc8..03227d0d9f5ab 100755 --- a/telephony/java/android/telephony/mbms/IMbmsDownloadManagerListener.aidl +++ b/telephony/java/android/telephony/mbms/IMbmsDownloadManagerCallback.aidl @@ -24,7 +24,7 @@ import java.util.List; * The interface the clients top-level file download listener will satisfy. * @hide */ -interface IMbmsDownloadManagerListener +interface IMbmsDownloadManagerCallback { void error(int errorCode, String message); diff --git a/telephony/java/android/telephony/mbms/IMbmsStreamingManagerListener.aidl b/telephony/java/android/telephony/mbms/IMbmsStreamingManagerCallback.aidl similarity index 97% rename from telephony/java/android/telephony/mbms/IMbmsStreamingManagerListener.aidl rename to telephony/java/android/telephony/mbms/IMbmsStreamingManagerCallback.aidl index 80176bfa55e40..cbf0fca461f0d 100755 --- a/telephony/java/android/telephony/mbms/IMbmsStreamingManagerListener.aidl +++ b/telephony/java/android/telephony/mbms/IMbmsStreamingManagerCallback.aidl @@ -24,7 +24,7 @@ import java.util.List; * The interface the clients top-level streaming listener will satisfy. * @hide */ -interface IMbmsStreamingManagerListener +interface IMbmsStreamingManagerCallback { void error(int errorCode, String message); diff --git a/telephony/java/android/telephony/mbms/IStreamingServiceListener.aidl b/telephony/java/android/telephony/mbms/IStreamingServiceCallback.aidl similarity index 84% rename from telephony/java/android/telephony/mbms/IStreamingServiceListener.aidl rename to telephony/java/android/telephony/mbms/IStreamingServiceCallback.aidl index a41aca30a1913..7b4ecf25ea9c7 100755 --- a/telephony/java/android/telephony/mbms/IStreamingServiceListener.aidl +++ b/telephony/java/android/telephony/mbms/IStreamingServiceCallback.aidl @@ -18,13 +18,14 @@ package android.telephony.mbms; import android.net.Uri; import android.telephony.SignalStrength; +import android.telephony.mbms.StreamingService; /** * @hide */ -oneway interface IStreamingServiceListener { +oneway interface IStreamingServiceCallback { void error(int errorCode, String message); - void stateUpdated(int state); + void streamStateChanged(in StreamingService service, int state); void uriUpdated(in Uri uri); void signalStrengthUpdated(in SignalStrength signalStrength); } diff --git a/telephony/java/android/telephony/mbms/MbmsDownloadManagerListener.java b/telephony/java/android/telephony/mbms/MbmsDownloadManagerCallback.java similarity index 95% rename from telephony/java/android/telephony/mbms/MbmsDownloadManagerListener.java rename to telephony/java/android/telephony/mbms/MbmsDownloadManagerCallback.java index 04c2f9ac5dbdb..16fafe415b0f3 100644 --- a/telephony/java/android/telephony/mbms/MbmsDownloadManagerListener.java +++ b/telephony/java/android/telephony/mbms/MbmsDownloadManagerCallback.java @@ -22,7 +22,7 @@ import java.util.List; * A Parcelable class with Cell-Broadcast service information. * @hide */ -public class MbmsDownloadManagerListener extends IMbmsDownloadManagerListener.Stub { +public class MbmsDownloadManagerCallback extends IMbmsDownloadManagerCallback.Stub { public final static int ERROR_CARRIER_NOT_SUPPORTED = 1; public final static int ERROR_UNABLE_TO_INITIALIZE = 2; diff --git a/telephony/java/android/telephony/mbms/MbmsInitializationException.java b/telephony/java/android/telephony/mbms/MbmsInitializationException.java new file mode 100644 index 0000000000000..1612bc9cc1b32 --- /dev/null +++ b/telephony/java/android/telephony/mbms/MbmsInitializationException.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2017 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.mbms; + +/** @hide */ +public class MbmsInitializationException extends Exception { + private final int mErrorCode; + + /** @hide */ + public MbmsInitializationException(int errorCode) { + super(); + mErrorCode = errorCode; + } + + public int getErrorCode() { + return mErrorCode; + } +} diff --git a/telephony/java/android/telephony/mbms/MbmsStreamingManagerListener.java b/telephony/java/android/telephony/mbms/MbmsStreamingManagerCallback.java similarity index 96% rename from telephony/java/android/telephony/mbms/MbmsStreamingManagerListener.java rename to telephony/java/android/telephony/mbms/MbmsStreamingManagerCallback.java index c64ad440ed181..b3bc8146275eb 100644 --- a/telephony/java/android/telephony/mbms/MbmsStreamingManagerListener.java +++ b/telephony/java/android/telephony/mbms/MbmsStreamingManagerCallback.java @@ -22,7 +22,7 @@ import java.util.List; * A Parcelable class with Cell-Broadcast service information. * @hide */ -public class MbmsStreamingManagerListener extends IMbmsStreamingManagerListener.Stub { +public class MbmsStreamingManagerCallback extends IMbmsStreamingManagerCallback.Stub { public final static int ERROR_CARRIER_NOT_SUPPORTED = 1; public final static int ERROR_UNABLE_TO_INITIALIZE = 2; diff --git a/telephony/java/android/telephony/mbms/StreamingService.java b/telephony/java/android/telephony/mbms/StreamingService.java index ee0d89421fa96..8cc604356badb 100644 --- a/telephony/java/android/telephony/mbms/StreamingService.java +++ b/telephony/java/android/telephony/mbms/StreamingService.java @@ -33,7 +33,7 @@ public class StreamingService { /** */ StreamingService(StreamingServiceInfo streamingServiceInfo, - IStreamingServiceListener listener) { + IStreamingServiceCallback listener) { } /** diff --git a/telephony/java/android/telephony/mbms/StreamingServiceListener.java b/telephony/java/android/telephony/mbms/StreamingServiceCallback.java similarity index 93% rename from telephony/java/android/telephony/mbms/StreamingServiceListener.java rename to telephony/java/android/telephony/mbms/StreamingServiceCallback.java index bc5aebbbd6b3d..7f5c486f8d903 100644 --- a/telephony/java/android/telephony/mbms/StreamingServiceListener.java +++ b/telephony/java/android/telephony/mbms/StreamingServiceCallback.java @@ -23,7 +23,7 @@ import android.telephony.SignalStrength; * A Callback class for use when the applicaiton is actively streaming content. * @hide */ -public class StreamingServiceListener extends IStreamingServiceListener.Stub { +public class StreamingServiceCallback extends IStreamingServiceCallback.Stub { public void error(int errorCode, String message) { @@ -36,7 +36,7 @@ public class StreamingServiceListener extends IStreamingServiceListener.Stub { * See {@link StreamingService#STATE_STOPPED}, {@link StreamingService#STATE_STARTED} * and {@link StreamingService#STATE_STALLED}. */ - public void stateUpdated(int state) { + public void streamStateChanged(StreamingService service, int state) { // default implementation empty } diff --git a/telephony/java/android/telephony/mbms/UriPathPair.aidl b/telephony/java/android/telephony/mbms/UriPathPair.aidl new file mode 100755 index 0000000000000..8bf768246da95 --- /dev/null +++ b/telephony/java/android/telephony/mbms/UriPathPair.aidl @@ -0,0 +1,20 @@ +/* +** +** Copyright 2016, 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.mbms; + +parcelable UriPathPair; diff --git a/telephony/java/android/telephony/mbms/UriPathPair.java b/telephony/java/android/telephony/mbms/UriPathPair.java new file mode 100644 index 0000000000000..7acc270ed7291 --- /dev/null +++ b/telephony/java/android/telephony/mbms/UriPathPair.java @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2017 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.mbms; + +import android.content.ContentResolver; +import android.net.Uri; +import android.os.Parcel; +import android.os.Parcelable; + +/** @hide */ +public class UriPathPair implements Parcelable { + private final Uri mFilePathUri; + private final Uri mContentUri; + + /** @hide */ + public UriPathPair(Uri fileUri, Uri contentUri) { + if (fileUri == null || !ContentResolver.SCHEME_FILE.equals(fileUri.getScheme())) { + throw new IllegalArgumentException("File URI must have file scheme"); + } + if (contentUri == null || !ContentResolver.SCHEME_CONTENT.equals(contentUri.getScheme())) { + throw new IllegalArgumentException("Content URI must have content scheme"); + } + + mFilePathUri = fileUri; + mContentUri = contentUri; + } + + /** @hide */ + protected UriPathPair(Parcel in) { + mFilePathUri = in.readParcelable(Uri.class.getClassLoader()); + mContentUri = in.readParcelable(Uri.class.getClassLoader()); + } + + public static final Creator CREATOR = new Creator() { + @Override + public UriPathPair createFromParcel(Parcel in) { + return new UriPathPair(in); + } + + @Override + public UriPathPair[] newArray(int size) { + return new UriPathPair[size]; + } + }; + + /** future systemapi */ + public Uri getFilePathUri() { + return mFilePathUri; + } + + /** future systemapi */ + public Uri getContentUri() { + return mContentUri; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeParcelable(mFilePathUri, flags); + dest.writeParcelable(mContentUri, flags); + } +} diff --git a/telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl b/telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl index 4ec40dafc301c..3090e1275f54d 100755 --- a/telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl +++ b/telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl @@ -20,8 +20,8 @@ import android.app.PendingIntent; import android.net.Uri; import android.telephony.mbms.DownloadRequest; import android.telephony.mbms.DownloadStatus; -import android.telephony.mbms.IMbmsDownloadManagerListener; -import android.telephony.mbms.IDownloadListener; +import android.telephony.mbms.IMbmsDownloadManagerCallback; +import android.telephony.mbms.IDownloadCallback; /** * The interface the opaque MbmsStreamingService will satisfy. @@ -35,7 +35,7 @@ interface IMbmsDownloadService * * No return value. Async errors may be reported, but none expected (not doing anything yet). */ - void initialize(String appName, int subId, IMbmsDownloadManagerListener listener); + void initialize(String appName, int subId, IMbmsDownloadManagerCallback listener); /** * - Registers serviceClasses of interest with the uid/appName/subId key. @@ -50,20 +50,20 @@ interface IMbmsDownloadService /** * should move the params into a DownloadRequest parcelable */ - int download(in DownloadRequest downloadRequest, IDownloadListener listener); + int download(String appName, in DownloadRequest downloadRequest, IDownloadCallback listener); - List listPendingDownloads(); + List listPendingDownloads(String appName); - int cancelDownload(in DownloadRequest downloadRequest); + int cancelDownload(String appName, in DownloadRequest downloadRequest); - DownloadStatus getDownloadStatus(in DownloadRequest downloadRequest); + DownloadStatus getDownloadStatus(String appName, 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(in DownloadRequest downloadRequest); + void resetDownloadKnowledge(String appName, in DownloadRequest downloadRequest); /** * End of life for this MbmsDownloadManager. diff --git a/telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl b/telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl index cb83969b09582..fbc093134abad 100755 --- a/telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl +++ b/telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl @@ -17,8 +17,8 @@ package android.telephony.mbms.vendor; import android.net.Uri; -import android.telephony.mbms.IMbmsStreamingManagerListener; -import android.telephony.mbms.IStreamingServiceListener; +import android.telephony.mbms.IMbmsStreamingManagerCallback; +import android.telephony.mbms.IStreamingServiceCallback; import android.telephony.mbms.StreamingService; import android.telephony.mbms.StreamingServiceInfo; import android.telephony.SignalStrength; @@ -34,7 +34,7 @@ interface IMbmsStreamingService * Registers this listener, subId with this appName * */ - int initialize(IMbmsStreamingManagerListener listener, String appName, int subId); + int initialize(IMbmsStreamingManagerCallback listener, String appName, int subId); /** @@ -55,7 +55,7 @@ interface IMbmsStreamingService * URL-change and State-change pair. */ StreamingService startStreaming(String appName, int subId, String serviceId, - IStreamingServiceListener listener); + IStreamingServiceCallback listener); /** * Asynchronously fetches all Services being streamed by this uid/appName/subId. diff --git a/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java b/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java new file mode 100644 index 0000000000000..369aef1c2c684 --- /dev/null +++ b/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2017 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.mbms.vendor; + +import android.os.RemoteException; +import android.telephony.mbms.DownloadRequest; +import android.telephony.mbms.DownloadStatus; +import android.telephony.mbms.IDownloadCallback; +import android.telephony.mbms.IMbmsDownloadManagerCallback; + +import java.util.List; + +/** + * Base class for MbmsDownloadService. The middleware should extend this base class rather than + * the aidl stub for compatibility + * @hide + * TODO: future systemapi + */ +public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub { + @Override + public void initialize(String appName, int subId, IMbmsDownloadManagerCallback listener) + throws RemoteException { + } + + @Override + public int getFileServices(String appName, int subId, List serviceClasses) throws + RemoteException { + return 0; + } + + @Override + public int download(String appName, DownloadRequest downloadRequest, IDownloadCallback listener) + throws RemoteException { + return 0; + } + + @Override + public List listPendingDownloads(String appName) throws RemoteException { + return null; + } + + @Override + public int cancelDownload(String appName, DownloadRequest downloadRequest) + throws RemoteException { + return 0; + } + + @Override + public DownloadStatus getDownloadStatus(String appName, DownloadRequest downloadRequest) + throws RemoteException { + return null; + } + + @Override + public void resetDownloadKnowledge(String appName, DownloadRequest downloadRequest) + throws RemoteException { + } + + @Override + public void dispose(String appName, int subId) throws RemoteException { + } +} diff --git a/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java b/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java new file mode 100644 index 0000000000000..1c8ab7c544d09 --- /dev/null +++ b/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2017 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.mbms.vendor; + +import android.net.Uri; +import android.os.RemoteException; +import android.telephony.mbms.IMbmsStreamingManagerCallback; +import android.telephony.mbms.IStreamingServiceCallback; +import android.telephony.mbms.StreamingService; + +import java.util.List; + +/** + * @hide + * TODO: future systemapi + */ +public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub { + + @Override + public int initialize(IMbmsStreamingManagerCallback listener, String appName, int subId) + throws RemoteException { + return 0; + } + + @Override + public int getStreamingServices(String appName, int subId, List serviceClasses) + throws RemoteException { + return 0; + } + + @Override + public StreamingService startStreaming(String appName, int subId, + String serviceId, IStreamingServiceCallback listener) throws RemoteException { + return null; + } + + @Override + public int getActiveStreamingServices(String appName, int subId) throws RemoteException { + return 0; + } + + @Override + public Uri getPlaybackUri(String appName, int subId, String serviceId) throws RemoteException { + return null; + } + + @Override + public void switchStreams(String appName, int subId, String oldServiceId, String newServiceId) + throws RemoteException { + } + + @Override + public int getState(String appName, int subId, String serviceId) throws RemoteException { + return 0; + } + + @Override + public void stopStreaming(String appName, int subId, String serviceId) throws RemoteException { + } + + @Override + public void disposeStream(String appName, int subId, String serviceId) throws RemoteException { + } + + @Override + public void dispose(String appName, int subId) throws RemoteException { + } +}