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

Commit 4343998d authored by Hall Liu's avatar Hall Liu
Browse files

Add the addServiceAnnouncement API for EMBMS

Add addServiceAnnouncement to MbmsDownloadSession, allowing apps to add
service announcements from group call servers and receive information
about available files via the MbmsDownloadSession API surface.

Fixes: 144368478
Test: CTS
Change-Id: I760400f56219879fe71d0115042a3be2f83cef90
Merged-In: I760400f56219879fe71d0115042a3be2f83cef90
parent 14c78c2a
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -45340,12 +45340,14 @@ package android.telephony {
  public class MbmsDownloadSession implements java.lang.AutoCloseable {
  public class MbmsDownloadSession implements java.lang.AutoCloseable {
    method public void addProgressListener(@NonNull android.telephony.mbms.DownloadRequest, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.mbms.DownloadProgressListener);
    method public void addProgressListener(@NonNull android.telephony.mbms.DownloadRequest, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.mbms.DownloadProgressListener);
    method public void addServiceAnnouncementFile(@NonNull byte[]);
    method public void addStatusListener(@NonNull android.telephony.mbms.DownloadRequest, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.mbms.DownloadStatusListener);
    method public void addStatusListener(@NonNull android.telephony.mbms.DownloadRequest, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.mbms.DownloadStatusListener);
    method public void cancelDownload(@NonNull android.telephony.mbms.DownloadRequest);
    method public void cancelDownload(@NonNull android.telephony.mbms.DownloadRequest);
    method public void close();
    method public void close();
    method public static android.telephony.MbmsDownloadSession create(@NonNull android.content.Context, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.mbms.MbmsDownloadSessionCallback);
    method public static android.telephony.MbmsDownloadSession create(@NonNull android.content.Context, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.mbms.MbmsDownloadSessionCallback);
    method @Nullable public static android.telephony.MbmsDownloadSession create(@NonNull android.content.Context, @NonNull java.util.concurrent.Executor, int, @NonNull android.telephony.mbms.MbmsDownloadSessionCallback);
    method @Nullable public static android.telephony.MbmsDownloadSession create(@NonNull android.content.Context, @NonNull java.util.concurrent.Executor, int, @NonNull android.telephony.mbms.MbmsDownloadSessionCallback);
    method public void download(@NonNull android.telephony.mbms.DownloadRequest);
    method public void download(@NonNull android.telephony.mbms.DownloadRequest);
    method public static int getMaximumServiceAnnouncementFileSize();
    method @Nullable public java.io.File getTempFileRootDirectory();
    method @Nullable public java.io.File getTempFileRootDirectory();
    method @NonNull public java.util.List<android.telephony.mbms.DownloadRequest> listPendingDownloads();
    method @NonNull public java.util.List<android.telephony.mbms.DownloadRequest> listPendingDownloads();
    method public void removeProgressListener(@NonNull android.telephony.mbms.DownloadRequest, @NonNull android.telephony.mbms.DownloadProgressListener);
    method public void removeProgressListener(@NonNull android.telephony.mbms.DownloadRequest, @NonNull android.telephony.mbms.DownloadProgressListener);
@@ -46956,6 +46958,7 @@ package android.telephony.mbms {
  public static class MbmsErrors.DownloadErrors {
  public static class MbmsErrors.DownloadErrors {
    field public static final int ERROR_CANNOT_CHANGE_TEMP_FILE_ROOT = 401; // 0x191
    field public static final int ERROR_CANNOT_CHANGE_TEMP_FILE_ROOT = 401; // 0x191
    field public static final int ERROR_MALFORMED_SERVICE_ANNOUNCEMENT_FILE = 404; // 0x194
    field public static final int ERROR_UNKNOWN_DOWNLOAD_REQUEST = 402; // 0x192
    field public static final int ERROR_UNKNOWN_DOWNLOAD_REQUEST = 402; // 0x192
    field public static final int ERROR_UNKNOWN_FILE_INFO = 403; // 0x193
    field public static final int ERROR_UNKNOWN_FILE_INFO = 403; // 0x193
  }
  }
+1 −0
Original line number Original line Diff line number Diff line
@@ -10320,6 +10320,7 @@ package android.telephony.mbms.vendor {
  public class MbmsDownloadServiceBase extends android.os.Binder implements android.os.IInterface {
  public class MbmsDownloadServiceBase extends android.os.Binder implements android.os.IInterface {
    ctor public MbmsDownloadServiceBase();
    ctor public MbmsDownloadServiceBase();
    method public int addProgressListener(android.telephony.mbms.DownloadRequest, android.telephony.mbms.DownloadProgressListener) throws android.os.RemoteException;
    method public int addProgressListener(android.telephony.mbms.DownloadRequest, android.telephony.mbms.DownloadProgressListener) throws android.os.RemoteException;
    method public int addServiceAnnouncementFile(int, @NonNull byte[]);
    method public int addStatusListener(android.telephony.mbms.DownloadRequest, android.telephony.mbms.DownloadStatusListener) throws android.os.RemoteException;
    method public int addStatusListener(android.telephony.mbms.DownloadRequest, android.telephony.mbms.DownloadStatusListener) throws android.os.RemoteException;
    method public android.os.IBinder asBinder();
    method public android.os.IBinder asBinder();
    method public int cancelDownload(android.telephony.mbms.DownloadRequest) throws android.os.RemoteException;
    method public int cancelDownload(android.telephony.mbms.DownloadRequest) throws android.os.RemoteException;
+1 −0
Original line number Original line Diff line number Diff line
@@ -4098,6 +4098,7 @@ package android.telephony.mbms.vendor {
  public class MbmsDownloadServiceBase extends android.os.Binder implements android.os.IInterface {
  public class MbmsDownloadServiceBase extends android.os.Binder implements android.os.IInterface {
    ctor public MbmsDownloadServiceBase();
    ctor public MbmsDownloadServiceBase();
    method public int addProgressListener(android.telephony.mbms.DownloadRequest, android.telephony.mbms.DownloadProgressListener) throws android.os.RemoteException;
    method public int addProgressListener(android.telephony.mbms.DownloadRequest, android.telephony.mbms.DownloadProgressListener) throws android.os.RemoteException;
    method public int addServiceAnnouncementFile(int, @NonNull byte[]);
    method public int addStatusListener(android.telephony.mbms.DownloadRequest, android.telephony.mbms.DownloadStatusListener) throws android.os.RemoteException;
    method public int addStatusListener(android.telephony.mbms.DownloadRequest, android.telephony.mbms.DownloadStatusListener) throws android.os.RemoteException;
    method public android.os.IBinder asBinder();
    method public android.os.IBinder asBinder();
    method public int cancelDownload(android.telephony.mbms.DownloadRequest) throws android.os.RemoteException;
    method public int cancelDownload(android.telephony.mbms.DownloadRequest) throws android.os.RemoteException;
+66 −0
Original line number Original line Diff line number Diff line
@@ -231,6 +231,8 @@ public class MbmsDownloadSession implements AutoCloseable {


    private static final String DESTINATION_SANITY_CHECK_FILE_NAME = "destinationSanityCheckFile";
    private static final String DESTINATION_SANITY_CHECK_FILE_NAME = "destinationSanityCheckFile";


    private static final int MAX_SERVICE_ANNOUNCEMENT_FILE_SIZE = 10 * 1024; // 10KB

    private static AtomicBoolean sIsInitialized = new AtomicBoolean(false);
    private static AtomicBoolean sIsInitialized = new AtomicBoolean(false);


    private final Context mContext;
    private final Context mContext;
@@ -318,6 +320,16 @@ public class MbmsDownloadSession implements AutoCloseable {
        return session;
        return session;
    }
    }


    /**
     * Returns the maximum size of the service announcement file that can be provided via
     * {@link #addServiceAnnouncementFile}
     * @return The maximum length of the byte array passed as an argument to
     *         {@link #addServiceAnnouncementFile}.
     */
    public static int getMaximumServiceAnnouncementFileSize() {
        return MAX_SERVICE_ANNOUNCEMENT_FILE_SIZE;
    }

    private int bindAndInitialize() {
    private int bindAndInitialize() {
        mServiceConnection = new ServiceConnection() {
        mServiceConnection = new ServiceConnection() {
            @Override
            @Override
@@ -423,6 +435,60 @@ public class MbmsDownloadSession implements AutoCloseable {
        }
        }
    }
    }


    /**
     * Inform the middleware of a service announcement file received from a group communication
     * server.
     *
     * When participating in a group call via the {@link MbmsGroupCallSession} API, applications may
     * receive a service announcement file from the group call server that informs them of
     * files that may be relevant to users communicating on the group call.
     *
     * After supplying the service announcement file received from the server to the middleware via
     * this API, applications will receive information on the available files via
     * {@link MbmsDownloadSessionCallback#onFileServicesUpdated}, and the available files will be
     * downloadable via {@link MbmsDownloadSession#download} like other files published via
     * {@link MbmsDownloadSessionCallback#onFileServicesUpdated}.
     *
     * Asynchronous error codes via the {@link MbmsDownloadSessionCallback#onError(int, String)}
     * callback may include any of the errors that are not specific to the streaming use-case.
     *
     * May throw an {@link IllegalStateException} when the middleware has not yet been bound,
     * or an {@link IllegalArgumentException} if the file is too large.
     *
     * @param fileContents The contents of the service announcement file received from the group
     *                     call server. If the size of this array is greater than the value of
     *                     {@link #getMaximumServiceAnnouncementFileSize()}, an
     *                     {@link IllegalArgumentException} will be thrown.
     */
    public void addServiceAnnouncementFile(@NonNull byte[] fileContents) {
        IMbmsDownloadService downloadService = mService.get();
        if (downloadService == null) {
            throw new IllegalStateException("Middleware not yet bound");
        }

        if (fileContents.length > MAX_SERVICE_ANNOUNCEMENT_FILE_SIZE) {
            throw new IllegalArgumentException("File too large");
        }

        try {
            int returnCode = downloadService.addServiceAnnouncementFile(
                    mSubscriptionId, fileContents);
            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);
            }
        } catch (RemoteException e) {
            Log.w(LOG_TAG, "Remote process died");
            mService.set(null);
            sIsInitialized.set(false);
            sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
        }
    }

    /**
    /**
     * Sets the temp file root for downloads.
     * Sets the temp file root for downloads.
     * All temp files created for the middleware to write to will be contained in the specified
     * All temp files created for the middleware to write to will be contained in the specified
+41 −0
Original line number Original line Diff line number Diff line
@@ -16,8 +16,12 @@


package android.telephony.mbms;
package android.telephony.mbms;


import android.annotation.IntDef;
import android.telephony.MbmsStreamingSession;
import android.telephony.MbmsStreamingSession;


import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

public class MbmsErrors {
public class MbmsErrors {
    /**
    /**
     * Indicates that the middleware has sent an error code that is not defined in the version of
     * Indicates that the middleware has sent an error code that is not defined in the version of
@@ -138,6 +142,13 @@ public class MbmsErrors {


        /** Indicates the the middleware has no record of the supplied {@link FileInfo} */
        /** Indicates the the middleware has no record of the supplied {@link FileInfo} */
        public static final int ERROR_UNKNOWN_FILE_INFO = 403;
        public static final int ERROR_UNKNOWN_FILE_INFO = 403;

        /**
         * Indicates that the service announcement file passed via
         * {@link android.telephony.MbmsDownloadSession#addServiceAnnouncementFile(byte[])}
         * is malformed.
         */
        public static final int ERROR_MALFORMED_SERVICE_ANNOUNCEMENT_FILE = 404;
    }
    }


    /**
    /**
@@ -156,5 +167,35 @@ public class MbmsErrors {
        public static final int ERROR_DUPLICATE_START_GROUP_CALL = 502;
        public static final int ERROR_DUPLICATE_START_GROUP_CALL = 502;
    }
    }


    /** @hide */
    @IntDef(value = {
            SUCCESS,
            ERROR_NO_UNIQUE_MIDDLEWARE,
            ERROR_MIDDLEWARE_NOT_BOUND,
            ERROR_MIDDLEWARE_LOST,
            InitializationErrors.ERROR_DUPLICATE_INITIALIZE,
            InitializationErrors.ERROR_APP_PERMISSIONS_NOT_GRANTED,
            InitializationErrors.ERROR_UNABLE_TO_INITIALIZE,
            GeneralErrors.ERROR_MIDDLEWARE_NOT_YET_READY,
            GeneralErrors.ERROR_OUT_OF_MEMORY,
            GeneralErrors.ERROR_MIDDLEWARE_TEMPORARILY_UNAVAILABLE,
            GeneralErrors.ERROR_IN_E911,
            GeneralErrors.ERROR_NOT_CONNECTED_TO_HOME_CARRIER_LTE,
            GeneralErrors.ERROR_UNABLE_TO_READ_SIM,
            GeneralErrors.ERROR_CARRIER_CHANGE_NOT_ALLOWED,
            StreamingErrors.ERROR_CONCURRENT_SERVICE_LIMIT_REACHED,
            StreamingErrors.ERROR_UNABLE_TO_START_SERVICE,
            StreamingErrors.ERROR_DUPLICATE_START_STREAM,
            DownloadErrors.ERROR_CANNOT_CHANGE_TEMP_FILE_ROOT,
            DownloadErrors.ERROR_UNKNOWN_DOWNLOAD_REQUEST,
            DownloadErrors.ERROR_UNKNOWN_FILE_INFO,
            DownloadErrors.ERROR_MALFORMED_SERVICE_ANNOUNCEMENT_FILE,
            GroupCallErrors.ERROR_UNABLE_TO_START_SERVICE,
            GroupCallErrors.ERROR_DUPLICATE_START_GROUP_CALL,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface MbmsError {
    }

    private MbmsErrors() {}
    private MbmsErrors() {}
}
}
Loading