Loading telephony/java/android/telephony/MbmsDownloadManager.java +72 −35 Original line number Diff line number Diff line Loading @@ -27,11 +27,15 @@ import android.content.Intent; import android.content.ServiceConnection; import android.content.SharedPreferences; import android.net.Uri; import android.os.Handler; import android.os.IBinder; import android.os.Looper; import android.os.RemoteException; import android.telephony.mbms.DownloadStateCallback; import android.telephony.mbms.FileInfo; import android.telephony.mbms.DownloadRequest; import android.telephony.mbms.InternalDownloadManagerCallback; import android.telephony.mbms.InternalDownloadStateCallback; import android.telephony.mbms.MbmsDownloadManagerCallback; import android.telephony.mbms.MbmsDownloadReceiver; import android.telephony.mbms.MbmsException; Loading Loading @@ -62,7 +66,7 @@ public class MbmsDownloadManager { * interface. * @hide */ @SystemApi //@SystemApi @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION) public static final String MBMS_DOWNLOAD_SERVICE_ACTION = "android.telephony.action.EmbmsDownload"; Loading @@ -76,7 +80,8 @@ public class MbmsDownloadManager { * * This extra may also be used by the middleware when it is sending intents to the app. */ public static final String EXTRA_RESULT = "android.telephony.mbms.extra.RESULT"; public static final String EXTRA_MBMS_DOWNLOAD_RESULT = "android.telephony.extra.MBMS_DOWNLOAD_RESULT"; /** * {@link FileInfo} extra that Android will attach to the intent supplied via Loading @@ -85,21 +90,21 @@ public class MbmsDownloadManager { * * This extra may also be used by the middleware when it is sending intents to the app. */ public static final String EXTRA_FILE_INFO = "android.telephony.mbms.extra.FILE_INFO"; public static final String EXTRA_MBMS_FILE_INFO = "android.telephony.extra.MBMS_FILE_INFO"; /** * {@link Uri} extra that Android will attach to the intent supplied via * {@link android.telephony.mbms.DownloadRequest.Builder#setAppIntent(Intent)} * Indicates the location of the successfully * downloaded file. Will always be set to a non-null value if {@link #EXTRA_RESULT} is set to * {@link #RESULT_SUCCESSFUL}. * downloaded file. Will always be set to a non-null value if * {@link #EXTRA_MBMS_DOWNLOAD_RESULT} is set to {@link #RESULT_SUCCESSFUL}. */ public static final String EXTRA_COMPLETED_FILE_URI = "android.telephony.mbms.extra.COMPLETED_FILE_URI"; public static final String EXTRA_MBMS_COMPLETED_FILE_URI = "android.telephony.extra.MBMS_COMPLETED_FILE_URI"; /** * The default directory name for all MBMS temp files. If you call * {@link #download(DownloadRequest, DownloadStateCallback)} without first calling * {@link #download(DownloadRequest, DownloadStateCallback, Handler)} without first calling * {@link #setTempFileRootDirectory(File)}, this directory will be created for you under the * path returned by {@link Context#getFilesDir()}. */ Loading Loading @@ -173,24 +178,47 @@ public class MbmsDownloadManager { }; private AtomicReference<IMbmsDownloadService> mService = new AtomicReference<>(null); private final MbmsDownloadManagerCallback mCallback; private final InternalDownloadManagerCallback mInternalCallback; private MbmsDownloadManager(Context context, MbmsDownloadManagerCallback callback, int subId) { private MbmsDownloadManager(Context context, MbmsDownloadManagerCallback callback, int subscriptionId, Handler handler) { mContext = context; mCallback = callback; mSubscriptionId = subId; mSubscriptionId = subscriptionId; if (handler == null) { handler = new Handler(Looper.myLooper()); } mInternalCallback = new InternalDownloadManagerCallback(callback, handler); } /** * Create a new MbmsDownloadManager using the system default data subscription ID and default * {@link Handler} * See {@link #create(Context, MbmsDownloadManagerCallback, int, Handler)} */ public static MbmsDownloadManager create(Context context, MbmsDownloadManagerCallback callback) throws MbmsException { return create(context, callback, SubscriptionManager.getDefaultSubscriptionId(), null); } /** * Create a new MbmsDownloadManager using the system default data subscription ID. * See {@link #create(Context, MbmsDownloadManagerCallback, int)} * * @hide * See {@link #create(Context, MbmsDownloadManagerCallback, int, Handler)} */ public static MbmsDownloadManager create(Context context, MbmsDownloadManagerCallback listener) MbmsDownloadManagerCallback callback, Handler handler) throws MbmsException { return create(context, listener, SubscriptionManager.getDefaultSubscriptionId()); return create(context, callback, SubscriptionManager.getDefaultSubscriptionId(), handler); } /** * Create a new MbmsDownloadManager using the default {@link Handler} * See {@link #create(Context, MbmsDownloadManagerCallback, int, Handler)} */ public static MbmsDownloadManager create(Context context, MbmsDownloadManagerCallback callback, int subscriptionId) throws MbmsException { return create(context, callback, subscriptionId, null); } /** Loading @@ -198,7 +226,7 @@ public class MbmsDownloadManager { * * Note that this call will bind a remote service and that may take a bit. The instance of * {@link MbmsDownloadManager} that is returned will not be ready for use until * {@link MbmsDownloadManagerCallback#middlewareReady()} is called on the provided callback. * {@link MbmsDownloadManagerCallback#onMiddlewareReady()} is called on the provided callback. * If you attempt to use the manager before it is ready, a {@link MbmsException} will be thrown. * * This also may throw an {@link IllegalArgumentException} or an {@link IllegalStateException}. Loading @@ -208,7 +236,7 @@ public class MbmsDownloadManager { * (in other words, one that has not had {@link #dispose()} called on it), this method will * throw an {@link MbmsException}. If you call this method in a different process * running under the same UID, an error will be indicated via * {@link MbmsDownloadManagerCallback#error(int, String)}. * {@link MbmsDownloadManagerCallback#onError(int, String)}. * * Note that initialization may fail asynchronously. If you wish to try again after you * receive such an asynchronous error, you must call dispose() on the instance of Loading @@ -217,15 +245,15 @@ 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 subscriptionId The data subscription ID to use * @hide */ public static MbmsDownloadManager create(Context context, MbmsDownloadManagerCallback listener, int subscriptionId) MbmsDownloadManagerCallback listener, int subscriptionId, Handler handler) throws MbmsException { if (!sIsInitialized.compareAndSet(false, true)) { throw new MbmsException(MbmsException.InitializationErrors.ERROR_DUPLICATE_INITIALIZE); } MbmsDownloadManager mdm = new MbmsDownloadManager(context, listener, subscriptionId); MbmsDownloadManager mdm = new MbmsDownloadManager(context, listener, subscriptionId, handler); try { mdm.bindAndInitialize(); } catch (MbmsException e) { Loading @@ -244,7 +272,7 @@ public class MbmsDownloadManager { IMbmsDownloadService.Stub.asInterface(service); int result; try { result = downloadService.initialize(mSubscriptionId, mCallback); result = downloadService.initialize(mSubscriptionId, mInternalCallback); } catch (RemoteException e) { Log.e(LOG_TAG, "Service died before initialization"); sIsInitialized.set(false); Loading Loading @@ -285,7 +313,7 @@ public class MbmsDownloadManager { * An inspection API to retrieve the list of available * {@link android.telephony.mbms.FileServiceInfo}s currently being advertised. * The results are returned asynchronously via a call to * {@link MbmsDownloadManagerCallback#fileServicesUpdated(List)} * {@link MbmsDownloadManagerCallback#onFileServicesUpdated(List)} * * The serviceClasses argument lets the app filter on types of programming and is opaque data * negotiated beforehand between the app and the carrier. Loading @@ -294,12 +322,12 @@ public class MbmsDownloadManager { * {@link MbmsException#ERROR_MIDDLEWARE_NOT_BOUND} * {@link MbmsException#ERROR_MIDDLEWARE_LOST} * * Asynchronous error codes via the {@link MbmsDownloadManagerCallback#error(int, String)} * Asynchronous error codes via the {@link MbmsDownloadManagerCallback#onError(int, String)} * callback can include any of the errors except: * {@link MbmsException.StreamingErrors#ERROR_UNABLE_TO_START_SERVICE} * * @param classList A list of service classes which the app wishes to receive * {@link MbmsDownloadManagerCallback#fileServicesUpdated(List)} callbacks * {@link MbmsDownloadManagerCallback#onFileServicesUpdated(List)} callbacks * about. Subsequent calls to this method will replace this list of service * classes (i.e. the middleware will no longer send updates for services * matching classes only in the old list). Loading Loading @@ -329,7 +357,7 @@ public class MbmsDownloadManager { * local instance of {@link android.content.SharedPreferences} and by the middleware. * * If this method is not called at least once before calling * {@link #download(DownloadRequest, DownloadStateCallback)}, the framework * {@link #download(DownloadRequest, DownloadStateCallback, Handler)}, the framework * will default to a directory formed by the concatenation of the app's files directory and * {@link MbmsDownloadManager#DEFAULT_TOP_LEVEL_TEMP_DIRECTORY}. * Loading Loading @@ -380,9 +408,9 @@ public class MbmsDownloadManager { /** * Retrieves the currently configured temp file root directory. Returns the file that was * configured via {@link #setTempFileRootDirectory(File)} or the default directory * {@link #download(DownloadRequest, DownloadStateCallback)} was called without ever setting * the temp file root. If neither method has been called since the last time the app's shared * preferences were reset, returns null. * {@link #download(DownloadRequest, DownloadStateCallback, Handler)} was called without ever * setting the temp file root. If neither method has been called since the last time the app's * shared preferences were reset, returns {@code null}. * * @return A {@link File} pointing to the configured temp file directory, or null if not yet * configured. Loading Loading @@ -410,11 +438,15 @@ public class MbmsDownloadManager { * Asynchronous errors through the listener include any of the errors * * @param request The request that specifies what should be downloaded * @param progressListener Optional listener that will be provided progress updates * @param stateCallback Optional listener that will be provided progress updates * if the app is running. If {@code null}, no callbacks will be * provided. * @param handler A handler that calls to {@code stateCallback} should be called on. If * null, defaults to the handler provided via * {@link #create(Context, MbmsDownloadManagerCallback, int, Handler)} */ public void download(DownloadRequest request, @Nullable DownloadStateCallback progressListener) public void download(DownloadRequest request, @Nullable DownloadStateCallback stateCallback, Handler handler) throws MbmsException { IMbmsDownloadService downloadService = mService.get(); if (downloadService == null) { Loading @@ -430,11 +462,16 @@ public class MbmsDownloadManager { tempRootDirectory.mkdirs(); setTempFileRootDirectory(tempRootDirectory); } InternalDownloadStateCallback internalCallback = null; if (stateCallback != null) { internalCallback = new InternalDownloadStateCallback(stateCallback, handler == null ? mInternalCallback.getHandler() : handler); } checkValidDownloadDestination(request); writeDownloadRequestToken(request); try { downloadService.download(request, progressListener); downloadService.download(request, internalCallback); } catch (RemoteException e) { mService.set(null); throw new MbmsException(MbmsException.ERROR_MIDDLEWARE_LOST); Loading @@ -444,7 +481,7 @@ public class MbmsDownloadManager { /** * Returns a list of pending {@link DownloadRequest}s that originated from this application. * A pending request is one that was issued via * {@link #download(DownloadRequest, DownloadStateCallback)} but not cancelled through * {@link #download(DownloadRequest, DownloadStateCallback, Handler)} but not cancelled through * {@link #cancelDownload(DownloadRequest)}. * @return A list, possibly empty, of {@link DownloadRequest}s */ Loading Loading @@ -636,7 +673,7 @@ public class MbmsDownloadManager { private void sendErrorToApp(int errorCode, String message) { try { mCallback.error(errorCode, message); mInternalCallback.error(errorCode, message); } catch (RemoteException e) { // Ignore, should not happen locally. } Loading telephony/java/android/telephony/mbms/DownloadRequest.java +19 −14 Original line number Diff line number Diff line Loading @@ -43,21 +43,15 @@ import java.util.Objects; * to the app when the middleware updates the status of the download. * @hide */ public class DownloadRequest implements Parcelable { public final class DownloadRequest implements Parcelable { // Version code used to keep token calculation consistent. private static final int CURRENT_VERSION = 1; private static final String LOG_TAG = "MbmsDownloadRequest"; /** * Maximum permissible length for the app's download-completion intent, when serialized via * {@link Intent#toUri(int)}. */ /** @hide */ public static final int MAX_APP_INTENT_SIZE = 50000; /** * Maximum permissible length for the app's destination path, when serialized via * {@link Uri#toString()}. */ /** @hide */ public static final int MAX_DESTINATION_URI_SIZE = 50000; /** @hide */ Loading Loading @@ -104,7 +98,6 @@ public class DownloadRequest implements Parcelable { /** * Sets the source URI for the download request to be built. * @param source * @return */ public Builder setSource(Uri source) { this.source = source; Loading @@ -116,7 +109,6 @@ public class DownloadRequest implements Parcelable { * not set this directly. * @param dest A URI obtained from {@link Uri#fromFile(File)}, denoting the requested * final destination of the download. * @return */ public Builder setDest(Uri dest) { if (dest.toString().length() > MAX_DESTINATION_URI_SIZE) { Loading @@ -130,7 +122,6 @@ public class DownloadRequest implements Parcelable { /** * Set the subscription ID on which the file(s) should be downloaded. * @param subscriptionId * @return */ public Builder setSubscriptionId(int subscriptionId) { this.subscriptionId = subscriptionId; Loading @@ -144,7 +135,6 @@ public class DownloadRequest implements Parcelable { * * The middleware should not use this method. * @param intent * @return */ public Builder setAppIntent(Intent intent) { this.appIntent = intent.toUri(0); Loading @@ -161,7 +151,6 @@ public class DownloadRequest implements Parcelable { * manager code, but is irrelevant to the middleware. * @param data A byte array, the contents of which should have been originally obtained * from {@link DownloadRequest#getOpaqueData()}. * @return * @hide */ //@SystemApi Loading Loading @@ -323,6 +312,22 @@ public class DownloadRequest implements Parcelable { } }; /** * Maximum permissible length for the app's destination path, when serialized via * {@link Uri#toString()}. */ public static int getMaxAppIntentSize() { return MAX_APP_INTENT_SIZE; } /** * Maximum permissible length for the app's download-completion intent, when serialized via * {@link Intent#toUri(int)}. */ public static int getMaxDestinationUriSize() { return MAX_DESTINATION_URI_SIZE; } /** * @hide */ Loading telephony/java/android/telephony/mbms/DownloadStateCallback.java +7 −8 Original line number Diff line number Diff line Loading @@ -16,19 +16,20 @@ package android.telephony.mbms; import android.os.RemoteException; import android.os.Handler; import android.telephony.MbmsDownloadManager; /** * A optional listener class used by download clients to track progress. Apps should extend this * class and pass an instance into * {@link android.telephony.MbmsDownloadManager#download(DownloadRequest, DownloadStateCallback)} * {@link android.telephony.MbmsDownloadManager#download( * DownloadRequest, DownloadStateCallback, Handler)} * * This is optionally specified when requesting a download and will only be called while the app * is running. * @hide */ public class DownloadStateCallback extends IDownloadStateCallback.Stub { public class DownloadStateCallback { /** * Called when the middleware wants to report progress for a file in a {@link DownloadRequest}. Loading @@ -44,10 +45,9 @@ public class DownloadStateCallback extends IDownloadStateCallback.Stub { * @param currentDecodedSize is the number of bytes that have been decoded. * @param fullDecodedSize is the total number of bytes that make up the final decoded content. */ @Override public void progress(DownloadRequest request, FileInfo fileInfo, public void onProgressUpdated(DownloadRequest request, FileInfo fileInfo, int currentDownloadSize, int fullDownloadSize, int currentDecodedSize, int fullDecodedSize) throws RemoteException { int currentDecodedSize, int fullDecodedSize) { } /** Loading @@ -59,8 +59,7 @@ public class DownloadStateCallback extends IDownloadStateCallback.Stub { * may not have been able to get a list of them in advance. * @param state The current state of the download. */ @Override public void state(DownloadRequest request, FileInfo fileInfo, public void onStateChanged(DownloadRequest request, FileInfo fileInfo, @MbmsDownloadManager.DownloadStatus int state) { } } telephony/java/android/telephony/mbms/FileInfo.java +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import android.os.Parcelable; * Describes a single file that is available over MBMS. * @hide */ public class FileInfo implements Parcelable { public final class FileInfo implements Parcelable { private final Uri uri; Loading telephony/java/android/telephony/mbms/FileServiceInfo.java +2 −2 Original line number Diff line number Diff line Loading @@ -31,11 +31,11 @@ import java.util.Map; * cell-broadcast. * @hide */ public class FileServiceInfo extends ServiceInfo implements Parcelable { public final class FileServiceInfo extends ServiceInfo implements Parcelable { private final List<FileInfo> files; /** @hide */ @SystemApi //@SystemApi public FileServiceInfo(Map<Locale, String> newNames, String newClassName, List<Locale> newLocales, String newServiceId, Date start, Date end, List<FileInfo> newFiles) { Loading Loading
telephony/java/android/telephony/MbmsDownloadManager.java +72 −35 Original line number Diff line number Diff line Loading @@ -27,11 +27,15 @@ import android.content.Intent; import android.content.ServiceConnection; import android.content.SharedPreferences; import android.net.Uri; import android.os.Handler; import android.os.IBinder; import android.os.Looper; import android.os.RemoteException; import android.telephony.mbms.DownloadStateCallback; import android.telephony.mbms.FileInfo; import android.telephony.mbms.DownloadRequest; import android.telephony.mbms.InternalDownloadManagerCallback; import android.telephony.mbms.InternalDownloadStateCallback; import android.telephony.mbms.MbmsDownloadManagerCallback; import android.telephony.mbms.MbmsDownloadReceiver; import android.telephony.mbms.MbmsException; Loading Loading @@ -62,7 +66,7 @@ public class MbmsDownloadManager { * interface. * @hide */ @SystemApi //@SystemApi @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION) public static final String MBMS_DOWNLOAD_SERVICE_ACTION = "android.telephony.action.EmbmsDownload"; Loading @@ -76,7 +80,8 @@ public class MbmsDownloadManager { * * This extra may also be used by the middleware when it is sending intents to the app. */ public static final String EXTRA_RESULT = "android.telephony.mbms.extra.RESULT"; public static final String EXTRA_MBMS_DOWNLOAD_RESULT = "android.telephony.extra.MBMS_DOWNLOAD_RESULT"; /** * {@link FileInfo} extra that Android will attach to the intent supplied via Loading @@ -85,21 +90,21 @@ public class MbmsDownloadManager { * * This extra may also be used by the middleware when it is sending intents to the app. */ public static final String EXTRA_FILE_INFO = "android.telephony.mbms.extra.FILE_INFO"; public static final String EXTRA_MBMS_FILE_INFO = "android.telephony.extra.MBMS_FILE_INFO"; /** * {@link Uri} extra that Android will attach to the intent supplied via * {@link android.telephony.mbms.DownloadRequest.Builder#setAppIntent(Intent)} * Indicates the location of the successfully * downloaded file. Will always be set to a non-null value if {@link #EXTRA_RESULT} is set to * {@link #RESULT_SUCCESSFUL}. * downloaded file. Will always be set to a non-null value if * {@link #EXTRA_MBMS_DOWNLOAD_RESULT} is set to {@link #RESULT_SUCCESSFUL}. */ public static final String EXTRA_COMPLETED_FILE_URI = "android.telephony.mbms.extra.COMPLETED_FILE_URI"; public static final String EXTRA_MBMS_COMPLETED_FILE_URI = "android.telephony.extra.MBMS_COMPLETED_FILE_URI"; /** * The default directory name for all MBMS temp files. If you call * {@link #download(DownloadRequest, DownloadStateCallback)} without first calling * {@link #download(DownloadRequest, DownloadStateCallback, Handler)} without first calling * {@link #setTempFileRootDirectory(File)}, this directory will be created for you under the * path returned by {@link Context#getFilesDir()}. */ Loading Loading @@ -173,24 +178,47 @@ public class MbmsDownloadManager { }; private AtomicReference<IMbmsDownloadService> mService = new AtomicReference<>(null); private final MbmsDownloadManagerCallback mCallback; private final InternalDownloadManagerCallback mInternalCallback; private MbmsDownloadManager(Context context, MbmsDownloadManagerCallback callback, int subId) { private MbmsDownloadManager(Context context, MbmsDownloadManagerCallback callback, int subscriptionId, Handler handler) { mContext = context; mCallback = callback; mSubscriptionId = subId; mSubscriptionId = subscriptionId; if (handler == null) { handler = new Handler(Looper.myLooper()); } mInternalCallback = new InternalDownloadManagerCallback(callback, handler); } /** * Create a new MbmsDownloadManager using the system default data subscription ID and default * {@link Handler} * See {@link #create(Context, MbmsDownloadManagerCallback, int, Handler)} */ public static MbmsDownloadManager create(Context context, MbmsDownloadManagerCallback callback) throws MbmsException { return create(context, callback, SubscriptionManager.getDefaultSubscriptionId(), null); } /** * Create a new MbmsDownloadManager using the system default data subscription ID. * See {@link #create(Context, MbmsDownloadManagerCallback, int)} * * @hide * See {@link #create(Context, MbmsDownloadManagerCallback, int, Handler)} */ public static MbmsDownloadManager create(Context context, MbmsDownloadManagerCallback listener) MbmsDownloadManagerCallback callback, Handler handler) throws MbmsException { return create(context, listener, SubscriptionManager.getDefaultSubscriptionId()); return create(context, callback, SubscriptionManager.getDefaultSubscriptionId(), handler); } /** * Create a new MbmsDownloadManager using the default {@link Handler} * See {@link #create(Context, MbmsDownloadManagerCallback, int, Handler)} */ public static MbmsDownloadManager create(Context context, MbmsDownloadManagerCallback callback, int subscriptionId) throws MbmsException { return create(context, callback, subscriptionId, null); } /** Loading @@ -198,7 +226,7 @@ public class MbmsDownloadManager { * * Note that this call will bind a remote service and that may take a bit. The instance of * {@link MbmsDownloadManager} that is returned will not be ready for use until * {@link MbmsDownloadManagerCallback#middlewareReady()} is called on the provided callback. * {@link MbmsDownloadManagerCallback#onMiddlewareReady()} is called on the provided callback. * If you attempt to use the manager before it is ready, a {@link MbmsException} will be thrown. * * This also may throw an {@link IllegalArgumentException} or an {@link IllegalStateException}. Loading @@ -208,7 +236,7 @@ public class MbmsDownloadManager { * (in other words, one that has not had {@link #dispose()} called on it), this method will * throw an {@link MbmsException}. If you call this method in a different process * running under the same UID, an error will be indicated via * {@link MbmsDownloadManagerCallback#error(int, String)}. * {@link MbmsDownloadManagerCallback#onError(int, String)}. * * Note that initialization may fail asynchronously. If you wish to try again after you * receive such an asynchronous error, you must call dispose() on the instance of Loading @@ -217,15 +245,15 @@ 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 subscriptionId The data subscription ID to use * @hide */ public static MbmsDownloadManager create(Context context, MbmsDownloadManagerCallback listener, int subscriptionId) MbmsDownloadManagerCallback listener, int subscriptionId, Handler handler) throws MbmsException { if (!sIsInitialized.compareAndSet(false, true)) { throw new MbmsException(MbmsException.InitializationErrors.ERROR_DUPLICATE_INITIALIZE); } MbmsDownloadManager mdm = new MbmsDownloadManager(context, listener, subscriptionId); MbmsDownloadManager mdm = new MbmsDownloadManager(context, listener, subscriptionId, handler); try { mdm.bindAndInitialize(); } catch (MbmsException e) { Loading @@ -244,7 +272,7 @@ public class MbmsDownloadManager { IMbmsDownloadService.Stub.asInterface(service); int result; try { result = downloadService.initialize(mSubscriptionId, mCallback); result = downloadService.initialize(mSubscriptionId, mInternalCallback); } catch (RemoteException e) { Log.e(LOG_TAG, "Service died before initialization"); sIsInitialized.set(false); Loading Loading @@ -285,7 +313,7 @@ public class MbmsDownloadManager { * An inspection API to retrieve the list of available * {@link android.telephony.mbms.FileServiceInfo}s currently being advertised. * The results are returned asynchronously via a call to * {@link MbmsDownloadManagerCallback#fileServicesUpdated(List)} * {@link MbmsDownloadManagerCallback#onFileServicesUpdated(List)} * * The serviceClasses argument lets the app filter on types of programming and is opaque data * negotiated beforehand between the app and the carrier. Loading @@ -294,12 +322,12 @@ public class MbmsDownloadManager { * {@link MbmsException#ERROR_MIDDLEWARE_NOT_BOUND} * {@link MbmsException#ERROR_MIDDLEWARE_LOST} * * Asynchronous error codes via the {@link MbmsDownloadManagerCallback#error(int, String)} * Asynchronous error codes via the {@link MbmsDownloadManagerCallback#onError(int, String)} * callback can include any of the errors except: * {@link MbmsException.StreamingErrors#ERROR_UNABLE_TO_START_SERVICE} * * @param classList A list of service classes which the app wishes to receive * {@link MbmsDownloadManagerCallback#fileServicesUpdated(List)} callbacks * {@link MbmsDownloadManagerCallback#onFileServicesUpdated(List)} callbacks * about. Subsequent calls to this method will replace this list of service * classes (i.e. the middleware will no longer send updates for services * matching classes only in the old list). Loading Loading @@ -329,7 +357,7 @@ public class MbmsDownloadManager { * local instance of {@link android.content.SharedPreferences} and by the middleware. * * If this method is not called at least once before calling * {@link #download(DownloadRequest, DownloadStateCallback)}, the framework * {@link #download(DownloadRequest, DownloadStateCallback, Handler)}, the framework * will default to a directory formed by the concatenation of the app's files directory and * {@link MbmsDownloadManager#DEFAULT_TOP_LEVEL_TEMP_DIRECTORY}. * Loading Loading @@ -380,9 +408,9 @@ public class MbmsDownloadManager { /** * Retrieves the currently configured temp file root directory. Returns the file that was * configured via {@link #setTempFileRootDirectory(File)} or the default directory * {@link #download(DownloadRequest, DownloadStateCallback)} was called without ever setting * the temp file root. If neither method has been called since the last time the app's shared * preferences were reset, returns null. * {@link #download(DownloadRequest, DownloadStateCallback, Handler)} was called without ever * setting the temp file root. If neither method has been called since the last time the app's * shared preferences were reset, returns {@code null}. * * @return A {@link File} pointing to the configured temp file directory, or null if not yet * configured. Loading Loading @@ -410,11 +438,15 @@ public class MbmsDownloadManager { * Asynchronous errors through the listener include any of the errors * * @param request The request that specifies what should be downloaded * @param progressListener Optional listener that will be provided progress updates * @param stateCallback Optional listener that will be provided progress updates * if the app is running. If {@code null}, no callbacks will be * provided. * @param handler A handler that calls to {@code stateCallback} should be called on. If * null, defaults to the handler provided via * {@link #create(Context, MbmsDownloadManagerCallback, int, Handler)} */ public void download(DownloadRequest request, @Nullable DownloadStateCallback progressListener) public void download(DownloadRequest request, @Nullable DownloadStateCallback stateCallback, Handler handler) throws MbmsException { IMbmsDownloadService downloadService = mService.get(); if (downloadService == null) { Loading @@ -430,11 +462,16 @@ public class MbmsDownloadManager { tempRootDirectory.mkdirs(); setTempFileRootDirectory(tempRootDirectory); } InternalDownloadStateCallback internalCallback = null; if (stateCallback != null) { internalCallback = new InternalDownloadStateCallback(stateCallback, handler == null ? mInternalCallback.getHandler() : handler); } checkValidDownloadDestination(request); writeDownloadRequestToken(request); try { downloadService.download(request, progressListener); downloadService.download(request, internalCallback); } catch (RemoteException e) { mService.set(null); throw new MbmsException(MbmsException.ERROR_MIDDLEWARE_LOST); Loading @@ -444,7 +481,7 @@ public class MbmsDownloadManager { /** * Returns a list of pending {@link DownloadRequest}s that originated from this application. * A pending request is one that was issued via * {@link #download(DownloadRequest, DownloadStateCallback)} but not cancelled through * {@link #download(DownloadRequest, DownloadStateCallback, Handler)} but not cancelled through * {@link #cancelDownload(DownloadRequest)}. * @return A list, possibly empty, of {@link DownloadRequest}s */ Loading Loading @@ -636,7 +673,7 @@ public class MbmsDownloadManager { private void sendErrorToApp(int errorCode, String message) { try { mCallback.error(errorCode, message); mInternalCallback.error(errorCode, message); } catch (RemoteException e) { // Ignore, should not happen locally. } Loading
telephony/java/android/telephony/mbms/DownloadRequest.java +19 −14 Original line number Diff line number Diff line Loading @@ -43,21 +43,15 @@ import java.util.Objects; * to the app when the middleware updates the status of the download. * @hide */ public class DownloadRequest implements Parcelable { public final class DownloadRequest implements Parcelable { // Version code used to keep token calculation consistent. private static final int CURRENT_VERSION = 1; private static final String LOG_TAG = "MbmsDownloadRequest"; /** * Maximum permissible length for the app's download-completion intent, when serialized via * {@link Intent#toUri(int)}. */ /** @hide */ public static final int MAX_APP_INTENT_SIZE = 50000; /** * Maximum permissible length for the app's destination path, when serialized via * {@link Uri#toString()}. */ /** @hide */ public static final int MAX_DESTINATION_URI_SIZE = 50000; /** @hide */ Loading Loading @@ -104,7 +98,6 @@ public class DownloadRequest implements Parcelable { /** * Sets the source URI for the download request to be built. * @param source * @return */ public Builder setSource(Uri source) { this.source = source; Loading @@ -116,7 +109,6 @@ public class DownloadRequest implements Parcelable { * not set this directly. * @param dest A URI obtained from {@link Uri#fromFile(File)}, denoting the requested * final destination of the download. * @return */ public Builder setDest(Uri dest) { if (dest.toString().length() > MAX_DESTINATION_URI_SIZE) { Loading @@ -130,7 +122,6 @@ public class DownloadRequest implements Parcelable { /** * Set the subscription ID on which the file(s) should be downloaded. * @param subscriptionId * @return */ public Builder setSubscriptionId(int subscriptionId) { this.subscriptionId = subscriptionId; Loading @@ -144,7 +135,6 @@ public class DownloadRequest implements Parcelable { * * The middleware should not use this method. * @param intent * @return */ public Builder setAppIntent(Intent intent) { this.appIntent = intent.toUri(0); Loading @@ -161,7 +151,6 @@ public class DownloadRequest implements Parcelable { * manager code, but is irrelevant to the middleware. * @param data A byte array, the contents of which should have been originally obtained * from {@link DownloadRequest#getOpaqueData()}. * @return * @hide */ //@SystemApi Loading Loading @@ -323,6 +312,22 @@ public class DownloadRequest implements Parcelable { } }; /** * Maximum permissible length for the app's destination path, when serialized via * {@link Uri#toString()}. */ public static int getMaxAppIntentSize() { return MAX_APP_INTENT_SIZE; } /** * Maximum permissible length for the app's download-completion intent, when serialized via * {@link Intent#toUri(int)}. */ public static int getMaxDestinationUriSize() { return MAX_DESTINATION_URI_SIZE; } /** * @hide */ Loading
telephony/java/android/telephony/mbms/DownloadStateCallback.java +7 −8 Original line number Diff line number Diff line Loading @@ -16,19 +16,20 @@ package android.telephony.mbms; import android.os.RemoteException; import android.os.Handler; import android.telephony.MbmsDownloadManager; /** * A optional listener class used by download clients to track progress. Apps should extend this * class and pass an instance into * {@link android.telephony.MbmsDownloadManager#download(DownloadRequest, DownloadStateCallback)} * {@link android.telephony.MbmsDownloadManager#download( * DownloadRequest, DownloadStateCallback, Handler)} * * This is optionally specified when requesting a download and will only be called while the app * is running. * @hide */ public class DownloadStateCallback extends IDownloadStateCallback.Stub { public class DownloadStateCallback { /** * Called when the middleware wants to report progress for a file in a {@link DownloadRequest}. Loading @@ -44,10 +45,9 @@ public class DownloadStateCallback extends IDownloadStateCallback.Stub { * @param currentDecodedSize is the number of bytes that have been decoded. * @param fullDecodedSize is the total number of bytes that make up the final decoded content. */ @Override public void progress(DownloadRequest request, FileInfo fileInfo, public void onProgressUpdated(DownloadRequest request, FileInfo fileInfo, int currentDownloadSize, int fullDownloadSize, int currentDecodedSize, int fullDecodedSize) throws RemoteException { int currentDecodedSize, int fullDecodedSize) { } /** Loading @@ -59,8 +59,7 @@ public class DownloadStateCallback extends IDownloadStateCallback.Stub { * may not have been able to get a list of them in advance. * @param state The current state of the download. */ @Override public void state(DownloadRequest request, FileInfo fileInfo, public void onStateChanged(DownloadRequest request, FileInfo fileInfo, @MbmsDownloadManager.DownloadStatus int state) { } }
telephony/java/android/telephony/mbms/FileInfo.java +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import android.os.Parcelable; * Describes a single file that is available over MBMS. * @hide */ public class FileInfo implements Parcelable { public final class FileInfo implements Parcelable { private final Uri uri; Loading
telephony/java/android/telephony/mbms/FileServiceInfo.java +2 −2 Original line number Diff line number Diff line Loading @@ -31,11 +31,11 @@ import java.util.Map; * cell-broadcast. * @hide */ public class FileServiceInfo extends ServiceInfo implements Parcelable { public final class FileServiceInfo extends ServiceInfo implements Parcelable { private final List<FileInfo> files; /** @hide */ @SystemApi //@SystemApi public FileServiceInfo(Map<Locale, String> newNames, String newClassName, List<Locale> newLocales, String newServiceId, Date start, Date end, List<FileInfo> newFiles) { Loading