diff options
| author | 2017-08-04 18:41:56 -0700 | |
|---|---|---|
| committer | 2017-08-28 14:27:56 -0700 | |
| commit | 571293ad96eae0a10d61fa2bd9e78f8cbb78803e (patch) | |
| tree | 0be94e57cc798ccd2365535c000547d93fe4434c | |
| parent | ff6f9862e5dd1b2fd825ed69dc11918a0565fd33 (diff) | |
Make EMBMS adjustments for 08/04
* Add a download state callback to the callback formerly for progress
* Rename EXTRA_SERVICE_INFO to EXTRA_SERVICE_ID, and specify that it
should be a String rather than a ServiceInfo
* Add documentation to clarify that the progress/state callback may be
null
Bug: 30981736
Test: manual
Change-Id: Ie1ec99868f5b09a270b500dc97abeb9f819cfa56
| -rw-r--r-- | Android.mk | 2 | ||||
| -rw-r--r-- | telephony/java/android/telephony/MbmsDownloadManager.java | 20 | ||||
| -rw-r--r-- | telephony/java/android/telephony/mbms/DownloadStateCallback.java (renamed from telephony/java/android/telephony/mbms/DownloadProgressListener.java) | 28 | ||||
| -rwxr-xr-x | telephony/java/android/telephony/mbms/IDownloadStateCallback.aidl (renamed from telephony/java/android/telephony/mbms/IDownloadProgressListener.aidl) | 4 | ||||
| -rw-r--r-- | telephony/java/android/telephony/mbms/MbmsDownloadReceiver.java | 35 | ||||
| -rwxr-xr-x | telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl | 4 | ||||
| -rw-r--r-- | telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java | 16 | ||||
| -rw-r--r-- | telephony/java/android/telephony/mbms/vendor/VendorUtils.java | 8 |
8 files changed, 63 insertions, 54 deletions
diff --git a/Android.mk b/Android.mk index 0e6642d70a28..bd32b55dfd51 100644 --- a/Android.mk +++ b/Android.mk @@ -488,7 +488,7 @@ LOCAL_SRC_FILES += \ telecomm/java/com/android/internal/telecom/RemoteServiceCallback.aidl \ telephony/java/android/telephony/mbms/IMbmsDownloadManagerCallback.aidl \ telephony/java/android/telephony/mbms/IMbmsStreamingManagerCallback.aidl \ - telephony/java/android/telephony/mbms/IDownloadProgressListener.aidl \ + telephony/java/android/telephony/mbms/IDownloadStateCallback.aidl \ telephony/java/android/telephony/mbms/IStreamingServiceCallback.aidl \ telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl \ telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl \ diff --git a/telephony/java/android/telephony/MbmsDownloadManager.java b/telephony/java/android/telephony/MbmsDownloadManager.java index 608f415b7a56..d76fca5f83ab 100644 --- a/telephony/java/android/telephony/MbmsDownloadManager.java +++ b/telephony/java/android/telephony/MbmsDownloadManager.java @@ -29,7 +29,7 @@ import android.content.SharedPreferences; import android.net.Uri; import android.os.IBinder; import android.os.RemoteException; -import android.telephony.mbms.DownloadProgressListener; +import android.telephony.mbms.DownloadStateCallback; import android.telephony.mbms.FileInfo; import android.telephony.mbms.DownloadRequest; import android.telephony.mbms.MbmsDownloadManagerCallback; @@ -99,7 +99,7 @@ public class MbmsDownloadManager { /** * The default directory name for all MBMS temp files. If you call - * {@link #download(DownloadRequest, DownloadProgressListener)} without first calling + * {@link #download(DownloadRequest, DownloadStateCallback)} without first calling * {@link #setTempFileRootDirectory(File)}, this directory will be created for you under the * path returned by {@link Context#getFilesDir()}. */ @@ -329,7 +329,7 @@ public class MbmsDownloadManager { * local instance of {@link android.content.SharedPreferences} and by the middleware. * * If this method is not called at least once before calling - * {@link #download(DownloadRequest, DownloadProgressListener)}, the framework + * {@link #download(DownloadRequest, DownloadStateCallback)}, the framework * will default to a directory formed by the concatenation of the app's files directory and * {@link MbmsDownloadManager#DEFAULT_TOP_LEVEL_TEMP_DIRECTORY}. * @@ -380,7 +380,7 @@ public class MbmsDownloadManager { /** * Retrieves the currently configured temp file root directory. Returns the file that was * configured via {@link #setTempFileRootDirectory(File)} or the default directory - * {@link #download(DownloadRequest, DownloadProgressListener)} was called without ever setting + * {@link #download(DownloadRequest, DownloadStateCallback)} was called without ever setting * the temp file root. If neither method has been called since the last time the app's shared * preferences were reset, returns null. * @@ -400,11 +400,6 @@ public class MbmsDownloadManager { /** * Requests a download of a file that is available via multicast. * - * 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 - * for completed or errored-out downloads. A NULL indicates no callbacks are needed. - * * May throw an {@link IllegalArgumentException} * * If {@link #setTempFileRootDirectory(File)} has not called after the app has been installed, @@ -416,9 +411,10 @@ public class MbmsDownloadManager { * * @param request The request that specifies what should be downloaded * @param progressListener Optional listener that will be provided progress updates - * if the app is running. + * if the app is running. If {@code null}, no callbacks will be + * provided. */ - public void download(DownloadRequest request, DownloadProgressListener progressListener) + public void download(DownloadRequest request, @Nullable DownloadStateCallback progressListener) throws MbmsException { IMbmsDownloadService downloadService = mService.get(); if (downloadService == null) { @@ -448,7 +444,7 @@ public class MbmsDownloadManager { /** * Returns a list of pending {@link DownloadRequest}s that originated from this application. * A pending request is one that was issued via - * {@link #download(DownloadRequest, DownloadProgressListener)} but not cancelled through + * {@link #download(DownloadRequest, DownloadStateCallback)} but not cancelled through * {@link #cancelDownload(DownloadRequest)}. * @return A list, possibly empty, of {@link DownloadRequest}s */ diff --git a/telephony/java/android/telephony/mbms/DownloadProgressListener.java b/telephony/java/android/telephony/mbms/DownloadStateCallback.java index 729c8fe8965e..a144f3e89b11 100644 --- a/telephony/java/android/telephony/mbms/DownloadProgressListener.java +++ b/telephony/java/android/telephony/mbms/DownloadStateCallback.java @@ -17,19 +17,21 @@ package android.telephony.mbms; import android.os.RemoteException; +import android.telephony.MbmsDownloadManager; /** * A optional listener class used by download clients to track progress. Apps should extend this * class and pass an instance into - * {@link android.telephony.MbmsDownloadManager#download(DownloadRequest, DownloadProgressListener)} + * {@link android.telephony.MbmsDownloadManager#download(DownloadRequest, DownloadStateCallback)} + * + * This is optionally specified when requesting a download and will only be called while the app + * is running. * @hide */ -public class DownloadProgressListener extends IDownloadProgressListener.Stub { +public class DownloadStateCallback extends IDownloadStateCallback.Stub { + /** - * Gives process callbacks for a given DownloadRequest. - * This is optionally specified when requesting a download and - * only lives while the app is running - it's unlikely to be useful for - * downloads far in the future. + * Called when the middleware wants to report progress for a file in a {@link DownloadRequest}. * * @param request a {@link DownloadRequest}, indicating which download is being referenced. * @param fileInfo a {@link FileInfo} specifying the file to report progress on. Note that @@ -47,4 +49,18 @@ public class DownloadProgressListener extends IDownloadProgressListener.Stub { int currentDownloadSize, int fullDownloadSize, int currentDecodedSize, int fullDecodedSize) throws RemoteException { } + + /** + * Gives download state callbacks for a file in a {@link DownloadRequest}. + * + * @param request a {@link DownloadRequest}, indicating which download is being referenced. + * @param fileInfo a {@link FileInfo} specifying the file to report progress on. Note that + * the request may result in many files being downloaded and the client + * may not have been able to get a list of them in advance. + * @param state The current state of the download. + */ + @Override + public void state(DownloadRequest request, FileInfo fileInfo, + @MbmsDownloadManager.DownloadStatus int state) { + } } diff --git a/telephony/java/android/telephony/mbms/IDownloadProgressListener.aidl b/telephony/java/android/telephony/mbms/IDownloadStateCallback.aidl index bb9dc6cfea9f..d62247be127d 100755 --- a/telephony/java/android/telephony/mbms/IDownloadProgressListener.aidl +++ b/telephony/java/android/telephony/mbms/IDownloadStateCallback.aidl @@ -23,7 +23,7 @@ import android.telephony.mbms.FileInfo; * The optional interface used by download clients to track progress. * @hide */ -interface IDownloadProgressListener +interface IDownloadStateCallback { /** * Gives progress callbacks for a given DownloadRequest. Includes a FileInfo @@ -31,4 +31,6 @@ interface IDownloadProgressListener */ void progress(in DownloadRequest request, in FileInfo fileInfo, int currentDownloadSize, int fullDownloadSize, int currentDecodedSize, int fullDecodedSize); + + void state(in DownloadRequest request, in FileInfo fileInfo, int state); } diff --git a/telephony/java/android/telephony/mbms/MbmsDownloadReceiver.java b/telephony/java/android/telephony/mbms/MbmsDownloadReceiver.java index 0c9b35abad2b..8745d8e403b4 100644 --- a/telephony/java/android/telephony/mbms/MbmsDownloadReceiver.java +++ b/telephony/java/android/telephony/mbms/MbmsDownloadReceiver.java @@ -182,8 +182,8 @@ public class MbmsDownloadReceiver extends BroadcastReceiver { return false; } } else if (VendorUtils.ACTION_FILE_DESCRIPTOR_REQUEST.equals(intent.getAction())) { - if (!intent.hasExtra(VendorUtils.EXTRA_SERVICE_INFO)) { - Log.w(LOG_TAG, "Temp file request did not include the associated service info." + + if (!intent.hasExtra(VendorUtils.EXTRA_SERVICE_ID)) { + Log.w(LOG_TAG, "Temp file request did not include the associated service id." + " Ignoring."); return false; } @@ -192,8 +192,8 @@ public class MbmsDownloadReceiver extends BroadcastReceiver { return false; } } else if (VendorUtils.ACTION_CLEANUP.equals(intent.getAction())) { - if (!intent.hasExtra(VendorUtils.EXTRA_SERVICE_INFO)) { - Log.w(LOG_TAG, "Cleanup request did not include the associated service info." + + if (!intent.hasExtra(VendorUtils.EXTRA_SERVICE_ID)) { + Log.w(LOG_TAG, "Cleanup request did not include the associated service id." + " Ignoring."); return false; } @@ -270,10 +270,9 @@ public class MbmsDownloadReceiver extends BroadcastReceiver { } private void generateTempFiles(Context context, Intent intent) { - FileServiceInfo serviceInfo = - intent.getParcelableExtra(VendorUtils.EXTRA_SERVICE_INFO); - if (serviceInfo == null) { - Log.w(LOG_TAG, "Temp file request did not include the associated service info. " + + String serviceId = intent.getStringExtra(VendorUtils.EXTRA_SERVICE_ID); + if (serviceId == null) { + Log.w(LOG_TAG, "Temp file request did not include the associated service id. " + "Ignoring."); setResultCode(RESULT_MALFORMED_INTENT); return; @@ -289,9 +288,9 @@ public class MbmsDownloadReceiver extends BroadcastReceiver { } ArrayList<UriPathPair> freshTempFiles = - generateFreshTempFiles(context, serviceInfo, fdCount); + generateFreshTempFiles(context, serviceId, fdCount); ArrayList<UriPathPair> pausedFiles = - generateUrisForPausedFiles(context, serviceInfo, pausedList); + generateUrisForPausedFiles(context, serviceId, pausedList); Bundle result = new Bundle(); result.putParcelableArrayList(VendorUtils.EXTRA_FREE_URI_LIST, freshTempFiles); @@ -300,11 +299,9 @@ public class MbmsDownloadReceiver extends BroadcastReceiver { setResultExtras(result); } - private ArrayList<UriPathPair> generateFreshTempFiles(Context context, - FileServiceInfo serviceInfo, + private ArrayList<UriPathPair> generateFreshTempFiles(Context context, String serviceId, int freshFdCount) { - File tempFileDir = MbmsUtils.getEmbmsTempFileDirForService(context, - serviceInfo.getServiceId()); + File tempFileDir = MbmsUtils.getEmbmsTempFileDirForService(context, serviceId); if (!tempFileDir.exists()) { tempFileDir.mkdirs(); } @@ -348,14 +345,14 @@ public class MbmsDownloadReceiver extends BroadcastReceiver { } private ArrayList<UriPathPair> generateUrisForPausedFiles(Context context, - FileServiceInfo serviceInfo, List<Uri> pausedFiles) { + String serviceId, List<Uri> pausedFiles) { if (pausedFiles == null) { return new ArrayList<>(0); } ArrayList<UriPathPair> result = new ArrayList<>(pausedFiles.size()); for (Uri fileUri : pausedFiles) { - if (!verifyTempFilePath(context, serviceInfo.getServiceId(), fileUri)) { + if (!verifyTempFilePath(context, serviceId, fileUri)) { Log.w(LOG_TAG, "Supplied file " + fileUri + " is not a valid temp file to resume"); setResultCode(RESULT_TEMP_FILE_GENERATION_ERROR); continue; @@ -377,10 +374,8 @@ public class MbmsDownloadReceiver extends BroadcastReceiver { } private void cleanupTempFiles(Context context, Intent intent) { - FileServiceInfo serviceInfo = - intent.getParcelableExtra(VendorUtils.EXTRA_SERVICE_INFO); - File tempFileDir = MbmsUtils.getEmbmsTempFileDirForService(context, - serviceInfo.getServiceId()); + String serviceId = intent.getStringExtra(VendorUtils.EXTRA_SERVICE_ID); + File tempFileDir = MbmsUtils.getEmbmsTempFileDirForService(context, serviceId); final List<Uri> filesInUse = intent.getParcelableArrayListExtra(VendorUtils.EXTRA_TEMP_FILES_IN_USE); File[] filesToDelete = tempFileDir.listFiles(new FileFilter() { diff --git a/telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl b/telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl index dfcc5f7c8793..f29499d9cb31 100755 --- a/telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl +++ b/telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl @@ -21,7 +21,7 @@ import android.net.Uri; import android.telephony.mbms.DownloadRequest; import android.telephony.mbms.FileInfo; import android.telephony.mbms.IMbmsDownloadManagerCallback; -import android.telephony.mbms.IDownloadProgressListener; +import android.telephony.mbms.IDownloadStateCallback; /** * @hide @@ -34,7 +34,7 @@ interface IMbmsDownloadService int setTempFileRootDirectory(int subId, String rootDirectoryPath); - int download(in DownloadRequest downloadRequest, IDownloadProgressListener listener); + int download(in DownloadRequest downloadRequest, IDownloadStateCallback listener); List<DownloadRequest> listPendingDownloads(int subscriptionId); diff --git a/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java b/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java index b6ed889d69f1..0baa37564966 100644 --- a/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java +++ b/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java @@ -20,11 +20,11 @@ import android.annotation.NonNull; import android.annotation.SystemApi; import android.content.Intent; import android.os.RemoteException; -import android.telephony.mbms.DownloadProgressListener; +import android.telephony.mbms.DownloadStateCallback; import android.telephony.mbms.DownloadRequest; import android.telephony.mbms.FileInfo; import android.telephony.mbms.FileServiceInfo; -import android.telephony.mbms.IDownloadProgressListener; +import android.telephony.mbms.IDownloadStateCallback; import android.telephony.mbms.IMbmsDownloadManagerCallback; import android.telephony.mbms.MbmsDownloadManagerCallback; import android.telephony.mbms.MbmsException; @@ -134,12 +134,12 @@ public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub { * this is not the case, an {@link IllegalStateException} may be thrown. * * @param downloadRequest An object describing the set of files to be downloaded. - * @param listener A listener through which the middleware can provide progress updates to + * @param callback A callback through which the middleware can provide progress updates to * the app while both are still running. * @return Any error from {@link android.telephony.mbms.MbmsException.GeneralErrors} * or {@link MbmsException#SUCCESS} */ - public int download(DownloadRequest downloadRequest, DownloadProgressListener listener) { + public int download(DownloadRequest downloadRequest, DownloadStateCallback callback) { return 0; } @@ -148,14 +148,14 @@ public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub { * @hide */ @Override - public final int download(DownloadRequest downloadRequest, IDownloadProgressListener listener) + public final int download(DownloadRequest downloadRequest, IDownloadStateCallback callback) throws RemoteException { - return download(downloadRequest, new DownloadProgressListener() { + return download(downloadRequest, new DownloadStateCallback() { @Override public void progress(DownloadRequest request, FileInfo fileInfo, int currentDownloadSize, int fullDownloadSize, int currentDecodedSize, int fullDecodedSize) throws RemoteException { - listener.progress(request, fileInfo, currentDownloadSize, fullDownloadSize, + callback.progress(request, fileInfo, currentDownloadSize, fullDownloadSize, currentDecodedSize, fullDecodedSize); } }); @@ -165,7 +165,7 @@ public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub { /** * Returns a list of pending {@link DownloadRequest}s that originated from the calling * application, identified by its uid. A pending request is one that was issued via - * {@link #download(DownloadRequest, IDownloadProgressListener)} but not cancelled through + * {@link #download(DownloadRequest, DownloadStateCallback)} but not cancelled through * {@link #cancelDownload(DownloadRequest)}. * The middleware must return a non-null result synchronously or throw an exception * inheriting from {@link RuntimeException}. diff --git a/telephony/java/android/telephony/mbms/vendor/VendorUtils.java b/telephony/java/android/telephony/mbms/vendor/VendorUtils.java index bcae7822b475..a01e57dfdda1 100644 --- a/telephony/java/android/telephony/mbms/vendor/VendorUtils.java +++ b/telephony/java/android/telephony/mbms/vendor/VendorUtils.java @@ -52,7 +52,7 @@ public class VendorUtils { * 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} + * {@link #EXTRA_SERVICE_ID} * * Optional extras are * {@link #EXTRA_FD_COUNT} (0 if not present) @@ -133,12 +133,12 @@ public class VendorUtils { public static final String EXTRA_FINAL_URI = "android.telephony.mbms.extra.FINAL_URI"; /** - * Extra containing an instance of {@link android.telephony.mbms.ServiceInfo}, used by + * Extra containing a String representing a service ID, used by * file-descriptor requests and cleanup requests to specify which service they want to * request temp files or clean up temp files for, respectively. */ - public static final String EXTRA_SERVICE_INFO = - "android.telephony.mbms.extra.SERVICE_INFO"; + public static final String EXTRA_SERVICE_ID = + "android.telephony.mbms.extra.SERVICE_ID"; /** * Retrieves the {@link ComponentName} for the {@link android.content.BroadcastReceiver} that |