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

Commit 8023332b authored by Hall Liu's avatar Hall Liu
Browse files

getStreamingServices for embms

Add code to pipe through getStreamingServices for EMBMS and improve
documentation.

Test: testapps
Change-Id: I5248b69fda0cfdb10ffdc4f6952a1da52b47a716
parent aa9a59ab
Loading
Loading
Loading
Loading
+31 −24
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.DeadObjectException;
import android.os.IBinder;
import android.os.RemoteException;
import android.telephony.mbms.IMbmsStreamingManagerCallback;
@@ -96,15 +95,15 @@ public class MbmsStreamingManager {
    /**
     * Create a new MbmsStreamingManager using the given subscription ID.
     *
     * Note that this call will bind a remote service and that may take a bit.  This
     * may throw an {@link MbmsException}, indicating errors that may happen during
     * the initialization or binding process.
     * Note that this call will bind a remote service. You may not call this method on your app's
     * main thread. This may throw an {@link MbmsException}, indicating errors that may happen
     * during the initialization or binding process.
     *
     * @param context
     * @param listener
     * @param streamingAppName
     * @param subscriptionId
     * @return
     * @param context The {@link Context} to use.
     * @param listener A callback object on which you wish to receive results of asynchronous
     *                 operations.
     * @param streamingAppName The name of the streaming app, as specified by the carrier.
     * @param subscriptionId The subscription ID to use.
     */
    public static MbmsStreamingManager create(Context context,
            IMbmsStreamingManagerCallback listener, String streamingAppName, int subscriptionId)
@@ -117,9 +116,7 @@ public class MbmsStreamingManager {

    /**
     * Create a new MbmsStreamingManager using the system default data subscription ID.
     *
     * Note that this call will bind a remote service and that may take a bit.  This
     * may throw an IllegalArgumentException or RemoteException.
     * See {@link #create(Context, IMbmsStreamingManagerCallback, String, int)}.
     */
    public static MbmsStreamingManager create(Context context,
            IMbmsStreamingManagerCallback listener, String streamingAppName)
@@ -156,19 +153,29 @@ public class MbmsStreamingManager {
     *
     * Multiple calls replace the list of serviceClasses of interest.
     *
     * May throw an IllegalArgumentException or RemoteException.
     *
     * Synchronous responses include
     * <li>SUCCESS</li>
     * <li>ERROR_MSDC_CONCURRENT_SERVICE_LIMIT_REACHED</li>
     * This may throw an {@link MbmsException} containing one of the following errors:
     * {@link MbmsException#ERROR_MIDDLEWARE_NOT_BOUND}
     * {@link MbmsException#ERROR_NOT_YET_INITIALIZED}
     * {@link MbmsException#ERROR_CONCURRENT_SERVICE_LIMIT_REACHED}
     *
     * Asynchronous errors through the listener include any of the errors except
     * <li>ERROR_MSDC_UNABLE_TO_)START_SERVICE</li>
     * <li>ERROR_MSDC_INVALID_SERVICE_ID</li>
     * <li>ERROR_MSDC_END_OF_SESSION</li>
     * Asynchronous error codes via the {@link IMbmsStreamingManagerCallback#error(int, String)}
     * callback can include any of the errors except:
     * {@link MbmsException#ERROR_UNABLE_TO_START_SERVICE}
     * {@link MbmsException#ERROR_INVALID_SERVICE_ID}
     * {@link MbmsException#ERROR_END_OF_SESSION}
     */
    public int getStreamingServices(List<String> classList) {
        return 0;
    public void getStreamingServices(List<String> classList) throws MbmsException {
        if (mService == null) {
            throw new MbmsException(MbmsException.ERROR_MIDDLEWARE_NOT_BOUND);
        }
        try {
            int returnCode = mService.getStreamingServices(mAppName, mSubscriptionId, classList);
            if (returnCode != MbmsException.SUCCESS) {
                throw new MbmsException(returnCode);
            }
        } catch (RemoteException e) {
            throw new MbmsException(MbmsException.ERROR_UNKNOWN_REMOTE_EXCEPTION);
        }
    }

    /**
@@ -262,7 +269,7 @@ public class MbmsStreamingManager {
            } catch (RemoteException e) {
                mService = null;
                Log.e(LOG_TAG, "Service died before initialization");
                throw new MbmsException(MbmsException.ERROR_INITIALIZATION_REMOTE_EXCEPTION);
                throw new MbmsException(MbmsException.ERROR_UNKNOWN_REMOTE_EXCEPTION);
            }
        }
    }
+9 −4
Original line number Diff line number Diff line
@@ -16,16 +16,21 @@

package android.telephony.mbms;

import android.os.RemoteException;

/** @hide */
public class MbmsException extends RemoteException {
public class MbmsException extends Exception {
    public static final int SUCCESS = 0;
    public static final int ERROR_NO_SERVICE_INSTALLED = 1;
    public static final int ERROR_MULTIPLE_SERVICES_INSTALLED = 2;
    public static final int ERROR_BIND_TIMEOUT_OR_FAILURE = 3;
    public static final int ERROR_INITIALIZATION_REMOTE_EXCEPTION = 4;
    public static final int ERROR_UNKNOWN_REMOTE_EXCEPTION = 4;
    public static final int ERROR_ALREADY_INITIALIZED = 5;
    public static final int ERROR_CONCURRENT_SERVICE_LIMIT_REACHED = 6;
    public static final int ERROR_MIDDLEWARE_NOT_BOUND = 7;
    public static final int ERROR_UNABLE_TO_START_SERVICE = 8;
    public static final int ERROR_INVALID_SERVICE_ID = 9;
    public static final int ERROR_END_OF_SESSION = 10;
    public static final int ERROR_NOT_YET_INITIALIZED = 11;
    public static final int ERROR_APP_PERMISSIONS_NOT_GRANTED = 12;

    private final int mErrorCode;

+27 −0
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@ public class ServiceInfo implements Parcelable {
        sessionEndTime = (java.util.Date) in.readSerializable();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        Set<Locale> keySet = names.keySet();
        dest.writeInt(keySet.size());
@@ -128,7 +129,33 @@ public class ServiceInfo implements Parcelable {
        dest.writeSerializable(sessionEndTime);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public Map<Locale, String> getNames() {
        return names;
    }

    public String getClassName() {
        return className;
    }

    public Locale getLocale() {
        return locale;
    }

    public String getServiceId() {
        return serviceId;
    }

    public Date getSessionStartTime() {
        return sessionStartTime;
    }

    public Date getSessionEndTime() {
        return sessionEndTime;
    }

}
+0 −14
Original line number Diff line number Diff line
@@ -29,22 +29,8 @@ import android.telephony.SignalStrength;
 */
interface IMbmsStreamingService
{
    /**
     * Initialize streaming service
     * Registers this listener, subId with this appName
     *
     */
    int initialize(IMbmsStreamingManagerCallback listener, String appName, int subId);


    /**
     * - Registers serviceClasses of interest with the uid/appName/subId key.
     * - Starts asynch fetching data on streaming services of matching classes to be reported
     * later by callback.
     *
     * Note that subsequent calls with the same callback, appName, subId and uid will replace
     * the service class list.
     */
    int getStreamingServices(String appName, int subId, in List<String> serviceClasses);

    /**
+32 −6
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ import android.net.Uri;
import android.os.RemoteException;
import android.telephony.mbms.IMbmsStreamingManagerCallback;
import android.telephony.mbms.IStreamingServiceCallback;
import android.telephony.mbms.StreamingService;
import android.telephony.mbms.MbmsException;

import java.util.List;

@@ -29,16 +29,42 @@ import java.util.List;
 * TODO: future systemapi
 */
public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {

    /**
     * Initialize streaming service for this app and subId, registering the listener.
     *
     * @param listener The callback to use to communicate with the app.
     * @param appName The app name as negotiated with the wireless carrier.
     * @param subscriptionId The subscription ID to use.
     * @return {@link MbmsException#SUCCESS}, {@link MbmsException#ERROR_ALREADY_INITIALIZED}, or
     *         {@link MbmsException#ERROR_APP_PERMISSIONS_NOT_GRANTED}
     */
    @Override
    public int initialize(IMbmsStreamingManagerCallback listener, String appName, int subId)
            throws RemoteException {
    public int initialize(IMbmsStreamingManagerCallback listener, String appName,
            int subscriptionId) throws RemoteException {
        return 0;
    }

    /**
     * Registers serviceClasses of interest with the appName/subId key.
     * Starts async fetching data on streaming services of matching classes to be reported
     * later via {@link IMbmsStreamingManagerCallback#streamingServicesUpdated(List)}
     *
     * Note that subsequent calls with the same uid, appName and subId will replace
     * the service class list.
     *
     * @param appName The app name as negotiated with the wireless carrier.
     * @param subscriptionId The subscription id to use.
     * @param serviceClasses The service classes that the app wishes to get info on. The strings
     *                       may contain arbitrary data as negotiated between the app and the
     *                       carrier.
     * @return One of {@link MbmsException#SUCCESS},
     *         {@link MbmsException#ERROR_MIDDLEWARE_NOT_BOUND},
     *         {@link MbmsException#ERROR_NOT_YET_INITIALIZED}, or
     *         {@link MbmsException#ERROR_CONCURRENT_SERVICE_LIMIT_REACHED}
     */
    @Override
    public int getStreamingServices(String appName, int subId, List<String> serviceClasses)
            throws RemoteException {
    public int getStreamingServices(String appName, int subscriptionId,
            List<String> serviceClasses) throws RemoteException {
        return 0;
    }