Mock-un-hide the MBMS streaming APIs

In AOSP, this unhid the MBMS streaming APIs and modified the
vendor base classes to no longer pass raw AIDLs to the vendor code.

@hide tags put back in for MR1.

Bug: 30981736
Test: builds
Change-Id: I861e0568e3bf9ee9a937bf6314b1fc839a31f00c
Merged-In: I8dd83d01a7511968ed51a80ad358a48e50c3d1e7
This commit is contained in:
Hall Liu
2017-07-18 11:30:27 -07:00
parent 1e211675ca
commit 1169bc596c
10 changed files with 196 additions and 74 deletions

View File

@@ -16,6 +16,8 @@
package android.telephony; package android.telephony;
import android.annotation.SdkConstant;
import android.annotation.SystemApi;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.ServiceConnection; import android.content.ServiceConnection;
@@ -41,6 +43,14 @@ import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
*/ */
public class MbmsStreamingManager { public class MbmsStreamingManager {
private static final String LOG_TAG = "MbmsStreamingManager"; private static final String LOG_TAG = "MbmsStreamingManager";
/**
* Service action which must be handled by the middleware implementing the MBMS streaming
* interface.
* @hide
*/
@SystemApi
@SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION)
public static final String MBMS_STREAMING_SERVICE_ACTION = public static final String MBMS_STREAMING_SERVICE_ACTION =
"android.telephony.action.EmbmsStreaming"; "android.telephony.action.EmbmsStreaming";
@@ -203,13 +213,23 @@ public class MbmsStreamingManager {
return; return;
} catch (RuntimeException e) { } catch (RuntimeException e) {
Log.e(LOG_TAG, "Runtime exception during initialization"); Log.e(LOG_TAG, "Runtime exception during initialization");
try {
mCallbackToApp.error( mCallbackToApp.error(
MbmsException.InitializationErrors.ERROR_UNABLE_TO_INITIALIZE, MbmsException.InitializationErrors
.ERROR_UNABLE_TO_INITIALIZE,
e.toString()); e.toString());
} catch (RemoteException e1) {
// ignore
}
return; return;
} }
if (result != MbmsException.SUCCESS) { if (result != MbmsException.SUCCESS) {
mCallbackToApp.error(result, "Error returned during initialization"); try {
mCallbackToApp.error(
result, "Error returned during initialization");
} catch (RemoteException e) {
// ignore
}
return; return;
} }
mService.set(streamingService); mService.set(streamingService);

View File

@@ -61,6 +61,10 @@ public class FileInfo implements Parcelable {
} }
}; };
/**
* @hide
* TODO: systemapi
*/
public FileInfo(Uri uri, String mimeType, long size, byte[] md5Hash) { public FileInfo(Uri uri, String mimeType, long size, byte[] md5Hash) {
this.uri = uri; this.uri = uri;
this.mimeType = mimeType; this.mimeType = mimeType;

View File

@@ -32,6 +32,7 @@ import java.util.Map;
public class FileServiceInfo extends ServiceInfo implements Parcelable { public class FileServiceInfo extends ServiceInfo implements Parcelable {
private final List<FileInfo> files; private final List<FileInfo> files;
/** @hide TODO: systemapi */
public FileServiceInfo(Map<Locale, String> newNames, String newClassName, public FileServiceInfo(Map<Locale, String> newNames, String newClassName,
List<Locale> newLocales, String newServiceId, Date start, Date end, List<Locale> newLocales, String newServiceId, Date start, Date end,
List<FileInfo> newFiles) { List<FileInfo> newFiles) {

View File

@@ -31,7 +31,7 @@ public class MbmsException extends Exception {
/** /**
* Indicates that the app attempted to perform an operation on an instance of * Indicates that the app attempted to perform an operation on an instance of
* {@link android.telephony.MbmsDownloadManager} or * TODO: link android.telephony.MbmsDownloadManager or
* {@link android.telephony.MbmsStreamingManager} without being bound to the middleware. * {@link android.telephony.MbmsStreamingManager} without being bound to the middleware.
*/ */
public static final int ERROR_MIDDLEWARE_NOT_BOUND = 2; public static final int ERROR_MIDDLEWARE_NOT_BOUND = 2;
@@ -47,7 +47,7 @@ public class MbmsException extends Exception {
/** /**
* Indicates that the app tried to create more than one instance each of * Indicates that the app tried to create more than one instance each of
* {@link android.telephony.MbmsStreamingManager} or * {@link android.telephony.MbmsStreamingManager} or
* {@link android.telephony.MbmsDownloadManager}. * TODO: link android.telephony.MbmsDownloadManager
*/ */
public static final int ERROR_DUPLICATE_INITIALIZE = 101; public static final int ERROR_DUPLICATE_INITIALIZE = 101;
/** Indicates that the app is not authorized to access media via MBMS.*/ /** Indicates that the app is not authorized to access media via MBMS.*/
@@ -64,7 +64,7 @@ public class MbmsException extends Exception {
/** /**
* Indicates that the app attempted to perform an operation before receiving notification * Indicates that the app attempted to perform an operation before receiving notification
* that the middleware is ready via {@link MbmsStreamingManagerCallback#middlewareReady()} * that the middleware is ready via {@link MbmsStreamingManagerCallback#middlewareReady()}
* or {@link MbmsDownloadManagerCallback#middlewareReady()}. * or TODO: link MbmsDownloadManagerCallback#middlewareReady
*/ */
public static final int ERROR_MIDDLEWARE_NOT_YET_READY = 201; public static final int ERROR_MIDDLEWARE_NOT_YET_READY = 201;
/** /**
@@ -113,6 +113,8 @@ public class MbmsException extends Exception {
/** /**
* Indicates the errors that are applicable only to the file-download use-case * Indicates the errors that are applicable only to the file-download use-case
* TODO: unhide
* @hide
*/ */
public static class DownloadErrors { public static class DownloadErrors {
/** /**
@@ -127,9 +129,7 @@ public class MbmsException extends Exception {
private final int mErrorCode; private final int mErrorCode;
/** @hide /** @hide */
* TODO: future systemapi
*/
public MbmsException(int errorCode) { public MbmsException(int errorCode) {
super(); super();
mErrorCode = errorCode; mErrorCode = errorCode;

View File

@@ -16,20 +16,25 @@
package android.telephony.mbms; package android.telephony.mbms;
import android.content.Context;
import android.os.RemoteException;
import java.util.List; import java.util.List;
/** /**
* A Parcelable class with Cell-Broadcast service information. * 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)}.
* @hide * @hide
*/ */
public class MbmsStreamingManagerCallback extends IMbmsStreamingManagerCallback.Stub { public class MbmsStreamingManagerCallback extends IMbmsStreamingManagerCallback.Stub {
/**
public final static int ERROR_CARRIER_NOT_SUPPORTED = 1; * Called by the middleware when it has detected an error condition. The possible error codes
public final static int ERROR_UNABLE_TO_INITIALIZE = 2; * are listed in {@link MbmsException}.
public final static int ERROR_UNABLE_TO_ALLOCATE_MEMORY = 3; * @param errorCode The error code.
* @param message A human-readable message generated by the middleware for debugging purposes.
*/
public void error(int errorCode, String message) { public void error(int errorCode, String message) throws RemoteException {
// default implementation empty // default implementation empty
} }
@@ -45,7 +50,8 @@ public class MbmsStreamingManagerCallback extends IMbmsStreamingManagerCallback.
* @param services a List of StreamingServiceInfos * @param services a List of StreamingServiceInfos
* *
*/ */
public void streamingServicesUpdated(List<StreamingServiceInfo> services) { public void streamingServicesUpdated(List<StreamingServiceInfo> services)
throws RemoteException {
// default implementation empty // default implementation empty
} }
@@ -58,7 +64,7 @@ public class MbmsStreamingManagerCallback extends IMbmsStreamingManagerCallback.
* or {@link MbmsException.GeneralErrors#ERROR_MIDDLEWARE_NOT_YET_READY} * or {@link MbmsException.GeneralErrors#ERROR_MIDDLEWARE_NOT_YET_READY}
*/ */
@Override @Override
public void middlewareReady() { public void middlewareReady() throws RemoteException {
// default implementation empty // default implementation empty
} }
} }

View File

@@ -30,43 +30,22 @@ import java.util.Objects;
import java.util.Set; import java.util.Set;
/** /**
* A Parcelable class with Cell-Broadcast service information. * Describes a cell-broadcast service. This class should not be instantiated directly -- use
* {@link StreamingServiceInfo} or FileServiceInfo TODO: add link once that's unhidden
* @hide * @hide
*/ */
public class ServiceInfo implements Parcelable { public class ServiceInfo implements Parcelable {
// arbitrary limit on the number of locale -> name pairs we support // arbitrary limit on the number of locale -> name pairs we support
final static int MAP_LIMIT = 1000; final static int MAP_LIMIT = 1000;
/**
* User displayable names listed by language. Unmodifiable.
*/
final Map<Locale, String> names;
/**
* The class name for this service - used to catagorize and filter
*/
final String className;
/**
* The languages available for this service content
*/
final List<Locale> locales;
/**
* The carrier's identifier for the service.
*/
final String serviceId;
/**
* The start time indicating when this service will be available.
*/
final Date sessionStartTime;
/**
* The end time indicating when this sesion stops being available.
*/
final Date sessionEndTime;
private final Map<Locale, String> names;
private final String className;
private final List<Locale> locales;
private final String serviceId;
private final Date sessionStartTime;
private final Date sessionEndTime;
/** @hide */
public ServiceInfo(Map<Locale, String> newNames, String newClassName, List<Locale> newLocales, public ServiceInfo(Map<Locale, String> newNames, String newClassName, List<Locale> newLocales,
String newServiceId, Date start, Date end) { String newServiceId, Date start, Date end) {
if (newNames == null || newNames.isEmpty() || TextUtils.isEmpty(newClassName) if (newNames == null || newNames.isEmpty() || TextUtils.isEmpty(newClassName)
@@ -89,20 +68,21 @@ public class ServiceInfo implements Parcelable {
sessionEndTime = (Date)end.clone(); sessionEndTime = (Date)end.clone();
} }
public static final Parcelable.Creator<FileServiceInfo> CREATOR = public static final Parcelable.Creator<ServiceInfo> CREATOR =
new Parcelable.Creator<FileServiceInfo>() { new Parcelable.Creator<ServiceInfo>() {
@Override @Override
public FileServiceInfo createFromParcel(Parcel source) { public ServiceInfo createFromParcel(Parcel source) {
return new FileServiceInfo(source); return new ServiceInfo(source);
} }
@Override @Override
public FileServiceInfo[] newArray(int size) { public ServiceInfo[] newArray(int size) {
return new FileServiceInfo[size]; return new ServiceInfo[size];
} }
}; };
ServiceInfo(Parcel in) { /** @hide */
protected ServiceInfo(Parcel in) {
int mapCount = in.readInt(); int mapCount = in.readInt();
if (mapCount > MAP_LIMIT || mapCount < 0) { if (mapCount > MAP_LIMIT || mapCount < 0) {
throw new RuntimeException("bad map length" + mapCount); throw new RuntimeException("bad map length" + mapCount);
@@ -152,26 +132,44 @@ public class ServiceInfo implements Parcelable {
return 0; return 0;
} }
/**
* User displayable names listed by language. Do not modify the map returned from this method.
*/
public Map<Locale, String> getNames() { public Map<Locale, String> getNames() {
return names; return names;
} }
/**
* The class name for this service - used to categorize and filter
*/
public String getClassName() { public String getClassName() {
return className; return className;
} }
/**
* The languages available for this service content
*/
public List<Locale> getLocales() { public List<Locale> getLocales() {
return locales; return locales;
} }
/**
* The carrier's identifier for the service.
*/
public String getServiceId() { public String getServiceId() {
return serviceId; return serviceId;
} }
/**
* The start time indicating when this service will be available.
*/
public Date getSessionStartTime() { public Date getSessionStartTime() {
return sessionStartTime; return sessionStartTime;
} }
/**
* The end time indicating when this session stops being available.
*/
public Date getSessionEndTime() { public Date getSessionEndTime() {
return sessionEndTime; return sessionEndTime;
} }

View File

@@ -26,6 +26,10 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; 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,
* StreamingServiceCallback)},
* this class is used to hold information about the stream and control it.
* @hide * @hide
*/ */
public class StreamingService { public class StreamingService {
@@ -60,7 +64,8 @@ public class StreamingService {
/** /**
* State changed due to a call to {@link #stopStreaming()} or * State changed due to a call to {@link #stopStreaming()} or
* {@link android.telephony.MbmsStreamingManager#startStreaming(StreamingServiceInfo, StreamingServiceCallback)} * {@link android.telephony.MbmsStreamingManager#startStreaming(StreamingServiceInfo,
* StreamingServiceCallback)}
*/ */
public static final int REASON_BY_USER_REQUEST = 1; public static final int REASON_BY_USER_REQUEST = 1;

View File

@@ -16,8 +16,11 @@
package android.telephony.mbms; package android.telephony.mbms;
import android.os.RemoteException;
/** /**
* A Callback class for use when the application is actively streaming content. * 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.
* @hide * @hide
*/ */
public class StreamingServiceCallback extends IStreamingServiceCallback.Stub { public class StreamingServiceCallback extends IStreamingServiceCallback.Stub {
@@ -31,8 +34,14 @@ public class StreamingServiceCallback extends IStreamingServiceCallback.Stub {
*/ */
public static final int SIGNAL_STRENGTH_UNAVAILABLE = -1; public static final int SIGNAL_STRENGTH_UNAVAILABLE = -1;
/**
* Called by the middleware when it has detected an error condition in this stream. 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.
*/
@Override @Override
public void error(int errorCode, String message) { public void error(int errorCode, String message) throws RemoteException {
// default implementation empty // default implementation empty
} }
@@ -44,7 +53,7 @@ public class StreamingServiceCallback extends IStreamingServiceCallback.Stub {
*/ */
@Override @Override
public void streamStateUpdated(@StreamingService.StreamingState int state, public void streamStateUpdated(@StreamingService.StreamingState int state,
@StreamingService.StreamingStateChangeReason int reason) { @StreamingService.StreamingStateChangeReason int reason) throws RemoteException {
// default implementation empty // default implementation empty
} }
@@ -59,7 +68,7 @@ public class StreamingServiceCallback extends IStreamingServiceCallback.Stub {
* when parameters have changed to account for time drift. * when parameters have changed to account for time drift.
*/ */
@Override @Override
public void mediaDescriptionUpdated() { public void mediaDescriptionUpdated() throws RemoteException {
// default implementation empty // default implementation empty
} }
@@ -74,7 +83,7 @@ public class StreamingServiceCallback extends IStreamingServiceCallback.Stub {
* for this service due to timing, geography or popularity. * for this service due to timing, geography or popularity.
*/ */
@Override @Override
public void broadcastSignalStrengthUpdated(int signalStrength) { public void broadcastSignalStrengthUpdated(int signalStrength) throws RemoteException {
// default implementation empty // default implementation empty
} }
@@ -95,7 +104,7 @@ public class StreamingServiceCallback extends IStreamingServiceCallback.Stub {
* {@link StreamingService#UNICAST_METHOD} * {@link StreamingService#UNICAST_METHOD}
*/ */
@Override @Override
public void streamMethodUpdated(int methodType) { public void streamMethodUpdated(int methodType) throws RemoteException {
// default implementation empty // default implementation empty
} }
} }

View File

@@ -16,6 +16,7 @@
package android.telephony.mbms; package android.telephony.mbms;
import android.annotation.SystemApi;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
@@ -25,15 +26,25 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
/** /**
* A Parcelable class Cell-Broadcast media stream information. * Describes a single MBMS streaming service.
* This may not have any more info than ServiceInfo, but kept for completeness.
* @hide * @hide
*/ */
public class StreamingServiceInfo extends ServiceInfo implements Parcelable { public class StreamingServiceInfo extends ServiceInfo implements Parcelable {
public StreamingServiceInfo(Map<Locale, String> newNames, String newClassName, /**
List<Locale> newLocales, String newServiceId, Date start, Date end) { * @param names User displayable names listed by language.
super(newNames, newClassName, newLocales, newServiceId, start, end); * @param className The class name for this service - used by frontend apps to categorize and
* filter.
* @param locales The languages available for this service content.
* @param serviceId The carrier's identifier for the service.
* @param start The start time indicating when this service will be available.
* @param end The end time indicating when this session stops being available.
* @hide
*/
@SystemApi
public StreamingServiceInfo(Map<Locale, String> names, String className,
List<Locale> locales, String serviceId, Date start, Date end) {
super(names, className, locales, serviceId, start, end);
} }
public static final Parcelable.Creator<StreamingServiceInfo> CREATOR = public static final Parcelable.Creator<StreamingServiceInfo> CREATOR =
@@ -49,7 +60,7 @@ public class StreamingServiceInfo extends ServiceInfo implements Parcelable {
} }
}; };
StreamingServiceInfo(Parcel in) { private StreamingServiceInfo(Parcel in) {
super(in); super(in);
} }

View File

@@ -17,18 +17,23 @@
package android.telephony.mbms.vendor; package android.telephony.mbms.vendor;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.annotation.SystemApi;
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;
import android.telephony.mbms.IStreamingServiceCallback; 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.StreamingServiceCallback;
import android.telephony.mbms.StreamingServiceInfo;
import java.util.List; import java.util.List;
/** /**
* @hide * @hide
* TODO: future systemapi
*/ */
//@SystemApi
public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub { 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.
@@ -44,12 +49,38 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
* @param listener The callback to use to communicate with the app. * @param listener The callback to use to communicate with the app.
* @param subscriptionId The subscription ID to use. * @param subscriptionId The subscription ID to use.
*/ */
@Override public int initialize(MbmsStreamingManagerCallback listener, int subscriptionId)
public int initialize(IMbmsStreamingManagerCallback listener, int subscriptionId)
throws RemoteException { throws RemoteException {
return 0; return 0;
} }
/**
* Actual AIDL implementation that hides the callback AIDL from the middleware.
* @hide
*/
@Override
public final int initialize(IMbmsStreamingManagerCallback listener, int subscriptionId)
throws RemoteException {
return initialize(new MbmsStreamingManagerCallback() {
@Override
public void error(int errorCode, String message) throws RemoteException {
listener.error(errorCode, message);
}
@Override
public void streamingServicesUpdated(List<StreamingServiceInfo> services) throws
RemoteException {
listener.streamingServicesUpdated(services);
}
@Override
public void middlewareReady() throws RemoteException {
listener.middlewareReady();
}
}, subscriptionId);
}
/** /**
* Registers serviceClasses of interest with the appName/subId key. * Registers serviceClasses of interest with the appName/subId key.
* Starts async fetching data on streaming services of matching classes to be reported * Starts async fetching data on streaming services of matching classes to be reported
@@ -85,10 +116,47 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
* @param listener The listener object on which the app wishes to receive updates. * @param listener The listener object on which the app wishes to receive updates.
* @return Any error in {@link android.telephony.mbms.MbmsException.GeneralErrors} * @return Any error in {@link android.telephony.mbms.MbmsException.GeneralErrors}
*/ */
public int startStreaming(int subscriptionId, String serviceId,
StreamingServiceCallback listener) throws RemoteException {
return 0;
}
/**
* Actual AIDL implementation of startStreaming that hides the callback AIDL from the
* middleware.
* @hide
*/
@Override @Override
public int startStreaming(int subscriptionId, String serviceId, public int startStreaming(int subscriptionId, String serviceId,
IStreamingServiceCallback listener) throws RemoteException { IStreamingServiceCallback listener) throws RemoteException {
return 0; return startStreaming(subscriptionId, serviceId, new StreamingServiceCallback() {
@Override
public void error(int errorCode, String message) throws RemoteException {
listener.error(errorCode, message);
}
@Override
public void streamStateUpdated(@StreamingService.StreamingState int state,
@StreamingService.StreamingStateChangeReason int reason)
throws RemoteException {
listener.streamStateUpdated(state, reason);
}
@Override
public void mediaDescriptionUpdated() throws RemoteException {
listener.mediaDescriptionUpdated();
}
@Override
public void broadcastSignalStrengthUpdated(int signalStrength) throws RemoteException {
listener.broadcastSignalStrengthUpdated(signalStrength);
}
@Override
public void streamMethodUpdated(int methodType) throws RemoteException {
listener.streamMethodUpdated(methodType);
}
});
} }
/** /**