Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 571293ad authored by Hall Liu's avatar Hall Liu
Browse files

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
parent ff6f9862
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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 \
+8 −12
Original line number Diff line number Diff line
@@ -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
     */
+22 −6
Original line number Diff line number Diff line
@@ -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) {
    }
}
+3 −1
Original line number Diff line number Diff line
@@ -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);
}
+15 −20
Original line number Diff line number Diff line
@@ -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() {
Loading