Merge "startStreaming for MBMS apis"
am: 4b3c44be55
Change-Id: Id0e2e95387300147ba32ec3a418605901fdb241b
This commit is contained in:
@@ -553,7 +553,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 \
|
||||
|
||||
@@ -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<ServiceListener> 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<String> 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:
|
||||
* <li>SUCCESS</li>
|
||||
* <li>ERROR_MSDC_CONCURRENT_SERVICE_LIMIT_REACHED</li>
|
||||
*
|
||||
* Asynchronous errors through the listener include any of the errors except
|
||||
* <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;
|
||||
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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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<StreamingService> CREATOR =
|
||||
new Parcelable.Creator<StreamingService>() {
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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<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,
|
||||
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
|
||||
|
||||
@@ -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 {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user