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

Commit 1a5b1304 authored by Hall Liu's avatar Hall Liu
Browse files

Apply suggested edits to the file-download API

* Rename Manager -> Session
* Add Handler for callbacks in download flow
* Separate out registering a state callback into another method
* Rename dispose -> close, implement AutoClosable
* No more thrown MbmsExceptions
* Add sanity check for temp file root
* Remove the getNames method, replace with getNameForLocale

Bug: 30981736
Test: testapps
Change-Id: I1a2054d79c934bc4929464de4a644b6960db47e9
parent a96478a9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -502,7 +502,7 @@ 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/IMbmsDownloadManagerCallback.aidl \
	telephony/java/android/telephony/mbms/IMbmsDownloadSessionCallback.aidl \
	telephony/java/android/telephony/mbms/IMbmsStreamingSessionCallback.aidl \
	telephony/java/android/telephony/mbms/IDownloadStateCallback.aidl \
        telephony/java/android/telephony/mbms/IStreamingServiceCallback.aidl \
+2 −2
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@ public class MbmsStreamingSession implements AutoCloseable {
     * @return An instance of {@link MbmsStreamingSession}, or null if an error occurred.
     */
    public static @Nullable MbmsStreamingSession create(@NonNull Context context,
            @NonNull MbmsStreamingSessionCallback callback, int subscriptionId,
            final @NonNull MbmsStreamingSessionCallback callback, int subscriptionId,
            @NonNull Handler handler) {
        if (!sIsInitialized.compareAndSet(false, true)) {
            throw new IllegalStateException("Cannot create two instances of MbmsStreamingSession");
@@ -124,7 +124,7 @@ public class MbmsStreamingSession implements AutoCloseable {
        MbmsStreamingSession session = new MbmsStreamingSession(context, callback,
                subscriptionId, handler);

        int result = session.bindAndInitialize();
        final int result = session.bindAndInitialize();
        if (result != MbmsException.SUCCESS) {
            sIsInitialized.set(false);
            handler.post(new Runnable() {
+4 −6
Original line number Diff line number Diff line
@@ -16,14 +16,12 @@

package android.telephony.mbms;

import android.os.Handler;
import android.telephony.MbmsDownloadManager;
import android.telephony.MbmsDownloadSession;

/**
 * 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, DownloadStateCallback, Handler)}
 * {@link MbmsDownloadSession#download(DownloadRequest)}
 *
 * This is optionally specified when requesting a download and will only be called while the app
 * is running.
@@ -59,7 +57,7 @@ public class DownloadStateCallback {
     *   may not have been able to get a list of them in advance.
     * @param state The current state of the download.
     */
    public void onStateChanged(DownloadRequest request, FileInfo fileInfo,
            @MbmsDownloadManager.DownloadStatus int state) {
    public void onStateUpdated(DownloadRequest request, FileInfo fileInfo,
            @MbmsDownloadSession.DownloadStatus int state) {
    }
}
+4 −3
Original line number Diff line number Diff line
@@ -29,8 +29,9 @@ interface IDownloadStateCallback
     * Gives progress callbacks for a given DownloadRequest.  Includes a FileInfo
     * as the list of files may not have been known at request-time.
     */
    void progress(in DownloadRequest request, in FileInfo fileInfo, int currentDownloadSize,
            int fullDownloadSize, int currentDecodedSize, int fullDecodedSize);
    void onProgressUpdated(in DownloadRequest request, in FileInfo fileInfo,
            int currentDownloadSize, int fullDownloadSize,
            int currentDecodedSize, int fullDecodedSize);

    void state(in DownloadRequest request, in FileInfo fileInfo, int state);
    void onStateUpdated(in DownloadRequest request, in FileInfo fileInfo, int state);
}
Loading