Merge "startStreaming for MBMS apis"

am: 4b3c44be55

Change-Id: Id0e2e95387300147ba32ec3a418605901fdb241b
This commit is contained in:
Hall Liu
2017-05-16 19:52:26 +00:00
committed by android-build-merger
9 changed files with 109 additions and 134 deletions

View File

@@ -553,7 +553,6 @@ aidl_files := \
frameworks/base/telephony/java/android/telephony/mbms/FileInfo.aidl \ frameworks/base/telephony/java/android/telephony/mbms/FileInfo.aidl \
frameworks/base/telephony/java/android/telephony/mbms/FileServiceInfo.aidl \ frameworks/base/telephony/java/android/telephony/mbms/FileServiceInfo.aidl \
frameworks/base/telephony/java/android/telephony/mbms/ServiceInfo.aidl \ frameworks/base/telephony/java/android/telephony/mbms/ServiceInfo.aidl \
frameworks/base/telephony/java/android/telephony/mbms/StreamingService.aidl \
frameworks/base/telephony/java/android/telephony/mbms/StreamingServiceInfo.aidl \ frameworks/base/telephony/java/android/telephony/mbms/StreamingServiceInfo.aidl \
frameworks/base/telephony/java/android/telephony/ServiceState.aidl \ frameworks/base/telephony/java/android/telephony/ServiceState.aidl \
frameworks/base/telephony/java/android/telephony/SubscriptionInfo.aidl \ frameworks/base/telephony/java/android/telephony/SubscriptionInfo.aidl \

View File

@@ -24,10 +24,10 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.os.IBinder; import android.os.IBinder;
import android.os.RemoteException; import android.os.RemoteException;
import android.telephony.mbms.IMbmsStreamingManagerCallback;
import android.telephony.mbms.IStreamingServiceCallback;
import android.telephony.mbms.MbmsException; import android.telephony.mbms.MbmsException;
import android.telephony.mbms.MbmsStreamingManagerCallback;
import android.telephony.mbms.StreamingService; import android.telephony.mbms.StreamingService;
import android.telephony.mbms.StreamingServiceCallback;
import android.telephony.mbms.StreamingServiceInfo; import android.telephony.mbms.StreamingServiceInfo;
import android.telephony.mbms.vendor.IMbmsStreamingService; import android.telephony.mbms.vendor.IMbmsStreamingService;
import android.util.Log; import android.util.Log;
@@ -77,14 +77,14 @@ public class MbmsStreamingManager {
}; };
private List<ServiceListener> mServiceListeners = new LinkedList<>(); private List<ServiceListener> mServiceListeners = new LinkedList<>();
private IMbmsStreamingManagerCallback mCallbackToApp; private MbmsStreamingManagerCallback mCallbackToApp;
private final String mAppName; private final String mAppName;
private final Context mContext; private final Context mContext;
private int mSubscriptionId = INVALID_SUBSCRIPTION_ID; private int mSubscriptionId = INVALID_SUBSCRIPTION_ID;
/** @hide */ /** @hide */
private MbmsStreamingManager(Context context, IMbmsStreamingManagerCallback listener, private MbmsStreamingManager(Context context, MbmsStreamingManagerCallback listener,
String streamingAppName, int subscriptionId) { String streamingAppName, int subscriptionId) {
mContext = context; mContext = context;
mAppName = streamingAppName; mAppName = streamingAppName;
@@ -106,7 +106,7 @@ public class MbmsStreamingManager {
* @param subscriptionId The subscription ID to use. * @param subscriptionId The subscription ID to use.
*/ */
public static MbmsStreamingManager create(Context context, public static MbmsStreamingManager create(Context context,
IMbmsStreamingManagerCallback listener, String streamingAppName, int subscriptionId) MbmsStreamingManagerCallback listener, String streamingAppName, int subscriptionId)
throws MbmsException { throws MbmsException {
MbmsStreamingManager manager = new MbmsStreamingManager(context, listener, MbmsStreamingManager manager = new MbmsStreamingManager(context, listener,
streamingAppName, subscriptionId); streamingAppName, subscriptionId);
@@ -116,10 +116,10 @@ public class MbmsStreamingManager {
/** /**
* Create a new MbmsStreamingManager using the system default data subscription ID. * Create a new MbmsStreamingManager using the system default data subscription ID.
* See {@link #create(Context, IMbmsStreamingManagerCallback, String, int)}. * See {@link #create(Context, MbmsStreamingManagerCallback, String, int)}.
*/ */
public static MbmsStreamingManager create(Context context, public static MbmsStreamingManager create(Context context,
IMbmsStreamingManagerCallback listener, String streamingAppName) MbmsStreamingManagerCallback listener, String streamingAppName)
throws MbmsException { throws MbmsException {
int subId = SubscriptionManager.getDefaultSubscriptionId(); int subId = SubscriptionManager.getDefaultSubscriptionId();
MbmsStreamingManager manager = new MbmsStreamingManager(context, listener, MbmsStreamingManager manager = new MbmsStreamingManager(context, listener,
@@ -155,13 +155,12 @@ public class MbmsStreamingManager {
* *
* This may throw an {@link MbmsException} containing one of the following errors: * This may throw an {@link MbmsException} containing one of the following errors:
* {@link MbmsException#ERROR_MIDDLEWARE_NOT_BOUND} * {@link MbmsException#ERROR_MIDDLEWARE_NOT_BOUND}
* {@link MbmsException#ERROR_NOT_YET_INITIALIZED} * {@link MbmsException#ERROR_UNKNOWN_REMOTE_EXCEPTION}
* {@link MbmsException#ERROR_CONCURRENT_SERVICE_LIMIT_REACHED} * {@link MbmsException#ERROR_CONCURRENT_SERVICE_LIMIT_REACHED}
* *
* Asynchronous error codes via the {@link IMbmsStreamingManagerCallback#error(int, String)} * Asynchronous error codes via the {@link MbmsStreamingManagerCallback#error(int, String)}
* callback can include any of the errors except: * callback can include any of the errors except:
* {@link MbmsException#ERROR_UNABLE_TO_START_SERVICE} * {@link MbmsException#ERROR_UNABLE_TO_START_SERVICE}
* {@link MbmsException#ERROR_INVALID_SERVICE_ID}
* {@link MbmsException#ERROR_END_OF_SESSION} * {@link MbmsException#ERROR_END_OF_SESSION}
*/ */
public void getStreamingServices(List<String> classList) throws MbmsException { public void getStreamingServices(List<String> classList) throws MbmsException {
@@ -180,36 +179,37 @@ public class MbmsStreamingManager {
/** /**
* Starts streaming a requested service, reporting status to the indicated listener. * Starts streaming a requested service, reporting status to the indicated listener.
* Returns an object used to control that stream. * Returns an object used to control that stream. The stream may not be ready for consumption
* immediately upon return from this method -- wait until the streaming state has been
* reported via {@link android.telephony.mbms.StreamingServiceCallback#streamStateChanged(int)}.
* *
* May throw an IllegalArgumentException or RemoteException. * May throw an {@link MbmsException} containing any of the following error codes:
* {@link MbmsException#ERROR_MIDDLEWARE_NOT_BOUND}
* {@link MbmsException#ERROR_UNKNOWN_REMOTE_EXCEPTION}
* {@link MbmsException#ERROR_CONCURRENT_SERVICE_LIMIT_REACHED}
*
* May also throw an {@link IllegalArgumentException} or an {@link IllegalStateException}
* *
* Asynchronous errors through the listener include any of the errors * Asynchronous errors through the listener include any of the errors
*/ */
public StreamingService startStreaming(StreamingServiceInfo serviceInfo, public StreamingService startStreaming(StreamingServiceInfo serviceInfo,
IStreamingServiceCallback listener) { StreamingServiceCallback listener) throws MbmsException {
return null; if (mService == null) {
} throw new MbmsException(MbmsException.ERROR_MIDDLEWARE_NOT_BOUND);
}
/** try {
* Lists all the services currently being streamed to the device by this application int returnCode = mService.startStreaming(
* on this given subId. Results are returned asynchronously through the previously mAppName, mSubscriptionId, serviceInfo.getServiceId(), listener);
* registered callback. if (returnCode != MbmsException.SUCCESS) {
* throw new MbmsException(returnCode);
* May throw a RemoteException. }
* } catch (RemoteException e) {
* The return value is a success/error-code with the following possible values: throw new MbmsException(MbmsException.ERROR_UNKNOWN_REMOTE_EXCEPTION);
* <li>SUCCESS</li> }
* <li>ERROR_MSDC_CONCURRENT_SERVICE_LIMIT_REACHED</li>
* return new StreamingService(
* Asynchronous errors through the listener include any of the errors except mAppName, mSubscriptionId, mService, serviceInfo, listener);
* <li>ERROR_UNABLED_TO_START_SERVICE</li>
* <li>ERROR_MSDC_INVALID_SERVICE_ID</li>
* <li>ERROR_MSDC_END_OF_SESSION</li>
*
*/
public int getActiveStreamingServices() {
return 0;
} }
private void bindAndInitialize() throws MbmsException { private void bindAndInitialize() throws MbmsException {

View File

@@ -17,14 +17,13 @@
package android.telephony.mbms; package android.telephony.mbms;
import android.net.Uri; import android.net.Uri;
import android.telephony.mbms.StreamingService;
/** /**
* @hide * @hide
*/ */
oneway interface IStreamingServiceCallback { oneway interface IStreamingServiceCallback {
void error(int errorCode, String message); void error(int errorCode, String message);
void streamStateChanged(in StreamingService service, int state); void streamStateChanged(int state);
void uriUpdated(in Uri uri); void uriUpdated(in Uri uri);
void broadcastSignalStrengthUpdated(int signalStrength); void broadcastSignalStrengthUpdated(int signalStrength);
} }

View File

@@ -27,16 +27,14 @@ public class MbmsException extends Exception {
public static final int ERROR_CONCURRENT_SERVICE_LIMIT_REACHED = 6; public static final int ERROR_CONCURRENT_SERVICE_LIMIT_REACHED = 6;
public static final int ERROR_MIDDLEWARE_NOT_BOUND = 7; public static final int ERROR_MIDDLEWARE_NOT_BOUND = 7;
public static final int ERROR_UNABLE_TO_START_SERVICE = 8; public static final int ERROR_UNABLE_TO_START_SERVICE = 8;
public static final int ERROR_INVALID_SERVICE_ID = 9; public static final int ERROR_STREAM_ALREADY_STARTED = 9;
public static final int ERROR_END_OF_SESSION = 10; 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; private final int mErrorCode;
/** @hide /** @hide
* TODO: future systemapi * TODO: future systemapi
* */ */
public MbmsException(int errorCode) { public MbmsException(int errorCode) {
super(); super();
mErrorCode = errorCode; mErrorCode = errorCode;

View File

@@ -1,19 +0,0 @@
/*
** Copyright 2017, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
package android.telephony.mbms;
parcelable StreamingService;

View File

@@ -19,45 +19,60 @@ package android.telephony.mbms;
import android.net.Uri; import android.net.Uri;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.os.RemoteException;
import android.telephony.mbms.vendor.IMbmsStreamingService;
import android.util.Log;
/** /**
* @hide * @hide
*/ */
public class StreamingService { public class StreamingService {
private static final String LOG_TAG = "MbmsStreamingService";
public final static int STATE_STOPPED = 1; public final static int STATE_STOPPED = 1;
public final static int STATE_STARTED = 2; public final static int STATE_STARTED = 2;
public final static int STATE_STALLED = 3; public final static int STATE_STALLED = 3;
private final String mAppName;
private final int mSubscriptionId;
private final IMbmsStreamingService mService;
private final StreamingServiceInfo mServiceInfo;
private final IStreamingServiceCallback mCallback;
/** /**
* @hide
*/ */
StreamingService(StreamingServiceInfo streamingServiceInfo, public StreamingService(String appName,
IStreamingServiceCallback listener) { int subscriptionId,
IMbmsStreamingService service,
StreamingServiceInfo streamingServiceInfo,
IStreamingServiceCallback callback) {
mAppName = appName;
mSubscriptionId = subscriptionId;
mService = service;
mServiceInfo = streamingServiceInfo;
mCallback = callback;
} }
/** /**
* Retreive the Uri used to play this stream. * Retreive the Uri used to play this stream.
* *
* This may throw a RemoteException. * This may throw a {@link MbmsException} with the error code
* {@link MbmsException#ERROR_UNKNOWN_REMOTE_EXCEPTION}
* @return The {@link Uri} to pass to the streaming client.
*/ */
public Uri getPlaybackUri() { public Uri getPlaybackUri() throws MbmsException {
return null; try {
return mService.getPlaybackUri(mAppName, mSubscriptionId, mServiceInfo.getServiceId());
} catch (RemoteException e) {
Log.w(LOG_TAG, "Caught remote exception calling getPlaybackUri: " + e);
throw new MbmsException(MbmsException.ERROR_UNKNOWN_REMOTE_EXCEPTION);
}
} }
/** /**
* Retreive the info for this StreamingService. * Retreive the info for this StreamingService.
*/ */
public StreamingServiceInfo getInfo() { public StreamingServiceInfo getInfo() {
return null; return mServiceInfo;
}
/**
* Retreive the current state of this stream.
*
* This may throw a RemoteException.
*/
public int getState() {
return STATE_STOPPED;
} }
/** /**
@@ -68,30 +83,13 @@ public class StreamingService {
public void stopStreaming() { public void stopStreaming() {
} }
public void dispose() { public void dispose() throws MbmsException {
} try {
mService.disposeStream(mAppName, mSubscriptionId, mServiceInfo.getServiceId());
public static final Parcelable.Creator<StreamingService> CREATOR = } catch (RemoteException e) {
new Parcelable.Creator<StreamingService>() { Log.w(LOG_TAG, "Caught remote exception calling disposeStream: " + e);
@Override throw new MbmsException(MbmsException.ERROR_UNKNOWN_REMOTE_EXCEPTION);
public StreamingService createFromParcel(Parcel in) {
return new StreamingService(in);
} }
@Override
public StreamingService[] newArray(int size) {
return new StreamingService[size];
}
};
private StreamingService(Parcel in) {
}
public void writeToParcel(Parcel dest, int flags) {
}
public int describeContents() {
return 0;
} }
} }

View File

@@ -19,7 +19,7 @@ package android.telephony.mbms;
import android.net.Uri; import android.net.Uri;
/** /**
* A Callback class for use when the applicaiton is actively streaming content. * A Callback class for use when the application is actively streaming content.
* @hide * @hide
*/ */
public class StreamingServiceCallback extends IStreamingServiceCallback.Stub { public class StreamingServiceCallback extends IStreamingServiceCallback.Stub {
@@ -33,7 +33,6 @@ public class StreamingServiceCallback extends IStreamingServiceCallback.Stub {
*/ */
public static final int SIGNAL_STRENGTH_UNAVAILABLE = -1; public static final int SIGNAL_STRENGTH_UNAVAILABLE = -1;
public void error(int errorCode, String message) { public void error(int errorCode, String message) {
// default implementation empty // default implementation empty
} }
@@ -44,7 +43,7 @@ public class StreamingServiceCallback extends IStreamingServiceCallback.Stub {
* See {@link StreamingService#STATE_STOPPED}, {@link StreamingService#STATE_STARTED} * See {@link StreamingService#STATE_STOPPED}, {@link StreamingService#STATE_STARTED}
* and {@link StreamingService#STATE_STALLED}. * and {@link StreamingService#STATE_STALLED}.
*/ */
public void streamStateChanged(StreamingService service, int state) { public void streamStateChanged(int state) {
// default implementation empty // default implementation empty
} }

View File

@@ -19,7 +19,6 @@ package android.telephony.mbms.vendor;
import android.net.Uri; import android.net.Uri;
import android.telephony.mbms.IMbmsStreamingManagerCallback; import android.telephony.mbms.IMbmsStreamingManagerCallback;
import android.telephony.mbms.IStreamingServiceCallback; import android.telephony.mbms.IStreamingServiceCallback;
import android.telephony.mbms.StreamingService;
import android.telephony.mbms.StreamingServiceInfo; import android.telephony.mbms.StreamingServiceInfo;
/** /**
@@ -32,35 +31,19 @@ interface IMbmsStreamingService
int getStreamingServices(String appName, int subId, in List<String> serviceClasses); int getStreamingServices(String appName, int subId, in List<String> serviceClasses);
/**
* - Starts streaming the serviceId given.
* - if the uid/appName/subId don't match a previously registered callback an error will
* be returned
* - Streaming status will be sent via the included listener, including an initial
* URL-change and State-change pair.
*/
int startStreaming(String appName, int subId, String serviceId, int startStreaming(String appName, int subId, String serviceId,
IStreamingServiceCallback listener); IStreamingServiceCallback listener);
/**
* Asynchronously fetches all Services being streamed by this uid/appName/subId.
*/
int getActiveStreamingServices(String appName, int subId);
/** /**
* Per-stream api. Note each specifies what stream they apply to. * Per-stream api. Note each specifies what stream they apply to.
*/ */
Uri getPlaybackUri(String appName, int subId, String serviceId); Uri getPlaybackUri(String appName, int subId, String serviceId);
int getState(String appName, int subId, String serviceId);
void stopStreaming(String appName, int subId, String serviceId); void stopStreaming(String appName, int subId, String serviceId);
void disposeStream(String appName, int subId, String serviceId); void disposeStream(String appName, int subId, String serviceId);
/** /**
* End of life for all MbmsStreamingManager's created by this uid/appName/subId. * End of life for all MbmsStreamingManager's created by this uid/appName/subId.
* Ends any streams run under this uid/appname/subId and calls the disposed methods * Ends any streams run under this uid/appname/subId and calls the disposed methods

View File

@@ -16,6 +16,7 @@
package android.telephony.mbms.vendor; package android.telephony.mbms.vendor;
import android.annotation.Nullable;
import android.net.Uri; import android.net.Uri;
import android.os.RemoteException; import android.os.RemoteException;
import android.telephony.mbms.IMbmsStreamingManagerCallback; import android.telephony.mbms.IMbmsStreamingManagerCallback;
@@ -32,11 +33,12 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
/** /**
* Initialize streaming service for this app and subId, registering the listener. * Initialize streaming service for this app and subId, registering the listener.
* *
* May throw an {@link IllegalArgumentException} or a {@link SecurityException}
*
* @param listener The callback to use to communicate with the app. * @param listener The callback to use to communicate with the app.
* @param appName The app name as negotiated with the wireless carrier. * @param appName The app name as negotiated with the wireless carrier.
* @param subscriptionId The subscription ID to use. * @param subscriptionId The subscription ID to use.
* @return {@link MbmsException#SUCCESS}, {@link MbmsException#ERROR_ALREADY_INITIALIZED}, or * @return {@link MbmsException#SUCCESS} or {@link MbmsException#ERROR_ALREADY_INITIALIZED}
* {@link MbmsException#ERROR_APP_PERMISSIONS_NOT_GRANTED}
*/ */
@Override @Override
public int initialize(IMbmsStreamingManagerCallback listener, String appName, public int initialize(IMbmsStreamingManagerCallback listener, String appName,
@@ -52,6 +54,8 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
* Note that subsequent calls with the same uid, appName and subId will replace * Note that subsequent calls with the same uid, appName and subId will replace
* the service class list. * the service class list.
* *
* May throw an {@link IllegalArgumentException} or an {@link IllegalStateException}
*
* @param appName The app name as negotiated with the wireless carrier. * @param appName The app name as negotiated with the wireless carrier.
* @param subscriptionId The subscription id to use. * @param subscriptionId The subscription id to use.
* @param serviceClasses The service classes that the app wishes to get info on. The strings * @param serviceClasses The service classes that the app wishes to get info on. The strings
@@ -59,7 +63,6 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
* carrier. * carrier.
* @return One of {@link MbmsException#SUCCESS}, * @return One of {@link MbmsException#SUCCESS},
* {@link MbmsException#ERROR_MIDDLEWARE_NOT_BOUND}, * {@link MbmsException#ERROR_MIDDLEWARE_NOT_BOUND},
* {@link MbmsException#ERROR_NOT_YET_INITIALIZED}, or
* {@link MbmsException#ERROR_CONCURRENT_SERVICE_LIMIT_REACHED} * {@link MbmsException#ERROR_CONCURRENT_SERVICE_LIMIT_REACHED}
*/ */
@Override @Override
@@ -68,27 +71,42 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
return 0; return 0;
} }
/**
* 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#streamStateChanged(int)}.
*
* May throw an {@link IllegalArgumentException} or an {@link IllegalStateException}
*
* @param appName The app name as negotiated with the wireless carrier.
* @param subscriptionId The subscription id to use.
* @param serviceId The ID of the streaming service that the app has requested.
* @param listener The listener object on which the app wishes to receive updates.
* @return TODO: document possible errors
*/
@Override @Override
public int startStreaming(String appName, int subId, public int startStreaming(String appName, int subscriptionId,
String serviceId, IStreamingServiceCallback listener) throws RemoteException { String serviceId, IStreamingServiceCallback listener) throws RemoteException {
return 0; return 0;
} }
/**
* Retrieves the streaming URI for a particular service. If the middleware is not yet ready to
* stream the service, this method may return null.
*
* May throw an {@link IllegalArgumentException} or an {@link IllegalStateException}
*
* @param appName The app name as negotiated with the wireless carrier.
* @param subscriptionId The subscription id to use.
* @param serviceId The ID of the streaming service that the app has requested.
* @return An opaque {@link Uri} to be passed to a video player that understands the format.
*/
@Override @Override
public int getActiveStreamingServices(String appName, int subId) throws RemoteException { public @Nullable Uri getPlaybackUri(String appName, int subscriptionId, String serviceId)
return 0; throws RemoteException {
}
@Override
public Uri getPlaybackUri(String appName, int subId, String serviceId) throws RemoteException {
return null; return null;
} }
@Override
public int getState(String appName, int subId, String serviceId) throws RemoteException {
return 0;
}
@Override @Override
public void stopStreaming(String appName, int subId, String serviceId) throws RemoteException { public void stopStreaming(String appName, int subId, String serviceId) throws RemoteException {
} }