Strip out unnecessary Downloads class

This commit is contained in:
Moez Bhatti
2018-01-17 04:39:48 -05:00
parent fd95a4f1af
commit 0a9a4566b8
2 changed files with 16 additions and 847 deletions
@@ -18,7 +18,6 @@ package com.google.android.mms.util_alt;
import android.content.Context;
import android.drm.DrmConvertedStatus;
import android.drm.DrmManagerClient;
import android.provider.Downloads;
import com.klinker.android.logger.Log;
import java.io.FileNotFoundException;
@@ -31,6 +30,11 @@ public class DrmConvertSession {
private int mConvertSessionId;
private static final String TAG = "DrmConvertSession";
private static final int STATUS_UNKNOWN_ERROR = 491;
private static final int STATUS_NOT_ACCEPTABLE = 406;
private static final int STATUS_SUCCESS = 200;
private static final int STATUS_FILE_ERROR = 492;
private DrmConvertSession(DrmManagerClient drmClient, int convertSessionId) {
mDrmClient = drmClient;
mConvertSessionId = convertSessionId;
@@ -114,37 +118,37 @@ 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.
*/
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 +
@@ -154,7 +158,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);
}