Merge changes from topics "embms-0804-adjustments", "prepare-download-unhide"
* changes: Make EMBMS adjustments for 08/04 Prepare EMBMS apis for un-hiding
This commit is contained in:
@@ -488,7 +488,7 @@ LOCAL_SRC_FILES += \
|
||||
telecomm/java/com/android/internal/telecom/RemoteServiceCallback.aidl \
|
||||
telephony/java/android/telephony/mbms/IMbmsDownloadManagerCallback.aidl \
|
||||
telephony/java/android/telephony/mbms/IMbmsStreamingManagerCallback.aidl \
|
||||
telephony/java/android/telephony/mbms/IDownloadProgressListener.aidl \
|
||||
telephony/java/android/telephony/mbms/IDownloadStateCallback.aidl \
|
||||
telephony/java/android/telephony/mbms/IStreamingServiceCallback.aidl \
|
||||
telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl \
|
||||
telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl \
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SdkConstant;
|
||||
import android.annotation.SystemApi;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -28,7 +29,7 @@ import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.telephony.mbms.DownloadProgressListener;
|
||||
import android.telephony.mbms.DownloadStateCallback;
|
||||
import android.telephony.mbms.FileInfo;
|
||||
import android.telephony.mbms.DownloadRequest;
|
||||
import android.telephony.mbms.MbmsDownloadManagerCallback;
|
||||
@@ -49,41 +50,82 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
|
||||
/** @hide */
|
||||
/**
|
||||
* This class provides functionality for file download over MBMS.
|
||||
* @hide
|
||||
*/
|
||||
public class MbmsDownloadManager {
|
||||
private static final String LOG_TAG = MbmsDownloadManager.class.getSimpleName();
|
||||
|
||||
/** @hide */
|
||||
// TODO: systemapi
|
||||
/**
|
||||
* Service action which must be handled by the middleware implementing the MBMS file download
|
||||
* interface.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION)
|
||||
public static final String MBMS_DOWNLOAD_SERVICE_ACTION =
|
||||
"android.telephony.action.EmbmsDownload";
|
||||
|
||||
/**
|
||||
* Integer extra indicating the result code of the download. One of
|
||||
* {@link #RESULT_SUCCESSFUL}, {@link #RESULT_EXPIRED}, or {@link #RESULT_CANCELLED}.
|
||||
* Integer extra that Android will attach to the intent supplied via
|
||||
* {@link android.telephony.mbms.DownloadRequest.Builder#setAppIntent(Intent)}
|
||||
* Indicates the result code of the download. One of
|
||||
* {@link #RESULT_SUCCESSFUL}, {@link #RESULT_EXPIRED}, {@link #RESULT_CANCELLED}, or
|
||||
* {@link #RESULT_IO_ERROR}.
|
||||
*
|
||||
* 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";
|
||||
|
||||
/**
|
||||
* Extra containing the {@link android.telephony.mbms.FileInfo} for which the download result
|
||||
* is for. Must not be null.
|
||||
* {@link FileInfo} extra that Android will attach to the intent supplied via
|
||||
* {@link android.telephony.mbms.DownloadRequest.Builder#setAppIntent(Intent)}
|
||||
* Indicates the file for which the download result is for. Never null.
|
||||
*
|
||||
* 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";
|
||||
|
||||
/**
|
||||
* Extra containing a single {@link Uri} indicating the location of the successfully
|
||||
* downloaded file. Set on the intent provided via
|
||||
* {@link android.telephony.mbms.DownloadRequest.Builder#setAppIntent(Intent)}.
|
||||
* Will always be set to a non-null value if {@link #EXTRA_RESULT} is set to
|
||||
* {@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}.
|
||||
*/
|
||||
public static final String EXTRA_COMPLETED_FILE_URI =
|
||||
"android.telephony.mbms.extra.COMPLETED_FILE_URI";
|
||||
|
||||
/**
|
||||
* The default directory name for all MBMS temp files. If you call
|
||||
* {@link #download(DownloadRequest, DownloadStateCallback)} without first calling
|
||||
* {@link #setTempFileRootDirectory(File)}, this directory will be created for you under the
|
||||
* path returned by {@link Context#getFilesDir()}.
|
||||
*/
|
||||
public static final String DEFAULT_TOP_LEVEL_TEMP_DIRECTORY = "androidMbmsTempFileRoot";
|
||||
|
||||
/**
|
||||
* Indicates that the download was successful.
|
||||
*/
|
||||
public static final int RESULT_SUCCESSFUL = 1;
|
||||
|
||||
/**
|
||||
* Indicates that the download was cancelled via {@link #cancelDownload(DownloadRequest)}.
|
||||
*/
|
||||
public static final int RESULT_CANCELLED = 2;
|
||||
|
||||
/**
|
||||
* Indicates that the download will not be completed due to the expiration of its download
|
||||
* window on the carrier's network.
|
||||
*/
|
||||
public static final int RESULT_EXPIRED = 3;
|
||||
|
||||
/**
|
||||
* Indicates that the download will not be completed due to an I/O error incurred while
|
||||
* writing to temp files. This commonly indicates that the device is out of storage space,
|
||||
* but may indicate other conditions as well (such as an SD card being removed).
|
||||
*/
|
||||
public static final int RESULT_IO_ERROR = 4;
|
||||
// TODO - more results!
|
||||
|
||||
@@ -93,10 +135,30 @@ public class MbmsDownloadManager {
|
||||
STATUS_PENDING_REPAIR, STATUS_PENDING_DOWNLOAD_WINDOW})
|
||||
public @interface DownloadStatus {}
|
||||
|
||||
/**
|
||||
* Indicates that the middleware has no information on the file.
|
||||
*/
|
||||
public static final int STATUS_UNKNOWN = 0;
|
||||
|
||||
/**
|
||||
* Indicates that the file is actively downloading.
|
||||
*/
|
||||
public static final int STATUS_ACTIVELY_DOWNLOADING = 1;
|
||||
|
||||
/**
|
||||
* TODO: I don't know...
|
||||
*/
|
||||
public static final int STATUS_PENDING_DOWNLOAD = 2;
|
||||
|
||||
/**
|
||||
* Indicates that the file is being repaired after the download being interrupted.
|
||||
*/
|
||||
public static final int STATUS_PENDING_REPAIR = 3;
|
||||
|
||||
/**
|
||||
* Indicates that the file is waiting to download because its download window has not yet
|
||||
* started.
|
||||
*/
|
||||
public static final int STATUS_PENDING_DOWNLOAD_WINDOW = 4;
|
||||
|
||||
private static AtomicBoolean sIsInitialized = new AtomicBoolean(false);
|
||||
@@ -267,9 +329,9 @@ 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, DownloadProgressListener)}, the framework
|
||||
* {@link #download(DownloadRequest, DownloadStateCallback)}, the framework
|
||||
* will default to a directory formed by the concatenation of the app's files directory and
|
||||
* {@link android.telephony.mbms.MbmsTempFileProvider#DEFAULT_TOP_LEVEL_TEMP_DIRECTORY}.
|
||||
* {@link MbmsDownloadManager#DEFAULT_TOP_LEVEL_TEMP_DIRECTORY}.
|
||||
*
|
||||
* Before calling this method, the app must cancel all of its pending
|
||||
* {@link DownloadRequest}s via {@link #cancelDownload(DownloadRequest)}. If this is not done,
|
||||
@@ -318,7 +380,7 @@ 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, DownloadProgressListener)} was called without ever setting
|
||||
* {@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.
|
||||
*
|
||||
@@ -338,25 +400,21 @@ public class MbmsDownloadManager {
|
||||
/**
|
||||
* Requests a download of a file that is available via multicast.
|
||||
*
|
||||
* downloadListener is an optional callback object which can be used to get progress reports
|
||||
* of a currently occuring download. Note this can only run while the calling app
|
||||
* is running, so future downloads will simply result in resultIntents being sent
|
||||
* for completed or errored-out downloads. A NULL indicates no callbacks are needed.
|
||||
*
|
||||
* May throw an {@link IllegalArgumentException}
|
||||
*
|
||||
* If {@link #setTempFileRootDirectory(File)} has not called after the app has been installed,
|
||||
* this method will create a directory at the default location defined at
|
||||
* {@link MbmsTempFileProvider#DEFAULT_TOP_LEVEL_TEMP_DIRECTORY} and store that as the temp
|
||||
* {@link MbmsDownloadManager#DEFAULT_TOP_LEVEL_TEMP_DIRECTORY} and store that as the temp
|
||||
* file root directory.
|
||||
*
|
||||
* 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
|
||||
* if the app is running.
|
||||
* if the app is running. If {@code null}, no callbacks will be
|
||||
* provided.
|
||||
*/
|
||||
public void download(DownloadRequest request, DownloadProgressListener progressListener)
|
||||
public void download(DownloadRequest request, @Nullable DownloadStateCallback progressListener)
|
||||
throws MbmsException {
|
||||
IMbmsDownloadService downloadService = mService.get();
|
||||
if (downloadService == null) {
|
||||
@@ -368,7 +426,7 @@ public class MbmsDownloadManager {
|
||||
MbmsTempFileProvider.TEMP_FILE_ROOT_PREF_FILE_NAME, 0);
|
||||
if (prefs.getString(MbmsTempFileProvider.TEMP_FILE_ROOT_PREF_NAME, null) == null) {
|
||||
File tempRootDirectory = new File(mContext.getFilesDir(),
|
||||
MbmsTempFileProvider.DEFAULT_TOP_LEVEL_TEMP_DIRECTORY);
|
||||
DEFAULT_TOP_LEVEL_TEMP_DIRECTORY);
|
||||
tempRootDirectory.mkdirs();
|
||||
setTempFileRootDirectory(tempRootDirectory);
|
||||
}
|
||||
@@ -386,7 +444,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, DownloadProgressListener)} but not cancelled through
|
||||
* {@link #download(DownloadRequest, DownloadStateCallback)} but not cancelled through
|
||||
* {@link #cancelDownload(DownloadRequest)}.
|
||||
* @return A list, possibly empty, of {@link DownloadRequest}s
|
||||
*/
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.telephony.mbms;
|
||||
|
||||
import android.annotation.SystemApi;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Parcel;
|
||||
@@ -37,7 +38,9 @@ import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* A Parcelable class describing a pending Cell-Broadcast download request
|
||||
* Describes a request to download files over cell-broadcast. Instances of this class should be
|
||||
* created by the app when requesting a download, and instances of this class will be passed back
|
||||
* to the app when the middleware updates the status of the download.
|
||||
* @hide
|
||||
*/
|
||||
public class DownloadRequest implements Parcelable {
|
||||
@@ -91,8 +94,8 @@ public class DownloadRequest implements Parcelable {
|
||||
/**
|
||||
* Set the service ID for the download request. For use by the middleware only.
|
||||
* @hide
|
||||
* TODO: systemapi
|
||||
*/
|
||||
//@SystemApi
|
||||
public Builder setServiceId(String serviceId) {
|
||||
fileServiceId = serviceId;
|
||||
return this;
|
||||
@@ -159,9 +162,9 @@ public class DownloadRequest implements Parcelable {
|
||||
* @param data A byte array, the contents of which should have been originally obtained
|
||||
* from {@link DownloadRequest#getOpaqueData()}.
|
||||
* @return
|
||||
* TODO: systemapi
|
||||
* @hide
|
||||
*/
|
||||
//@SystemApi
|
||||
public Builder setOpaqueData(byte[] data) {
|
||||
try {
|
||||
ObjectInputStream stream = new ObjectInputStream(new ByteArrayInputStream(data));
|
||||
@@ -287,8 +290,8 @@ public class DownloadRequest implements Parcelable {
|
||||
* {@link Builder#setOpaqueData(byte[])}.
|
||||
* @return A byte array of opaque data to persist.
|
||||
* @hide
|
||||
* TODO: systemapi
|
||||
*/
|
||||
//@SystemApi
|
||||
public byte[] getOpaqueData() {
|
||||
try {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
|
||||
@@ -17,17 +17,21 @@
|
||||
package android.telephony.mbms;
|
||||
|
||||
import android.os.RemoteException;
|
||||
import android.telephony.MbmsDownloadManager;
|
||||
|
||||
/**
|
||||
* A optional listener class used by download clients to track progress.
|
||||
* 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)}
|
||||
*
|
||||
* This is optionally specified when requesting a download and will only be called while the app
|
||||
* is running.
|
||||
* @hide
|
||||
*/
|
||||
public class DownloadProgressListener extends IDownloadProgressListener.Stub {
|
||||
public class DownloadStateCallback extends IDownloadStateCallback.Stub {
|
||||
|
||||
/**
|
||||
* Gives process callbacks for a given DownloadRequest.
|
||||
* This is optionally specified when requesting a download and
|
||||
* only lives while the app is running - it's unlikely to be useful for
|
||||
* downloads far in the future.
|
||||
* Called when the middleware wants to report progress for a file in a {@link DownloadRequest}.
|
||||
*
|
||||
* @param request a {@link DownloadRequest}, indicating which download is being referenced.
|
||||
* @param fileInfo a {@link FileInfo} specifying the file to report progress on. Note that
|
||||
@@ -45,4 +49,18 @@ public class DownloadProgressListener extends IDownloadProgressListener.Stub {
|
||||
int currentDownloadSize, int fullDownloadSize,
|
||||
int currentDecodedSize, int fullDecodedSize) throws RemoteException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives download state callbacks for a file in a {@link DownloadRequest}.
|
||||
*
|
||||
* @param request a {@link DownloadRequest}, indicating which download is being referenced.
|
||||
* @param fileInfo a {@link FileInfo} specifying the file to report progress on. Note that
|
||||
* the request may result in many files being downloaded and the client
|
||||
* 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,
|
||||
@MbmsDownloadManager.DownloadStatus int state) {
|
||||
}
|
||||
}
|
||||
@@ -16,26 +16,19 @@
|
||||
|
||||
package android.telephony.mbms;
|
||||
|
||||
import android.annotation.SystemApi;
|
||||
import android.net.Uri;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* A Parcelable class Cell-Broadcast downloadable file information.
|
||||
* Describes a single file that is available over MBMS.
|
||||
* @hide
|
||||
*/
|
||||
public class FileInfo implements Parcelable {
|
||||
|
||||
/**
|
||||
* The URI into the carriers infrastructure which points to this file.
|
||||
* This is used internally but is also one of the few pieces of data about the content that is
|
||||
* exposed and may be needed for disambiguation by the application.
|
||||
*/
|
||||
private final Uri uri;
|
||||
|
||||
/**
|
||||
* The mime type of the content.
|
||||
*/
|
||||
private final String mimeType;
|
||||
|
||||
public static final Parcelable.Creator<FileInfo> CREATOR =
|
||||
@@ -53,8 +46,8 @@ public class FileInfo implements Parcelable {
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* TODO: systemapi
|
||||
*/
|
||||
//@SystemApi
|
||||
public FileInfo(Uri uri, String mimeType) {
|
||||
this.uri = uri;
|
||||
this.mimeType = mimeType;
|
||||
@@ -76,10 +69,17 @@ public class FileInfo implements Parcelable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The URI in the carrier's infrastructure which points to this file. Apps should
|
||||
* negotiate the contents of this URI separately with the carrier.
|
||||
*/
|
||||
public Uri getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The MIME type of the file.
|
||||
*/
|
||||
public String getMimeType() {
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.telephony.mbms;
|
||||
|
||||
import android.annotation.SystemApi;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
@@ -26,13 +27,15 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A Parcelable class Cell-Broadcast downloadable file information.
|
||||
* Describes a file service available from the carrier from which files can be downloaded via
|
||||
* cell-broadcast.
|
||||
* @hide
|
||||
*/
|
||||
public class FileServiceInfo extends ServiceInfo implements Parcelable {
|
||||
private final List<FileInfo> files;
|
||||
|
||||
/** @hide TODO: systemapi */
|
||||
/** @hide */
|
||||
@SystemApi
|
||||
public FileServiceInfo(Map<Locale, String> newNames, String newClassName,
|
||||
List<Locale> newLocales, String newServiceId, Date start, Date end,
|
||||
List<FileInfo> newFiles) {
|
||||
@@ -70,8 +73,12 @@ public class FileServiceInfo extends ServiceInfo implements Parcelable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A list of files available from this service. Note that this list may not be
|
||||
* exhaustive -- the middleware may not have information on all files that are available.
|
||||
* Consult the carrier for an authoritative and exhaustive list.
|
||||
*/
|
||||
public List<FileInfo> getFiles() {
|
||||
return files;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import android.telephony.mbms.FileInfo;
|
||||
* The optional interface used by download clients to track progress.
|
||||
* @hide
|
||||
*/
|
||||
interface IDownloadProgressListener
|
||||
interface IDownloadStateCallback
|
||||
{
|
||||
/**
|
||||
* Gives progress callbacks for a given DownloadRequest. Includes a FileInfo
|
||||
@@ -31,4 +31,6 @@ interface IDownloadProgressListener
|
||||
*/
|
||||
void progress(in DownloadRequest request, in FileInfo fileInfo, int currentDownloadSize,
|
||||
int fullDownloadSize, int currentDecodedSize, int fullDecodedSize);
|
||||
|
||||
void state(in DownloadRequest request, in FileInfo fileInfo, int state);
|
||||
}
|
||||
@@ -22,11 +22,19 @@ import android.telephony.MbmsDownloadManager;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A Parcelable class with Cell-Broadcast service information.
|
||||
* A callback class that apps should use to receive information on file downloads over
|
||||
* cell-broadcast.
|
||||
* @hide
|
||||
*/
|
||||
public class MbmsDownloadManagerCallback extends IMbmsDownloadManagerCallback.Stub {
|
||||
|
||||
/**
|
||||
* Indicates that the middleware has encountered an asynchronous error.
|
||||
* @param errorCode Any error code listed in {@link MbmsException}
|
||||
* @param message A message, intended for debugging purposes, describing the error in further
|
||||
* detail.
|
||||
* @throws RemoteException
|
||||
*/
|
||||
@Override
|
||||
public void error(int errorCode, String message) throws RemoteException {
|
||||
// default implementation empty
|
||||
@@ -35,14 +43,13 @@ public class MbmsDownloadManagerCallback extends IMbmsDownloadManagerCallback.St
|
||||
/**
|
||||
* Called to indicate published File Services have changed.
|
||||
*
|
||||
* This will only be called after the application has requested
|
||||
* a list of file services and specified a service class list
|
||||
* of interest AND the results of a subsequent getFileServices
|
||||
* call with the same service class list would return different
|
||||
* results.
|
||||
*
|
||||
* @param services a List of FileServiceInfos
|
||||
* This will only be called after the application has requested a list of file services and
|
||||
* specified a service class list of interest via
|
||||
* {@link MbmsDownloadManager#getFileServices(List)}. If there are subsequent calls to
|
||||
* {@link MbmsDownloadManager#getFileServices(List)}, this method may not be called again if
|
||||
* the list of service classes would remain the same.
|
||||
*
|
||||
* @param services The most recently updated list of available file services.
|
||||
*/
|
||||
@Override
|
||||
public void fileServicesUpdated(List<FileServiceInfo> services) throws RemoteException {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.telephony.mbms;
|
||||
|
||||
import android.annotation.SystemApi;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
@@ -25,7 +26,7 @@ import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.telephony.MbmsDownloadManager;
|
||||
import android.telephony.mbms.vendor.VendorIntents;
|
||||
import android.telephony.mbms.vendor.VendorUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.File;
|
||||
@@ -42,45 +43,66 @@ import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* The {@link BroadcastReceiver} responsible for handling intents sent from the middleware. Apps
|
||||
* that wish to download using MBMS APIs should declare this class in their AndroidManifest.xml as
|
||||
* follows:
|
||||
<pre>{@code
|
||||
<receiver
|
||||
android:name="android.telephony.mbms.MbmsDownloadReceiver"
|
||||
android:permission="android.permission.SEND_EMBMS_INTENTS"
|
||||
android:enabled="true"
|
||||
android:exported="true">
|
||||
</receiver>}</pre>
|
||||
* @hide
|
||||
*/
|
||||
public class MbmsDownloadReceiver extends BroadcastReceiver {
|
||||
/** @hide */
|
||||
public static final String DOWNLOAD_TOKEN_SUFFIX = ".download_token";
|
||||
/** @hide */
|
||||
public static final String MBMS_FILE_PROVIDER_META_DATA_KEY = "mbms-file-provider-authority";
|
||||
|
||||
/**
|
||||
* TODO: @SystemApi all these result codes
|
||||
* Indicates that the requested operation completed without error.
|
||||
* @hide
|
||||
*/
|
||||
//@SystemApi
|
||||
public static final int RESULT_OK = 0;
|
||||
|
||||
/**
|
||||
* Indicates that the intent sent had an invalid action. This will be the result if
|
||||
* {@link Intent#getAction()} returns anything other than
|
||||
* {@link VendorIntents#ACTION_DOWNLOAD_RESULT_INTERNAL},
|
||||
* {@link VendorIntents#ACTION_FILE_DESCRIPTOR_REQUEST}, or
|
||||
* {@link VendorIntents#ACTION_CLEANUP}.
|
||||
* {@link VendorUtils#ACTION_DOWNLOAD_RESULT_INTERNAL},
|
||||
* {@link VendorUtils#ACTION_FILE_DESCRIPTOR_REQUEST}, or
|
||||
* {@link VendorUtils#ACTION_CLEANUP}.
|
||||
* This is a fatal result code and no result extras should be expected.
|
||||
* @hide
|
||||
*/
|
||||
//@SystemApi
|
||||
public static final int RESULT_INVALID_ACTION = 1;
|
||||
|
||||
/**
|
||||
* Indicates that the intent was missing some required extras.
|
||||
* This is a fatal result code and no result extras should be expected.
|
||||
* @hide
|
||||
*/
|
||||
//@SystemApi
|
||||
public static final int RESULT_MALFORMED_INTENT = 2;
|
||||
|
||||
/**
|
||||
* Indicates that the supplied value for {@link VendorIntents#EXTRA_TEMP_FILE_ROOT}
|
||||
* Indicates that the supplied value for {@link VendorUtils#EXTRA_TEMP_FILE_ROOT}
|
||||
* does not match what the app has stored.
|
||||
* This is a fatal result code and no result extras should be expected.
|
||||
* @hide
|
||||
*/
|
||||
//@SystemApi
|
||||
public static final int RESULT_BAD_TEMP_FILE_ROOT = 3;
|
||||
|
||||
/**
|
||||
* Indicates that the manager was unable to move the completed download to its final location.
|
||||
* This is a fatal result code and no result extras should be expected.
|
||||
* @hide
|
||||
*/
|
||||
//@SystemApi
|
||||
public static final int RESULT_DOWNLOAD_FINALIZATION_ERROR = 4;
|
||||
|
||||
/**
|
||||
@@ -88,35 +110,37 @@ public class MbmsDownloadReceiver extends BroadcastReceiver {
|
||||
* descriptors.
|
||||
* This is a non-fatal result code -- some file descriptors may still be generated, but there
|
||||
* is no guarantee that they will be the same number as requested.
|
||||
* @hide
|
||||
*/
|
||||
//@SystemApi
|
||||
public static final int RESULT_TEMP_FILE_GENERATION_ERROR = 5;
|
||||
|
||||
private static final String LOG_TAG = "MbmsDownloadReceiver";
|
||||
private static final String TEMP_FILE_SUFFIX = ".embms.temp";
|
||||
private static final int MAX_TEMP_FILE_RETRIES = 5;
|
||||
|
||||
|
||||
private String mFileProviderAuthorityCache = null;
|
||||
private String mMiddlewarePackageNameCache = null;
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (!verifyIntentContents(context, intent)) {
|
||||
setResultCode(RESULT_MALFORMED_INTENT);
|
||||
return;
|
||||
}
|
||||
if (!Objects.equals(intent.getStringExtra(VendorIntents.EXTRA_TEMP_FILE_ROOT),
|
||||
if (!Objects.equals(intent.getStringExtra(VendorUtils.EXTRA_TEMP_FILE_ROOT),
|
||||
MbmsTempFileProvider.getEmbmsTempFileDir(context).getPath())) {
|
||||
setResultCode(RESULT_BAD_TEMP_FILE_ROOT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (VendorIntents.ACTION_DOWNLOAD_RESULT_INTERNAL.equals(intent.getAction())) {
|
||||
if (VendorUtils.ACTION_DOWNLOAD_RESULT_INTERNAL.equals(intent.getAction())) {
|
||||
moveDownloadedFile(context, intent);
|
||||
cleanupPostMove(context, intent);
|
||||
} else if (VendorIntents.ACTION_FILE_DESCRIPTOR_REQUEST.equals(intent.getAction())) {
|
||||
} else if (VendorUtils.ACTION_FILE_DESCRIPTOR_REQUEST.equals(intent.getAction())) {
|
||||
generateTempFiles(context, intent);
|
||||
} else if (VendorIntents.ACTION_CLEANUP.equals(intent.getAction())) {
|
||||
} else if (VendorUtils.ACTION_CLEANUP.equals(intent.getAction())) {
|
||||
cleanupTempFiles(context, intent);
|
||||
} else {
|
||||
setResultCode(RESULT_INVALID_ACTION);
|
||||
@@ -124,16 +148,16 @@ public class MbmsDownloadReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
private boolean verifyIntentContents(Context context, Intent intent) {
|
||||
if (VendorIntents.ACTION_DOWNLOAD_RESULT_INTERNAL.equals(intent.getAction())) {
|
||||
if (VendorUtils.ACTION_DOWNLOAD_RESULT_INTERNAL.equals(intent.getAction())) {
|
||||
if (!intent.hasExtra(MbmsDownloadManager.EXTRA_RESULT)) {
|
||||
Log.w(LOG_TAG, "Download result did not include a result code. Ignoring.");
|
||||
return false;
|
||||
}
|
||||
if (!intent.hasExtra(VendorIntents.EXTRA_REQUEST)) {
|
||||
if (!intent.hasExtra(VendorUtils.EXTRA_REQUEST)) {
|
||||
Log.w(LOG_TAG, "Download result did not include the associated request. Ignoring.");
|
||||
return false;
|
||||
}
|
||||
if (!intent.hasExtra(VendorIntents.EXTRA_TEMP_FILE_ROOT)) {
|
||||
if (!intent.hasExtra(VendorUtils.EXTRA_TEMP_FILE_ROOT)) {
|
||||
Log.w(LOG_TAG, "Download result did not include the temp file root. Ignoring.");
|
||||
return false;
|
||||
}
|
||||
@@ -142,12 +166,12 @@ public class MbmsDownloadReceiver extends BroadcastReceiver {
|
||||
"Ignoring.");
|
||||
return false;
|
||||
}
|
||||
if (!intent.hasExtra(VendorIntents.EXTRA_FINAL_URI)) {
|
||||
if (!intent.hasExtra(VendorUtils.EXTRA_FINAL_URI)) {
|
||||
Log.w(LOG_TAG, "Download result did not include the path to the final " +
|
||||
"temp file. Ignoring.");
|
||||
return false;
|
||||
}
|
||||
DownloadRequest request = intent.getParcelableExtra(VendorIntents.EXTRA_REQUEST);
|
||||
DownloadRequest request = intent.getParcelableExtra(VendorUtils.EXTRA_REQUEST);
|
||||
String expectedTokenFileName = request.getHash() + DOWNLOAD_TOKEN_SUFFIX;
|
||||
File expectedTokenFile = new File(
|
||||
MbmsUtils.getEmbmsTempFileDirForService(context, request.getFileServiceId()),
|
||||
@@ -157,27 +181,27 @@ public class MbmsDownloadReceiver extends BroadcastReceiver {
|
||||
"Expected " + expectedTokenFile);
|
||||
return false;
|
||||
}
|
||||
} else if (VendorIntents.ACTION_FILE_DESCRIPTOR_REQUEST.equals(intent.getAction())) {
|
||||
if (!intent.hasExtra(VendorIntents.EXTRA_SERVICE_INFO)) {
|
||||
Log.w(LOG_TAG, "Temp file request did not include the associated service info." +
|
||||
} else if (VendorUtils.ACTION_FILE_DESCRIPTOR_REQUEST.equals(intent.getAction())) {
|
||||
if (!intent.hasExtra(VendorUtils.EXTRA_SERVICE_ID)) {
|
||||
Log.w(LOG_TAG, "Temp file request did not include the associated service id." +
|
||||
" Ignoring.");
|
||||
return false;
|
||||
}
|
||||
if (!intent.hasExtra(VendorIntents.EXTRA_TEMP_FILE_ROOT)) {
|
||||
if (!intent.hasExtra(VendorUtils.EXTRA_TEMP_FILE_ROOT)) {
|
||||
Log.w(LOG_TAG, "Download result did not include the temp file root. Ignoring.");
|
||||
return false;
|
||||
}
|
||||
} else if (VendorIntents.ACTION_CLEANUP.equals(intent.getAction())) {
|
||||
if (!intent.hasExtra(VendorIntents.EXTRA_SERVICE_INFO)) {
|
||||
Log.w(LOG_TAG, "Cleanup request did not include the associated service info." +
|
||||
} else if (VendorUtils.ACTION_CLEANUP.equals(intent.getAction())) {
|
||||
if (!intent.hasExtra(VendorUtils.EXTRA_SERVICE_ID)) {
|
||||
Log.w(LOG_TAG, "Cleanup request did not include the associated service id." +
|
||||
" Ignoring.");
|
||||
return false;
|
||||
}
|
||||
if (!intent.hasExtra(VendorIntents.EXTRA_TEMP_FILE_ROOT)) {
|
||||
if (!intent.hasExtra(VendorUtils.EXTRA_TEMP_FILE_ROOT)) {
|
||||
Log.w(LOG_TAG, "Cleanup request did not include the temp file root. Ignoring.");
|
||||
return false;
|
||||
}
|
||||
if (!intent.hasExtra(VendorIntents.EXTRA_TEMP_FILES_IN_USE)) {
|
||||
if (!intent.hasExtra(VendorUtils.EXTRA_TEMP_FILES_IN_USE)) {
|
||||
Log.w(LOG_TAG, "Cleanup request did not include the list of temp files in use. " +
|
||||
"Ignoring.");
|
||||
return false;
|
||||
@@ -187,7 +211,7 @@ public class MbmsDownloadReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
private void moveDownloadedFile(Context context, Intent intent) {
|
||||
DownloadRequest request = intent.getParcelableExtra(VendorIntents.EXTRA_REQUEST);
|
||||
DownloadRequest request = intent.getParcelableExtra(VendorUtils.EXTRA_REQUEST);
|
||||
Intent intentForApp = request.getIntentForApp();
|
||||
|
||||
int result = intent.getIntExtra(MbmsDownloadManager.EXTRA_RESULT,
|
||||
@@ -201,7 +225,7 @@ public class MbmsDownloadReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
Uri destinationUri = request.getDestinationUri();
|
||||
Uri finalTempFile = intent.getParcelableExtra(VendorIntents.EXTRA_FINAL_URI);
|
||||
Uri finalTempFile = intent.getParcelableExtra(VendorUtils.EXTRA_FINAL_URI);
|
||||
if (!verifyTempFilePath(context, request.getFileServiceId(), finalTempFile)) {
|
||||
Log.w(LOG_TAG, "Download result specified an invalid temp file " + finalTempFile);
|
||||
setResultCode(RESULT_DOWNLOAD_FINALIZATION_ERROR);
|
||||
@@ -226,13 +250,13 @@ public class MbmsDownloadReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
private void cleanupPostMove(Context context, Intent intent) {
|
||||
DownloadRequest request = intent.getParcelableExtra(VendorIntents.EXTRA_REQUEST);
|
||||
DownloadRequest request = intent.getParcelableExtra(VendorUtils.EXTRA_REQUEST);
|
||||
if (request == null) {
|
||||
Log.w(LOG_TAG, "Intent does not include a DownloadRequest. Ignoring.");
|
||||
return;
|
||||
}
|
||||
|
||||
List<Uri> tempFiles = intent.getParcelableExtra(VendorIntents.EXTRA_TEMP_LIST);
|
||||
List<Uri> tempFiles = intent.getParcelableExtra(VendorUtils.EXTRA_TEMP_LIST);
|
||||
if (tempFiles == null) {
|
||||
return;
|
||||
}
|
||||
@@ -246,16 +270,15 @@ public class MbmsDownloadReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
private void generateTempFiles(Context context, Intent intent) {
|
||||
FileServiceInfo serviceInfo =
|
||||
intent.getParcelableExtra(VendorIntents.EXTRA_SERVICE_INFO);
|
||||
if (serviceInfo == null) {
|
||||
Log.w(LOG_TAG, "Temp file request did not include the associated service info. " +
|
||||
String serviceId = intent.getStringExtra(VendorUtils.EXTRA_SERVICE_ID);
|
||||
if (serviceId == null) {
|
||||
Log.w(LOG_TAG, "Temp file request did not include the associated service id. " +
|
||||
"Ignoring.");
|
||||
setResultCode(RESULT_MALFORMED_INTENT);
|
||||
return;
|
||||
}
|
||||
int fdCount = intent.getIntExtra(VendorIntents.EXTRA_FD_COUNT, 0);
|
||||
List<Uri> pausedList = intent.getParcelableExtra(VendorIntents.EXTRA_PAUSED_LIST);
|
||||
int fdCount = intent.getIntExtra(VendorUtils.EXTRA_FD_COUNT, 0);
|
||||
List<Uri> pausedList = intent.getParcelableExtra(VendorUtils.EXTRA_PAUSED_LIST);
|
||||
|
||||
if (fdCount == 0 && (pausedList == null || pausedList.size() == 0)) {
|
||||
Log.i(LOG_TAG, "No temp files actually requested. Ending.");
|
||||
@@ -265,22 +288,20 @@ public class MbmsDownloadReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
ArrayList<UriPathPair> freshTempFiles =
|
||||
generateFreshTempFiles(context, serviceInfo, fdCount);
|
||||
generateFreshTempFiles(context, serviceId, fdCount);
|
||||
ArrayList<UriPathPair> pausedFiles =
|
||||
generateUrisForPausedFiles(context, serviceInfo, pausedList);
|
||||
generateUrisForPausedFiles(context, serviceId, pausedList);
|
||||
|
||||
Bundle result = new Bundle();
|
||||
result.putParcelableArrayList(VendorIntents.EXTRA_FREE_URI_LIST, freshTempFiles);
|
||||
result.putParcelableArrayList(VendorIntents.EXTRA_PAUSED_URI_LIST, pausedFiles);
|
||||
result.putParcelableArrayList(VendorUtils.EXTRA_FREE_URI_LIST, freshTempFiles);
|
||||
result.putParcelableArrayList(VendorUtils.EXTRA_PAUSED_URI_LIST, pausedFiles);
|
||||
setResultCode(RESULT_OK);
|
||||
setResultExtras(result);
|
||||
}
|
||||
|
||||
private ArrayList<UriPathPair> generateFreshTempFiles(Context context,
|
||||
FileServiceInfo serviceInfo,
|
||||
private ArrayList<UriPathPair> generateFreshTempFiles(Context context, String serviceId,
|
||||
int freshFdCount) {
|
||||
File tempFileDir = MbmsUtils.getEmbmsTempFileDirForService(context,
|
||||
serviceInfo.getServiceId());
|
||||
File tempFileDir = MbmsUtils.getEmbmsTempFileDirForService(context, serviceId);
|
||||
if (!tempFileDir.exists()) {
|
||||
tempFileDir.mkdirs();
|
||||
}
|
||||
@@ -324,14 +345,14 @@ public class MbmsDownloadReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
private ArrayList<UriPathPair> generateUrisForPausedFiles(Context context,
|
||||
FileServiceInfo serviceInfo, List<Uri> pausedFiles) {
|
||||
String serviceId, List<Uri> pausedFiles) {
|
||||
if (pausedFiles == null) {
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
ArrayList<UriPathPair> result = new ArrayList<>(pausedFiles.size());
|
||||
|
||||
for (Uri fileUri : pausedFiles) {
|
||||
if (!verifyTempFilePath(context, serviceInfo.getServiceId(), fileUri)) {
|
||||
if (!verifyTempFilePath(context, serviceId, fileUri)) {
|
||||
Log.w(LOG_TAG, "Supplied file " + fileUri + " is not a valid temp file to resume");
|
||||
setResultCode(RESULT_TEMP_FILE_GENERATION_ERROR);
|
||||
continue;
|
||||
@@ -353,12 +374,10 @@ public class MbmsDownloadReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
private void cleanupTempFiles(Context context, Intent intent) {
|
||||
FileServiceInfo serviceInfo =
|
||||
intent.getParcelableExtra(VendorIntents.EXTRA_SERVICE_INFO);
|
||||
File tempFileDir = MbmsUtils.getEmbmsTempFileDirForService(context,
|
||||
serviceInfo.getServiceId());
|
||||
String serviceId = intent.getStringExtra(VendorUtils.EXTRA_SERVICE_ID);
|
||||
File tempFileDir = MbmsUtils.getEmbmsTempFileDirForService(context, serviceId);
|
||||
final List<Uri> filesInUse =
|
||||
intent.getParcelableArrayListExtra(VendorIntents.EXTRA_TEMP_FILES_IN_USE);
|
||||
intent.getParcelableArrayListExtra(VendorUtils.EXTRA_TEMP_FILES_IN_USE);
|
||||
File[] filesToDelete = tempFileDir.listFiles(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File file) {
|
||||
|
||||
@@ -30,7 +30,7 @@ public class MbmsException extends Exception {
|
||||
|
||||
/**
|
||||
* Indicates that the app attempted to perform an operation on an instance of
|
||||
* TODO: link android.telephony.MbmsDownloadManager or
|
||||
* TODO link android.telephony.MbmsDownloadManager or
|
||||
* {@link android.telephony.MbmsStreamingManager} without being bound to the middleware.
|
||||
*/
|
||||
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
|
||||
* {@link android.telephony.MbmsStreamingManager} or
|
||||
* TODO: link android.telephony.MbmsDownloadManager
|
||||
* TODO link android.telephony.MbmsDownloadManager
|
||||
*/
|
||||
public static final int ERROR_DUPLICATE_INITIALIZE = 101;
|
||||
/** Indicates that the app is not authorized to access media via MBMS.*/
|
||||
@@ -116,10 +116,10 @@ public class MbmsException extends Exception {
|
||||
|
||||
/**
|
||||
* Indicates the errors that are applicable only to the file-download use-case
|
||||
* TODO: unhide
|
||||
* @hide
|
||||
*/
|
||||
public static class DownloadErrors {
|
||||
private DownloadErrors() { }
|
||||
/**
|
||||
* Indicates that the app is not allowed to change the temp file root at this time due to
|
||||
* outstanding download requests.
|
||||
|
||||
@@ -23,12 +23,11 @@ import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ProviderInfo;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.telephony.MbmsDownloadManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@@ -39,7 +38,6 @@ import java.util.Objects;
|
||||
* @hide
|
||||
*/
|
||||
public class MbmsTempFileProvider extends ContentProvider {
|
||||
public static final String DEFAULT_TOP_LEVEL_TEMP_DIRECTORY = "androidMbmsTempFileRoot";
|
||||
public static final String TEMP_FILE_ROOT_PREF_FILE_NAME = "MbmsTempFileRootPrefs";
|
||||
public static final String TEMP_FILE_ROOT_PREF_NAME = "mbms_temp_file_root";
|
||||
|
||||
@@ -182,8 +180,8 @@ public class MbmsTempFileProvider extends ContentProvider {
|
||||
if (storedTempFileRoot != null) {
|
||||
return new File(storedTempFileRoot).getCanonicalFile();
|
||||
} else {
|
||||
return new File(context.getFilesDir(), DEFAULT_TOP_LEVEL_TEMP_DIRECTORY)
|
||||
.getCanonicalFile();
|
||||
return new File(context.getFilesDir(),
|
||||
MbmsDownloadManager.DEFAULT_TOP_LEVEL_TEMP_DIRECTORY).getCanonicalFile();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Unable to canonicalize temp file root path " + e);
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.util.Set;
|
||||
|
||||
/**
|
||||
* Describes a cell-broadcast service. This class should not be instantiated directly -- use
|
||||
* {@link StreamingServiceInfo} or FileServiceInfo TODO: add link once that's unhidden
|
||||
* {@link StreamingServiceInfo} or TODO link FileServiceInfo
|
||||
*/
|
||||
public class ServiceInfo {
|
||||
// arbitrary limit on the number of locale -> name pairs we support
|
||||
|
||||
@@ -16,12 +16,19 @@
|
||||
|
||||
package android.telephony.mbms;
|
||||
|
||||
import android.annotation.SystemApi;
|
||||
import android.content.ContentResolver;
|
||||
import android.net.Uri;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.telephony.mbms.vendor.VendorUtils;
|
||||
|
||||
/** @hide */
|
||||
/**
|
||||
* Wrapper for a pair of {@link Uri}s that describe a temp file used by the middleware to
|
||||
* download files via cell-broadcast.
|
||||
* @hide
|
||||
*/
|
||||
//@SystemApi
|
||||
public class UriPathPair implements Parcelable {
|
||||
private final Uri mFilePathUri;
|
||||
private final Uri mContentUri;
|
||||
@@ -40,7 +47,7 @@ public class UriPathPair implements Parcelable {
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
protected UriPathPair(Parcel in) {
|
||||
private UriPathPair(Parcel in) {
|
||||
mFilePathUri = in.readParcelable(Uri.class.getClassLoader());
|
||||
mContentUri = in.readParcelable(Uri.class.getClassLoader());
|
||||
}
|
||||
@@ -57,12 +64,23 @@ public class UriPathPair implements Parcelable {
|
||||
}
|
||||
};
|
||||
|
||||
/** future systemapi */
|
||||
/**
|
||||
* Returns the file-path {@link Uri}. This has scheme {@code file} and points to the actual
|
||||
* location on disk where the temp file resides. Use this when sending {@link Uri}s back to the
|
||||
* app in the intents in {@link VendorUtils}.
|
||||
* @return A {@code file} {@link Uri}.
|
||||
*/
|
||||
public Uri getFilePathUri() {
|
||||
return mFilePathUri;
|
||||
}
|
||||
|
||||
/** future systemapi */
|
||||
/**
|
||||
* Returns the content {@link Uri} that may be used with
|
||||
* {@link ContentResolver#openFileDescriptor(Uri, String)} to obtain a
|
||||
* {@link android.os.ParcelFileDescriptor} to a temp file to write to. This {@link Uri} will
|
||||
* expire if the middleware process dies.
|
||||
* @return A {@code content} {@link Uri}
|
||||
*/
|
||||
public Uri getContentUri() {
|
||||
return mContentUri;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import android.net.Uri;
|
||||
import android.telephony.mbms.DownloadRequest;
|
||||
import android.telephony.mbms.FileInfo;
|
||||
import android.telephony.mbms.IMbmsDownloadManagerCallback;
|
||||
import android.telephony.mbms.IDownloadProgressListener;
|
||||
import android.telephony.mbms.IDownloadStateCallback;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
@@ -34,7 +34,7 @@ interface IMbmsDownloadService
|
||||
|
||||
int setTempFileRootDirectory(int subId, String rootDirectoryPath);
|
||||
|
||||
int download(in DownloadRequest downloadRequest, IDownloadProgressListener listener);
|
||||
int download(in DownloadRequest downloadRequest, IDownloadStateCallback listener);
|
||||
|
||||
List<DownloadRequest> listPendingDownloads(int subscriptionId);
|
||||
|
||||
|
||||
@@ -17,12 +17,14 @@
|
||||
package android.telephony.mbms.vendor;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.SystemApi;
|
||||
import android.content.Intent;
|
||||
import android.os.RemoteException;
|
||||
import android.telephony.mbms.DownloadProgressListener;
|
||||
import android.telephony.mbms.DownloadStateCallback;
|
||||
import android.telephony.mbms.DownloadRequest;
|
||||
import android.telephony.mbms.FileInfo;
|
||||
import android.telephony.mbms.FileServiceInfo;
|
||||
import android.telephony.mbms.IDownloadProgressListener;
|
||||
import android.telephony.mbms.IDownloadStateCallback;
|
||||
import android.telephony.mbms.IMbmsDownloadManagerCallback;
|
||||
import android.telephony.mbms.MbmsDownloadManagerCallback;
|
||||
import android.telephony.mbms.MbmsException;
|
||||
@@ -30,11 +32,11 @@ import android.telephony.mbms.MbmsException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Base class for MbmsDownloadService. The middleware should extend this base class rather than
|
||||
* the aidl stub for compatibility
|
||||
* Base class for MbmsDownloadService. The middleware should return an instance of this object from
|
||||
* its {@link android.app.Service#onBind(Intent)} method.
|
||||
* @hide
|
||||
* TODO: future systemapi
|
||||
*/
|
||||
//@SystemApi
|
||||
public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub {
|
||||
/**
|
||||
* Initialize the download service for this app and subId, registering the listener.
|
||||
@@ -132,12 +134,12 @@ public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub {
|
||||
* this is not the case, an {@link IllegalStateException} may be thrown.
|
||||
*
|
||||
* @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
|
||||
* @param callback A callback through which the middleware can provide progress updates to
|
||||
* the app while both are still running.
|
||||
* @return Any error from {@link android.telephony.mbms.MbmsException.GeneralErrors}
|
||||
* or {@link MbmsException#SUCCESS}
|
||||
*/
|
||||
public int download(DownloadRequest downloadRequest, DownloadProgressListener listener) {
|
||||
public int download(DownloadRequest downloadRequest, DownloadStateCallback callback) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -146,14 +148,14 @@ public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub {
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public final int download(DownloadRequest downloadRequest, IDownloadProgressListener listener)
|
||||
public final int download(DownloadRequest downloadRequest, IDownloadStateCallback callback)
|
||||
throws RemoteException {
|
||||
return download(downloadRequest, new DownloadProgressListener() {
|
||||
return download(downloadRequest, new DownloadStateCallback() {
|
||||
@Override
|
||||
public void progress(DownloadRequest request, FileInfo fileInfo, int
|
||||
currentDownloadSize, int fullDownloadSize, int currentDecodedSize, int
|
||||
fullDecodedSize) throws RemoteException {
|
||||
listener.progress(request, fileInfo, currentDownloadSize, fullDownloadSize,
|
||||
callback.progress(request, fileInfo, currentDownloadSize, fullDownloadSize,
|
||||
currentDecodedSize, fullDecodedSize);
|
||||
}
|
||||
});
|
||||
@@ -163,7 +165,7 @@ public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub {
|
||||
/**
|
||||
* Returns a list of pending {@link DownloadRequest}s that originated from the calling
|
||||
* application, identified by its uid. A pending request is one that was issued via
|
||||
* {@link #download(DownloadRequest, IDownloadProgressListener)} but not cancelled through
|
||||
* {@link #download(DownloadRequest, DownloadStateCallback)} but not cancelled through
|
||||
* {@link #cancelDownload(DownloadRequest)}.
|
||||
* The middleware must return a non-null result synchronously or throw an exception
|
||||
* inheriting from {@link RuntimeException}.
|
||||
|
||||
@@ -18,6 +18,7 @@ package android.telephony.mbms.vendor;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SystemApi;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Binder;
|
||||
import android.os.RemoteException;
|
||||
@@ -32,6 +33,8 @@ import android.telephony.mbms.StreamingServiceInfo;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Base class for MBMS streaming services. The middleware should return an instance of this
|
||||
* object from its {@link android.app.Service#onBind(Intent)} method.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.telephony.mbms.vendor;
|
||||
|
||||
import android.annotation.SystemApi;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -28,10 +29,12 @@ import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Contains constants and utility methods for MBMS Download middleware apps to communicate with
|
||||
* frontend apps.
|
||||
* @hide
|
||||
* TODO: future systemapi
|
||||
*/
|
||||
public class VendorIntents {
|
||||
//@SystemApi
|
||||
public class VendorUtils {
|
||||
|
||||
/**
|
||||
* The MBMS middleware should send this when a download of single file has completed or
|
||||
@@ -49,7 +52,7 @@ public class VendorIntents {
|
||||
* The MBMS middleware should send this when it wishes to request {@code content://} URIs to
|
||||
* serve as temp files for downloads or when it wishes to resume paused downloads. Mandatory
|
||||
* extras are
|
||||
* {@link #EXTRA_REQUEST}
|
||||
* {@link #EXTRA_SERVICE_ID}
|
||||
*
|
||||
* Optional extras are
|
||||
* {@link #EXTRA_FD_COUNT} (0 if not present)
|
||||
@@ -130,36 +133,29 @@ public class VendorIntents {
|
||||
public static final String EXTRA_FINAL_URI = "android.telephony.mbms.extra.FINAL_URI";
|
||||
|
||||
/**
|
||||
* Extra containing an instance of {@link android.telephony.mbms.ServiceInfo}, used by
|
||||
* Extra containing a String representing a service ID, used by
|
||||
* file-descriptor requests and cleanup requests to specify which service they want to
|
||||
* request temp files or clean up temp files for, respectively.
|
||||
*/
|
||||
public static final String EXTRA_SERVICE_INFO =
|
||||
"android.telephony.mbms.extra.SERVICE_INFO";
|
||||
public static final String EXTRA_SERVICE_ID =
|
||||
"android.telephony.mbms.extra.SERVICE_ID";
|
||||
|
||||
/**
|
||||
* Retrieves the {@link ComponentName} for the {@link android.content.BroadcastReceiver} that
|
||||
* the various intents from the middleware should be targeted towards.
|
||||
* @param uid The uid of the frontend app.
|
||||
* @param packageName The package name of the app.
|
||||
* @return The component name of the receiver that the middleware should send its intents to,
|
||||
* or null if the app didn't declare it in the manifest.
|
||||
*/
|
||||
public static ComponentName getAppReceiverFromUid(Context context, int uid) {
|
||||
String[] packageNames = context.getPackageManager().getPackagesForUid(uid);
|
||||
if (packageNames == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (String packageName : packageNames) {
|
||||
ComponentName candidate = new ComponentName(packageName,
|
||||
MbmsDownloadReceiver.class.getCanonicalName());
|
||||
Intent queryIntent = new Intent();
|
||||
queryIntent.setComponent(candidate);
|
||||
List<ResolveInfo> receivers =
|
||||
context.getPackageManager().queryBroadcastReceivers(queryIntent, 0);
|
||||
if (receivers != null && receivers.size() > 0) {
|
||||
return candidate;
|
||||
}
|
||||
public static ComponentName getAppReceiverFromPackageName(Context context, String packageName) {
|
||||
ComponentName candidate = new ComponentName(packageName,
|
||||
MbmsDownloadReceiver.class.getCanonicalName());
|
||||
Intent queryIntent = new Intent();
|
||||
queryIntent.setComponent(candidate);
|
||||
List<ResolveInfo> receivers =
|
||||
context.getPackageManager().queryBroadcastReceivers(queryIntent, 0);
|
||||
if (receivers != null && receivers.size() > 0) {
|
||||
return candidate;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user