diff --git a/Android.mk b/Android.mk index 5529bfcfe787b15cef38ab4a95e02b165fdae73c..623b5220747d72fd87f26193f5d1c227664755dd 100644 --- a/Android.mk +++ b/Android.mk @@ -635,7 +635,6 @@ aidl_files := \ 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/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/ServiceState.aidl \ frameworks/base/telephony/java/android/telephony/SubscriptionInfo.aidl \ diff --git a/telephony/java/android/telephony/MbmsStreamingManager.java b/telephony/java/android/telephony/MbmsStreamingManager.java index 58262e1df28d93c347069b7c79c94b1096d0edf9..251d5bb561d922f4d9e1e05eeb15658e43f01d6e 100644 --- a/telephony/java/android/telephony/MbmsStreamingManager.java +++ b/telephony/java/android/telephony/MbmsStreamingManager.java @@ -24,10 +24,10 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.IBinder; import android.os.RemoteException; -import android.telephony.mbms.IMbmsStreamingManagerCallback; -import android.telephony.mbms.IStreamingServiceCallback; import android.telephony.mbms.MbmsException; +import android.telephony.mbms.MbmsStreamingManagerCallback; import android.telephony.mbms.StreamingService; +import android.telephony.mbms.StreamingServiceCallback; import android.telephony.mbms.StreamingServiceInfo; import android.telephony.mbms.vendor.IMbmsStreamingService; import android.util.Log; @@ -77,14 +77,14 @@ public class MbmsStreamingManager { }; private List mServiceListeners = new LinkedList<>(); - private IMbmsStreamingManagerCallback mCallbackToApp; + private MbmsStreamingManagerCallback mCallbackToApp; private final String mAppName; private final Context mContext; private int mSubscriptionId = INVALID_SUBSCRIPTION_ID; /** @hide */ - private MbmsStreamingManager(Context context, IMbmsStreamingManagerCallback listener, + private MbmsStreamingManager(Context context, MbmsStreamingManagerCallback listener, String streamingAppName, int subscriptionId) { mContext = context; mAppName = streamingAppName; @@ -106,7 +106,7 @@ public class MbmsStreamingManager { * @param subscriptionId The subscription ID to use. */ public static MbmsStreamingManager create(Context context, - IMbmsStreamingManagerCallback listener, String streamingAppName, int subscriptionId) + MbmsStreamingManagerCallback listener, String streamingAppName, int subscriptionId) throws MbmsException { MbmsStreamingManager manager = new MbmsStreamingManager(context, listener, streamingAppName, subscriptionId); @@ -116,10 +116,10 @@ public class MbmsStreamingManager { /** * 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, - IMbmsStreamingManagerCallback listener, String streamingAppName) + MbmsStreamingManagerCallback listener, String streamingAppName) throws MbmsException { int subId = SubscriptionManager.getDefaultSubscriptionId(); 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: * {@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} * - * 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: * {@link MbmsException#ERROR_UNABLE_TO_START_SERVICE} - * {@link MbmsException#ERROR_INVALID_SERVICE_ID} * {@link MbmsException#ERROR_END_OF_SESSION} */ public void getStreamingServices(List classList) throws MbmsException { @@ -180,36 +179,37 @@ public class MbmsStreamingManager { /** * 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 */ public StreamingService startStreaming(StreamingServiceInfo serviceInfo, - IStreamingServiceCallback listener) { - return null; - } + StreamingServiceCallback listener) throws MbmsException { + if (mService == null) { + throw new MbmsException(MbmsException.ERROR_MIDDLEWARE_NOT_BOUND); + } - /** - * Lists all the services currently being streamed to the device by this application - * on this given subId. Results are returned asynchronously through the previously - * registered callback. - * - * May throw a RemoteException. - * - * The return value is a success/error-code with the following possible values: - *
  • SUCCESS
  • - *
  • ERROR_MSDC_CONCURRENT_SERVICE_LIMIT_REACHED
  • - * - * Asynchronous errors through the listener include any of the errors except - *
  • ERROR_UNABLED_TO_START_SERVICE
  • - *
  • ERROR_MSDC_INVALID_SERVICE_ID
  • - *
  • ERROR_MSDC_END_OF_SESSION
  • - * - */ - public int getActiveStreamingServices() { - return 0; + try { + int returnCode = mService.startStreaming( + mAppName, mSubscriptionId, serviceInfo.getServiceId(), listener); + if (returnCode != MbmsException.SUCCESS) { + throw new MbmsException(returnCode); + } + } catch (RemoteException e) { + throw new MbmsException(MbmsException.ERROR_UNKNOWN_REMOTE_EXCEPTION); + } + + return new StreamingService( + mAppName, mSubscriptionId, mService, serviceInfo, listener); } private void bindAndInitialize() throws MbmsException { diff --git a/telephony/java/android/telephony/mbms/IStreamingServiceCallback.aidl b/telephony/java/android/telephony/mbms/IStreamingServiceCallback.aidl index 6d2e031250df6ca89147439d4b189dfec728300c..891edad8c9bfed7b15644d9aebe57f23db8ad01d 100755 --- a/telephony/java/android/telephony/mbms/IStreamingServiceCallback.aidl +++ b/telephony/java/android/telephony/mbms/IStreamingServiceCallback.aidl @@ -17,14 +17,13 @@ package android.telephony.mbms; import android.net.Uri; -import android.telephony.mbms.StreamingService; /** * @hide */ oneway interface IStreamingServiceCallback { void error(int errorCode, String message); - void streamStateChanged(in StreamingService service, int state); + void streamStateChanged(int state); void uriUpdated(in Uri uri); void broadcastSignalStrengthUpdated(int signalStrength); } diff --git a/telephony/java/android/telephony/mbms/MbmsException.java b/telephony/java/android/telephony/mbms/MbmsException.java index e8680ea4683d4b560d5a3aefe79a35822a1aecb1..a0ded9bd565b293ee2fe4b8d69e192a83782f461 100644 --- a/telephony/java/android/telephony/mbms/MbmsException.java +++ b/telephony/java/android/telephony/mbms/MbmsException.java @@ -27,16 +27,14 @@ public class MbmsException extends Exception { 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_STREAM_ALREADY_STARTED = 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; /** @hide * TODO: future systemapi - * */ + */ public MbmsException(int errorCode) { super(); mErrorCode = errorCode; diff --git a/telephony/java/android/telephony/mbms/StreamingService.aidl b/telephony/java/android/telephony/mbms/StreamingService.aidl deleted file mode 100755 index 0c286f3a0502108273e9d46a924c0660a9f3642d..0000000000000000000000000000000000000000 --- a/telephony/java/android/telephony/mbms/StreamingService.aidl +++ /dev/null @@ -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; diff --git a/telephony/java/android/telephony/mbms/StreamingService.java b/telephony/java/android/telephony/mbms/StreamingService.java index 08c4a27d485e0352e614666c5c3d53f64be92539..ac5fbdf62666f8cda1fdbaeadeb8a7f3af38c43e 100644 --- a/telephony/java/android/telephony/mbms/StreamingService.java +++ b/telephony/java/android/telephony/mbms/StreamingService.java @@ -19,45 +19,60 @@ package android.telephony.mbms; import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; +import android.os.RemoteException; +import android.telephony.mbms.vendor.IMbmsStreamingService; +import android.util.Log; /** * @hide */ public class StreamingService { - + private static final String LOG_TAG = "MbmsStreamingService"; public final static int STATE_STOPPED = 1; public final static int STATE_STARTED = 2; 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, - IStreamingServiceCallback listener) { + public StreamingService(String appName, + 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. * - * 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() { - return null; + public Uri getPlaybackUri() throws MbmsException { + 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. */ public StreamingServiceInfo getInfo() { - return null; - } - - /** - * Retreive the current state of this stream. - * - * This may throw a RemoteException. - */ - public int getState() { - return STATE_STOPPED; + return mServiceInfo; } /** @@ -68,30 +83,13 @@ public class StreamingService { public void stopStreaming() { } - public void dispose() { - } - - public static final Parcelable.Creator CREATOR = - new Parcelable.Creator() { - @Override - public StreamingService createFromParcel(Parcel in) { - return new StreamingService(in); + public void dispose() throws MbmsException { + try { + mService.disposeStream(mAppName, mSubscriptionId, mServiceInfo.getServiceId()); + } catch (RemoteException e) { + Log.w(LOG_TAG, "Caught remote exception calling disposeStream: " + e); + throw new MbmsException(MbmsException.ERROR_UNKNOWN_REMOTE_EXCEPTION); } - - @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; } } diff --git a/telephony/java/android/telephony/mbms/StreamingServiceCallback.java b/telephony/java/android/telephony/mbms/StreamingServiceCallback.java index 752a4b3a44b81f9267c130be8cbea316b3bc46f0..bd0a1b3bd7d93d56e18271debfec6d3c818aa606 100644 --- a/telephony/java/android/telephony/mbms/StreamingServiceCallback.java +++ b/telephony/java/android/telephony/mbms/StreamingServiceCallback.java @@ -19,7 +19,7 @@ package android.telephony.mbms; 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 */ 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 void error(int errorCode, String message) { // default implementation empty } @@ -44,7 +43,7 @@ public class StreamingServiceCallback extends IStreamingServiceCallback.Stub { * See {@link StreamingService#STATE_STOPPED}, {@link StreamingService#STATE_STARTED} * and {@link StreamingService#STATE_STALLED}. */ - public void streamStateChanged(StreamingService service, int state) { + public void streamStateChanged(int state) { // default implementation empty } diff --git a/telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl b/telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl index a77a10a9badd1b91d85f808ecf5511bc6f7f8267..8ff7fa7c54f30ea7238e39d366e2f8972fa384e0 100755 --- a/telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl +++ b/telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl @@ -19,7 +19,6 @@ package android.telephony.mbms.vendor; import android.net.Uri; import android.telephony.mbms.IMbmsStreamingManagerCallback; import android.telephony.mbms.IStreamingServiceCallback; -import android.telephony.mbms.StreamingService; import android.telephony.mbms.StreamingServiceInfo; /** @@ -32,35 +31,19 @@ interface IMbmsStreamingService int getStreamingServices(String appName, int subId, in List 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, 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. */ 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 disposeStream(String appName, int subId, String serviceId); - /** * 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 diff --git a/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java b/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java index 467035254696b8156059534a95eb6cca6a177b12..37f47ffb52f23f15e490ccada0e503fc49eb4122 100644 --- a/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java +++ b/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java @@ -16,6 +16,7 @@ package android.telephony.mbms.vendor; +import android.annotation.Nullable; import android.net.Uri; import android.os.RemoteException; 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. * + * May throw an {@link IllegalArgumentException} or a {@link SecurityException} + * * @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} + * @return {@link MbmsException#SUCCESS} or {@link MbmsException#ERROR_ALREADY_INITIALIZED} */ @Override 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 * 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 subscriptionId The subscription id to use. * @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. * @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 @@ -68,27 +71,42 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub { 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 - public int startStreaming(String appName, int subId, + public int startStreaming(String appName, int subscriptionId, String serviceId, IStreamingServiceCallback listener) throws RemoteException { 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 - public int getActiveStreamingServices(String appName, int subId) throws RemoteException { - return 0; - } - - @Override - public Uri getPlaybackUri(String appName, int subId, String serviceId) throws RemoteException { + public @Nullable Uri getPlaybackUri(String appName, int subscriptionId, String serviceId) + throws RemoteException { return null; } - @Override - public int getState(String appName, int subId, String serviceId) throws RemoteException { - return 0; - } - @Override public void stopStreaming(String appName, int subId, String serviceId) throws RemoteException { }