Merge "Make changes to MBMS Streaming APIs per recommendations"
am: 1bbf287859
Change-Id: I76662fd9822dcde781cdecafb45239e1da6337d9
This commit is contained in:
@@ -505,7 +505,7 @@ LOCAL_SRC_FILES += \
|
||||
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/IMbmsStreamingManagerCallback.aidl \
|
||||
telephony/java/android/telephony/mbms/IMbmsStreamingSessionCallback.aidl \
|
||||
telephony/java/android/telephony/mbms/IDownloadStateCallback.aidl \
|
||||
telephony/java/android/telephony/mbms/IStreamingServiceCallback.aidl \
|
||||
telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl \
|
||||
|
||||
@@ -39746,13 +39746,12 @@ package android.telephony {
|
||||
field public static final int STATUS_UNKNOWN = 0; // 0x0
|
||||
}
|
||||
|
||||
public class MbmsStreamingManager {
|
||||
method public static android.telephony.MbmsStreamingManager create(android.content.Context, android.telephony.mbms.MbmsStreamingManagerCallback, int, android.os.Handler) throws android.telephony.mbms.MbmsException;
|
||||
method public static android.telephony.MbmsStreamingManager create(android.content.Context, android.telephony.mbms.MbmsStreamingManagerCallback, android.os.Handler) throws android.telephony.mbms.MbmsException;
|
||||
method public static android.telephony.MbmsStreamingManager create(android.content.Context, android.telephony.mbms.MbmsStreamingManagerCallback) throws android.telephony.mbms.MbmsException;
|
||||
method public void dispose();
|
||||
method public void getStreamingServices(java.util.List<java.lang.String>) throws android.telephony.mbms.MbmsException;
|
||||
method public android.telephony.mbms.StreamingService startStreaming(android.telephony.mbms.StreamingServiceInfo, android.telephony.mbms.StreamingServiceCallback, android.os.Handler) throws android.telephony.mbms.MbmsException;
|
||||
public class MbmsStreamingSession implements java.lang.AutoCloseable {
|
||||
method public void close();
|
||||
method public static android.telephony.MbmsStreamingSession create(android.content.Context, android.telephony.mbms.MbmsStreamingSessionCallback, int, android.os.Handler);
|
||||
method public static android.telephony.MbmsStreamingSession create(android.content.Context, android.telephony.mbms.MbmsStreamingSessionCallback, android.os.Handler);
|
||||
method public void requestUpdateStreamingServices(java.util.List<java.lang.String>);
|
||||
method public android.telephony.mbms.StreamingService startStreaming(android.telephony.mbms.StreamingServiceInfo, android.telephony.mbms.StreamingServiceCallback, android.os.Handler);
|
||||
}
|
||||
|
||||
public class NeighboringCellInfo implements android.os.Parcelable {
|
||||
@@ -40476,27 +40475,26 @@ package android.telephony.mbms {
|
||||
field public static final int ERROR_UNABLE_TO_START_SERVICE = 302; // 0x12e
|
||||
}
|
||||
|
||||
public class MbmsStreamingManagerCallback {
|
||||
ctor public MbmsStreamingManagerCallback();
|
||||
public class MbmsStreamingSessionCallback {
|
||||
ctor public MbmsStreamingSessionCallback();
|
||||
method public void onError(int, java.lang.String);
|
||||
method public void onMiddlewareReady();
|
||||
method public void onStreamingServicesUpdated(java.util.List<android.telephony.mbms.StreamingServiceInfo>);
|
||||
}
|
||||
|
||||
public class ServiceInfo {
|
||||
method public java.lang.String getClassName();
|
||||
method public java.util.List<java.util.Locale> getLocales();
|
||||
method public java.util.Map<java.util.Locale, java.lang.String> getNames();
|
||||
method public java.lang.String getServiceClassName();
|
||||
method public java.lang.String getServiceId();
|
||||
method public java.util.Date getSessionEndTime();
|
||||
method public java.util.Date getSessionStartTime();
|
||||
}
|
||||
|
||||
public class StreamingService {
|
||||
method public void dispose() throws android.telephony.mbms.MbmsException;
|
||||
method public android.telephony.mbms.StreamingServiceInfo getInfo();
|
||||
method public android.net.Uri getPlaybackUri() throws android.telephony.mbms.MbmsException;
|
||||
method public void stopStreaming() throws android.telephony.mbms.MbmsException;
|
||||
method public android.net.Uri getPlaybackUri();
|
||||
method public void stopStreaming();
|
||||
field public static final int BROADCAST_METHOD = 1; // 0x1
|
||||
field public static final int REASON_BY_USER_REQUEST = 1; // 0x1
|
||||
field public static final int REASON_END_OF_SESSION = 2; // 0x2
|
||||
|
||||
@@ -43176,13 +43176,12 @@ package android.telephony {
|
||||
field public static final int STATUS_UNKNOWN = 0; // 0x0
|
||||
}
|
||||
|
||||
public class MbmsStreamingManager {
|
||||
method public static android.telephony.MbmsStreamingManager create(android.content.Context, android.telephony.mbms.MbmsStreamingManagerCallback, int, android.os.Handler) throws android.telephony.mbms.MbmsException;
|
||||
method public static android.telephony.MbmsStreamingManager create(android.content.Context, android.telephony.mbms.MbmsStreamingManagerCallback, android.os.Handler) throws android.telephony.mbms.MbmsException;
|
||||
method public static android.telephony.MbmsStreamingManager create(android.content.Context, android.telephony.mbms.MbmsStreamingManagerCallback) throws android.telephony.mbms.MbmsException;
|
||||
method public void dispose();
|
||||
method public void getStreamingServices(java.util.List<java.lang.String>) throws android.telephony.mbms.MbmsException;
|
||||
method public android.telephony.mbms.StreamingService startStreaming(android.telephony.mbms.StreamingServiceInfo, android.telephony.mbms.StreamingServiceCallback, android.os.Handler) throws android.telephony.mbms.MbmsException;
|
||||
public class MbmsStreamingSession implements java.lang.AutoCloseable {
|
||||
method public void close();
|
||||
method public static android.telephony.MbmsStreamingSession create(android.content.Context, android.telephony.mbms.MbmsStreamingSessionCallback, int, android.os.Handler);
|
||||
method public static android.telephony.MbmsStreamingSession create(android.content.Context, android.telephony.mbms.MbmsStreamingSessionCallback, android.os.Handler);
|
||||
method public void requestUpdateStreamingServices(java.util.List<java.lang.String>);
|
||||
method public android.telephony.mbms.StreamingService startStreaming(android.telephony.mbms.StreamingServiceInfo, android.telephony.mbms.StreamingServiceCallback, android.os.Handler);
|
||||
field public static final java.lang.String MBMS_STREAMING_SERVICE_ACTION = "android.telephony.action.EmbmsStreaming";
|
||||
}
|
||||
|
||||
@@ -44001,27 +44000,26 @@ package android.telephony.mbms {
|
||||
field public static final int ERROR_UNABLE_TO_START_SERVICE = 302; // 0x12e
|
||||
}
|
||||
|
||||
public class MbmsStreamingManagerCallback {
|
||||
ctor public MbmsStreamingManagerCallback();
|
||||
public class MbmsStreamingSessionCallback {
|
||||
ctor public MbmsStreamingSessionCallback();
|
||||
method public void onError(int, java.lang.String);
|
||||
method public void onMiddlewareReady();
|
||||
method public void onStreamingServicesUpdated(java.util.List<android.telephony.mbms.StreamingServiceInfo>);
|
||||
}
|
||||
|
||||
public class ServiceInfo {
|
||||
method public java.lang.String getClassName();
|
||||
method public java.util.List<java.util.Locale> getLocales();
|
||||
method public java.util.Map<java.util.Locale, java.lang.String> getNames();
|
||||
method public java.lang.String getServiceClassName();
|
||||
method public java.lang.String getServiceId();
|
||||
method public java.util.Date getSessionEndTime();
|
||||
method public java.util.Date getSessionStartTime();
|
||||
}
|
||||
|
||||
public class StreamingService {
|
||||
method public void dispose() throws android.telephony.mbms.MbmsException;
|
||||
method public android.telephony.mbms.StreamingServiceInfo getInfo();
|
||||
method public android.net.Uri getPlaybackUri() throws android.telephony.mbms.MbmsException;
|
||||
method public void stopStreaming() throws android.telephony.mbms.MbmsException;
|
||||
method public android.net.Uri getPlaybackUri();
|
||||
method public void stopStreaming();
|
||||
field public static final int BROADCAST_METHOD = 1; // 0x1
|
||||
field public static final int REASON_BY_USER_REQUEST = 1; // 0x1
|
||||
field public static final int REASON_END_OF_SESSION = 2; // 0x2
|
||||
@@ -44082,11 +44080,10 @@ package android.telephony.mbms.vendor {
|
||||
public class MbmsStreamingServiceBase extends android.os.Binder {
|
||||
ctor public MbmsStreamingServiceBase();
|
||||
method public void dispose(int) throws android.os.RemoteException;
|
||||
method public void disposeStream(int, java.lang.String) throws android.os.RemoteException;
|
||||
method public android.net.Uri getPlaybackUri(int, java.lang.String) throws android.os.RemoteException;
|
||||
method public int getStreamingServices(int, java.util.List<java.lang.String>) throws android.os.RemoteException;
|
||||
method public int initialize(android.telephony.mbms.MbmsStreamingManagerCallback, int) throws android.os.RemoteException;
|
||||
method public int initialize(android.telephony.mbms.MbmsStreamingSessionCallback, int) throws android.os.RemoteException;
|
||||
method public void onAppCallbackDied(int, int);
|
||||
method public int requestUpdateStreamingServices(int, java.util.List<java.lang.String>) throws android.os.RemoteException;
|
||||
method public int startStreaming(int, java.lang.String, android.telephony.mbms.StreamingServiceCallback) throws android.os.RemoteException;
|
||||
method public void stopStreaming(int, java.lang.String) throws android.os.RemoteException;
|
||||
}
|
||||
|
||||
@@ -39970,13 +39970,12 @@ package android.telephony {
|
||||
field public static final int STATUS_UNKNOWN = 0; // 0x0
|
||||
}
|
||||
|
||||
public class MbmsStreamingManager {
|
||||
method public static android.telephony.MbmsStreamingManager create(android.content.Context, android.telephony.mbms.MbmsStreamingManagerCallback, int, android.os.Handler) throws android.telephony.mbms.MbmsException;
|
||||
method public static android.telephony.MbmsStreamingManager create(android.content.Context, android.telephony.mbms.MbmsStreamingManagerCallback, android.os.Handler) throws android.telephony.mbms.MbmsException;
|
||||
method public static android.telephony.MbmsStreamingManager create(android.content.Context, android.telephony.mbms.MbmsStreamingManagerCallback) throws android.telephony.mbms.MbmsException;
|
||||
method public void dispose();
|
||||
method public void getStreamingServices(java.util.List<java.lang.String>) throws android.telephony.mbms.MbmsException;
|
||||
method public android.telephony.mbms.StreamingService startStreaming(android.telephony.mbms.StreamingServiceInfo, android.telephony.mbms.StreamingServiceCallback, android.os.Handler) throws android.telephony.mbms.MbmsException;
|
||||
public class MbmsStreamingSession implements java.lang.AutoCloseable {
|
||||
method public void close();
|
||||
method public static android.telephony.MbmsStreamingSession create(android.content.Context, android.telephony.mbms.MbmsStreamingSessionCallback, int, android.os.Handler);
|
||||
method public static android.telephony.MbmsStreamingSession create(android.content.Context, android.telephony.mbms.MbmsStreamingSessionCallback, android.os.Handler);
|
||||
method public void requestUpdateStreamingServices(java.util.List<java.lang.String>);
|
||||
method public android.telephony.mbms.StreamingService startStreaming(android.telephony.mbms.StreamingServiceInfo, android.telephony.mbms.StreamingServiceCallback, android.os.Handler);
|
||||
}
|
||||
|
||||
public class NeighboringCellInfo implements android.os.Parcelable {
|
||||
@@ -40700,27 +40699,26 @@ package android.telephony.mbms {
|
||||
field public static final int ERROR_UNABLE_TO_START_SERVICE = 302; // 0x12e
|
||||
}
|
||||
|
||||
public class MbmsStreamingManagerCallback {
|
||||
ctor public MbmsStreamingManagerCallback();
|
||||
public class MbmsStreamingSessionCallback {
|
||||
ctor public MbmsStreamingSessionCallback();
|
||||
method public void onError(int, java.lang.String);
|
||||
method public void onMiddlewareReady();
|
||||
method public void onStreamingServicesUpdated(java.util.List<android.telephony.mbms.StreamingServiceInfo>);
|
||||
}
|
||||
|
||||
public class ServiceInfo {
|
||||
method public java.lang.String getClassName();
|
||||
method public java.util.List<java.util.Locale> getLocales();
|
||||
method public java.util.Map<java.util.Locale, java.lang.String> getNames();
|
||||
method public java.lang.String getServiceClassName();
|
||||
method public java.lang.String getServiceId();
|
||||
method public java.util.Date getSessionEndTime();
|
||||
method public java.util.Date getSessionStartTime();
|
||||
}
|
||||
|
||||
public class StreamingService {
|
||||
method public void dispose() throws android.telephony.mbms.MbmsException;
|
||||
method public android.telephony.mbms.StreamingServiceInfo getInfo();
|
||||
method public android.net.Uri getPlaybackUri() throws android.telephony.mbms.MbmsException;
|
||||
method public void stopStreaming() throws android.telephony.mbms.MbmsException;
|
||||
method public android.net.Uri getPlaybackUri();
|
||||
method public void stopStreaming();
|
||||
field public static final int BROADCAST_METHOD = 1; // 0x1
|
||||
field public static final int REASON_BY_USER_REQUEST = 1; // 0x1
|
||||
field public static final int REASON_END_OF_SESSION = 2; // 0x2
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package android.telephony;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SdkConstant;
|
||||
import android.annotation.SystemApi;
|
||||
import android.content.ComponentName;
|
||||
@@ -25,18 +27,20 @@ import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.RemoteException;
|
||||
import android.telephony.mbms.InternalStreamingManagerCallback;
|
||||
import android.telephony.mbms.InternalStreamingSessionCallback;
|
||||
import android.telephony.mbms.InternalStreamingServiceCallback;
|
||||
import android.telephony.mbms.MbmsException;
|
||||
import android.telephony.mbms.MbmsStreamingManagerCallback;
|
||||
import android.telephony.mbms.MbmsStreamingSessionCallback;
|
||||
import android.telephony.mbms.MbmsUtils;
|
||||
import android.telephony.mbms.StreamingService;
|
||||
import android.telephony.mbms.StreamingServiceCallback;
|
||||
import android.telephony.mbms.StreamingServiceInfo;
|
||||
import android.telephony.mbms.vendor.IMbmsStreamingService;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@@ -45,8 +49,8 @@ import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
/**
|
||||
* This class provides functionality for streaming media over MBMS.
|
||||
*/
|
||||
public class MbmsStreamingManager {
|
||||
private static final String LOG_TAG = "MbmsStreamingManager";
|
||||
public class MbmsStreamingSession implements AutoCloseable {
|
||||
private static final String LOG_TAG = "MbmsStreamingSession";
|
||||
|
||||
/**
|
||||
* Service action which must be handled by the middleware implementing the MBMS streaming
|
||||
@@ -69,94 +73,94 @@ public class MbmsStreamingManager {
|
||||
}
|
||||
};
|
||||
|
||||
private InternalStreamingManagerCallback mInternalCallback;
|
||||
private InternalStreamingSessionCallback mInternalCallback;
|
||||
private Set<StreamingService> mKnownActiveStreamingServices = new ArraySet<>();
|
||||
|
||||
private final Context mContext;
|
||||
private int mSubscriptionId = INVALID_SUBSCRIPTION_ID;
|
||||
|
||||
/** @hide */
|
||||
private MbmsStreamingManager(Context context, MbmsStreamingManagerCallback callback,
|
||||
private MbmsStreamingSession(Context context, MbmsStreamingSessionCallback callback,
|
||||
int subscriptionId, Handler handler) {
|
||||
mContext = context;
|
||||
mSubscriptionId = subscriptionId;
|
||||
if (handler == null) {
|
||||
handler = new Handler(Looper.getMainLooper());
|
||||
}
|
||||
mInternalCallback = new InternalStreamingManagerCallback(callback, handler);
|
||||
mInternalCallback = new InternalStreamingSessionCallback(callback, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new MbmsStreamingManager using the given subscription ID.
|
||||
* Create a new {@link MbmsStreamingSession} using the given subscription ID.
|
||||
*
|
||||
* 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.
|
||||
* main thread.
|
||||
*
|
||||
*
|
||||
* You may only have one instance of {@link MbmsStreamingManager} per UID. If you call this
|
||||
* method while there is an active instance of {@link MbmsStreamingManager} in your process
|
||||
* (in other words, one that has not had {@link #dispose()} called on it), this method will
|
||||
* throw an {@link MbmsException}. If you call this method in a different process
|
||||
* You may only have one instance of {@link MbmsStreamingSession} per UID. If you call this
|
||||
* method while there is an active instance of {@link MbmsStreamingSession} in your process
|
||||
* (in other words, one that has not had {@link #close()} called on it), this method will
|
||||
* throw an {@link IllegalStateException}. If you call this method in a different process
|
||||
* running under the same UID, an error will be indicated via
|
||||
* {@link MbmsStreamingManagerCallback#onError(int, String)}.
|
||||
* {@link MbmsStreamingSessionCallback#onError(int, String)}.
|
||||
*
|
||||
* Note that initialization may fail asynchronously. If you wish to try again after you
|
||||
* receive such an asynchronous error, you must call dispose() on the instance of
|
||||
* {@link MbmsStreamingManager} that you received before calling this method again.
|
||||
* receive such an asynchronous error, you must call {@link #close()} on the instance of
|
||||
* {@link MbmsStreamingSession} that you received before calling this method again.
|
||||
*
|
||||
* @param context The {@link Context} to use.
|
||||
* @param callback A callback object on which you wish to receive results of asynchronous
|
||||
* operations.
|
||||
* @param subscriptionId The subscription ID to use.
|
||||
* @param handler The handler you wish to receive callbacks on. If null, callbacks will be
|
||||
* processed on the main looper (in other words, the looper returned from
|
||||
* {@link Looper#getMainLooper()}).
|
||||
* @param handler The handler you wish to receive callbacks on.
|
||||
* @return An instance of {@link MbmsStreamingSession}, or null if an error occurred.
|
||||
*/
|
||||
public static MbmsStreamingManager create(Context context,
|
||||
MbmsStreamingManagerCallback callback, int subscriptionId, Handler handler)
|
||||
throws MbmsException {
|
||||
public static @Nullable MbmsStreamingSession create(@NonNull Context context,
|
||||
@NonNull MbmsStreamingSessionCallback callback, int subscriptionId,
|
||||
@NonNull Handler handler) {
|
||||
if (!sIsInitialized.compareAndSet(false, true)) {
|
||||
throw new MbmsException(MbmsException.InitializationErrors.ERROR_DUPLICATE_INITIALIZE);
|
||||
throw new IllegalStateException("Cannot create two instances of MbmsStreamingSession");
|
||||
}
|
||||
MbmsStreamingManager manager = new MbmsStreamingManager(context, callback,
|
||||
MbmsStreamingSession session = new MbmsStreamingSession(context, callback,
|
||||
subscriptionId, handler);
|
||||
try {
|
||||
manager.bindAndInitialize();
|
||||
} catch (MbmsException e) {
|
||||
|
||||
int result = session.bindAndInitialize();
|
||||
if (result != MbmsException.SUCCESS) {
|
||||
sIsInitialized.set(false);
|
||||
throw e;
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
callback.onError(result, null);
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
return manager;
|
||||
return session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new MbmsStreamingManager using the system default data subscription ID.
|
||||
* See {@link #create(Context, MbmsStreamingManagerCallback, int, Handler)}.
|
||||
* Create a new {@link MbmsStreamingSession} using the system default data subscription ID.
|
||||
* See {@link #create(Context, MbmsStreamingSessionCallback, int, Handler)}.
|
||||
*/
|
||||
public static MbmsStreamingManager create(Context context,
|
||||
MbmsStreamingManagerCallback callback, Handler handler)
|
||||
throws MbmsException {
|
||||
public static MbmsStreamingSession create(@NonNull Context context,
|
||||
@NonNull MbmsStreamingSessionCallback callback, @NonNull Handler handler) {
|
||||
return create(context, callback, SubscriptionManager.getDefaultSubscriptionId(), handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new MbmsStreamingManager using the system default data subscription ID and
|
||||
* default {@link Handler}.
|
||||
* See {@link #create(Context, MbmsStreamingManagerCallback, int, Handler)}.
|
||||
*/
|
||||
public static MbmsStreamingManager create(Context context,
|
||||
MbmsStreamingManagerCallback callback)
|
||||
throws MbmsException {
|
||||
return create(context, callback, SubscriptionManager.getDefaultSubscriptionId(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Terminates this instance, ending calls to the registered listener. Also terminates
|
||||
* any streaming services spawned from this instance.
|
||||
* Terminates this instance. Also terminates
|
||||
* any streaming services spawned from this instance as if
|
||||
* {@link StreamingService#stopStreaming()} had been called on them. After this method returns,
|
||||
* no further callbacks originating from the middleware will be enqueued on the provided
|
||||
* instance of {@link MbmsStreamingSessionCallback}, but callbacks that have already been
|
||||
* enqueued will still be delivered.
|
||||
*
|
||||
* It is safe to call {@link #create(Context, MbmsStreamingSessionCallback, int, Handler)} to
|
||||
* obtain another instance of {@link MbmsStreamingSession} immediately after this method
|
||||
* returns.
|
||||
*
|
||||
* May throw an {@link IllegalStateException}
|
||||
*/
|
||||
public void dispose() {
|
||||
public void close() {
|
||||
try {
|
||||
IMbmsStreamingService streamingService = mService.get();
|
||||
if (streamingService == null) {
|
||||
@@ -164,47 +168,49 @@ public class MbmsStreamingManager {
|
||||
return;
|
||||
}
|
||||
streamingService.dispose(mSubscriptionId);
|
||||
for (StreamingService s : mKnownActiveStreamingServices) {
|
||||
s.getCallback().stop();
|
||||
}
|
||||
mKnownActiveStreamingServices.clear();
|
||||
} catch (RemoteException e) {
|
||||
// Ignore for now
|
||||
} finally {
|
||||
mService.set(null);
|
||||
sIsInitialized.set(false);
|
||||
mInternalCallback.stop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An inspection API to retrieve the list of streaming media currently be advertised.
|
||||
* The results are returned asynchronously through the previously registered callback.
|
||||
* serviceClasses lets the app filter on types of programming and is opaque data between
|
||||
* the app and the carrier.
|
||||
* The results are returned asynchronously via
|
||||
* {@link MbmsStreamingSessionCallback#onStreamingServicesUpdated(List)} on the callback
|
||||
* provided upon creation.
|
||||
*
|
||||
* Multiple calls replace the list of serviceClasses of interest.
|
||||
* Multiple calls replace the list of service classes of interest.
|
||||
*
|
||||
* This may throw an {@link MbmsException} containing any error in
|
||||
* {@link android.telephony.mbms.MbmsException.GeneralErrors},
|
||||
* {@link MbmsException#ERROR_MIDDLEWARE_NOT_BOUND}, or
|
||||
* {@link MbmsException#ERROR_MIDDLEWARE_LOST}.
|
||||
* May throw an {@link IllegalArgumentException} or an {@link IllegalStateException}.
|
||||
*
|
||||
* May also throw an unchecked {@link IllegalArgumentException} or an
|
||||
* {@link IllegalStateException}
|
||||
*
|
||||
* @param classList A list of streaming service classes that the app would like updates on.
|
||||
* @param serviceClassList A list of streaming service classes that the app would like updates
|
||||
* on. The exact names of these classes should be negotiated with the
|
||||
* wireless carrier separately.
|
||||
*/
|
||||
public void getStreamingServices(List<String> classList) throws MbmsException {
|
||||
public void requestUpdateStreamingServices(List<String> serviceClassList) {
|
||||
IMbmsStreamingService streamingService = mService.get();
|
||||
if (streamingService == null) {
|
||||
throw new MbmsException(MbmsException.ERROR_MIDDLEWARE_NOT_BOUND);
|
||||
throw new IllegalStateException("Middleware not yet bound");
|
||||
}
|
||||
try {
|
||||
int returnCode = streamingService.getStreamingServices(mSubscriptionId, classList);
|
||||
int returnCode = streamingService.requestUpdateStreamingServices(
|
||||
mSubscriptionId, serviceClassList);
|
||||
if (returnCode != MbmsException.SUCCESS) {
|
||||
throw new MbmsException(returnCode);
|
||||
sendErrorToApp(returnCode, null);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.w(LOG_TAG, "Remote process died");
|
||||
mService.set(null);
|
||||
sIsInitialized.set(false);
|
||||
throw new MbmsException(MbmsException.ERROR_MIDDLEWARE_LOST);
|
||||
sendErrorToApp(MbmsException.ERROR_MIDDLEWARE_LOST, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,13 +221,7 @@ public class MbmsStreamingManager {
|
||||
* reported via
|
||||
* {@link android.telephony.mbms.StreamingServiceCallback#onStreamStateUpdated(int, int)}
|
||||
*
|
||||
* May throw an
|
||||
* {@link MbmsException} containing any of the error codes in
|
||||
* {@link android.telephony.mbms.MbmsException.GeneralErrors},
|
||||
* {@link MbmsException#ERROR_MIDDLEWARE_NOT_BOUND}, or
|
||||
* {@link MbmsException#ERROR_MIDDLEWARE_LOST}.
|
||||
*
|
||||
* May also throw an {@link IllegalArgumentException} or an {@link IllegalStateException}
|
||||
* May throw an {@link IllegalArgumentException} or an {@link IllegalStateException}
|
||||
*
|
||||
* Asynchronous errors through the callback include any of the errors in
|
||||
* {@link android.telephony.mbms.MbmsException.GeneralErrors} or
|
||||
@@ -229,42 +229,49 @@ public class MbmsStreamingManager {
|
||||
*
|
||||
* @param serviceInfo The information about the service to stream.
|
||||
* @param callback A callback that'll be called when something about the stream changes.
|
||||
* @param handler A handler that calls to {@code callback} should be called on. If null,
|
||||
* defaults to the handler provided via
|
||||
* {@link #create(Context, MbmsStreamingManagerCallback, int, Handler)}.
|
||||
* @param handler A handler that calls to {@code callback} should be called on.
|
||||
* @return An instance of {@link StreamingService} through which the stream can be controlled.
|
||||
* May be {@code null} if an error occurred.
|
||||
*/
|
||||
public StreamingService startStreaming(StreamingServiceInfo serviceInfo,
|
||||
StreamingServiceCallback callback, Handler handler) throws MbmsException {
|
||||
public @Nullable StreamingService startStreaming(StreamingServiceInfo serviceInfo,
|
||||
StreamingServiceCallback callback, @NonNull Handler handler) {
|
||||
IMbmsStreamingService streamingService = mService.get();
|
||||
if (streamingService == null) {
|
||||
throw new MbmsException(MbmsException.ERROR_MIDDLEWARE_NOT_BOUND);
|
||||
throw new IllegalStateException("Middleware not yet bound");
|
||||
}
|
||||
|
||||
InternalStreamingServiceCallback serviceCallback = new InternalStreamingServiceCallback(
|
||||
callback, handler == null ? mInternalCallback.getHandler() : handler);
|
||||
callback, handler);
|
||||
|
||||
StreamingService serviceForApp = new StreamingService(
|
||||
mSubscriptionId, streamingService, serviceInfo, serviceCallback);
|
||||
mSubscriptionId, streamingService, this, serviceInfo, serviceCallback);
|
||||
mKnownActiveStreamingServices.add(serviceForApp);
|
||||
|
||||
try {
|
||||
int returnCode = streamingService.startStreaming(
|
||||
mSubscriptionId, serviceInfo.getServiceId(), serviceCallback);
|
||||
if (returnCode != MbmsException.SUCCESS) {
|
||||
throw new MbmsException(returnCode);
|
||||
sendErrorToApp(returnCode, null);
|
||||
return null;
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.w(LOG_TAG, "Remote process died");
|
||||
mService.set(null);
|
||||
sIsInitialized.set(false);
|
||||
throw new MbmsException(MbmsException.ERROR_MIDDLEWARE_LOST);
|
||||
sendErrorToApp(MbmsException.ERROR_MIDDLEWARE_LOST, null);
|
||||
return null;
|
||||
}
|
||||
|
||||
return serviceForApp;
|
||||
}
|
||||
|
||||
private void bindAndInitialize() throws MbmsException {
|
||||
MbmsUtils.startBinding(mContext, MBMS_STREAMING_SERVICE_ACTION,
|
||||
/** @hide */
|
||||
public void onStreamingServiceStopped(StreamingService service) {
|
||||
mKnownActiveStreamingServices.remove(service);
|
||||
}
|
||||
|
||||
private int bindAndInitialize() {
|
||||
return MbmsUtils.startBinding(mContext, MBMS_STREAMING_SERVICE_ACTION,
|
||||
new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
@@ -315,7 +322,7 @@ public class MbmsStreamingManager {
|
||||
|
||||
private void sendErrorToApp(int errorCode, String message) {
|
||||
try {
|
||||
mInternalCallback.error(errorCode, message);
|
||||
mInternalCallback.onError(errorCode, message);
|
||||
} catch (RemoteException e) {
|
||||
// Ignore, should not happen locally.
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public final class FileServiceInfo extends ServiceInfo implements Parcelable {
|
||||
FileServiceInfo(Parcel in) {
|
||||
super(in);
|
||||
files = new ArrayList<FileInfo>();
|
||||
in.readList(files, null);
|
||||
in.readList(files, FileInfo.class.getClassLoader());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,11 +24,11 @@ import java.util.List;
|
||||
* The interface the clients top-level streaming listener will satisfy.
|
||||
* @hide
|
||||
*/
|
||||
oneway interface IMbmsStreamingManagerCallback
|
||||
oneway interface IMbmsStreamingSessionCallback
|
||||
{
|
||||
void error(int errorCode, String message);
|
||||
void onError(int errorCode, String message);
|
||||
|
||||
void streamingServicesUpdated(in List<StreamingServiceInfo> services);
|
||||
void onStreamingServicesUpdated(in List<StreamingServiceInfo> services);
|
||||
|
||||
void middlewareReady();
|
||||
void onMiddlewareReady();
|
||||
}
|
||||
@@ -20,9 +20,9 @@ package android.telephony.mbms;
|
||||
* @hide
|
||||
*/
|
||||
oneway interface IStreamingServiceCallback {
|
||||
void error(int errorCode, String message);
|
||||
void streamStateUpdated(int state, int reason);
|
||||
void mediaDescriptionUpdated();
|
||||
void broadcastSignalStrengthUpdated(int signalStrength);
|
||||
void streamMethodUpdated(int methodType);
|
||||
void onError(int errorCode, String message);
|
||||
void onStreamStateUpdated(int state, int reason);
|
||||
void onMediaDescriptionUpdated();
|
||||
void onBroadcastSignalStrengthUpdated(int signalStrength);
|
||||
void onStreamMethodUpdated(int methodType);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.os.RemoteException;
|
||||
public class InternalStreamingServiceCallback extends IStreamingServiceCallback.Stub {
|
||||
private final StreamingServiceCallback mAppCallback;
|
||||
private final Handler mHandler;
|
||||
private volatile boolean mIsStopped = false;
|
||||
|
||||
public InternalStreamingServiceCallback(StreamingServiceCallback appCallback, Handler handler) {
|
||||
mAppCallback = appCallback;
|
||||
@@ -30,7 +31,11 @@ public class InternalStreamingServiceCallback extends IStreamingServiceCallback.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(int errorCode, String message) throws RemoteException {
|
||||
public void onError(int errorCode, String message) throws RemoteException {
|
||||
if (mIsStopped) {
|
||||
return;
|
||||
}
|
||||
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -40,7 +45,11 @@ public class InternalStreamingServiceCallback extends IStreamingServiceCallback.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void streamStateUpdated(int state, int reason) throws RemoteException {
|
||||
public void onStreamStateUpdated(int state, int reason) throws RemoteException {
|
||||
if (mIsStopped) {
|
||||
return;
|
||||
}
|
||||
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -50,7 +59,11 @@ public class InternalStreamingServiceCallback extends IStreamingServiceCallback.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mediaDescriptionUpdated() throws RemoteException {
|
||||
public void onMediaDescriptionUpdated() throws RemoteException {
|
||||
if (mIsStopped) {
|
||||
return;
|
||||
}
|
||||
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -60,7 +73,11 @@ public class InternalStreamingServiceCallback extends IStreamingServiceCallback.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastSignalStrengthUpdated(int signalStrength) throws RemoteException {
|
||||
public void onBroadcastSignalStrengthUpdated(int signalStrength) throws RemoteException {
|
||||
if (mIsStopped) {
|
||||
return;
|
||||
}
|
||||
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -70,7 +87,11 @@ public class InternalStreamingServiceCallback extends IStreamingServiceCallback.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void streamMethodUpdated(int methodType) throws RemoteException {
|
||||
public void onStreamMethodUpdated(int methodType) throws RemoteException {
|
||||
if (mIsStopped) {
|
||||
return;
|
||||
}
|
||||
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -78,4 +99,8 @@ public class InternalStreamingServiceCallback extends IStreamingServiceCallback.
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
mIsStopped = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,25 +18,27 @@ package android.telephony.mbms;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.RemoteException;
|
||||
import android.telephony.mbms.IMbmsStreamingManagerCallback;
|
||||
import android.telephony.mbms.MbmsStreamingManagerCallback;
|
||||
import android.telephony.mbms.StreamingServiceInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** @hide */
|
||||
public class InternalStreamingManagerCallback extends IMbmsStreamingManagerCallback.Stub {
|
||||
public class InternalStreamingSessionCallback extends IMbmsStreamingSessionCallback.Stub {
|
||||
private final Handler mHandler;
|
||||
private final MbmsStreamingManagerCallback mAppCallback;
|
||||
private final MbmsStreamingSessionCallback mAppCallback;
|
||||
private volatile boolean mIsStopped = false;
|
||||
|
||||
public InternalStreamingManagerCallback(MbmsStreamingManagerCallback appCallback,
|
||||
public InternalStreamingSessionCallback(MbmsStreamingSessionCallback appCallback,
|
||||
Handler handler) {
|
||||
mAppCallback = appCallback;
|
||||
mHandler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(int errorCode, String message) throws RemoteException {
|
||||
public void onError(int errorCode, String message) throws RemoteException {
|
||||
if (mIsStopped) {
|
||||
return;
|
||||
}
|
||||
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -46,8 +48,12 @@ public class InternalStreamingManagerCallback extends IMbmsStreamingManagerCallb
|
||||
}
|
||||
|
||||
@Override
|
||||
public void streamingServicesUpdated(List<StreamingServiceInfo> services)
|
||||
public void onStreamingServicesUpdated(List<StreamingServiceInfo> services)
|
||||
throws RemoteException {
|
||||
if (mIsStopped) {
|
||||
return;
|
||||
}
|
||||
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -57,7 +63,11 @@ public class InternalStreamingManagerCallback extends IMbmsStreamingManagerCallb
|
||||
}
|
||||
|
||||
@Override
|
||||
public void middlewareReady() throws RemoteException {
|
||||
public void onMiddlewareReady() throws RemoteException {
|
||||
if (mIsStopped) {
|
||||
return;
|
||||
}
|
||||
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -69,4 +79,8 @@ public class InternalStreamingManagerCallback extends IMbmsStreamingManagerCallb
|
||||
public Handler getHandler() {
|
||||
return mHandler;
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
mIsStopped = true;
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package android.telephony.mbms;
|
||||
|
||||
import android.telephony.MbmsStreamingSession;
|
||||
|
||||
public class MbmsException extends Exception {
|
||||
/** Indicates that the operation was successful. */
|
||||
public static final int SUCCESS = 0;
|
||||
@@ -31,7 +33,7 @@ public class MbmsException extends Exception {
|
||||
/**
|
||||
* Indicates that the app attempted to perform an operation on an instance of
|
||||
* TODO link android.telephony.MbmsDownloadManager or
|
||||
* {@link android.telephony.MbmsStreamingManager} without being bound to the middleware.
|
||||
* {@link MbmsStreamingSession} without being bound to the middleware.
|
||||
*/
|
||||
public static final int ERROR_MIDDLEWARE_NOT_BOUND = 2;
|
||||
|
||||
@@ -46,7 +48,7 @@ public class MbmsException extends Exception {
|
||||
private InitializationErrors() {}
|
||||
/**
|
||||
* Indicates that the app tried to create more than one instance each of
|
||||
* {@link android.telephony.MbmsStreamingManager} or
|
||||
* {@link MbmsStreamingSession} or
|
||||
* TODO link android.telephony.MbmsDownloadManager
|
||||
*/
|
||||
public static final int ERROR_DUPLICATE_INITIALIZE = 101;
|
||||
@@ -64,7 +66,7 @@ public class MbmsException extends Exception {
|
||||
private GeneralErrors() {}
|
||||
/**
|
||||
* Indicates that the app attempted to perform an operation before receiving notification
|
||||
* that the middleware is ready via {@link MbmsStreamingManagerCallback#onMiddlewareReady()}
|
||||
* that the middleware is ready via {@link MbmsStreamingSessionCallback#onMiddlewareReady()}
|
||||
* or TODO: link MbmsDownloadManagerCallback#middlewareReady
|
||||
*/
|
||||
public static final int ERROR_MIDDLEWARE_NOT_YET_READY = 201;
|
||||
@@ -107,7 +109,7 @@ public class MbmsException extends Exception {
|
||||
|
||||
/**
|
||||
* Indicates that the app called
|
||||
* {@link android.telephony.MbmsStreamingManager#startStreaming(
|
||||
* {@link MbmsStreamingSession#startStreaming(
|
||||
* StreamingServiceInfo, StreamingServiceCallback, android.os.Handler)}
|
||||
* more than once for the same {@link StreamingServiceInfo}.
|
||||
*/
|
||||
|
||||
@@ -16,25 +16,26 @@
|
||||
|
||||
package android.telephony.mbms;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.os.RemoteException;
|
||||
import android.telephony.MbmsStreamingManager;
|
||||
import android.os.Handler;
|
||||
import android.telephony.MbmsStreamingSession;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A callback class that is used to receive information from the middleware on MBMS streaming
|
||||
* services. An instance of this object should be passed into
|
||||
* {@link android.telephony.MbmsStreamingManager#create(Context, MbmsStreamingManagerCallback)}.
|
||||
* {@link MbmsStreamingSession#create(Context, MbmsStreamingSessionCallback, int, Handler)}.
|
||||
*/
|
||||
public class MbmsStreamingManagerCallback {
|
||||
public class MbmsStreamingSessionCallback {
|
||||
/**
|
||||
* Called by the middleware when it has detected an error condition. The possible error codes
|
||||
* are listed in {@link MbmsException}.
|
||||
* @param errorCode The error code.
|
||||
* @param message A human-readable message generated by the middleware for debugging purposes.
|
||||
*/
|
||||
public void onError(int errorCode, String message) {
|
||||
public void onError(int errorCode, @Nullable String message) {
|
||||
// default implementation empty
|
||||
}
|
||||
|
||||
@@ -47,8 +48,7 @@ public class MbmsStreamingManagerCallback {
|
||||
* call with the same service class list would return different
|
||||
* results.
|
||||
*
|
||||
* @param services a List of StreamingServiceInfos
|
||||
*
|
||||
* @param services The list of available services.
|
||||
*/
|
||||
public void onStreamingServicesUpdated(List<StreamingServiceInfo> services) {
|
||||
// default implementation empty
|
||||
@@ -58,9 +58,9 @@ public class MbmsStreamingManagerCallback {
|
||||
* Called to indicate that the middleware has been initialized and is ready.
|
||||
*
|
||||
* Before this method is called, calling any method on an instance of
|
||||
* {@link android.telephony.MbmsStreamingManager} will result in an {@link MbmsException}
|
||||
* being thrown with error code {@link MbmsException#ERROR_MIDDLEWARE_NOT_BOUND}
|
||||
* or {@link MbmsException.GeneralErrors#ERROR_MIDDLEWARE_NOT_YET_READY}
|
||||
* {@link MbmsStreamingSession} will result in an {@link IllegalStateException} or an error
|
||||
* delivered via {@link #onError(int, String)} with error code
|
||||
* {@link MbmsException.GeneralErrors#ERROR_MIDDLEWARE_NOT_YET_READY}.
|
||||
*/
|
||||
public void onMiddlewareReady() {
|
||||
// default implementation empty
|
||||
@@ -68,19 +68,20 @@ public class MbmsUtils {
|
||||
return downloadServices.get(0).serviceInfo;
|
||||
}
|
||||
|
||||
public static void startBinding(Context context, String serviceAction,
|
||||
ServiceConnection serviceConnection) throws MbmsException {
|
||||
public static int startBinding(Context context, String serviceAction,
|
||||
ServiceConnection serviceConnection) {
|
||||
Intent bindIntent = new Intent();
|
||||
ServiceInfo mbmsServiceInfo =
|
||||
MbmsUtils.getMiddlewareServiceInfo(context, serviceAction);
|
||||
|
||||
if (mbmsServiceInfo == null) {
|
||||
throw new MbmsException(MbmsException.ERROR_NO_UNIQUE_MIDDLEWARE);
|
||||
return MbmsException.ERROR_NO_UNIQUE_MIDDLEWARE;
|
||||
}
|
||||
|
||||
bindIntent.setComponent(MbmsUtils.toComponentName(mbmsServiceInfo));
|
||||
|
||||
context.bindService(bindIntent, serviceConnection, Context.BIND_AUTO_CREATE);
|
||||
return MbmsException.SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -123,7 +123,7 @@ public class ServiceInfo {
|
||||
/**
|
||||
* The class name for this service - used to categorize and filter
|
||||
*/
|
||||
public String getClassName() {
|
||||
public String getServiceClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,10 @@
|
||||
package android.telephony.mbms;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.Nullable;
|
||||
import android.net.Uri;
|
||||
import android.os.RemoteException;
|
||||
import android.telephony.MbmsStreamingSession;
|
||||
import android.telephony.mbms.vendor.IMbmsStreamingService;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -27,7 +29,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* Class used to represent a single MBMS stream. After a stream has been started with
|
||||
* {@link android.telephony.MbmsStreamingManager#startStreaming(StreamingServiceInfo,
|
||||
* {@link MbmsStreamingSession#startStreaming(StreamingServiceInfo,
|
||||
* StreamingServiceCallback, android.os.Handler)},
|
||||
* this class is used to hold information about the stream and control it.
|
||||
*/
|
||||
@@ -63,7 +65,7 @@ public class StreamingService {
|
||||
|
||||
/**
|
||||
* State changed due to a call to {@link #stopStreaming()} or
|
||||
* {@link android.telephony.MbmsStreamingManager#startStreaming(StreamingServiceInfo,
|
||||
* {@link MbmsStreamingSession#startStreaming(StreamingServiceInfo,
|
||||
* StreamingServiceCallback, android.os.Handler)}
|
||||
*/
|
||||
public static final int REASON_BY_USER_REQUEST = 1;
|
||||
@@ -101,6 +103,7 @@ public class StreamingService {
|
||||
public final static int UNICAST_METHOD = 2;
|
||||
|
||||
private final int mSubscriptionId;
|
||||
private final MbmsStreamingSession mParentSession;
|
||||
private final StreamingServiceInfo mServiceInfo;
|
||||
private final InternalStreamingServiceCallback mCallback;
|
||||
|
||||
@@ -111,25 +114,25 @@ public class StreamingService {
|
||||
*/
|
||||
public StreamingService(int subscriptionId,
|
||||
IMbmsStreamingService service,
|
||||
MbmsStreamingSession session,
|
||||
StreamingServiceInfo streamingServiceInfo,
|
||||
InternalStreamingServiceCallback callback) {
|
||||
mSubscriptionId = subscriptionId;
|
||||
mParentSession = session;
|
||||
mService = service;
|
||||
mServiceInfo = streamingServiceInfo;
|
||||
mCallback = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retreive the Uri used to play this stream.
|
||||
* Retrieve the Uri used to play this stream.
|
||||
*
|
||||
* This may throw a {@link MbmsException} with the error code
|
||||
* {@link MbmsException#ERROR_MIDDLEWARE_LOST}
|
||||
* May throw an {@link IllegalArgumentException} or an {@link IllegalStateException}.
|
||||
*
|
||||
* May also throw an {@link IllegalArgumentException} or an {@link IllegalStateException}
|
||||
*
|
||||
* @return The {@link Uri} to pass to the streaming client.
|
||||
* @return The {@link Uri} to pass to the streaming client, or {@code null} if an error
|
||||
* occurred.
|
||||
*/
|
||||
public Uri getPlaybackUri() throws MbmsException {
|
||||
public @Nullable Uri getPlaybackUri() {
|
||||
if (mService == null) {
|
||||
throw new IllegalStateException("No streaming service attached");
|
||||
}
|
||||
@@ -139,25 +142,26 @@ public class StreamingService {
|
||||
} catch (RemoteException e) {
|
||||
Log.w(LOG_TAG, "Remote process died");
|
||||
mService = null;
|
||||
throw new MbmsException(MbmsException.ERROR_MIDDLEWARE_LOST);
|
||||
mParentSession.onStreamingServiceStopped(this);
|
||||
sendErrorToApp(MbmsException.ERROR_MIDDLEWARE_LOST, null);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retreive the info for this StreamingService.
|
||||
* Retrieve the {@link StreamingServiceInfo} corresponding to this stream.
|
||||
*/
|
||||
public StreamingServiceInfo getInfo() {
|
||||
return mServiceInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop streaming this service.
|
||||
* This may throw a {@link MbmsException} with the error code
|
||||
* {@link MbmsException#ERROR_MIDDLEWARE_LOST}
|
||||
* Stop streaming this service. Further operations on this object will fail with an
|
||||
* {@link IllegalStateException}.
|
||||
*
|
||||
* May also throw an {@link IllegalArgumentException} or an {@link IllegalStateException}
|
||||
* May throw an {@link IllegalArgumentException} or an {@link IllegalStateException}
|
||||
*/
|
||||
public void stopStreaming() throws MbmsException {
|
||||
public void stopStreaming() {
|
||||
if (mService == null) {
|
||||
throw new IllegalStateException("No streaming service attached");
|
||||
}
|
||||
@@ -167,32 +171,22 @@ public class StreamingService {
|
||||
} catch (RemoteException e) {
|
||||
Log.w(LOG_TAG, "Remote process died");
|
||||
mService = null;
|
||||
throw new MbmsException(MbmsException.ERROR_MIDDLEWARE_LOST);
|
||||
sendErrorToApp(MbmsException.ERROR_MIDDLEWARE_LOST, null);
|
||||
} finally {
|
||||
mParentSession.onStreamingServiceStopped(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disposes of this stream. Further operations on this object will fail with an
|
||||
* {@link IllegalStateException}.
|
||||
*
|
||||
* This may throw a {@link MbmsException} with the error code
|
||||
* {@link MbmsException#ERROR_MIDDLEWARE_LOST}
|
||||
* May also throw an {@link IllegalStateException}
|
||||
*/
|
||||
public void dispose() throws MbmsException {
|
||||
if (mService == null) {
|
||||
throw new IllegalStateException("No streaming service attached");
|
||||
}
|
||||
/** @hide */
|
||||
public InternalStreamingServiceCallback getCallback() {
|
||||
return mCallback;
|
||||
}
|
||||
|
||||
private void sendErrorToApp(int errorCode, String message) {
|
||||
try {
|
||||
mService.disposeStream(mSubscriptionId, mServiceInfo.getServiceId());
|
||||
mCallback.onError(errorCode, message);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(LOG_TAG, "Remote process died");
|
||||
throw new MbmsException(MbmsException.ERROR_MIDDLEWARE_LOST);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new IllegalStateException("StreamingService state inconsistent with middleware");
|
||||
} finally {
|
||||
mService = null;
|
||||
// Ignore, should not happen locally.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package android.telephony.mbms;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A callback class for use when the application is actively streaming content. The middleware
|
||||
* will provide updates on the status of the stream via this callback.
|
||||
@@ -37,7 +39,7 @@ public class StreamingServiceCallback {
|
||||
* @param errorCode The error code.
|
||||
* @param message A human-readable message generated by the middleware for debugging purposes.
|
||||
*/
|
||||
public void onError(int errorCode, String message) {
|
||||
public void onError(int errorCode, @Nullable String message) {
|
||||
// default implementation empty
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package android.telephony.mbms.vendor;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.telephony.mbms.IMbmsStreamingManagerCallback;
|
||||
import android.telephony.mbms.IMbmsStreamingSessionCallback;
|
||||
import android.telephony.mbms.IStreamingServiceCallback;
|
||||
import android.telephony.mbms.StreamingServiceInfo;
|
||||
|
||||
@@ -26,18 +26,16 @@ import android.telephony.mbms.StreamingServiceInfo;
|
||||
*/
|
||||
interface IMbmsStreamingService
|
||||
{
|
||||
int initialize(IMbmsStreamingManagerCallback listener, int subId);
|
||||
int initialize(IMbmsStreamingSessionCallback callback, int subId);
|
||||
|
||||
int getStreamingServices(int subId, in List<String> serviceClasses);
|
||||
int requestUpdateStreamingServices(int subId, in List<String> serviceClasses);
|
||||
|
||||
int startStreaming(int subId, String serviceId,
|
||||
IStreamingServiceCallback listener);
|
||||
IStreamingServiceCallback callback);
|
||||
|
||||
Uri getPlaybackUri(int subId, String serviceId);
|
||||
|
||||
void stopStreaming(int subId, String serviceId);
|
||||
|
||||
void disposeStream(int subId, String serviceId);
|
||||
|
||||
void dispose(int subId);
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Binder;
|
||||
import android.os.RemoteException;
|
||||
import android.telephony.mbms.IMbmsStreamingManagerCallback;
|
||||
import android.telephony.mbms.IMbmsStreamingSessionCallback;
|
||||
import android.telephony.mbms.IStreamingServiceCallback;
|
||||
import android.telephony.mbms.MbmsException;
|
||||
import android.telephony.mbms.MbmsStreamingManagerCallback;
|
||||
import android.telephony.mbms.MbmsStreamingSessionCallback;
|
||||
import android.telephony.mbms.StreamingService;
|
||||
import android.telephony.mbms.StreamingServiceCallback;
|
||||
import android.telephony.mbms.StreamingServiceInfo;
|
||||
@@ -48,12 +48,12 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
|
||||
*
|
||||
* May return any value from {@link android.telephony.mbms.MbmsException.InitializationErrors}
|
||||
* or {@link MbmsException#SUCCESS}. Non-successful error codes will be passed to the app via
|
||||
* {@link IMbmsStreamingManagerCallback#error(int, String)}.
|
||||
* {@link IMbmsStreamingSessionCallback#onError(int, String)}.
|
||||
*
|
||||
* @param callback The callback to use to communicate with the app.
|
||||
* @param subscriptionId The subscription ID to use.
|
||||
*/
|
||||
public int initialize(MbmsStreamingManagerCallback callback, int subscriptionId)
|
||||
public int initialize(MbmsStreamingSessionCallback callback, int subscriptionId)
|
||||
throws RemoteException {
|
||||
return 0;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public final int initialize(final IMbmsStreamingManagerCallback callback,
|
||||
public final int initialize(final IMbmsStreamingSessionCallback callback,
|
||||
final int subscriptionId) throws RemoteException {
|
||||
final int uid = Binder.getCallingUid();
|
||||
callback.asBinder().linkToDeath(new DeathRecipient() {
|
||||
@@ -73,11 +73,11 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
|
||||
}
|
||||
}, 0);
|
||||
|
||||
return initialize(new MbmsStreamingManagerCallback() {
|
||||
return initialize(new MbmsStreamingSessionCallback() {
|
||||
@Override
|
||||
public void onError(int errorCode, String message) {
|
||||
try {
|
||||
callback.error(errorCode, message);
|
||||
callback.onError(errorCode, message);
|
||||
} catch (RemoteException e) {
|
||||
onAppCallbackDied(uid, subscriptionId);
|
||||
}
|
||||
@@ -86,7 +86,7 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
|
||||
@Override
|
||||
public void onStreamingServicesUpdated(List<StreamingServiceInfo> services) {
|
||||
try {
|
||||
callback.streamingServicesUpdated(services);
|
||||
callback.onStreamingServicesUpdated(services);
|
||||
} catch (RemoteException e) {
|
||||
onAppCallbackDied(uid, subscriptionId);
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
|
||||
@Override
|
||||
public void onMiddlewareReady() {
|
||||
try {
|
||||
callback.middlewareReady();
|
||||
callback.onMiddlewareReady();
|
||||
} catch (RemoteException e) {
|
||||
onAppCallbackDied(uid, subscriptionId);
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
|
||||
/**
|
||||
* 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)}
|
||||
* later via {@link IMbmsStreamingSessionCallback#onStreamingServicesUpdated(List)}
|
||||
*
|
||||
* Note that subsequent calls with the same uid and subId will replace
|
||||
* the service class list.
|
||||
@@ -122,7 +122,7 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
|
||||
* {@link android.telephony.mbms.MbmsException.GeneralErrors}
|
||||
*/
|
||||
@Override
|
||||
public int getStreamingServices(int subscriptionId,
|
||||
public int requestUpdateStreamingServices(int subscriptionId,
|
||||
List<String> serviceClasses) throws RemoteException {
|
||||
return 0;
|
||||
}
|
||||
@@ -130,7 +130,7 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
|
||||
/**
|
||||
* Starts streaming on a particular service. This method may perform asynchronous work. When
|
||||
* the middleware is ready to send bits to the frontend, it should inform the app via
|
||||
* {@link IStreamingServiceCallback#streamStateUpdated(int, int)}.
|
||||
* {@link IStreamingServiceCallback#onStreamStateUpdated(int, int)}.
|
||||
*
|
||||
* May throw an {@link IllegalArgumentException} or an {@link IllegalStateException}
|
||||
*
|
||||
@@ -164,7 +164,7 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
|
||||
@Override
|
||||
public void onError(int errorCode, String message) {
|
||||
try {
|
||||
callback.error(errorCode, message);
|
||||
callback.onError(errorCode, message);
|
||||
} catch (RemoteException e) {
|
||||
onAppCallbackDied(uid, subscriptionId);
|
||||
}
|
||||
@@ -174,7 +174,7 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
|
||||
public void onStreamStateUpdated(@StreamingService.StreamingState int state,
|
||||
@StreamingService.StreamingStateChangeReason int reason) {
|
||||
try {
|
||||
callback.streamStateUpdated(state, reason);
|
||||
callback.onStreamStateUpdated(state, reason);
|
||||
} catch (RemoteException e) {
|
||||
onAppCallbackDied(uid, subscriptionId);
|
||||
}
|
||||
@@ -183,7 +183,7 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
|
||||
@Override
|
||||
public void onMediaDescriptionUpdated() {
|
||||
try {
|
||||
callback.mediaDescriptionUpdated();
|
||||
callback.onMediaDescriptionUpdated();
|
||||
} catch (RemoteException e) {
|
||||
onAppCallbackDied(uid, subscriptionId);
|
||||
}
|
||||
@@ -192,7 +192,7 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
|
||||
@Override
|
||||
public void onBroadcastSignalStrengthUpdated(int signalStrength) {
|
||||
try {
|
||||
callback.broadcastSignalStrengthUpdated(signalStrength);
|
||||
callback.onBroadcastSignalStrengthUpdated(signalStrength);
|
||||
} catch (RemoteException e) {
|
||||
onAppCallbackDied(uid, subscriptionId);
|
||||
}
|
||||
@@ -201,7 +201,7 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
|
||||
@Override
|
||||
public void onStreamMethodUpdated(int methodType) {
|
||||
try {
|
||||
callback.streamMethodUpdated(methodType);
|
||||
callback.onStreamMethodUpdated(methodType);
|
||||
} catch (RemoteException e) {
|
||||
onAppCallbackDied(uid, subscriptionId);
|
||||
}
|
||||
@@ -228,7 +228,11 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
|
||||
/**
|
||||
* Stop streaming the stream identified by {@code serviceId}. Notification of the resulting
|
||||
* stream state change should be reported to the app via
|
||||
* {@link IStreamingServiceCallback#streamStateUpdated(int, int)}.
|
||||
* {@link IStreamingServiceCallback#onStreamStateUpdated(int, int)}.
|
||||
*
|
||||
* In addition, the callback provided via
|
||||
* {@link #startStreaming(int, String, IStreamingServiceCallback)} should no longer be
|
||||
* used after this method has called by the app.
|
||||
*
|
||||
* May throw an {@link IllegalArgumentException} or an {@link IllegalStateException}
|
||||
*
|
||||
@@ -240,28 +244,11 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
|
||||
throws RemoteException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose of the stream identified by {@code serviceId} for the app identified by the
|
||||
* {@code appName} and {@code subscriptionId} arguments along with the caller's uid.
|
||||
* No notification back to the app is required for this operation, and the callback provided via
|
||||
* {@link #startStreaming(int, String, IStreamingServiceCallback)} should no longer be
|
||||
* used after this method has called by the app.
|
||||
*
|
||||
* May throw an {@link IllegalArgumentException} or an {@link IllegalStateException}
|
||||
*
|
||||
* @param subscriptionId The subscription id to use.
|
||||
* @param serviceId The ID of the streaming service that the app wishes to dispose of.
|
||||
*/
|
||||
@Override
|
||||
public void disposeStream(int subscriptionId, String serviceId)
|
||||
throws RemoteException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Signals that the app wishes to dispose of the session identified by the
|
||||
* {@code subscriptionId} argument and the caller's uid. No notification back to the
|
||||
* app is required for this operation, and the corresponding callback provided via
|
||||
* {@link #initialize(IMbmsStreamingManagerCallback, int)} should no longer be used
|
||||
* {@link #initialize(IMbmsStreamingSessionCallback, int)} should no longer be used
|
||||
* after this method has been called by the app.
|
||||
*
|
||||
* May throw an {@link IllegalStateException}
|
||||
|
||||
Reference in New Issue
Block a user