diff options
| author | 2017-05-12 01:52:29 +0000 | |
|---|---|---|
| committer | 2017-05-12 01:52:29 +0000 | |
| commit | 1d274ca5eccdd8cff62ddbc213b456793b0ce72f (patch) | |
| tree | 3727a8b068600171fb415696e1778f3495375e71 | |
| parent | cca5fbe7794eb5e5f7001ad23446c2205c451b24 (diff) | |
| parent | b73fe9a751cdfc3457c35fae20fec7069fab194d (diff) | |
Merge "getStreamingServices for embms"
am: b73fe9a751
Change-Id: I391004c1ee0e5815147349f488b537ed4d645e73
5 files changed, 99 insertions, 48 deletions
diff --git a/telephony/java/android/telephony/MbmsStreamingManager.java b/telephony/java/android/telephony/MbmsStreamingManager.java index fc406ee54ce8..58262e1df28d 100644 --- a/telephony/java/android/telephony/MbmsStreamingManager.java +++ b/telephony/java/android/telephony/MbmsStreamingManager.java @@ -22,7 +22,6 @@ import android.content.Intent; import android.content.ServiceConnection; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; -import android.os.DeadObjectException; import android.os.IBinder; import android.os.RemoteException; import android.telephony.mbms.IMbmsStreamingManagerCallback; @@ -96,15 +95,15 @@ public class MbmsStreamingManager { /** * Create a new MbmsStreamingManager using the given subscription ID. * - * Note that this call will bind a remote service and that may take a bit. This - * may throw an {@link MbmsException}, indicating errors that may happen during - * the initialization or binding process. + * Note that this call will bind a remote service. You may not call this method on your app's + * main thread. This may throw an {@link MbmsException}, indicating errors that may happen + * during the initialization or binding process. * - * @param context - * @param listener - * @param streamingAppName - * @param subscriptionId - * @return + * @param context The {@link Context} to use. + * @param listener A callback object on which you wish to receive results of asynchronous + * operations. + * @param streamingAppName The name of the streaming app, as specified by the carrier. + * @param subscriptionId The subscription ID to use. */ public static MbmsStreamingManager create(Context context, IMbmsStreamingManagerCallback listener, String streamingAppName, int subscriptionId) @@ -117,9 +116,7 @@ public class MbmsStreamingManager { /** * Create a new MbmsStreamingManager using the system default data subscription ID. - * - * Note that this call will bind a remote service and that may take a bit. This - * may throw an IllegalArgumentException or RemoteException. + * See {@link #create(Context, IMbmsStreamingManagerCallback, String, int)}. */ public static MbmsStreamingManager create(Context context, IMbmsStreamingManagerCallback listener, String streamingAppName) @@ -156,19 +153,29 @@ public class MbmsStreamingManager { * * Multiple calls replace the list of serviceClasses of interest. * - * May throw an IllegalArgumentException or RemoteException. - * - * Synchronous responses include - * <li>SUCCESS</li> - * <li>ERROR_MSDC_CONCURRENT_SERVICE_LIMIT_REACHED</li> + * 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_CONCURRENT_SERVICE_LIMIT_REACHED} * - * Asynchronous errors through the listener include any of the errors except - * <li>ERROR_MSDC_UNABLE_TO_)START_SERVICE</li> - * <li>ERROR_MSDC_INVALID_SERVICE_ID</li> - * <li>ERROR_MSDC_END_OF_SESSION</li> + * Asynchronous error codes via the {@link IMbmsStreamingManagerCallback#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 int getStreamingServices(List<String> classList) { - return 0; + public void getStreamingServices(List<String> classList) throws MbmsException { + if (mService == null) { + throw new MbmsException(MbmsException.ERROR_MIDDLEWARE_NOT_BOUND); + } + try { + int returnCode = mService.getStreamingServices(mAppName, mSubscriptionId, classList); + if (returnCode != MbmsException.SUCCESS) { + throw new MbmsException(returnCode); + } + } catch (RemoteException e) { + throw new MbmsException(MbmsException.ERROR_UNKNOWN_REMOTE_EXCEPTION); + } } /** @@ -262,7 +269,7 @@ public class MbmsStreamingManager { } catch (RemoteException e) { mService = null; Log.e(LOG_TAG, "Service died before initialization"); - throw new MbmsException(MbmsException.ERROR_INITIALIZATION_REMOTE_EXCEPTION); + throw new MbmsException(MbmsException.ERROR_UNKNOWN_REMOTE_EXCEPTION); } } } diff --git a/telephony/java/android/telephony/mbms/MbmsException.java b/telephony/java/android/telephony/mbms/MbmsException.java index cc4a02a13717..e8680ea4683d 100644 --- a/telephony/java/android/telephony/mbms/MbmsException.java +++ b/telephony/java/android/telephony/mbms/MbmsException.java @@ -16,16 +16,21 @@ package android.telephony.mbms; -import android.os.RemoteException; - /** @hide */ -public class MbmsException extends RemoteException { +public class MbmsException extends Exception { public static final int SUCCESS = 0; public static final int ERROR_NO_SERVICE_INSTALLED = 1; public static final int ERROR_MULTIPLE_SERVICES_INSTALLED = 2; public static final int ERROR_BIND_TIMEOUT_OR_FAILURE = 3; - public static final int ERROR_INITIALIZATION_REMOTE_EXCEPTION = 4; + public static final int ERROR_UNKNOWN_REMOTE_EXCEPTION = 4; public static final int ERROR_ALREADY_INITIALIZED = 5; + 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_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; diff --git a/telephony/java/android/telephony/mbms/ServiceInfo.java b/telephony/java/android/telephony/mbms/ServiceInfo.java index cb621c8bbfd0..f167f0ab228e 100644 --- a/telephony/java/android/telephony/mbms/ServiceInfo.java +++ b/telephony/java/android/telephony/mbms/ServiceInfo.java @@ -114,6 +114,7 @@ public class ServiceInfo implements Parcelable { sessionEndTime = (java.util.Date) in.readSerializable(); } + @Override public void writeToParcel(Parcel dest, int flags) { Set<Locale> keySet = names.keySet(); dest.writeInt(keySet.size()); @@ -128,7 +129,33 @@ public class ServiceInfo implements Parcelable { dest.writeSerializable(sessionEndTime); } + @Override public int describeContents() { return 0; } + + public Map<Locale, String> getNames() { + return names; + } + + public String getClassName() { + return className; + } + + public Locale getLocale() { + return locale; + } + + public String getServiceId() { + return serviceId; + } + + public Date getSessionStartTime() { + return sessionStartTime; + } + + public Date getSessionEndTime() { + return sessionEndTime; + } + } diff --git a/telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl b/telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl index ddc661df8c91..fed0a403bc69 100755 --- a/telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl +++ b/telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl @@ -29,22 +29,8 @@ import android.telephony.SignalStrength; */ interface IMbmsStreamingService { - /** - * Initialize streaming service - * Registers this listener, subId with this appName - * - */ int initialize(IMbmsStreamingManagerCallback listener, String appName, int subId); - - /** - * - Registers serviceClasses of interest with the uid/appName/subId key. - * - Starts asynch fetching data on streaming services of matching classes to be reported - * later by callback. - * - * Note that subsequent calls with the same callback, appName, subId and uid will replace - * the service class list. - */ int getStreamingServices(String appName, int subId, in List<String> serviceClasses); /** diff --git a/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java b/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java index 9f0c0e94d66b..e23d12b21ace 100644 --- a/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java +++ b/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java @@ -20,7 +20,7 @@ import android.net.Uri; import android.os.RemoteException; import android.telephony.mbms.IMbmsStreamingManagerCallback; import android.telephony.mbms.IStreamingServiceCallback; -import android.telephony.mbms.StreamingService; +import android.telephony.mbms.MbmsException; import java.util.List; @@ -29,16 +29,42 @@ import java.util.List; * TODO: future systemapi */ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub { - + /** + * Initialize streaming service for this app and subId, registering the listener. + * + * @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} + */ @Override - public int initialize(IMbmsStreamingManagerCallback listener, String appName, int subId) - throws RemoteException { + public int initialize(IMbmsStreamingManagerCallback listener, String appName, + int subscriptionId) throws RemoteException { return 0; } + /** + * Registers serviceClasses of interest with the appName/subId key. + * Starts async fetching data on streaming services of matching classes to be reported + * later via {@link IMbmsStreamingManagerCallback#streamingServicesUpdated(List)} + * + * Note that subsequent calls with the same uid, appName and subId will replace + * the service class list. + * + * @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 + * may contain arbitrary data as negotiated between the app and the + * 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 - public int getStreamingServices(String appName, int subId, List<String> serviceClasses) - throws RemoteException { + public int getStreamingServices(String appName, int subscriptionId, + List<String> serviceClasses) throws RemoteException { return 0; } |