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

Commit 46b959e9 authored by Android Build Merger (Role)'s avatar Android Build Merger (Role) Committed by Android (Google) Code Review
Browse files

Merge "Merge "Make changes to MBMS API following recs" am: feb60e08 am:...

Merge "Merge "Make changes to MBMS API following recs" am: feb60e08 am: 2fa2a9d0" into pi-dev-plus-aosp
parents d110770c 6705ef99
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -41930,17 +41930,17 @@ package android.telephony {
  }
  public class MbmsDownloadSession implements java.lang.AutoCloseable {
    method public int addProgressListener(android.telephony.mbms.DownloadRequest, java.util.concurrent.Executor, android.telephony.mbms.DownloadProgressListener);
    method public int addStatusListener(android.telephony.mbms.DownloadRequest, java.util.concurrent.Executor, android.telephony.mbms.DownloadStatusListener);
    method public int cancelDownload(android.telephony.mbms.DownloadRequest);
    method public void addProgressListener(android.telephony.mbms.DownloadRequest, java.util.concurrent.Executor, android.telephony.mbms.DownloadProgressListener);
    method public void addStatusListener(android.telephony.mbms.DownloadRequest, java.util.concurrent.Executor, android.telephony.mbms.DownloadStatusListener);
    method public void cancelDownload(android.telephony.mbms.DownloadRequest);
    method public void close();
    method public static android.telephony.MbmsDownloadSession create(android.content.Context, java.util.concurrent.Executor, android.telephony.mbms.MbmsDownloadSessionCallback);
    method public static android.telephony.MbmsDownloadSession create(android.content.Context, java.util.concurrent.Executor, int, android.telephony.mbms.MbmsDownloadSessionCallback);
    method public int download(android.telephony.mbms.DownloadRequest);
    method public void download(android.telephony.mbms.DownloadRequest);
    method public java.io.File getTempFileRootDirectory();
    method public java.util.List<android.telephony.mbms.DownloadRequest> listPendingDownloads();
    method public int removeProgressListener(android.telephony.mbms.DownloadRequest, android.telephony.mbms.DownloadProgressListener);
    method public int removeStatusListener(android.telephony.mbms.DownloadRequest, android.telephony.mbms.DownloadStatusListener);
    method public void removeProgressListener(android.telephony.mbms.DownloadRequest, android.telephony.mbms.DownloadProgressListener);
    method public void removeStatusListener(android.telephony.mbms.DownloadRequest, android.telephony.mbms.DownloadStatusListener);
    method public void requestDownloadState(android.telephony.mbms.DownloadRequest, android.telephony.mbms.FileInfo);
    method public void requestUpdateFileServices(java.util.List<java.lang.String>);
    method public void resetDownloadKnowledge(android.telephony.mbms.DownloadRequest);
@@ -42907,6 +42907,7 @@ package android.telephony.mbms {
    field public static final int ERROR_MIDDLEWARE_NOT_BOUND = 2; // 0x2
    field public static final int ERROR_NO_UNIQUE_MIDDLEWARE = 1; // 0x1
    field public static final int SUCCESS = 0; // 0x0
    field public static final int UNKNOWN = -1; // 0xffffffff
  }
  public static class MbmsErrors.DownloadErrors {
+109 −49
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.telephony;

import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -32,14 +34,14 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
import android.telephony.mbms.DownloadProgressListener;
import android.telephony.mbms.DownloadRequest;
import android.telephony.mbms.DownloadStatusListener;
import android.telephony.mbms.FileInfo;
import android.telephony.mbms.DownloadRequest;
import android.telephony.mbms.InternalDownloadProgressListener;
import android.telephony.mbms.InternalDownloadSessionCallback;
import android.telephony.mbms.InternalDownloadStatusListener;
import android.telephony.mbms.MbmsDownloadSessionCallback;
import android.telephony.mbms.MbmsDownloadReceiver;
import android.telephony.mbms.MbmsDownloadSessionCallback;
import android.telephony.mbms.MbmsErrors;
import android.telephony.mbms.MbmsTempFileProvider;
import android.telephony.mbms.MbmsUtils;
@@ -58,8 +60,6 @@ import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;

import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;

/**
 * This class provides functionality for file download over MBMS.
 */
@@ -337,6 +337,12 @@ public class MbmsDownloadSession implements AutoCloseable {
                            sIsInitialized.set(false);
                            return;
                        }
                        if (result == MbmsErrors.UNKNOWN) {
                            // Unbind and throw an obvious error
                            close();
                            throw new IllegalStateException("Middleware must not return an"
                                    + " unknown error code");
                        }
                        if (result != MbmsErrors.SUCCESS) {
                            sendErrorToApp(result, "Error returned during initialization");
                            sIsInitialized.set(false);
@@ -388,6 +394,11 @@ public class MbmsDownloadSession implements AutoCloseable {
        }
        try {
            int returnCode = downloadService.requestUpdateFileServices(mSubscriptionId, classList);
            if (returnCode == MbmsErrors.UNKNOWN) {
                // Unbind and throw an obvious error
                close();
                throw new IllegalStateException("Middleware must not return an unknown error code");
            }
            if (returnCode != MbmsErrors.SUCCESS) {
                sendErrorToApp(returnCode, null);
            }
@@ -443,6 +454,11 @@ public class MbmsDownloadSession implements AutoCloseable {

        try {
            int result = downloadService.setTempFileRootDirectory(mSubscriptionId, filePath);
            if (result == MbmsErrors.UNKNOWN) {
                // Unbind and throw an obvious error
                close();
                throw new IllegalStateException("Middleware must not return an unknown error code");
            }
            if (result != MbmsErrors.SUCCESS) {
                sendErrorToApp(result, null);
                return;
@@ -514,11 +530,13 @@ public class MbmsDownloadSession implements AutoCloseable {
     *
     * Asynchronous errors through the callback may include any error not specific to the
     * streaming use-case.
     *
     * If no error is delivered via the callback after calling this method, that means that the
     * middleware has successfully started the download or scheduled the download, if the download
     * is at a future time.
     * @param request The request that specifies what should be downloaded.
     * @return {@link MbmsErrors#SUCCESS} if the operation did not encounter a synchronous error,
     * and some other error code otherwise.
     */
    public int download(@NonNull DownloadRequest request) {
    public void download(@NonNull DownloadRequest request) {
        IMbmsDownloadService downloadService = mService.get();
        if (downloadService == null) {
            throw new IllegalStateException("Middleware not yet bound");
@@ -540,12 +558,19 @@ public class MbmsDownloadSession implements AutoCloseable {
            int result = downloadService.download(request);
            if (result == MbmsErrors.SUCCESS) {
                writeDownloadRequestToken(request);
            } else {
                if (result == MbmsErrors.UNKNOWN) {
                    // Unbind and throw an obvious error
                    close();
                    throw new IllegalStateException("Middleware must not return an unknown"
                            + " error code");
                }
                sendErrorToApp(result, null);
            }
            return result;
        } catch (RemoteException e) {
            mService.set(null);
            sIsInitialized.set(false);
            return MbmsErrors.ERROR_MIDDLEWARE_LOST;
            sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
        }
    }

@@ -581,14 +606,15 @@ public class MbmsDownloadSession implements AutoCloseable {
     * If the middleware is not aware of the specified download request,
     * this method will throw an {@link IllegalArgumentException}.
     *
     * If the operation encountered an error, the error code will be delivered via
     * {@link MbmsDownloadSessionCallback#onError}.
     *
     * @param request The {@link DownloadRequest} that you want updates on.
     * @param executor The {@link Executor} on which calls to {@code listener } should be executed.
     * @param listener The listener that should be called when the middleware has information to
     *                 share on the status download.
     * @return {@link MbmsErrors#SUCCESS} if the operation did not encounter a synchronous error,
     * and some other error code otherwise.
     */
    public int addStatusListener(@NonNull DownloadRequest request,
    public void addStatusListener(@NonNull DownloadRequest request,
            @NonNull Executor executor, @NonNull DownloadStatusListener listener) {
        IMbmsDownloadService downloadService = mService.get();
        if (downloadService == null) {
@@ -600,20 +626,25 @@ public class MbmsDownloadSession implements AutoCloseable {

        try {
            int result = downloadService.addStatusListener(request, internalListener);
            if (result == MbmsErrors.UNKNOWN) {
                // Unbind and throw an obvious error
                close();
                throw new IllegalStateException("Middleware must not return an unknown error code");
            }
            if (result != MbmsErrors.SUCCESS) {
                if (result == MbmsErrors.DownloadErrors.ERROR_UNKNOWN_DOWNLOAD_REQUEST) {
                    throw new IllegalArgumentException("Unknown download request.");
                }
                return result;
                sendErrorToApp(result, null);
                return;
            }
        } catch (RemoteException e) {
            mService.set(null);
            sIsInitialized.set(false);
            return MbmsErrors.ERROR_MIDDLEWARE_LOST;
            sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
            return;
        }
        mInternalDownloadStatusListeners.put(listener, internalListener);
        return MbmsErrors.SUCCESS;

    }

    /**
@@ -625,12 +656,13 @@ public class MbmsDownloadSession implements AutoCloseable {
     * If the middleware is not aware of the specified download request,
     * this method will throw an {@link IllegalArgumentException}.
     *
     * If the operation encountered an error, the error code will be delivered via
     * {@link MbmsDownloadSessionCallback#onError}.
     *
     * @param request The {@link DownloadRequest} provided during registration
     * @param listener The listener provided during registration.
     * @return {@link MbmsErrors#SUCCESS} if the operation did not encounter a synchronous error,
     * and some other error code otherwise.
     */
    public int removeStatusListener(@NonNull DownloadRequest request,
    public void removeStatusListener(@NonNull DownloadRequest request,
            @NonNull DownloadStatusListener listener) {
        try {
            IMbmsDownloadService downloadService = mService.get();
@@ -646,16 +678,24 @@ public class MbmsDownloadSession implements AutoCloseable {

            try {
                int result = downloadService.removeStatusListener(request, internalListener);
                if (result == MbmsErrors.UNKNOWN) {
                    // Unbind and throw an obvious error
                    close();
                    throw new IllegalStateException("Middleware must not return an"
                            + " unknown error code");
                }
                if (result != MbmsErrors.SUCCESS) {
                    if (result == MbmsErrors.DownloadErrors.ERROR_UNKNOWN_DOWNLOAD_REQUEST) {
                        throw new IllegalArgumentException("Unknown download request.");
                    }
                    return result;
                    sendErrorToApp(result, null);
                    return;
                }
            } catch (RemoteException e) {
                mService.set(null);
                sIsInitialized.set(false);
                return MbmsErrors.ERROR_MIDDLEWARE_LOST;
                sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
                return;
            }
        } finally {
            InternalDownloadStatusListener internalCallback =
@@ -664,7 +704,6 @@ public class MbmsDownloadSession implements AutoCloseable {
                internalCallback.stop();
            }
        }
        return MbmsErrors.SUCCESS;
    }

    /**
@@ -676,14 +715,15 @@ public class MbmsDownloadSession implements AutoCloseable {
     * If the middleware is not aware of the specified download request,
     * this method will throw an {@link IllegalArgumentException}.
     *
     * If the operation encountered an error, the error code will be delivered via
     * {@link MbmsDownloadSessionCallback#onError}.
     *
     * @param request The {@link DownloadRequest} that you want updates on.
     * @param executor The {@link Executor} on which calls to {@code listener} should be executed.
     * @param listener The listener that should be called when the middleware has information to
     *                 share on the progress of the download.
     * @return {@link MbmsErrors#SUCCESS} if the operation did not encounter a synchronous error,
     * and some other error code otherwise.
     */
    public int addProgressListener(@NonNull DownloadRequest request,
    public void addProgressListener(@NonNull DownloadRequest request,
            @NonNull Executor executor, @NonNull DownloadProgressListener listener) {
        IMbmsDownloadService downloadService = mService.get();
        if (downloadService == null) {
@@ -695,19 +735,25 @@ public class MbmsDownloadSession implements AutoCloseable {

        try {
            int result = downloadService.addProgressListener(request, internalListener);
            if (result == MbmsErrors.UNKNOWN) {
                // Unbind and throw an obvious error
                close();
                throw new IllegalStateException("Middleware must not return an unknown error code");
            }
            if (result != MbmsErrors.SUCCESS) {
                if (result == MbmsErrors.DownloadErrors.ERROR_UNKNOWN_DOWNLOAD_REQUEST) {
                    throw new IllegalArgumentException("Unknown download request.");
                }
                return result;
                sendErrorToApp(result, null);
                return;
            }
        } catch (RemoteException e) {
            mService.set(null);
            sIsInitialized.set(false);
            return MbmsErrors.ERROR_MIDDLEWARE_LOST;
            sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
            return;
        }
        mInternalDownloadProgressListeners.put(listener, internalListener);
        return MbmsErrors.SUCCESS;
    }

    /**
@@ -719,12 +765,13 @@ public class MbmsDownloadSession implements AutoCloseable {
     * If the middleware is not aware of the specified download request,
     * this method will throw an {@link IllegalArgumentException}.
     *
     * If the operation encountered an error, the error code will be delivered via
     * {@link MbmsDownloadSessionCallback#onError}.
     *
     * @param request The {@link DownloadRequest} provided during registration
     * @param listener The listener provided during registration.
     * @return {@link MbmsErrors#SUCCESS} if the operation did not encounter a synchronous error,
     * and some other error code otherwise.
     */
    public int removeProgressListener(@NonNull DownloadRequest request,
    public void removeProgressListener(@NonNull DownloadRequest request,
            @NonNull DownloadProgressListener listener) {
        try {
            IMbmsDownloadService downloadService = mService.get();
@@ -740,16 +787,24 @@ public class MbmsDownloadSession implements AutoCloseable {

            try {
                int result = downloadService.removeProgressListener(request, internalListener);
                if (result == MbmsErrors.UNKNOWN) {
                    // Unbind and throw an obvious error
                    close();
                    throw new IllegalStateException("Middleware must not"
                            + " return an unknown error code");
                }
                if (result != MbmsErrors.SUCCESS) {
                    if (result == MbmsErrors.DownloadErrors.ERROR_UNKNOWN_DOWNLOAD_REQUEST) {
                        throw new IllegalArgumentException("Unknown download request.");
                    }
                    return result;
                    sendErrorToApp(result, null);
                    return;
                }
            } catch (RemoteException e) {
                mService.set(null);
                sIsInitialized.set(false);
                return MbmsErrors.ERROR_MIDDLEWARE_LOST;
                sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
                return;
            }
        } finally {
            InternalDownloadProgressListener internalCallback =
@@ -758,20 +813,17 @@ public class MbmsDownloadSession implements AutoCloseable {
                internalCallback.stop();
            }
        }
        return MbmsErrors.SUCCESS;
    }

    /**
     * Attempts to cancel the specified {@link DownloadRequest}.
     *
     * If the middleware is not aware of the specified download request,
     * this method will throw an {@link IllegalArgumentException}.
     * If the operation encountered an error, the error code will be delivered via
     * {@link MbmsDownloadSessionCallback#onError}.
     *
     * @param downloadRequest The download request that you wish to cancel.
     * @return {@link MbmsErrors#SUCCESS} if the operation did not encounter a synchronous error,
     * and some other error code otherwise.
     */
    public int cancelDownload(@NonNull DownloadRequest downloadRequest) {
    public void cancelDownload(@NonNull DownloadRequest downloadRequest) {
        IMbmsDownloadService downloadService = mService.get();
        if (downloadService == null) {
            throw new IllegalStateException("Middleware not yet bound");
@@ -779,18 +831,20 @@ public class MbmsDownloadSession implements AutoCloseable {

        try {
            int result = downloadService.cancelDownload(downloadRequest);
            if (result != MbmsErrors.SUCCESS) {
                if (result == MbmsErrors.DownloadErrors.ERROR_UNKNOWN_DOWNLOAD_REQUEST) {
                    throw new IllegalArgumentException("Unknown download request.");
            if (result == MbmsErrors.UNKNOWN) {
                // Unbind and throw an obvious error
                close();
                throw new IllegalStateException("Middleware must not return an unknown error code");
            }
            if (result != MbmsErrors.SUCCESS) {
                sendErrorToApp(result, null);
            } else {
                deleteDownloadRequestToken(downloadRequest);
            }
            return result;
        } catch (RemoteException e) {
            mService.set(null);
            sIsInitialized.set(false);
            return MbmsErrors.ERROR_MIDDLEWARE_LOST;
            sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
        }
    }

@@ -818,6 +872,11 @@ public class MbmsDownloadSession implements AutoCloseable {

        try {
            int result = downloadService.requestDownloadState(downloadRequest, fileInfo);
            if (result == MbmsErrors.UNKNOWN) {
                // Unbind and throw an obvious error
                close();
                throw new IllegalStateException("Middleware must not return an unknown error code");
            }
            if (result != MbmsErrors.SUCCESS) {
                if (result == MbmsErrors.DownloadErrors.ERROR_UNKNOWN_DOWNLOAD_REQUEST) {
                    throw new IllegalArgumentException("Unknown download request.");
@@ -862,6 +921,11 @@ public class MbmsDownloadSession implements AutoCloseable {

        try {
            int result = downloadService.resetDownloadKnowledge(downloadRequest);
            if (result == MbmsErrors.UNKNOWN) {
                // Unbind and throw an obvious error
                close();
                throw new IllegalStateException("Middleware must not return an unknown error code");
            }
            if (result != MbmsErrors.SUCCESS) {
                if (result == MbmsErrors.DownloadErrors.ERROR_UNKNOWN_DOWNLOAD_REQUEST) {
                    throw new IllegalArgumentException("Unknown download request.");
@@ -978,10 +1042,6 @@ public class MbmsDownloadSession implements AutoCloseable {
    }

    private void sendErrorToApp(int errorCode, String message) {
        try {
        mInternalCallback.onError(errorCode, message);
        } catch (RemoteException e) {
            // Ignore, should not happen locally.
        }
    }
}
+19 −3
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.telephony;

import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SdkConstant;
@@ -26,8 +28,8 @@ import android.content.Context;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
import android.telephony.mbms.InternalStreamingSessionCallback;
import android.telephony.mbms.InternalStreamingServiceCallback;
import android.telephony.mbms.InternalStreamingSessionCallback;
import android.telephony.mbms.MbmsErrors;
import android.telephony.mbms.MbmsStreamingSessionCallback;
import android.telephony.mbms.MbmsUtils;
@@ -44,8 +46,6 @@ import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;

import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;

/**
 * This class provides functionality for streaming media over MBMS.
 */
@@ -208,6 +208,11 @@ public class MbmsStreamingSession implements AutoCloseable {
        try {
            int returnCode = streamingService.requestUpdateStreamingServices(
                    mSubscriptionId, serviceClassList);
            if (returnCode == MbmsErrors.UNKNOWN) {
                // Unbind and throw an obvious error
                close();
                throw new IllegalStateException("Middleware must not return an unknown error code");
            }
            if (returnCode != MbmsErrors.SUCCESS) {
                sendErrorToApp(returnCode, null);
            }
@@ -255,6 +260,11 @@ public class MbmsStreamingSession implements AutoCloseable {
        try {
            int returnCode = streamingService.startStreaming(
                    mSubscriptionId, serviceInfo.getServiceId(), serviceCallback);
            if (returnCode == MbmsErrors.UNKNOWN) {
                // Unbind and throw an obvious error
                close();
                throw new IllegalStateException("Middleware must not return an unknown error code");
            }
            if (returnCode != MbmsErrors.SUCCESS) {
                sendErrorToApp(returnCode, null);
                return null;
@@ -301,6 +311,12 @@ public class MbmsStreamingSession implements AutoCloseable {
                            sIsInitialized.set(false);
                            return;
                        }
                        if (result == MbmsErrors.UNKNOWN) {
                            // Unbind and throw an obvious error
                            close();
                            throw new IllegalStateException("Middleware must not return"
                                    + " an unknown error code");
                        }
                        if (result != MbmsErrors.SUCCESS) {
                            sendErrorToApp(result, "Error returned during initialization");
                            sIsInitialized.set(false);
+3 −4
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package android.telephony.mbms;

import android.os.Binder;
import android.os.RemoteException;

import java.util.List;
import java.util.concurrent.Executor;
@@ -36,7 +35,7 @@ public class InternalDownloadSessionCallback extends IMbmsDownloadSessionCallbac
    }

    @Override
    public void onError(final int errorCode, final String message) throws RemoteException {
    public void onError(final int errorCode, final String message) {
        if (mIsStopped) {
            return;
        }
@@ -55,7 +54,7 @@ public class InternalDownloadSessionCallback extends IMbmsDownloadSessionCallbac
    }

    @Override
    public void onFileServicesUpdated(final List<FileServiceInfo> services) throws RemoteException {
    public void onFileServicesUpdated(final List<FileServiceInfo> services) {
        if (mIsStopped) {
            return;
        }
@@ -74,7 +73,7 @@ public class InternalDownloadSessionCallback extends IMbmsDownloadSessionCallbac
    }

    @Override
    public void onMiddlewareReady() throws RemoteException {
    public void onMiddlewareReady() {
        if (mIsStopped) {
            return;
        }
+42 −6

File changed.

Preview size limit exceeded, changes collapsed.

Loading