diff options
11 files changed, 286 insertions, 176 deletions
diff --git a/telephony/java/android/telephony/MbmsDownloadManager.java b/telephony/java/android/telephony/MbmsDownloadManager.java index 14ba7e5d274a..b3f46c22ba0a 100644 --- a/telephony/java/android/telephony/MbmsDownloadManager.java +++ b/telephony/java/android/telephony/MbmsDownloadManager.java @@ -194,27 +194,23 @@ public class MbmsDownloadManager { private AtomicReference<IMbmsDownloadService> mService = new AtomicReference<>(null); private final IMbmsDownloadManagerCallback mCallback; - private final String mDownloadAppName; - private MbmsDownloadManager(Context context, IMbmsDownloadManagerCallback callback, - String downloadAppName, int subId) { + private MbmsDownloadManager(Context context, IMbmsDownloadManagerCallback callback, int subId) { mContext = context; mCallback = callback; - mDownloadAppName = downloadAppName; mSubscriptionId = subId; } /** * Create a new MbmsDownloadManager using the system default data subscription ID. - * See {@link #create(Context, IMbmsDownloadManagerCallback, String, int)} + * See {@link #create(Context, IMbmsDownloadManagerCallback, int)} * * @hide */ public static MbmsDownloadManager create(Context context, - IMbmsDownloadManagerCallback listener, String downloadAppName) + IMbmsDownloadManagerCallback listener) throws MbmsException { - return create(context, listener, downloadAppName, - SubscriptionManager.getDefaultSubscriptionId()); + return create(context, listener, SubscriptionManager.getDefaultSubscriptionId()); } /** @@ -229,15 +225,13 @@ public class MbmsDownloadManager { * * @param context The instance of {@link Context} to use * @param listener A callback to get asynchronous error messages and file service updates. - * @param downloadAppName The app name, as negotiated with the eMBMS provider * @param subscriptionId The data subscription ID to use * @hide */ public static MbmsDownloadManager create(Context context, - IMbmsDownloadManagerCallback listener, String downloadAppName, int subscriptionId) + IMbmsDownloadManagerCallback listener, int subscriptionId) throws MbmsException { - MbmsDownloadManager mdm = new MbmsDownloadManager(context, listener, downloadAppName, - subscriptionId); + MbmsDownloadManager mdm = new MbmsDownloadManager(context, listener, subscriptionId); mdm.bindAndInitialize(); return mdm; } @@ -250,8 +244,7 @@ public class MbmsDownloadManager { IMbmsDownloadService downloadService = IMbmsDownloadService.Stub.asInterface(service); try { - downloadService.initialize( - mDownloadAppName, mSubscriptionId, mCallback); + downloadService.initialize(mSubscriptionId, mCallback); } catch (RemoteException e) { Log.e(LOG_TAG, "Service died before initialization"); return; @@ -293,8 +286,7 @@ public class MbmsDownloadManager { throw new MbmsException(MbmsException.ERROR_MIDDLEWARE_NOT_BOUND); } try { - int returnCode = downloadService.getFileServices( - mDownloadAppName, mSubscriptionId, classList); + int returnCode = downloadService.getFileServices(mSubscriptionId, classList); if (returnCode != MbmsException.SUCCESS) { throw new MbmsException(returnCode); } @@ -345,8 +337,7 @@ public class MbmsDownloadManager { } try { - int result = downloadService.setTempFileRootDirectory( - mDownloadAppName, mSubscriptionId, filePath); + int result = downloadService.setTempFileRootDirectory(mSubscriptionId, filePath); if (result != MbmsException.SUCCESS) { throw new MbmsException(result); } @@ -396,7 +387,6 @@ public class MbmsDownloadManager { tempRootDirectory.mkdirs(); setTempFileRootDirectory(tempRootDirectory); } - request.setAppName(mDownloadAppName); checkValidDownloadDestination(request); writeDownloadRequestToken(request); @@ -404,6 +394,7 @@ public class MbmsDownloadManager { downloadService.download(request, callback); } catch (RemoteException e) { mService.set(null); + throw new MbmsException(MbmsException.ERROR_SERVICE_LOST); } } @@ -422,18 +413,31 @@ public class MbmsDownloadManager { } /** - * Attempts to cancel the specified DownloadRequest. + * Attempts to cancel the specified {@link DownloadRequest}. * - * May throw a RemoteException. + * If the middleware is not aware of the specified download request, an MbmsException will be + * thrown with error code {@link MbmsException#ERROR_UNKNOWN_DOWNLOAD_REQUEST}. * - * Synchronous responses may include - * <li>SUCCESS</li> - * <li>ERROR_MSDC_CONCURRENT_SERVICE_LIMIT_REACHED</li> - * <li>ERROR_MSDC_UNKNOWN_REQUEST</li> + * If this method returns without throwing an exception, you may assume that cancellation + * was successful. + * @param downloadRequest The download request that you wish to cancel. */ - public int cancelDownload(DownloadRequest downloadRequest) { - // TODO: don't forget to delete the token - return 0; + public void cancelDownload(DownloadRequest downloadRequest) throws MbmsException { + IMbmsDownloadService downloadService = mService.get(); + if (downloadService == null) { + throw new MbmsException(MbmsException.ERROR_MIDDLEWARE_NOT_BOUND); + } + + try { + int result = downloadService.cancelDownload(downloadRequest); + if (result != MbmsException.SUCCESS) { + throw new MbmsException(result); + } + } catch (RemoteException e) { + mService.set(null); + throw new MbmsException(MbmsException.ERROR_SERVICE_LOST); + } + deleteDownloadRequestToken(downloadRequest); } /** @@ -472,6 +476,21 @@ public class MbmsDownloadManager { return 0; } + public void dispose() { + try { + IMbmsDownloadService downloadService = mService.get(); + if (downloadService == null) { + Log.i(LOG_TAG, "Service already dead"); + return; + } + downloadService.dispose(mSubscriptionId); + mService.set(null); + } catch (RemoteException e) { + // Ignore + Log.i(LOG_TAG, "Remote exception while disposing of service"); + } + } + /** * Retrieves the {@link ComponentName} for the {@link android.content.BroadcastReceiver} that * the various intents from the middleware should be targeted towards. @@ -502,32 +521,13 @@ public class MbmsDownloadManager { return null; } - public void dispose() { - try { - IMbmsDownloadService downloadService = mService.get(); - if (downloadService == null) { - Log.i(LOG_TAG, "Service already dead"); - return; - } - downloadService.dispose(mDownloadAppName, mSubscriptionId); - mService.set(null); - } catch (RemoteException e) { - // Ignore - Log.i(LOG_TAG, "Remote exception while disposing of service"); - } - } - private void writeDownloadRequestToken(DownloadRequest request) { - File tempFileLocation = MbmsUtils.getEmbmsTempFileDirForService(mContext, - request.getFileServiceInfo()); - if (!tempFileLocation.exists()) { - tempFileLocation.mkdirs(); + File token = getDownloadRequestTokenPath(request); + if (!token.getParentFile().exists()) { + token.getParentFile().mkdirs(); } - String downloadTokenFileName = request.getHash() - + MbmsDownloadReceiver.DOWNLOAD_TOKEN_SUFFIX; - File token = new File(tempFileLocation, downloadTokenFileName); if (token.exists()) { - Log.w(LOG_TAG, "Download token " + downloadTokenFileName + " already exists"); + Log.w(LOG_TAG, "Download token " + token.getName() + " already exists"); return; } try { @@ -541,6 +541,25 @@ public class MbmsDownloadManager { } } + private void deleteDownloadRequestToken(DownloadRequest request) { + File token = getDownloadRequestTokenPath(request); + if (!token.isFile()) { + Log.w(LOG_TAG, "Attempting to delete non-existent download token at " + token); + return; + } + if (!token.delete()) { + Log.w(LOG_TAG, "Couldn't delete download token at " + token); + } + } + + private File getDownloadRequestTokenPath(DownloadRequest request) { + File tempFileLocation = MbmsUtils.getEmbmsTempFileDirForService(mContext, + request.getFileServiceInfo()); + String downloadTokenFileName = request.getHash() + + MbmsDownloadReceiver.DOWNLOAD_TOKEN_SUFFIX; + return new File(tempFileLocation, downloadTokenFileName); + } + /** * Verifies the following: * If a request is multi-part, diff --git a/telephony/java/android/telephony/MbmsStreamingManager.java b/telephony/java/android/telephony/MbmsStreamingManager.java index af7f333390d8..fb3d5025dafa 100644 --- a/telephony/java/android/telephony/MbmsStreamingManager.java +++ b/telephony/java/android/telephony/MbmsStreamingManager.java @@ -43,16 +43,14 @@ public class MbmsStreamingManager { private AtomicReference<IMbmsStreamingService> mService = new AtomicReference<>(null); private MbmsStreamingManagerCallback mCallbackToApp; - private final String mAppName; private final Context mContext; private int mSubscriptionId = INVALID_SUBSCRIPTION_ID; /** @hide */ private MbmsStreamingManager(Context context, MbmsStreamingManagerCallback listener, - String streamingAppName, int subscriptionId) { + int subscriptionId) { mContext = context; - mAppName = streamingAppName; mCallbackToApp = listener; mSubscriptionId = subscriptionId; } @@ -67,27 +65,24 @@ public class MbmsStreamingManager { * @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, - MbmsStreamingManagerCallback listener, String streamingAppName, int subscriptionId) + MbmsStreamingManagerCallback listener, int subscriptionId) throws MbmsException { - MbmsStreamingManager manager = new MbmsStreamingManager(context, listener, - streamingAppName, subscriptionId); + MbmsStreamingManager manager = new MbmsStreamingManager(context, listener, subscriptionId); manager.bindAndInitialize(); return manager; } /** * Create a new MbmsStreamingManager using the system default data subscription ID. - * See {@link #create(Context, MbmsStreamingManagerCallback, String, int)}. + * See {@link #create(Context, MbmsStreamingManagerCallback, int)}. */ public static MbmsStreamingManager create(Context context, - MbmsStreamingManagerCallback listener, String streamingAppName) + MbmsStreamingManagerCallback listener) throws MbmsException { - return create(context, listener, streamingAppName, - SubscriptionManager.getDefaultSubscriptionId()); + return create(context, listener, SubscriptionManager.getDefaultSubscriptionId()); } /** @@ -101,7 +96,7 @@ public class MbmsStreamingManager { return; } try { - streamingService.dispose(mAppName, mSubscriptionId); + streamingService.dispose(mSubscriptionId); } catch (RemoteException e) { // Ignore for now } @@ -132,8 +127,7 @@ public class MbmsStreamingManager { throw new MbmsException(MbmsException.ERROR_MIDDLEWARE_NOT_BOUND); } try { - int returnCode = streamingService.getStreamingServices( - mAppName, mSubscriptionId, classList); + int returnCode = streamingService.getStreamingServices(mSubscriptionId, classList); if (returnCode != MbmsException.SUCCESS) { throw new MbmsException(returnCode); } @@ -168,7 +162,7 @@ public class MbmsStreamingManager { try { int returnCode = streamingService.startStreaming( - mAppName, mSubscriptionId, serviceInfo.getServiceId(), listener); + mSubscriptionId, serviceInfo.getServiceId(), listener); if (returnCode != MbmsException.SUCCESS) { throw new MbmsException(returnCode); } @@ -178,8 +172,7 @@ public class MbmsStreamingManager { throw new MbmsException(MbmsException.ERROR_SERVICE_LOST); } - return new StreamingService( - mAppName, mSubscriptionId, streamingService, serviceInfo, listener); + return new StreamingService(mSubscriptionId, streamingService, serviceInfo, listener); } private void bindAndInitialize() throws MbmsException { @@ -190,12 +183,12 @@ public class MbmsStreamingManager { IMbmsStreamingService streamingService = IMbmsStreamingService.Stub.asInterface(service); try { - streamingService.initialize(mCallbackToApp, mAppName, mSubscriptionId); + streamingService.initialize(mCallbackToApp, mSubscriptionId); } catch (RemoteException e) { Log.e(LOG_TAG, "Service died before initialization"); return; } - mService.set(null); + mService.set(streamingService); } @Override diff --git a/telephony/java/android/telephony/mbms/DownloadRequest.java b/telephony/java/android/telephony/mbms/DownloadRequest.java index 907b0cbd8004..345729d82dea 100644 --- a/telephony/java/android/telephony/mbms/DownloadRequest.java +++ b/telephony/java/android/telephony/mbms/DownloadRequest.java @@ -22,11 +22,11 @@ import android.os.Parcel; import android.os.Parcelable; import android.util.Base64; -import java.lang.IllegalStateException; import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; +import java.util.Objects; /** * A Parcelable class describing a pending Cell-Broadcast download request @@ -83,7 +83,7 @@ public class DownloadRequest implements Parcelable { public DownloadRequest build() { return new DownloadRequest(id, serviceInfo, source, dest, - subscriptionId, appIntent, null, version); + subscriptionId, appIntent, version); } } @@ -94,18 +94,16 @@ public class DownloadRequest implements Parcelable { private final int subscriptionId; private final String serializedResultIntentForApp; private final int version; - private String appName; // not the Android app Name, the embms app name private DownloadRequest(int id, FileServiceInfo serviceInfo, Uri source, Uri dest, - int sub, String appIntent, String name, int version) { + int sub, String appIntent, int version) { downloadId = id; fileServiceInfo = serviceInfo; sourceUri = source; destinationUri = dest; subscriptionId = sub; serializedResultIntentForApp = appIntent; - appName = name; this.version = version; } @@ -120,7 +118,6 @@ public class DownloadRequest implements Parcelable { destinationUri = dr.destinationUri; subscriptionId = dr.subscriptionId; serializedResultIntentForApp = dr.serializedResultIntentForApp; - appName = dr.appName; version = dr.version; } @@ -131,7 +128,6 @@ public class DownloadRequest implements Parcelable { destinationUri = in.readParcelable(getClass().getClassLoader()); subscriptionId = in.readInt(); serializedResultIntentForApp = in.readString(); - appName = in.readString(); version = in.readInt(); } @@ -146,7 +142,6 @@ public class DownloadRequest implements Parcelable { out.writeParcelable(destinationUri, flags); out.writeInt(subscriptionId); out.writeString(serializedResultIntentForApp); - out.writeString(appName); out.writeInt(version); } @@ -178,18 +173,6 @@ public class DownloadRequest implements Parcelable { } } - /** @hide */ - public synchronized void setAppName(String newAppName) { - if (appName != null) { - throw new IllegalStateException("Attempting to reset appName"); - } - appName = newAppName; - } - - public String getAppName() { - return appName; - } - public int getVersion() { return version; } @@ -234,4 +217,29 @@ public class DownloadRequest implements Parcelable { // Add updates for future versions here return Base64.encodeToString(digest.digest(), Base64.URL_SAFE | Base64.NO_WRAP); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) { + return false; + } + if (!(o instanceof DownloadRequest)) { + return false; + } + DownloadRequest request = (DownloadRequest) o; + return downloadId == request.downloadId && + subscriptionId == request.subscriptionId && + version == request.version && + Objects.equals(fileServiceInfo, request.fileServiceInfo) && + Objects.equals(sourceUri, request.sourceUri) && + Objects.equals(destinationUri, request.destinationUri) && + Objects.equals(serializedResultIntentForApp, request.serializedResultIntentForApp); + } + + @Override + public int hashCode() { + return Objects.hash(downloadId, fileServiceInfo, sourceUri, destinationUri, + subscriptionId, serializedResultIntentForApp, version); + } } diff --git a/telephony/java/android/telephony/mbms/MbmsDownloadReceiver.java b/telephony/java/android/telephony/mbms/MbmsDownloadReceiver.java index 1ce82d94b7e5..5bc53a82a3bb 100644 --- a/telephony/java/android/telephony/mbms/MbmsDownloadReceiver.java +++ b/telephony/java/android/telephony/mbms/MbmsDownloadReceiver.java @@ -29,16 +29,16 @@ import android.util.Log; import java.io.File; import java.io.FileFilter; -import java.io.FilenameFilter; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.util.ArrayList; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Objects; -import java.util.Set; import java.util.UUID; -import java.util.function.Predicate; /** * @hide @@ -431,17 +431,16 @@ public class MbmsDownloadReceiver extends BroadcastReceiver { } toFile.getParentFile().mkdirs(); - // TODO: This will not work if the two files are on different filesystems. Add manual - // copy later. if (fromFile.renameTo(toFile)) { return Uri.fromFile(toFile); + } else if (manualMove(fromFile, toFile)) { + return Uri.fromFile(toFile); } return null; } private static boolean verifyTempFilePath(Context context, FileServiceInfo serviceInfo, Uri filePath) { - // TODO: modify pursuant to final decision on temp file path scheme if (!ContentResolver.SCHEME_FILE.equals(filePath.getScheme())) { Log.w(LOG_TAG, "Uri " + filePath + " does not have a file scheme"); return false; @@ -493,4 +492,40 @@ public class MbmsDownloadReceiver extends BroadcastReceiver { } return mMiddlewarePackageNameCache; } + + private static boolean manualMove(File src, File dst) { + InputStream in = null; + OutputStream out = null; + try { + if (!dst.exists()) { + dst.createNewFile(); + } + in = new FileInputStream(src); + out = new FileOutputStream(dst); + byte[] buffer = new byte[2048]; + int len; + do { + len = in.read(buffer); + out.write(buffer, 0, len); + } while (len > 0); + } catch (IOException e) { + Log.w(LOG_TAG, "Manual file move failed due to exception " + e); + if (dst.exists()) { + dst.delete(); + } + return false; + } finally { + try { + if (in != null) { + in.close(); + } + if (out != null) { + out.close(); + } + } catch (IOException e) { + Log.w(LOG_TAG, "Error closing streams: " + e); + } + } + return true; + } } diff --git a/telephony/java/android/telephony/mbms/MbmsException.java b/telephony/java/android/telephony/mbms/MbmsException.java index 8260b728a52f..e190623f5529 100644 --- a/telephony/java/android/telephony/mbms/MbmsException.java +++ b/telephony/java/android/telephony/mbms/MbmsException.java @@ -37,6 +37,8 @@ public class MbmsException extends Exception { public static final int ERROR_UNABLE_TO_READ_SIM = 16; public static final int ERROR_CARRIER_CHANGE_NOT_ALLOWED = 17; public static final int ERROR_CANNOT_CHANGE_TEMP_FILE_ROOT = 18; + public static final int ERROR_UNKNOWN_DOWNLOAD_REQUEST = 19; + public static final int ERROR_UNABLE_TO_INITIALIZE = 20; private final int mErrorCode; diff --git a/telephony/java/android/telephony/mbms/ServiceInfo.java b/telephony/java/android/telephony/mbms/ServiceInfo.java index b5675b2576dc..f9ad44c63118 100644 --- a/telephony/java/android/telephony/mbms/ServiceInfo.java +++ b/telephony/java/android/telephony/mbms/ServiceInfo.java @@ -26,6 +26,7 @@ import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.Set; /** @@ -175,4 +176,26 @@ public class ServiceInfo implements Parcelable { return sessionEndTime; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) { + return false; + } + if (!(o instanceof ServiceInfo)) { + return false; + } + ServiceInfo that = (ServiceInfo) o; + return Objects.equals(names, that.names) && + Objects.equals(className, that.className) && + Objects.equals(locales, that.locales) && + Objects.equals(serviceId, that.serviceId) && + Objects.equals(sessionStartTime, that.sessionStartTime) && + Objects.equals(sessionEndTime, that.sessionEndTime); + } + + @Override + public int hashCode() { + return Objects.hash(names, className, locales, serviceId, sessionStartTime, sessionEndTime); + } } diff --git a/telephony/java/android/telephony/mbms/StreamingService.java b/telephony/java/android/telephony/mbms/StreamingService.java index 608d3a921dc7..85731a14277f 100644 --- a/telephony/java/android/telephony/mbms/StreamingService.java +++ b/telephony/java/android/telephony/mbms/StreamingService.java @@ -42,7 +42,6 @@ public class StreamingService { public final static int BROADCAST_METHOD = 1; public final static int UNICAST_METHOD = 2; - private final String mAppName; private final int mSubscriptionId; private final StreamingServiceInfo mServiceInfo; private final IStreamingServiceCallback mCallback; @@ -51,12 +50,10 @@ public class StreamingService { /** * @hide */ - public StreamingService(String appName, - int subscriptionId, + public StreamingService(int subscriptionId, IMbmsStreamingService service, StreamingServiceInfo streamingServiceInfo, IStreamingServiceCallback callback) { - mAppName = appName; mSubscriptionId = subscriptionId; mService = service; mServiceInfo = streamingServiceInfo; @@ -77,7 +74,7 @@ public class StreamingService { } try { - return mService.getPlaybackUri(mAppName, mSubscriptionId, mServiceInfo.getServiceId()); + return mService.getPlaybackUri(mSubscriptionId, mServiceInfo.getServiceId()); } catch (RemoteException e) { Log.w(LOG_TAG, "Remote process died"); mService = null; @@ -103,7 +100,7 @@ public class StreamingService { } try { - mService.stopStreaming(mAppName, mSubscriptionId, mServiceInfo.getServiceId()); + mService.stopStreaming(mSubscriptionId, mServiceInfo.getServiceId()); } catch (RemoteException e) { Log.w(LOG_TAG, "Remote process died"); mService = null; @@ -117,7 +114,7 @@ public class StreamingService { } try { - mService.disposeStream(mAppName, mSubscriptionId, mServiceInfo.getServiceId()); + mService.disposeStream(mSubscriptionId, mServiceInfo.getServiceId()); } catch (RemoteException e) { Log.w(LOG_TAG, "Remote process died"); mService = null; diff --git a/telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl b/telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl index ff7d233bbf2c..7112e13d5650 100755 --- a/telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl +++ b/telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl @@ -29,31 +29,15 @@ import android.telephony.mbms.IDownloadCallback; */ interface IMbmsDownloadService { - /** - * Initialize download service - * Registers this listener, subId with this appName - * - * No return value. Async errors may be reported, but none expected (not doing anything yet). - */ - void initialize(String appName, int subId, IMbmsDownloadManagerCallback listener); + void initialize(int subId, IMbmsDownloadManagerCallback listener); - /** - * - Registers serviceClasses of interest with the uid/appName/subId key. - * - Starts asynch fetching data on download 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 getFileServices(String appName, int subId, in List<String> serviceClasses); + int getFileServices(int subId, in List<String> serviceClasses); + + int setTempFileRootDirectory(int subId, String rootDirectoryPath); - int setTempFileRootDirectory(String appName, int subId, String rootDirectoryPath); - /** - * should move the params into a DownloadRequest parcelable - */ int download(in DownloadRequest downloadRequest, IDownloadCallback listener); - List<DownloadRequest> listPendingDownloads(String appName, int subscriptionId); + List<DownloadRequest> listPendingDownloads(int subscriptionId); int cancelDownload(in DownloadRequest downloadRequest); @@ -66,9 +50,5 @@ interface IMbmsDownloadService */ void resetDownloadKnowledge(in DownloadRequest downloadRequest); - /** - * End of life for this MbmsDownloadManager. - * Any pending downloads remain in affect and may start up independently in the future. - */ - void dispose(String appName, int subId); + void dispose(int subId); } diff --git a/telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl b/telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl index 8ff7fa7c54f3..1370b83857ec 100755 --- a/telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl +++ b/telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl @@ -27,28 +27,18 @@ import android.telephony.mbms.StreamingServiceInfo; */ interface IMbmsStreamingService { - int initialize(IMbmsStreamingManagerCallback listener, String appName, int subId); + int initialize(IMbmsStreamingManagerCallback listener, int subId); - int getStreamingServices(String appName, int subId, in List<String> serviceClasses); + int getStreamingServices(int subId, in List<String> serviceClasses); - int startStreaming(String appName, int subId, String serviceId, + int startStreaming(int subId, String serviceId, IStreamingServiceCallback listener); - /** - * Per-stream api. Note each specifies what stream they apply to. - */ + Uri getPlaybackUri(int subId, String serviceId); - Uri getPlaybackUri(String appName, int subId, String serviceId); + void stopStreaming(int subId, String serviceId); - void stopStreaming(String appName, int subId, String serviceId); + void disposeStream(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 - * an callbacks registered for this uid/appName/subId and the disposed methods on any - * listeners registered with startStreaming. - */ - void dispose(String appName, int subId); + void dispose(int subId); } diff --git a/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java b/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java index 9577dd2e3d78..58bda6480999 100644 --- a/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java +++ b/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java @@ -21,6 +21,7 @@ import android.telephony.mbms.DownloadRequest; import android.telephony.mbms.DownloadStatus; import android.telephony.mbms.IDownloadCallback; import android.telephony.mbms.IMbmsDownloadManagerCallback; +import android.telephony.mbms.MbmsException; import java.util.List; @@ -31,23 +32,66 @@ import java.util.List; * TODO: future systemapi */ public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub { + /** + * Initialize the download 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 subscriptionId The subscription ID to use. + */ @Override - public void initialize(String appName, int subscriptionId, + public void initialize(int subscriptionId, IMbmsDownloadManagerCallback listener) throws RemoteException { } + /** + * 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 IMbmsDownloadManagerCallback#fileServicesUpdated(List)} + * + * Note that subsequent calls with the same uid and subId will replace + * the service class list. + * + * May throw an {@link IllegalArgumentException} or an {@link IllegalStateException} + * + * @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_YET_READY}, + * {@link MbmsException#ERROR_CONCURRENT_SERVICE_LIMIT_REACHED} + */ @Override - public int getFileServices(String appName, int subscriptionId, List<String> serviceClasses) + public int getFileServices(int subscriptionId, List<String> serviceClasses) throws RemoteException { return 0; } + /** + * Sets the temp file root directory for this app/subscriptionId combination. The middleware + * should persist {@code rootDirectoryPath} and send it back when sending intents to the + * app's {@link android.telephony.mbms.MbmsDownloadReceiver}. + * @param subscriptionId The subscription id the download is operating under. + * @param rootDirectoryPath The path to the app's temp file root directory. + * @return {@link MbmsException#ERROR_MIDDLEWARE_NOT_YET_READY}, + * {@link MbmsException#ERROR_CANNOT_CHANGE_TEMP_FILE_ROOT}, + * or {@link MbmsException#ERROR_CONCURRENT_SERVICE_LIMIT_REACHED} + */ @Override - public int setTempFileRootDirectory(String appName, int subscriptionId, + public int setTempFileRootDirectory(int subscriptionId, String rootDirectoryPath) throws RemoteException { return 0; } + /** + * Issues a request to download a set of files. + * @param downloadRequest An object describing the set of files to be downloaded. + * @param listener A listener through which the middleware can provide progress updates to + * the app while both are still running. + * @return TODO: enumerate possible return values + */ @Override public int download(DownloadRequest downloadRequest, IDownloadCallback listener) throws RemoteException { @@ -55,11 +99,23 @@ public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub { } @Override - public List<DownloadRequest> listPendingDownloads(String appName, int subscriptionId) + public List<DownloadRequest> listPendingDownloads(int subscriptionId) throws RemoteException { return null; } + /** + * Issues a request to cancel the specified download request. + * + * If the middleware is unable to cancel the request for whatever reason, it should return + * synchronously with an error. If this method returns {@link MbmsException#SUCCESS}, the app + * will no longer be expecting any more file-completed intents from the middleware for this + * {@link DownloadRequest}. + * @param downloadRequest The request to cancel + * @return {@link MbmsException#SUCCESS}, + * {@link MbmsException#ERROR_UNKNOWN_DOWNLOAD_REQUEST}, + * {@link MbmsException#ERROR_MIDDLEWARE_NOT_YET_READY} + */ @Override public int cancelDownload(DownloadRequest downloadRequest) throws RemoteException { return 0; @@ -76,7 +132,21 @@ public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub { throws RemoteException { } + /** + * Signals that the app wishes to dispose of the session identified by the + * {@code subscriptionId} argument and the caller's uid. No notification back to the + * app is required for this operation, and the corresponding callback provided via + * {@link #initialize(int, IMbmsDownloadManagerCallback)} should no longer be used + * after this method has been called by the app. + * + * Any download requests issued by the app should remain in effect until the app calls + * {@link #cancelDownload(DownloadRequest)} on another session. + * + * May throw an {@link IllegalStateException} + * + * @param subscriptionId The subscription id to use. + */ @Override - public void dispose(String appName, int subscriptionId) throws RemoteException { + public void dispose(int subscriptionId) throws RemoteException { } } diff --git a/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java b/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java index 2c1f085b67d3..b6cf628d4036 100644 --- a/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java +++ b/telephony/java/android/telephony/mbms/vendor/MbmsStreamingServiceBase.java @@ -36,13 +36,12 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub { * 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} or {@link MbmsException#ERROR_ALREADY_INITIALIZED} */ @Override - public int initialize(IMbmsStreamingManagerCallback listener, String appName, - int subscriptionId) throws RemoteException { + public int initialize(IMbmsStreamingManagerCallback listener, int subscriptionId) + throws RemoteException { return 0; } @@ -51,22 +50,21 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub { * 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 + * Note that subsequent calls with the same uid 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 * 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_MIDDLEWARE_NOT_YET_READY}, * {@link MbmsException#ERROR_CONCURRENT_SERVICE_LIMIT_REACHED} */ @Override - public int getStreamingServices(String appName, int subscriptionId, + public int getStreamingServices(int subscriptionId, List<String> serviceClasses) throws RemoteException { return 0; } @@ -74,11 +72,10 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub { /** * 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)}. + * {@link IStreamingServiceCallback#streamStateUpdated(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. @@ -86,8 +83,8 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub { * or {@link MbmsException#ERROR_UNABLE_TO_START_SERVICE}. */ @Override - public int startStreaming(String appName, int subscriptionId, - String serviceId, IStreamingServiceCallback listener) throws RemoteException { + public int startStreaming(int subscriptionId, String serviceId, + IStreamingServiceCallback listener) throws RemoteException { return 0; } @@ -97,13 +94,12 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub { * * 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 @Nullable Uri getPlaybackUri(String appName, int subscriptionId, String serviceId) + public @Nullable Uri getPlaybackUri(int subscriptionId, String serviceId) throws RemoteException { return null; } @@ -111,16 +107,15 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub { /** * 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)}. + * {@link IStreamingServiceCallback#streamStateUpdated(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 wishes to stop. */ @Override - public void stopStreaming(String appName, int subscriptionId, String serviceId) + public void stopStreaming(int subscriptionId, String serviceId) throws RemoteException { } @@ -128,33 +123,31 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub { * 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 + * {@link #startStreaming(int, String, IStreamingServiceCallback)} should no longer be * used after this method has called by the app. * * 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 wishes to dispose of. */ @Override - public void disposeStream(String appName, int subscriptionId, String serviceId) + public void disposeStream(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 + * Signals that the app wishes to dispose of the session identified by the + * {@code subscriptionId} argument and 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 + * {@link #initialize(IMbmsStreamingManagerCallback, int)} should no longer be used * after this method has been called by the app. * * May throw an {@link IllegalStateException} * - * @param appName The app name as negotiated with the wireless carrier. * @param subscriptionId The subscription id to use. */ @Override - public void dispose(String appName, int subscriptionId) throws RemoteException { + public void dispose(int subscriptionId) throws RemoteException { } } |