Loading Android.mk +4 −4 Original line number Original line Diff line number Diff line Loading @@ -483,10 +483,10 @@ LOCAL_SRC_FILES += \ telecomm/java/com/android/internal/telecom/IInCallService.aidl \ telecomm/java/com/android/internal/telecom/IInCallService.aidl \ telecomm/java/com/android/internal/telecom/ITelecomService.aidl \ telecomm/java/com/android/internal/telecom/ITelecomService.aidl \ telecomm/java/com/android/internal/telecom/RemoteServiceCallback.aidl \ telecomm/java/com/android/internal/telecom/RemoteServiceCallback.aidl \ telephony/java/android/telephony/mbms/IMbmsDownloadManagerListener.aidl \ telephony/java/android/telephony/mbms/IMbmsDownloadManagerCallback.aidl \ telephony/java/android/telephony/mbms/IMbmsStreamingManagerListener.aidl \ telephony/java/android/telephony/mbms/IMbmsStreamingManagerCallback.aidl \ telephony/java/android/telephony/mbms/IDownloadListener.aidl \ telephony/java/android/telephony/mbms/IDownloadCallback.aidl \ telephony/java/android/telephony/mbms/IStreamingServiceListener.aidl \ telephony/java/android/telephony/mbms/IStreamingServiceCallback.aidl \ telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl \ telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl \ telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl \ telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl \ telephony/java/com/android/ims/internal/IImsCallSession.aidl \ telephony/java/com/android/ims/internal/IImsCallSession.aidl \ Loading telephony/java/android/telephony/MbmsDownloadManager.java +168 −34 Original line number Original line Diff line number Diff line Loading @@ -16,14 +16,16 @@ package android.telephony; package android.telephony; import android.app.PendingIntent; import android.content.Context; import android.content.Context; import android.net.Uri; 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.DownloadRequest; import android.telephony.mbms.DownloadStatus; import android.telephony.mbms.DownloadStatus; import android.telephony.mbms.FileServiceInfo; import android.telephony.mbms.IMbmsDownloadManagerCallback; import android.telephony.mbms.IMbmsDownloadManagerListener; import android.telephony.mbms.MbmsInitializationException; import android.telephony.mbms.vendor.IMbmsDownloadService; import android.util.Log; import java.util.List; import java.util.List; Loading @@ -31,9 +33,135 @@ import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID; /** @hide */ /** @hide */ public class MbmsDownloadManager { 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 final Context mContext; private int mSubId = INVALID_SUBSCRIPTION_ID; 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. * Create a new MbmsDownloadManager using the system default data subscription ID. * * Loading @@ -42,9 +170,13 @@ public class MbmsDownloadManager { * * * @hide * @hide */ */ public MbmsDownloadManager(Context context, IMbmsDownloadManagerListener listener, public static MbmsDownloadManager createManager(Context context, String downloadAppName) { IMbmsDownloadManagerCallback listener, String downloadAppName) mContext = context; throws MbmsInitializationException{ MbmsDownloadManager mdm = new MbmsDownloadManager(context, listener, downloadAppName, SubscriptionManager.getDefaultSubscriptionId()); mdm.bindAndInitialize(); return mdm; } } /** /** Loading @@ -55,9 +187,23 @@ public class MbmsDownloadManager { * * * @hide * @hide */ */ public MbmsDownloadManager(Context context, IMbmsDownloadManagerListener listener, String downloadAppName, int subId) { public static MbmsDownloadManager createManager(Context context, mContext = 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 } } } /** /** Loading @@ -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. * Requests a future download. * returns a token which may be used to cancel a 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 * 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 * 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 * is running, so future downloads will simply result in resultIntents being sent Loading @@ -118,7 +242,7 @@ public class MbmsDownloadManager { * * * Asynchronous errors through the listener include any of the errors * 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; return null; } } Loading Loading @@ -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. * 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 * Normally the middleware won't download files who's hash matches previously downloaded Loading @@ -187,5 +311,15 @@ public class MbmsDownloadManager { } } public void dispose() { 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"); } } } } } telephony/java/android/telephony/MbmsStreamingManager.java +61 −12 Original line number Original line Diff line number Diff line Loading @@ -17,10 +17,13 @@ package android.telephony; package android.telephony; import android.content.Context; import android.content.Context; import android.telephony.mbms.IMbmsStreamingManagerListener; import android.os.RemoteException; import android.telephony.mbms.IStreamingServiceListener; import android.telephony.mbms.IMbmsStreamingManagerCallback; import android.telephony.mbms.IStreamingServiceCallback; import android.telephony.mbms.MbmsInitializationException; import android.telephony.mbms.StreamingService; import android.telephony.mbms.StreamingService; import android.telephony.mbms.StreamingServiceInfo; import android.telephony.mbms.StreamingServiceInfo; import android.telephony.mbms.vendor.IMbmsStreamingService; import android.util.Log; import android.util.Log; import java.util.List; import java.util.List; Loading @@ -31,30 +34,60 @@ import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID; public class MbmsStreamingManager { public class MbmsStreamingManager { private static final String LOG_TAG = "MbmsStreamingManager"; private static final String LOG_TAG = "MbmsStreamingManager"; private static final boolean DEBUG = true; private static final boolean DEBUG = true; private IMbmsStreamingService mService; private IMbmsStreamingManagerCallback mCallbackToApp; private final String mAppName; private final Context mContext; private final Context mContext; private int mSubId = INVALID_SUBSCRIPTION_ID; private int mSubscriptionId = INVALID_SUBSCRIPTION_ID; /** @hide */ private MbmsStreamingManager(Context context, IMbmsStreamingManagerCallback listener, String streamingAppName, int subscriptionId) { mContext = context; mAppName = streamingAppName; mCallbackToApp = listener; mSubscriptionId = subscriptionId; } /** /** * Create a new MbmsStreamingManager using the system default data subscription ID. * Create a new MbmsStreamingManager using the given subscription ID. * * * Note that this call will bind a remote service and that may take a bit. This * Note that this call will bind a remote service and that may take a bit. This * may throw an IllegalArgumentException or RemoteException. * 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, public static MbmsStreamingManager create(Context context, String streamingAppName) { IMbmsStreamingManagerCallback listener, String streamingAppName, int subscriptionId) mContext = context; throws MbmsInitializationException { MbmsStreamingManager manager = new MbmsStreamingManager(context, listener, streamingAppName, subscriptionId); manager.bindAndInitialize(); return manager; } } /** /** * Create a new MbmsStreamingManager using the given 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 * Note that this call will bind a remote service and that may take a bit. This * may throw an IllegalArgumentException or RemoteException. * may throw an IllegalArgumentException or RemoteException. */ */ public MbmsStreamingManager(Context context, IMbmsStreamingManagerListener listener, public static MbmsStreamingManager create(Context context, String streamingAppName, int subId) { IMbmsStreamingManagerCallback listener, String streamingAppName) mContext = context; throws MbmsInitializationException { // TODO: get default sub id int subId = INVALID_SUBSCRIPTION_ID; MbmsStreamingManager manager = new MbmsStreamingManager(context, listener, streamingAppName, subId); manager.bindAndInitialize(); return manager; } } /** /** Loading Loading @@ -97,7 +130,7 @@ public class MbmsStreamingManager { * Asynchronous errors through the listener include any of the errors * Asynchronous errors through the listener include any of the errors */ */ public StreamingService startStreaming(StreamingServiceInfo serviceInfo, public StreamingService startStreaming(StreamingServiceInfo serviceInfo, IStreamingServiceListener listener) { IStreamingServiceCallback listener) { return null; return null; } } Loading Loading @@ -125,4 +158,20 @@ public class MbmsStreamingManager { private void logd(String str) { private void logd(String str) { Log.d(LOG_TAG, 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); } } } } telephony/java/android/telephony/mbms/DownloadListener.java→telephony/java/android/telephony/mbms/DownloadCallback.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -20,7 +20,7 @@ package android.telephony.mbms; * A optional listener class used by download clients to track progress. * A optional listener class used by download clients to track progress. * @hide * @hide */ */ public class DownloadListener extends IDownloadListener.Stub { public class DownloadCallback extends IDownloadCallback.Stub { /** /** * Gives process callbacks for a given DownloadRequest. * Gives process callbacks for a given DownloadRequest. * request indicates which download is being referenced. * request indicates which download is being referenced. Loading telephony/java/android/telephony/mbms/DownloadRequest.java +99 −21 Original line number Original line Diff line number Diff line Loading @@ -16,44 +16,101 @@ package android.telephony.mbms; package android.telephony.mbms; import android.app.PendingIntent; import android.content.Intent; import android.net.Uri; import android.net.Uri; import android.os.Parcel; import android.os.Parcel; import android.os.Parcelable; import android.os.Parcelable; import java.net.URISyntaxException; /** /** * A Parcelable class describing a pending Cell-Broadcast download request * A Parcelable class describing a pending Cell-Broadcast download request * @hide * @hide */ */ public class DownloadRequest implements Parcelable { public class DownloadRequest implements Parcelable { public DownloadRequest(int id, FileServiceInfo serviceInfo, Uri source, Uri dest, /** @hide */ PendingIntent resultPI, int sub) { 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; downloadId = id; fileServiceInfo = serviceInfo; fileServiceInfo = serviceInfo; sourceUri = source; sourceUri = source; destinationUri = dest; destinationUri = dest; subId = sub; subId = sub; serializedResultIntentForApp = appIntent; } } /** @hide */ public static DownloadRequest copy(DownloadRequest other) { public DownloadRequest(DownloadRequest dr, PendingIntent fdRequestPI, PendingIntent cleanupPI) { return new DownloadRequest(other); } private DownloadRequest(DownloadRequest dr) { downloadId = dr.downloadId; downloadId = dr.downloadId; fileServiceInfo = dr.fileServiceInfo; fileServiceInfo = dr.fileServiceInfo; sourceUri = dr.sourceUri; sourceUri = dr.sourceUri; destinationUri = dr.destinationUri; destinationUri = dr.destinationUri; subId = dr.subId; subId = dr.subId; /* serializedResultIntentForApp = dr.serializedResultIntentForApp; * resultPI = new PI * fileDescriptorRequstPI = fdRequestPI; * this.cleanupPI = cleanupPI; */ } } public final int downloadId; private DownloadRequest(Parcel in) { public final FileServiceInfo fileServiceInfo; downloadId = in.readInt(); public final Uri sourceUri; fileServiceInfo = in.readParcelable(getClass().getClassLoader()); public final Uri destinationUri; sourceUri = in.readParcelable(getClass().getClassLoader()); public final int subId; destinationUri = in.readParcelable(getClass().getClassLoader()); subId = in.readInt(); serializedResultIntentForApp = in.readString(); } public int describeContents() { public int describeContents() { return 0; return 0; Loading @@ -65,14 +122,35 @@ public class DownloadRequest implements Parcelable { out.writeParcelable(sourceUri, flags); out.writeParcelable(sourceUri, flags); out.writeParcelable(destinationUri, flags); out.writeParcelable(destinationUri, flags); out.writeInt(subId); out.writeInt(subId); out.writeString(serializedResultIntentForApp); } } private DownloadRequest(Parcel in) { public int getDownloadId() { downloadId = in.readInt(); return downloadId; fileServiceInfo = in.readParcelable(null); } sourceUri = in.readParcelable(null); destinationUri = in.readParcelable(null); public FileServiceInfo getFileServiceInfo() { subId = in.readInt(); 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<DownloadRequest> CREATOR = public static final Parcelable.Creator<DownloadRequest> CREATOR = Loading Loading
Android.mk +4 −4 Original line number Original line Diff line number Diff line Loading @@ -483,10 +483,10 @@ LOCAL_SRC_FILES += \ telecomm/java/com/android/internal/telecom/IInCallService.aidl \ telecomm/java/com/android/internal/telecom/IInCallService.aidl \ telecomm/java/com/android/internal/telecom/ITelecomService.aidl \ telecomm/java/com/android/internal/telecom/ITelecomService.aidl \ telecomm/java/com/android/internal/telecom/RemoteServiceCallback.aidl \ telecomm/java/com/android/internal/telecom/RemoteServiceCallback.aidl \ telephony/java/android/telephony/mbms/IMbmsDownloadManagerListener.aidl \ telephony/java/android/telephony/mbms/IMbmsDownloadManagerCallback.aidl \ telephony/java/android/telephony/mbms/IMbmsStreamingManagerListener.aidl \ telephony/java/android/telephony/mbms/IMbmsStreamingManagerCallback.aidl \ telephony/java/android/telephony/mbms/IDownloadListener.aidl \ telephony/java/android/telephony/mbms/IDownloadCallback.aidl \ telephony/java/android/telephony/mbms/IStreamingServiceListener.aidl \ telephony/java/android/telephony/mbms/IStreamingServiceCallback.aidl \ telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl \ telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl \ telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl \ telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl \ telephony/java/com/android/ims/internal/IImsCallSession.aidl \ telephony/java/com/android/ims/internal/IImsCallSession.aidl \ Loading
telephony/java/android/telephony/MbmsDownloadManager.java +168 −34 Original line number Original line Diff line number Diff line Loading @@ -16,14 +16,16 @@ package android.telephony; package android.telephony; import android.app.PendingIntent; import android.content.Context; import android.content.Context; import android.net.Uri; 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.DownloadRequest; import android.telephony.mbms.DownloadStatus; import android.telephony.mbms.DownloadStatus; import android.telephony.mbms.FileServiceInfo; import android.telephony.mbms.IMbmsDownloadManagerCallback; import android.telephony.mbms.IMbmsDownloadManagerListener; import android.telephony.mbms.MbmsInitializationException; import android.telephony.mbms.vendor.IMbmsDownloadService; import android.util.Log; import java.util.List; import java.util.List; Loading @@ -31,9 +33,135 @@ import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID; /** @hide */ /** @hide */ public class MbmsDownloadManager { 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 final Context mContext; private int mSubId = INVALID_SUBSCRIPTION_ID; 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. * Create a new MbmsDownloadManager using the system default data subscription ID. * * Loading @@ -42,9 +170,13 @@ public class MbmsDownloadManager { * * * @hide * @hide */ */ public MbmsDownloadManager(Context context, IMbmsDownloadManagerListener listener, public static MbmsDownloadManager createManager(Context context, String downloadAppName) { IMbmsDownloadManagerCallback listener, String downloadAppName) mContext = context; throws MbmsInitializationException{ MbmsDownloadManager mdm = new MbmsDownloadManager(context, listener, downloadAppName, SubscriptionManager.getDefaultSubscriptionId()); mdm.bindAndInitialize(); return mdm; } } /** /** Loading @@ -55,9 +187,23 @@ public class MbmsDownloadManager { * * * @hide * @hide */ */ public MbmsDownloadManager(Context context, IMbmsDownloadManagerListener listener, String downloadAppName, int subId) { public static MbmsDownloadManager createManager(Context context, mContext = 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 } } } /** /** Loading @@ -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. * Requests a future download. * returns a token which may be used to cancel a 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 * 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 * 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 * is running, so future downloads will simply result in resultIntents being sent Loading @@ -118,7 +242,7 @@ public class MbmsDownloadManager { * * * Asynchronous errors through the listener include any of the errors * 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; return null; } } Loading Loading @@ -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. * 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 * Normally the middleware won't download files who's hash matches previously downloaded Loading @@ -187,5 +311,15 @@ public class MbmsDownloadManager { } } public void dispose() { 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"); } } } } }
telephony/java/android/telephony/MbmsStreamingManager.java +61 −12 Original line number Original line Diff line number Diff line Loading @@ -17,10 +17,13 @@ package android.telephony; package android.telephony; import android.content.Context; import android.content.Context; import android.telephony.mbms.IMbmsStreamingManagerListener; import android.os.RemoteException; import android.telephony.mbms.IStreamingServiceListener; import android.telephony.mbms.IMbmsStreamingManagerCallback; import android.telephony.mbms.IStreamingServiceCallback; import android.telephony.mbms.MbmsInitializationException; import android.telephony.mbms.StreamingService; import android.telephony.mbms.StreamingService; import android.telephony.mbms.StreamingServiceInfo; import android.telephony.mbms.StreamingServiceInfo; import android.telephony.mbms.vendor.IMbmsStreamingService; import android.util.Log; import android.util.Log; import java.util.List; import java.util.List; Loading @@ -31,30 +34,60 @@ import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID; public class MbmsStreamingManager { public class MbmsStreamingManager { private static final String LOG_TAG = "MbmsStreamingManager"; private static final String LOG_TAG = "MbmsStreamingManager"; private static final boolean DEBUG = true; private static final boolean DEBUG = true; private IMbmsStreamingService mService; private IMbmsStreamingManagerCallback mCallbackToApp; private final String mAppName; private final Context mContext; private final Context mContext; private int mSubId = INVALID_SUBSCRIPTION_ID; private int mSubscriptionId = INVALID_SUBSCRIPTION_ID; /** @hide */ private MbmsStreamingManager(Context context, IMbmsStreamingManagerCallback listener, String streamingAppName, int subscriptionId) { mContext = context; mAppName = streamingAppName; mCallbackToApp = listener; mSubscriptionId = subscriptionId; } /** /** * Create a new MbmsStreamingManager using the system default data subscription ID. * Create a new MbmsStreamingManager using the given subscription ID. * * * Note that this call will bind a remote service and that may take a bit. This * Note that this call will bind a remote service and that may take a bit. This * may throw an IllegalArgumentException or RemoteException. * 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, public static MbmsStreamingManager create(Context context, String streamingAppName) { IMbmsStreamingManagerCallback listener, String streamingAppName, int subscriptionId) mContext = context; throws MbmsInitializationException { MbmsStreamingManager manager = new MbmsStreamingManager(context, listener, streamingAppName, subscriptionId); manager.bindAndInitialize(); return manager; } } /** /** * Create a new MbmsStreamingManager using the given 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 * Note that this call will bind a remote service and that may take a bit. This * may throw an IllegalArgumentException or RemoteException. * may throw an IllegalArgumentException or RemoteException. */ */ public MbmsStreamingManager(Context context, IMbmsStreamingManagerListener listener, public static MbmsStreamingManager create(Context context, String streamingAppName, int subId) { IMbmsStreamingManagerCallback listener, String streamingAppName) mContext = context; throws MbmsInitializationException { // TODO: get default sub id int subId = INVALID_SUBSCRIPTION_ID; MbmsStreamingManager manager = new MbmsStreamingManager(context, listener, streamingAppName, subId); manager.bindAndInitialize(); return manager; } } /** /** Loading Loading @@ -97,7 +130,7 @@ public class MbmsStreamingManager { * Asynchronous errors through the listener include any of the errors * Asynchronous errors through the listener include any of the errors */ */ public StreamingService startStreaming(StreamingServiceInfo serviceInfo, public StreamingService startStreaming(StreamingServiceInfo serviceInfo, IStreamingServiceListener listener) { IStreamingServiceCallback listener) { return null; return null; } } Loading Loading @@ -125,4 +158,20 @@ public class MbmsStreamingManager { private void logd(String str) { private void logd(String str) { Log.d(LOG_TAG, 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); } } } }
telephony/java/android/telephony/mbms/DownloadListener.java→telephony/java/android/telephony/mbms/DownloadCallback.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -20,7 +20,7 @@ package android.telephony.mbms; * A optional listener class used by download clients to track progress. * A optional listener class used by download clients to track progress. * @hide * @hide */ */ public class DownloadListener extends IDownloadListener.Stub { public class DownloadCallback extends IDownloadCallback.Stub { /** /** * Gives process callbacks for a given DownloadRequest. * Gives process callbacks for a given DownloadRequest. * request indicates which download is being referenced. * request indicates which download is being referenced. Loading
telephony/java/android/telephony/mbms/DownloadRequest.java +99 −21 Original line number Original line Diff line number Diff line Loading @@ -16,44 +16,101 @@ package android.telephony.mbms; package android.telephony.mbms; import android.app.PendingIntent; import android.content.Intent; import android.net.Uri; import android.net.Uri; import android.os.Parcel; import android.os.Parcel; import android.os.Parcelable; import android.os.Parcelable; import java.net.URISyntaxException; /** /** * A Parcelable class describing a pending Cell-Broadcast download request * A Parcelable class describing a pending Cell-Broadcast download request * @hide * @hide */ */ public class DownloadRequest implements Parcelable { public class DownloadRequest implements Parcelable { public DownloadRequest(int id, FileServiceInfo serviceInfo, Uri source, Uri dest, /** @hide */ PendingIntent resultPI, int sub) { 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; downloadId = id; fileServiceInfo = serviceInfo; fileServiceInfo = serviceInfo; sourceUri = source; sourceUri = source; destinationUri = dest; destinationUri = dest; subId = sub; subId = sub; serializedResultIntentForApp = appIntent; } } /** @hide */ public static DownloadRequest copy(DownloadRequest other) { public DownloadRequest(DownloadRequest dr, PendingIntent fdRequestPI, PendingIntent cleanupPI) { return new DownloadRequest(other); } private DownloadRequest(DownloadRequest dr) { downloadId = dr.downloadId; downloadId = dr.downloadId; fileServiceInfo = dr.fileServiceInfo; fileServiceInfo = dr.fileServiceInfo; sourceUri = dr.sourceUri; sourceUri = dr.sourceUri; destinationUri = dr.destinationUri; destinationUri = dr.destinationUri; subId = dr.subId; subId = dr.subId; /* serializedResultIntentForApp = dr.serializedResultIntentForApp; * resultPI = new PI * fileDescriptorRequstPI = fdRequestPI; * this.cleanupPI = cleanupPI; */ } } public final int downloadId; private DownloadRequest(Parcel in) { public final FileServiceInfo fileServiceInfo; downloadId = in.readInt(); public final Uri sourceUri; fileServiceInfo = in.readParcelable(getClass().getClassLoader()); public final Uri destinationUri; sourceUri = in.readParcelable(getClass().getClassLoader()); public final int subId; destinationUri = in.readParcelable(getClass().getClassLoader()); subId = in.readInt(); serializedResultIntentForApp = in.readString(); } public int describeContents() { public int describeContents() { return 0; return 0; Loading @@ -65,14 +122,35 @@ public class DownloadRequest implements Parcelable { out.writeParcelable(sourceUri, flags); out.writeParcelable(sourceUri, flags); out.writeParcelable(destinationUri, flags); out.writeParcelable(destinationUri, flags); out.writeInt(subId); out.writeInt(subId); out.writeString(serializedResultIntentForApp); } } private DownloadRequest(Parcel in) { public int getDownloadId() { downloadId = in.readInt(); return downloadId; fileServiceInfo = in.readParcelable(null); } sourceUri = in.readParcelable(null); destinationUri = in.readParcelable(null); public FileServiceInfo getFileServiceInfo() { subId = in.readInt(); 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<DownloadRequest> CREATOR = public static final Parcelable.Creator<DownloadRequest> CREATOR = Loading