summaryrefslogtreecommitdiff
path: root/telephony/common
diff options
context:
space:
mode:
authorAmit Mahajan <amitmahajan@google.com>2020-01-23 17:38:28 -0800
committerAmit Mahajan <amitmahajan@google.com>2020-01-27 15:19:33 -0800
commit113d4543ad3c758772a616cc17317a479cd99c19 (patch)
treec98fff5687ddd115f18df4d58b5a0447b0b304bc /telephony/common
parent8fe9f642714217f45603f7772711bb890d894374 (diff)
Remove the usage of Downloads.* constants.
Replaced them with local constants as it is only for internal use. Test: basic sanity Bug: 140908357 Change-Id: Icebabc4d16c2e6d5b6e2fb311fee697e8acfa285
Diffstat (limited to 'telephony/common')
-rw-r--r--telephony/common/com/google/android/mms/util/DrmConvertSession.java30
1 files changed, 18 insertions, 12 deletions
diff --git a/telephony/common/com/google/android/mms/util/DrmConvertSession.java b/telephony/common/com/google/android/mms/util/DrmConvertSession.java
index 156c7ad8baac..17ab15470670 100644
--- a/telephony/common/com/google/android/mms/util/DrmConvertSession.java
+++ b/telephony/common/com/google/android/mms/util/DrmConvertSession.java
@@ -20,7 +20,6 @@ import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.drm.DrmConvertedStatus;
import android.drm.DrmManagerClient;
-import android.provider.Downloads;
import android.util.Log;
import java.io.FileNotFoundException;
@@ -33,6 +32,13 @@ public class DrmConvertSession {
private int mConvertSessionId;
private static final String TAG = "DrmConvertSession";
+ // These values are copied from Downloads.Impl.* for backward compatibility since
+ // {@link #close()} that uses it is marked @UnsupportedAppUsage.
+ public static final int STATUS_SUCCESS = 200;
+ public static final int STATUS_NOT_ACCEPTABLE = 406;
+ public static final int STATUS_UNKNOWN_ERROR = 491;
+ public static final int STATUS_FILE_ERROR = 492;
+
private DrmConvertSession(DrmManagerClient drmClient, int convertSessionId) {
mDrmClient = drmClient;
mConvertSessionId = convertSessionId;
@@ -118,38 +124,38 @@ public class DrmConvertSession {
* Ends a conversion session of a file.
*
* @param fileName The filename of the converted file.
- * @return Downloads.Impl.STATUS_SUCCESS if execution is ok.
- * Downloads.Impl.STATUS_FILE_ERROR in case converted file can not
- * be accessed. Downloads.Impl.STATUS_NOT_ACCEPTABLE if a problem
+ * @return STATUS_SUCCESS if execution is ok.
+ * STATUS_FILE_ERROR in case converted file can not
+ * be accessed. STATUS_NOT_ACCEPTABLE if a problem
* occurs when accessing drm framework.
- * Downloads.Impl.STATUS_UNKNOWN_ERROR if a general error occurred.
+ * STATUS_UNKNOWN_ERROR if a general error occurred.
*/
@UnsupportedAppUsage
public int close(String filename) {
DrmConvertedStatus convertedStatus = null;
- int result = Downloads.Impl.STATUS_UNKNOWN_ERROR;
+ int result = STATUS_UNKNOWN_ERROR;
if (mDrmClient != null && mConvertSessionId >= 0) {
try {
convertedStatus = mDrmClient.closeConvertSession(mConvertSessionId);
if (convertedStatus == null ||
convertedStatus.statusCode != DrmConvertedStatus.STATUS_OK ||
convertedStatus.convertedData == null) {
- result = Downloads.Impl.STATUS_NOT_ACCEPTABLE;
+ result = STATUS_NOT_ACCEPTABLE;
} else {
RandomAccessFile rndAccessFile = null;
try {
rndAccessFile = new RandomAccessFile(filename, "rw");
rndAccessFile.seek(convertedStatus.offset);
rndAccessFile.write(convertedStatus.convertedData);
- result = Downloads.Impl.STATUS_SUCCESS;
+ result = STATUS_SUCCESS;
} catch (FileNotFoundException e) {
- result = Downloads.Impl.STATUS_FILE_ERROR;
+ result = STATUS_FILE_ERROR;
Log.w(TAG, "File: " + filename + " could not be found.", e);
} catch (IOException e) {
- result = Downloads.Impl.STATUS_FILE_ERROR;
+ result = STATUS_FILE_ERROR;
Log.w(TAG, "Could not access File: " + filename + " .", e);
} catch (IllegalArgumentException e) {
- result = Downloads.Impl.STATUS_FILE_ERROR;
+ result = STATUS_FILE_ERROR;
Log.w(TAG, "Could not open file in mode: rw", e);
} catch (SecurityException e) {
Log.w(TAG, "Access to File: " + filename +
@@ -159,7 +165,7 @@ public class DrmConvertSession {
try {
rndAccessFile.close();
} catch (IOException e) {
- result = Downloads.Impl.STATUS_FILE_ERROR;
+ result = STATUS_FILE_ERROR;
Log.w(TAG, "Failed to close File:" + filename
+ ".", e);
}