Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4c4fb3bd authored by Hall Liu's avatar Hall Liu Committed by android-build-merger
Browse files

Merge "API council suggested edits, part 3"

am: 7a4cc05d

Change-Id: Idec5544475dc5eee42009f4038f32b8d8b3c5450
parents 3934c475 7a4cc05d
Loading
Loading
Loading
Loading
+6 −8
Original line number Diff line number Diff line
@@ -39733,6 +39733,7 @@ package android.telephony {
    method public void unregisterStateCallback(android.telephony.mbms.DownloadRequest, android.telephony.mbms.DownloadStateCallback);
    field public static final java.lang.String DEFAULT_TOP_LEVEL_TEMP_DIRECTORY = "androidMbmsTempFileRoot";
    field public static final java.lang.String EXTRA_MBMS_COMPLETED_FILE_URI = "android.telephony.extra.MBMS_COMPLETED_FILE_URI";
    field public static final java.lang.String EXTRA_MBMS_DOWNLOAD_REQUEST = "android.telephony.extra.MBMS_DOWNLOAD_REQUEST";
    field public static final java.lang.String EXTRA_MBMS_DOWNLOAD_RESULT = "android.telephony.extra.MBMS_DOWNLOAD_RESULT";
    field public static final java.lang.String EXTRA_MBMS_FILE_INFO = "android.telephony.extra.MBMS_FILE_INFO";
    field public static final int RESULT_CANCELLED = 2; // 0x2
@@ -40387,7 +40388,6 @@ package android.telephony.mbms {
  public final class DownloadRequest implements android.os.Parcelable {
    method public static android.telephony.mbms.DownloadRequest copy(android.telephony.mbms.DownloadRequest);
    method public int describeContents();
    method public android.net.Uri getDestinationUri();
    method public java.lang.String getFileServiceId();
    method public static int getMaxAppIntentSize();
    method public static int getMaxDestinationUriSize();
@@ -40401,7 +40401,6 @@ package android.telephony.mbms {
    ctor public DownloadRequest.Builder();
    method public android.telephony.mbms.DownloadRequest build();
    method public android.telephony.mbms.DownloadRequest.Builder setAppIntent(android.content.Intent);
    method public android.telephony.mbms.DownloadRequest.Builder setDest(android.net.Uri);
    method public android.telephony.mbms.DownloadRequest.Builder setServiceInfo(android.telephony.mbms.FileServiceInfo);
    method public android.telephony.mbms.DownloadRequest.Builder setSource(android.net.Uri);
    method public android.telephony.mbms.DownloadRequest.Builder setSubscriptionId(int);
@@ -40440,20 +40439,19 @@ package android.telephony.mbms {
    method public void onMiddlewareReady();
  }
  public class MbmsException extends java.lang.Exception {
    method public int getErrorCode();
  public class MbmsErrors {
    field public static final int ERROR_MIDDLEWARE_LOST = 3; // 0x3
    field public static final int ERROR_MIDDLEWARE_NOT_BOUND = 2; // 0x2
    field public static final int ERROR_NO_UNIQUE_MIDDLEWARE = 1; // 0x1
    field public static final int SUCCESS = 0; // 0x0
  }
  public static class MbmsException.DownloadErrors {
  public static class MbmsErrors.DownloadErrors {
    field public static final int ERROR_CANNOT_CHANGE_TEMP_FILE_ROOT = 401; // 0x191
    field public static final int ERROR_UNKNOWN_DOWNLOAD_REQUEST = 402; // 0x192
  }
  public static class MbmsException.GeneralErrors {
  public static class MbmsErrors.GeneralErrors {
    field public static final int ERROR_CARRIER_CHANGE_NOT_ALLOWED = 207; // 0xcf
    field public static final int ERROR_IN_E911 = 204; // 0xcc
    field public static final int ERROR_MIDDLEWARE_NOT_YET_READY = 201; // 0xc9
@@ -40463,13 +40461,13 @@ package android.telephony.mbms {
    field public static final int ERROR_UNABLE_TO_READ_SIM = 206; // 0xce
  }
  public static class MbmsException.InitializationErrors {
  public static class MbmsErrors.InitializationErrors {
    field public static final int ERROR_APP_PERMISSIONS_NOT_GRANTED = 102; // 0x66
    field public static final int ERROR_DUPLICATE_INITIALIZE = 101; // 0x65
    field public static final int ERROR_UNABLE_TO_INITIALIZE = 103; // 0x67
  }
  public static class MbmsException.StreamingErrors {
  public static class MbmsErrors.StreamingErrors {
    field public static final int ERROR_CONCURRENT_SERVICE_LIMIT_REACHED = 301; // 0x12d
    field public static final int ERROR_DUPLICATE_START_STREAM = 303; // 0x12f
    field public static final int ERROR_UNABLE_TO_START_SERVICE = 302; // 0x12e
+7 −9
Original line number Diff line number Diff line
@@ -43162,6 +43162,7 @@ package android.telephony {
    method public void unregisterStateCallback(android.telephony.mbms.DownloadRequest, android.telephony.mbms.DownloadStateCallback);
    field public static final java.lang.String DEFAULT_TOP_LEVEL_TEMP_DIRECTORY = "androidMbmsTempFileRoot";
    field public static final java.lang.String EXTRA_MBMS_COMPLETED_FILE_URI = "android.telephony.extra.MBMS_COMPLETED_FILE_URI";
    field public static final java.lang.String EXTRA_MBMS_DOWNLOAD_REQUEST = "android.telephony.extra.MBMS_DOWNLOAD_REQUEST";
    field public static final java.lang.String EXTRA_MBMS_DOWNLOAD_RESULT = "android.telephony.extra.MBMS_DOWNLOAD_RESULT";
    field public static final java.lang.String EXTRA_MBMS_FILE_INFO = "android.telephony.extra.MBMS_FILE_INFO";
    field public static final java.lang.String MBMS_DOWNLOAD_SERVICE_ACTION = "android.telephony.action.EmbmsDownload";
@@ -43901,7 +43902,6 @@ package android.telephony.mbms {
  public final class DownloadRequest implements android.os.Parcelable {
    method public static android.telephony.mbms.DownloadRequest copy(android.telephony.mbms.DownloadRequest);
    method public int describeContents();
    method public android.net.Uri getDestinationUri();
    method public java.lang.String getFileServiceId();
    method public static int getMaxAppIntentSize();
    method public static int getMaxDestinationUriSize();
@@ -43916,7 +43916,6 @@ package android.telephony.mbms {
    ctor public DownloadRequest.Builder();
    method public android.telephony.mbms.DownloadRequest build();
    method public android.telephony.mbms.DownloadRequest.Builder setAppIntent(android.content.Intent);
    method public android.telephony.mbms.DownloadRequest.Builder setDest(android.net.Uri);
    method public android.telephony.mbms.DownloadRequest.Builder setOpaqueData(byte[]);
    method public android.telephony.mbms.DownloadRequest.Builder setServiceId(java.lang.String);
    method public android.telephony.mbms.DownloadRequest.Builder setServiceInfo(android.telephony.mbms.FileServiceInfo);
@@ -43950,6 +43949,7 @@ package android.telephony.mbms {
  public class MbmsDownloadReceiver extends android.content.BroadcastReceiver {
    ctor public MbmsDownloadReceiver();
    method public void onReceive(android.content.Context, android.content.Intent);
    field public static final int RESULT_APP_NOTIFICATION_ERROR = 6; // 0x6
    field public static final int RESULT_BAD_TEMP_FILE_ROOT = 3; // 0x3
    field public static final int RESULT_DOWNLOAD_FINALIZATION_ERROR = 4; // 0x4
    field public static final int RESULT_INVALID_ACTION = 1; // 0x1
@@ -43965,20 +43965,19 @@ package android.telephony.mbms {
    method public void onMiddlewareReady();
  }
  public class MbmsException extends java.lang.Exception {
    method public int getErrorCode();
  public class MbmsErrors {
    field public static final int ERROR_MIDDLEWARE_LOST = 3; // 0x3
    field public static final int ERROR_MIDDLEWARE_NOT_BOUND = 2; // 0x2
    field public static final int ERROR_NO_UNIQUE_MIDDLEWARE = 1; // 0x1
    field public static final int SUCCESS = 0; // 0x0
  }
  public static class MbmsException.DownloadErrors {
  public static class MbmsErrors.DownloadErrors {
    field public static final int ERROR_CANNOT_CHANGE_TEMP_FILE_ROOT = 401; // 0x191
    field public static final int ERROR_UNKNOWN_DOWNLOAD_REQUEST = 402; // 0x192
  }
  public static class MbmsException.GeneralErrors {
  public static class MbmsErrors.GeneralErrors {
    field public static final int ERROR_CARRIER_CHANGE_NOT_ALLOWED = 207; // 0xcf
    field public static final int ERROR_IN_E911 = 204; // 0xcc
    field public static final int ERROR_MIDDLEWARE_NOT_YET_READY = 201; // 0xc9
@@ -43988,13 +43987,13 @@ package android.telephony.mbms {
    field public static final int ERROR_UNABLE_TO_READ_SIM = 206; // 0xce
  }
  public static class MbmsException.InitializationErrors {
  public static class MbmsErrors.InitializationErrors {
    field public static final int ERROR_APP_PERMISSIONS_NOT_GRANTED = 102; // 0x66
    field public static final int ERROR_DUPLICATE_INITIALIZE = 101; // 0x65
    field public static final int ERROR_UNABLE_TO_INITIALIZE = 103; // 0x67
  }
  public static class MbmsException.StreamingErrors {
  public static class MbmsErrors.StreamingErrors {
    field public static final int ERROR_CONCURRENT_SERVICE_LIMIT_REACHED = 301; // 0x12d
    field public static final int ERROR_DUPLICATE_START_STREAM = 303; // 0x12f
    field public static final int ERROR_UNABLE_TO_START_SERVICE = 302; // 0x12e
@@ -44101,7 +44100,6 @@ package android.telephony.mbms.vendor {
    field public static final java.lang.String EXTRA_FREE_URI_LIST = "android.telephony.mbms.extra.FREE_URI_LIST";
    field public static final java.lang.String EXTRA_PAUSED_LIST = "android.telephony.mbms.extra.PAUSED_LIST";
    field public static final java.lang.String EXTRA_PAUSED_URI_LIST = "android.telephony.mbms.extra.PAUSED_URI_LIST";
    field public static final java.lang.String EXTRA_REQUEST = "android.telephony.mbms.extra.REQUEST";
    field public static final java.lang.String EXTRA_SERVICE_ID = "android.telephony.mbms.extra.SERVICE_ID";
    field public static final java.lang.String EXTRA_TEMP_FILES_IN_USE = "android.telephony.mbms.extra.TEMP_FILES_IN_USE";
    field public static final java.lang.String EXTRA_TEMP_FILE_ROOT = "android.telephony.mbms.extra.TEMP_FILE_ROOT";
+6 −8
Original line number Diff line number Diff line
@@ -39957,6 +39957,7 @@ package android.telephony {
    method public void unregisterStateCallback(android.telephony.mbms.DownloadRequest, android.telephony.mbms.DownloadStateCallback);
    field public static final java.lang.String DEFAULT_TOP_LEVEL_TEMP_DIRECTORY = "androidMbmsTempFileRoot";
    field public static final java.lang.String EXTRA_MBMS_COMPLETED_FILE_URI = "android.telephony.extra.MBMS_COMPLETED_FILE_URI";
    field public static final java.lang.String EXTRA_MBMS_DOWNLOAD_REQUEST = "android.telephony.extra.MBMS_DOWNLOAD_REQUEST";
    field public static final java.lang.String EXTRA_MBMS_DOWNLOAD_RESULT = "android.telephony.extra.MBMS_DOWNLOAD_RESULT";
    field public static final java.lang.String EXTRA_MBMS_FILE_INFO = "android.telephony.extra.MBMS_FILE_INFO";
    field public static final int RESULT_CANCELLED = 2; // 0x2
@@ -40611,7 +40612,6 @@ package android.telephony.mbms {
  public final class DownloadRequest implements android.os.Parcelable {
    method public static android.telephony.mbms.DownloadRequest copy(android.telephony.mbms.DownloadRequest);
    method public int describeContents();
    method public android.net.Uri getDestinationUri();
    method public java.lang.String getFileServiceId();
    method public static int getMaxAppIntentSize();
    method public static int getMaxDestinationUriSize();
@@ -40625,7 +40625,6 @@ package android.telephony.mbms {
    ctor public DownloadRequest.Builder();
    method public android.telephony.mbms.DownloadRequest build();
    method public android.telephony.mbms.DownloadRequest.Builder setAppIntent(android.content.Intent);
    method public android.telephony.mbms.DownloadRequest.Builder setDest(android.net.Uri);
    method public android.telephony.mbms.DownloadRequest.Builder setServiceInfo(android.telephony.mbms.FileServiceInfo);
    method public android.telephony.mbms.DownloadRequest.Builder setSource(android.net.Uri);
    method public android.telephony.mbms.DownloadRequest.Builder setSubscriptionId(int);
@@ -40664,20 +40663,19 @@ package android.telephony.mbms {
    method public void onMiddlewareReady();
  }
  public class MbmsException extends java.lang.Exception {
    method public int getErrorCode();
  public class MbmsErrors {
    field public static final int ERROR_MIDDLEWARE_LOST = 3; // 0x3
    field public static final int ERROR_MIDDLEWARE_NOT_BOUND = 2; // 0x2
    field public static final int ERROR_NO_UNIQUE_MIDDLEWARE = 1; // 0x1
    field public static final int SUCCESS = 0; // 0x0
  }
  public static class MbmsException.DownloadErrors {
  public static class MbmsErrors.DownloadErrors {
    field public static final int ERROR_CANNOT_CHANGE_TEMP_FILE_ROOT = 401; // 0x191
    field public static final int ERROR_UNKNOWN_DOWNLOAD_REQUEST = 402; // 0x192
  }
  public static class MbmsException.GeneralErrors {
  public static class MbmsErrors.GeneralErrors {
    field public static final int ERROR_CARRIER_CHANGE_NOT_ALLOWED = 207; // 0xcf
    field public static final int ERROR_IN_E911 = 204; // 0xcc
    field public static final int ERROR_MIDDLEWARE_NOT_YET_READY = 201; // 0xc9
@@ -40687,13 +40685,13 @@ package android.telephony.mbms {
    field public static final int ERROR_UNABLE_TO_READ_SIM = 206; // 0xce
  }
  public static class MbmsException.InitializationErrors {
  public static class MbmsErrors.InitializationErrors {
    field public static final int ERROR_APP_PERMISSIONS_NOT_GRANTED = 102; // 0x66
    field public static final int ERROR_DUPLICATE_INITIALIZE = 101; // 0x65
    field public static final int ERROR_UNABLE_TO_INITIALIZE = 103; // 0x67
  }
  public static class MbmsException.StreamingErrors {
  public static class MbmsErrors.StreamingErrors {
    field public static final int ERROR_CONCURRENT_SERVICE_LIMIT_REACHED = 301; // 0x12d
    field public static final int ERROR_DUPLICATE_START_STREAM = 303; // 0x12f
    field public static final int ERROR_UNABLE_TO_START_SERVICE = 302; // 0x12e
+40 −55
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ import android.telephony.mbms.InternalDownloadSessionCallback;
import android.telephony.mbms.InternalDownloadStateCallback;
import android.telephony.mbms.MbmsDownloadSessionCallback;
import android.telephony.mbms.MbmsDownloadReceiver;
import android.telephony.mbms.MbmsException;
import android.telephony.mbms.MbmsErrors;
import android.telephony.mbms.MbmsTempFileProvider;
import android.telephony.mbms.MbmsUtils;
import android.telephony.mbms.vendor.IMbmsDownloadService;
@@ -97,13 +97,25 @@ public class MbmsDownloadSession implements AutoCloseable {
    /**
     * {@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
     * Indicates the location of the successfully downloaded file within the temp file root set
     * via {@link #setTempFileRootDirectory(File)}.
     * While you may use this file in-place, it is highly encouraged that you move
     * this file to a different location after receiving the download completion intent, as this
     * file resides within the temp file directory.
     *
     * 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_MBMS_COMPLETED_FILE_URI =
            "android.telephony.extra.MBMS_COMPLETED_FILE_URI";

    /**
     * Extra containing the {@link DownloadRequest} for which the download result or file
     * descriptor request is for. Must not be null.
     */
    public static final String EXTRA_MBMS_DOWNLOAD_REQUEST =
            "android.telephony.extra.MBMS_DOWNLOAD_REQUEST";

    /**
     * The default directory name for all MBMS temp files. If you call
     * {@link #download(DownloadRequest)} without first calling
@@ -175,7 +187,7 @@ public class MbmsDownloadSession implements AutoCloseable {
    private IBinder.DeathRecipient mDeathRecipient = new IBinder.DeathRecipient() {
        @Override
        public void binderDied() {
            sendErrorToApp(MbmsException.ERROR_MIDDLEWARE_LOST, "Received death notification");
            sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, "Received death notification");
        }
    };

@@ -242,7 +254,7 @@ public class MbmsDownloadSession implements AutoCloseable {
        MbmsDownloadSession session =
                new MbmsDownloadSession(context, callback, subscriptionId, handler);
        final int result = session.bindAndInitialize();
        if (result != MbmsException.SUCCESS) {
        if (result != MbmsErrors.SUCCESS) {
            sIsInitialized.set(false);
            handler.post(new Runnable() {
                @Override
@@ -272,12 +284,12 @@ public class MbmsDownloadSession implements AutoCloseable {
                        } catch (RuntimeException e) {
                            Log.e(LOG_TAG, "Runtime exception during initialization");
                            sendErrorToApp(
                                    MbmsException.InitializationErrors.ERROR_UNABLE_TO_INITIALIZE,
                                    MbmsErrors.InitializationErrors.ERROR_UNABLE_TO_INITIALIZE,
                                    e.toString());
                            sIsInitialized.set(false);
                            return;
                        }
                        if (result != MbmsException.SUCCESS) {
                        if (result != MbmsErrors.SUCCESS) {
                            sendErrorToApp(result, "Error returned during initialization");
                            sIsInitialized.set(false);
                            return;
@@ -285,7 +297,7 @@ public class MbmsDownloadSession implements AutoCloseable {
                        try {
                            downloadService.asBinder().linkToDeath(mDeathRecipient, 0);
                        } catch (RemoteException e) {
                            sendErrorToApp(MbmsException.ERROR_MIDDLEWARE_LOST,
                            sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST,
                                    "Middleware lost during initialization");
                            sIsInitialized.set(false);
                            return;
@@ -327,13 +339,13 @@ public class MbmsDownloadSession implements AutoCloseable {
        }
        try {
            int returnCode = downloadService.requestUpdateFileServices(mSubscriptionId, classList);
            if (returnCode != MbmsException.SUCCESS) {
            if (returnCode != MbmsErrors.SUCCESS) {
                sendErrorToApp(returnCode, null);
            }
        } catch (RemoteException e) {
            Log.w(LOG_TAG, "Remote process died");
            mService.set(null);
            sendErrorToApp(MbmsException.ERROR_MIDDLEWARE_LOST, null);
            sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
        }
    }

@@ -352,7 +364,7 @@ public class MbmsDownloadSession implements AutoCloseable {
     * Before calling this method, the app must cancel all of its pending
     * {@link DownloadRequest}s via {@link #cancelDownload(DownloadRequest)}. If this is not done,
     * you will receive an asynchronous error with code
     * {@link MbmsException.DownloadErrors#ERROR_CANNOT_CHANGE_TEMP_FILE_ROOT} unless the
     * {@link MbmsErrors.DownloadErrors#ERROR_CANNOT_CHANGE_TEMP_FILE_ROOT} unless the
     * provided directory is the same as what has been previously configured.
     *
     * The {@link File} supplied as a root temp file directory must already exist. If not, an
@@ -381,12 +393,12 @@ public class MbmsDownloadSession implements AutoCloseable {

        try {
            int result = downloadService.setTempFileRootDirectory(mSubscriptionId, filePath);
            if (result != MbmsException.SUCCESS) {
            if (result != MbmsErrors.SUCCESS) {
                sendErrorToApp(result, null);
            }
        } catch (RemoteException e) {
            mService.set(null);
            sendErrorToApp(MbmsException.ERROR_MIDDLEWARE_LOST, null);
            sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
            return;
        }

@@ -464,13 +476,12 @@ public class MbmsDownloadSession implements AutoCloseable {
            setTempFileRootDirectory(tempRootDirectory);
        }

        checkValidDownloadDestination(request);
        writeDownloadRequestToken(request);
        try {
            downloadService.download(request);
        } catch (RemoteException e) {
            mService.set(null);
            sendErrorToApp(MbmsException.ERROR_MIDDLEWARE_LOST, null);
            sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
        }
    }

@@ -491,7 +502,7 @@ public class MbmsDownloadSession implements AutoCloseable {
            return downloadService.listPendingDownloads(mSubscriptionId);
        } catch (RemoteException e) {
            mService.set(null);
            sendErrorToApp(MbmsException.ERROR_MIDDLEWARE_LOST, null);
            sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
            return Collections.emptyList();
        }
    }
@@ -523,8 +534,8 @@ public class MbmsDownloadSession implements AutoCloseable {

        try {
            int result = downloadService.registerStateCallback(request, internalCallback);
            if (result != MbmsException.SUCCESS) {
                if (result == MbmsException.DownloadErrors.ERROR_UNKNOWN_DOWNLOAD_REQUEST) {
            if (result != MbmsErrors.SUCCESS) {
                if (result == MbmsErrors.DownloadErrors.ERROR_UNKNOWN_DOWNLOAD_REQUEST) {
                    throw new IllegalArgumentException("Unknown download request.");
                }
                sendErrorToApp(result, null);
@@ -532,7 +543,7 @@ public class MbmsDownloadSession implements AutoCloseable {
            }
        } catch (RemoteException e) {
            mService.set(null);
            sendErrorToApp(MbmsException.ERROR_MIDDLEWARE_LOST, null);
            sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
            return;
        }
        mInternalDownloadCallbacks.put(callback, internalCallback);
@@ -563,15 +574,15 @@ public class MbmsDownloadSession implements AutoCloseable {

            try {
                int result = downloadService.unregisterStateCallback(request, internalCallback);
                if (result != MbmsException.SUCCESS) {
                    if (result == MbmsException.DownloadErrors.ERROR_UNKNOWN_DOWNLOAD_REQUEST) {
                if (result != MbmsErrors.SUCCESS) {
                    if (result == MbmsErrors.DownloadErrors.ERROR_UNKNOWN_DOWNLOAD_REQUEST) {
                        throw new IllegalArgumentException("Unknown download request.");
                    }
                    sendErrorToApp(result, null);
                }
            } catch (RemoteException e) {
                mService.set(null);
                sendErrorToApp(MbmsException.ERROR_MIDDLEWARE_LOST, null);
                sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
            }
        } finally {
            InternalDownloadStateCallback internalCallback =
@@ -598,8 +609,8 @@ public class MbmsDownloadSession implements AutoCloseable {

        try {
            int result = downloadService.cancelDownload(downloadRequest);
            if (result != MbmsException.SUCCESS) {
                if (result == MbmsException.DownloadErrors.ERROR_UNKNOWN_DOWNLOAD_REQUEST) {
            if (result != MbmsErrors.SUCCESS) {
                if (result == MbmsErrors.DownloadErrors.ERROR_UNKNOWN_DOWNLOAD_REQUEST) {
                    throw new IllegalArgumentException("Unknown download request.");
                }
                sendErrorToApp(result, null);
@@ -607,7 +618,7 @@ public class MbmsDownloadSession implements AutoCloseable {
            }
        } catch (RemoteException e) {
            mService.set(null);
            sendErrorToApp(MbmsException.ERROR_MIDDLEWARE_LOST, null);
            sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
            return;
        }
        deleteDownloadRequestToken(downloadRequest);
@@ -635,7 +646,7 @@ public class MbmsDownloadSession implements AutoCloseable {
            return downloadService.getDownloadStatus(downloadRequest, fileInfo);
        } catch (RemoteException e) {
            mService.set(null);
            sendErrorToApp(MbmsException.ERROR_MIDDLEWARE_LOST, null);
            sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
            return STATUS_UNKNOWN;
        }
    }
@@ -668,15 +679,15 @@ public class MbmsDownloadSession implements AutoCloseable {

        try {
            int result = downloadService.resetDownloadKnowledge(downloadRequest);
            if (result != MbmsException.SUCCESS) {
                if (result == MbmsException.DownloadErrors.ERROR_UNKNOWN_DOWNLOAD_REQUEST) {
            if (result != MbmsErrors.SUCCESS) {
                if (result == MbmsErrors.DownloadErrors.ERROR_UNKNOWN_DOWNLOAD_REQUEST) {
                    throw new IllegalArgumentException("Unknown download request.");
                }
                sendErrorToApp(result, null);
            }
        } catch (RemoteException e) {
            mService.set(null);
            sendErrorToApp(MbmsException.ERROR_MIDDLEWARE_LOST, null);
            sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
        }
    }

@@ -752,32 +763,6 @@ public class MbmsDownloadSession implements AutoCloseable {
        return new File(tempFileLocation, downloadTokenFileName);
    }

    /**
     * Verifies the following:
     * If a request is multi-part,
     *     1. Destination Uri must exist and be a directory
     *     2. Directory specified must contain no files.
     * Otherwise
     *     1. The file specified by the destination Uri must not exist.
     */
    private void checkValidDownloadDestination(DownloadRequest request) {
        File toFile = new File(request.getDestinationUri().getSchemeSpecificPart());
        if (request.isMultipartDownload()) {
            if (!toFile.isDirectory()) {
                throw new IllegalArgumentException("Multipart download must specify valid " +
                        "destination directory.");
            }
            if (toFile.listFiles().length > 0) {
                throw new IllegalArgumentException("Destination directory must be clear of all " +
                        "files.");
            }
        } else {
            if (toFile.exists()) {
                throw new IllegalArgumentException("Destination file must not exist.");
            }
        }
    }

    private void sendErrorToApp(int errorCode, String message) {
        try {
            mInternalCallback.onError(errorCode, message);
+13 −13

File changed.

Preview size limit exceeded, changes collapsed.

Loading