Merge "Implement stopStreaming API for MBMS"
This commit is contained in:
@@ -22,6 +22,7 @@ import android.content.Intent;
|
|||||||
import android.content.ServiceConnection;
|
import android.content.ServiceConnection;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.os.DeadObjectException;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.telephony.mbms.MbmsException;
|
import android.telephony.mbms.MbmsException;
|
||||||
@@ -157,6 +158,7 @@ public class MbmsStreamingManager {
|
|||||||
* {@link MbmsException#ERROR_MIDDLEWARE_NOT_BOUND}
|
* {@link MbmsException#ERROR_MIDDLEWARE_NOT_BOUND}
|
||||||
* {@link MbmsException#ERROR_UNKNOWN_REMOTE_EXCEPTION}
|
* {@link MbmsException#ERROR_UNKNOWN_REMOTE_EXCEPTION}
|
||||||
* {@link MbmsException#ERROR_CONCURRENT_SERVICE_LIMIT_REACHED}
|
* {@link MbmsException#ERROR_CONCURRENT_SERVICE_LIMIT_REACHED}
|
||||||
|
* {@link MbmsException#ERROR_SERVICE_LOST}
|
||||||
*
|
*
|
||||||
* Asynchronous error codes via the {@link MbmsStreamingManagerCallback#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:
|
||||||
@@ -172,6 +174,10 @@ public class MbmsStreamingManager {
|
|||||||
if (returnCode != MbmsException.SUCCESS) {
|
if (returnCode != MbmsException.SUCCESS) {
|
||||||
throw new MbmsException(returnCode);
|
throw new MbmsException(returnCode);
|
||||||
}
|
}
|
||||||
|
} catch (DeadObjectException e) {
|
||||||
|
Log.w(LOG_TAG, "Remote process died");
|
||||||
|
mService = null;
|
||||||
|
throw new MbmsException(MbmsException.ERROR_SERVICE_LOST);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw new MbmsException(MbmsException.ERROR_UNKNOWN_REMOTE_EXCEPTION);
|
throw new MbmsException(MbmsException.ERROR_UNKNOWN_REMOTE_EXCEPTION);
|
||||||
}
|
}
|
||||||
@@ -187,6 +193,7 @@ public class MbmsStreamingManager {
|
|||||||
* {@link MbmsException#ERROR_MIDDLEWARE_NOT_BOUND}
|
* {@link MbmsException#ERROR_MIDDLEWARE_NOT_BOUND}
|
||||||
* {@link MbmsException#ERROR_UNKNOWN_REMOTE_EXCEPTION}
|
* {@link MbmsException#ERROR_UNKNOWN_REMOTE_EXCEPTION}
|
||||||
* {@link MbmsException#ERROR_CONCURRENT_SERVICE_LIMIT_REACHED}
|
* {@link MbmsException#ERROR_CONCURRENT_SERVICE_LIMIT_REACHED}
|
||||||
|
* {@link MbmsException#ERROR_SERVICE_LOST}
|
||||||
*
|
*
|
||||||
* May also throw an {@link IllegalArgumentException} or an {@link IllegalStateException}
|
* May also throw an {@link IllegalArgumentException} or an {@link IllegalStateException}
|
||||||
*
|
*
|
||||||
@@ -204,6 +211,10 @@ public class MbmsStreamingManager {
|
|||||||
if (returnCode != MbmsException.SUCCESS) {
|
if (returnCode != MbmsException.SUCCESS) {
|
||||||
throw new MbmsException(returnCode);
|
throw new MbmsException(returnCode);
|
||||||
}
|
}
|
||||||
|
} catch (DeadObjectException e) {
|
||||||
|
Log.w(LOG_TAG, "Remote process died");
|
||||||
|
mService = null;
|
||||||
|
throw new MbmsException(MbmsException.ERROR_SERVICE_LOST);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw new MbmsException(MbmsException.ERROR_UNKNOWN_REMOTE_EXCEPTION);
|
throw new MbmsException(MbmsException.ERROR_UNKNOWN_REMOTE_EXCEPTION);
|
||||||
}
|
}
|
||||||
@@ -269,10 +280,14 @@ public class MbmsStreamingManager {
|
|||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
mService = null;
|
mService = null;
|
||||||
Log.e(LOG_TAG, "Service died before initialization");
|
Log.e(LOG_TAG, "Service died before initialization");
|
||||||
|
if (e instanceof DeadObjectException) {
|
||||||
|
throw new MbmsException(MbmsException.ERROR_SERVICE_LOST);
|
||||||
|
} else {
|
||||||
throw new MbmsException(MbmsException.ERROR_UNKNOWN_REMOTE_EXCEPTION);
|
throw new MbmsException(MbmsException.ERROR_UNKNOWN_REMOTE_EXCEPTION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void waitOnLatchWithTimeout(CountDownLatch l, long timeoutMs) {
|
private static void waitOnLatchWithTimeout(CountDownLatch l, long timeoutMs) {
|
||||||
long endTime = System.currentTimeMillis() + timeoutMs;
|
long endTime = System.currentTimeMillis() + timeoutMs;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ public class MbmsException extends Exception {
|
|||||||
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_STREAM_ALREADY_STARTED = 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_SERVICE_LOST = 11;
|
||||||
|
|
||||||
private final int mErrorCode;
|
private final int mErrorCode;
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,7 @@
|
|||||||
package android.telephony.mbms;
|
package android.telephony.mbms;
|
||||||
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Parcel;
|
import android.os.DeadObjectException;
|
||||||
import android.os.Parcelable;
|
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.telephony.mbms.vendor.IMbmsStreamingService;
|
import android.telephony.mbms.vendor.IMbmsStreamingService;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -34,9 +33,10 @@ public class StreamingService {
|
|||||||
|
|
||||||
private final String mAppName;
|
private final String mAppName;
|
||||||
private final int mSubscriptionId;
|
private final int mSubscriptionId;
|
||||||
private final IMbmsStreamingService mService;
|
|
||||||
private final StreamingServiceInfo mServiceInfo;
|
private final StreamingServiceInfo mServiceInfo;
|
||||||
private final IStreamingServiceCallback mCallback;
|
private final IStreamingServiceCallback mCallback;
|
||||||
|
|
||||||
|
private IMbmsStreamingService mService;
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@@ -55,13 +55,23 @@ public class StreamingService {
|
|||||||
/**
|
/**
|
||||||
* Retreive the Uri used to play this stream.
|
* Retreive the Uri used to play this stream.
|
||||||
*
|
*
|
||||||
* This may throw a {@link MbmsException} with the error code
|
* This may throw a {@link MbmsException} with the error codes
|
||||||
* {@link MbmsException#ERROR_UNKNOWN_REMOTE_EXCEPTION}
|
* {@link MbmsException#ERROR_UNKNOWN_REMOTE_EXCEPTION} or
|
||||||
|
* {@link MbmsException#ERROR_SERVICE_LOST}
|
||||||
|
*
|
||||||
* @return The {@link Uri} to pass to the streaming client.
|
* @return The {@link Uri} to pass to the streaming client.
|
||||||
*/
|
*/
|
||||||
public Uri getPlaybackUri() throws MbmsException {
|
public Uri getPlaybackUri() throws MbmsException {
|
||||||
|
if (mService == null) {
|
||||||
|
throw new IllegalStateException("No streaming service attached");
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return mService.getPlaybackUri(mAppName, mSubscriptionId, mServiceInfo.getServiceId());
|
return mService.getPlaybackUri(mAppName, mSubscriptionId, mServiceInfo.getServiceId());
|
||||||
|
} catch (DeadObjectException e) {
|
||||||
|
Log.w(LOG_TAG, "Remote process died");
|
||||||
|
mService = null;
|
||||||
|
throw new MbmsException(MbmsException.ERROR_SERVICE_LOST);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.w(LOG_TAG, "Caught remote exception calling getPlaybackUri: " + e);
|
Log.w(LOG_TAG, "Caught remote exception calling getPlaybackUri: " + e);
|
||||||
throw new MbmsException(MbmsException.ERROR_UNKNOWN_REMOTE_EXCEPTION);
|
throw new MbmsException(MbmsException.ERROR_UNKNOWN_REMOTE_EXCEPTION);
|
||||||
@@ -76,18 +86,41 @@ public class StreamingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop streaming this service. Terminal.
|
* Stop streaming this service.
|
||||||
*
|
* This may throw a {@link MbmsException} with the error code
|
||||||
* This may throw a RemoteException.
|
* {@link MbmsException#ERROR_UNKNOWN_REMOTE_EXCEPTION} or
|
||||||
|
* {@link MbmsException#ERROR_SERVICE_LOST}
|
||||||
*/
|
*/
|
||||||
public void stopStreaming() {
|
public void stopStreaming() throws MbmsException {
|
||||||
|
if (mService == null) {
|
||||||
|
throw new IllegalStateException("No streaming service attached");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
mService.stopStreaming(mAppName, mSubscriptionId, mServiceInfo.getServiceId());
|
||||||
|
} catch (DeadObjectException e) {
|
||||||
|
Log.w(LOG_TAG, "Remote process died");
|
||||||
|
mService = null;
|
||||||
|
throw new MbmsException(MbmsException.ERROR_SERVICE_LOST);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.w(LOG_TAG, "Caught remote exception calling stopStreaming: " + e);
|
||||||
|
throw new MbmsException(MbmsException.ERROR_UNKNOWN_REMOTE_EXCEPTION);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() throws MbmsException {
|
public void dispose() throws MbmsException {
|
||||||
|
if (mService == null) {
|
||||||
|
throw new IllegalStateException("No streaming service attached");
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mService.disposeStream(mAppName, mSubscriptionId, mServiceInfo.getServiceId());
|
mService.disposeStream(mAppName, mSubscriptionId, mServiceInfo.getServiceId());
|
||||||
|
} catch (DeadObjectException e) {
|
||||||
|
Log.w(LOG_TAG, "Remote process died");
|
||||||
|
mService = null;
|
||||||
|
throw new MbmsException(MbmsException.ERROR_SERVICE_LOST);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.w(LOG_TAG, "Caught remote exception calling disposeStream: " + e);
|
Log.w(LOG_TAG, "Caught remote exception calling dispose: " + e);
|
||||||
throw new MbmsException(MbmsException.ERROR_UNKNOWN_REMOTE_EXCEPTION);
|
throw new MbmsException(MbmsException.ERROR_UNKNOWN_REMOTE_EXCEPTION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,15 +107,44 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop streaming the stream identified by {@code serviceId}. Notification of the resulting
|
||||||
|
* stream state change should be reported to the app via
|
||||||
|
* {@link IStreamingServiceCallback#streamStateChanged(int)}.
|
||||||
|
* @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 wishes to stop.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void stopStreaming(String appName, int subId, String serviceId) throws RemoteException {
|
public void stopStreaming(String appName, int subscriptionId, String serviceId)
|
||||||
|
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(String, int, String, IStreamingServiceCallback)} should no longer be
|
||||||
|
* used after this method has called by the app.
|
||||||
|
* @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 wishes to dispose of.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void disposeStream(String appName, int subId, String serviceId) throws RemoteException {
|
public void disposeStream(String appName, int subscriptionId, String serviceId)
|
||||||
|
throws RemoteException {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signals that the app wishes to dispose of the session identified by the {@code appName} and
|
||||||
|
* {@code subscriptionId} arguments, as well as the caller's uid. No notification back to the
|
||||||
|
* app is required for this operation, and the corresponding callback provided via
|
||||||
|
* {@link #initialize(IMbmsStreamingManagerCallback, String, int)} should no longer be used
|
||||||
|
* after this method has been called by the app.
|
||||||
|
* @param appName The app name as negotiated with the wireless carrier.
|
||||||
|
* @param subscriptionId The subscription id to use.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void dispose(String appName, int subId) throws RemoteException {
|
public void dispose(String appName, int subscriptionId) throws RemoteException {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user