微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > 访问浏览器时.由于can't know size of download,giving up的原因而导致下载失败的 ...

访问浏览器时.由于can't know size of download,giving up的原因而导致下载失败的 ...

时间:10-02 整理:3721RD 点击:
[DESCRIPTION]

访问浏览器时.无法下载某些文件的解决方法

[SOLUTION]

如果遇到有下载失败的情况时.请打开mtk log里的mobile log->APLOG->main_log
如果能搜索到类似下面的
Aborting request for download 2,currentThread id: 64,: can't know size of
download, giving up时.
则请修改:
请修改
alps\packages\providers\DownloadProvider\src\com\android\providers\downloADS\DownloadTh
read.Java 文件 中
1176 行 private void readResponseHeaders(State state, InnerState innerState,
HttpResponse response) 函数内容
private void readResponseHeaders(State state, InnerState innerState, HttpResponse
response)
throws StopRequestException {
Header header = response.getFirstHeader("Content-Disposition");
if (header != null) {
innerState.mHeaderContentDisposition = header.getValue();
}
header = response.getFirstHeader("Content-Location");
if (header != null) {
innerState.mHeaderContentLocation = header.getValue();
}
if (state.MMImeType == null) {
header = response.getFirstHeader("Content-Type");
if (header != null) {
state.mMimeType = Intent.normalizeMimeType(header.getValue());
}
}
header = response.getFirstHeader("ETag");
if (header != null) {
state.mHeaderETag = header.getValue();
}
String headerTransferEncoding = null;
header = response.getFirstHeader("Transfer-Encoding");
if (header != null) {
headerTransferEncoding = header.getValue();
}
if (headerTransferEncoding == null) {
header = response.getFirstHeader("Content-Length");
if (header != null) {
innerState.mHeaderContentLength = header.getValue();
Log.v(Constants.TAG, "mInfo.mTotalBytes: " + mInfo.mTotalBytes);
state.mTotalBytes = mInfo.mTotalBytes =
Long.parseLong(innerState.mHeaderContentLength);
Log.v(Constants.TAG, "mInfo.mTotalBytes: " + mInfo.mTotalBytes);
}
} else {
// Ignore content-length with transfer-encoding - 2616 4.4 3
if (Constants.LOGVV) {
Log.v(Constants.TAG,
"ignoring content-length because of xfer-encoding");
}
}
// if (Constants.LOGVV) {
Log.v(Constants.TAG, "Content-Disposition: " +
innerState.mHeaderContentDisposition);
Log.v(Constants.TAG, "Content-Length: " + innerState.mHeaderContentLength);
Log.v(Constants.TAG, "Content-Location: " + innerState.mHeaderContentLocation);
Log.v(Constants.TAG, "Content-Type: " + state.mMimeType);
Log.v(Constants.TAG, "ETag: " + state.mHeaderETag);
Log.v(Constants.TAG, "Transfer-Encoding: " + headerTransferEncoding);
// }
boolean noSizeInfo = innerState.mHeaderContentLength == null
&& (headerTransferEncoding == null
|| !headerTransferEncoding.equalsIgnoreCase("chunked"));
if (!mInfo.mNoIntegrity && noSizeInfo) {
throw new StopRequestException(Downloads.Impl.STATUS_HTTP_DATA_ERROR,
"can't know size of download, giving up");
}
/// M: Add this for OMA_DL
/// OMA_DL HLD: 4.4 Installation Failure: in the case of retrieval errors
/// If MimeType is not same with .dd file description, throw exception
ATTRIBUTE_MISMATCH exception
/// && !state.mMimeType.equals("audio/mp3") @{
if (Downloads.Impl.MTK_OMA_DOWNLOAD_SUPPORT && state.mOmaDownload == 1 &&
!state.mMimeType.equalsIgnoreCase("application/vnd.oma.dd+xml")) {
header = response.getFirstHeader("Content-Type");
if (header != null) {
String mimeType = sanitizeMimeType(header.getValue());
Xlog.d(Constants.LOG_OMA_DL, "DownloadThread:readResponseHeader():" +
" header mimeType is:" + mimeType
+ "state.mMimeType is :" + state.mMimeType);
if (Helpers.isMtkDRMFile(mimeType)) {
state.mMimeType = mimeType;
return;
}
if (((state.mMimeType.equals("audio/mp3") || state.mMimeType.equals("audio/mpeg")) &&
(mimeType.equals("audio/mp3") || mimeType.equals("audio/mpeg")))) {
return;
}
// This means ATTRIBUTE_MISMATCH
if (!mimeType.equals(state.mMimeType)) {
ContentValues values = new ContentValues();
values.put(Downloads.Impl.COLUMN_OMA_DOWNLOAD_STATUS,
Downloads.Impl.OMADL_STATUS_ERROR_ATTRIBUTE_MISMATCH);
mContext.getContentResolver().update(mInfo.getAllDownloadsUri(), values, null, null);
state.mOmaDownloadStatus = Downloads.Impl.OMADL_STATUS_ERROR_ATTRIBUTE_MISMATCH;
throw new StopRequestException(Downloads.Impl.OMADL_STATUS_ERROR_ATTRIBUTE_MISMATCH,
Downloads.Impl.OMADL_OCCUR_ERROR_NEED_NOTIFY);
}
}
}
/// @}
}
修改为:
private void readResponseHeaders(State state, InnerState innerState, HttpResponse
response)
throws StopRequestException {
Header header = response.getFirstHeader("Content-Disposition");
if (header != null) {
innerState.mHeaderContentDisposition = header.getValue();
}
header = response.getFirstHeader("Content-Location");
if (header != null) {
innerState.mHeaderContentLocation = header.getValue();
}
if (state.mMimeType == null) {
header = response.getFirstHeader("Content-Type");
if (header != null) {
state.mMimeType = Intent.normalizeMimeType(header.getValue());
}
}
header = response.getFirstHeader("ETag");
if (header != null) {
state.mHeaderETag = header.getValue();
}
String headerTransferEncoding = null;
header = response.getFirstHeader("Transfer-Encoding");
if (header != null) {
headerTransferEncoding = header.getValue();
}
if (headerTransferEncoding == null) {
header = response.getFirstHeader("Content-Length");
if (header != null) {
innerState.mHeaderContentLength = header.getValue();
Log.v(Constants.TAG, "mInfo.mTotalBytes: " + mInfo.mTotalBytes);
state.mTotalBytes = mInfo.mTotalBytes =
Long.parseLong(innerState.mHeaderContentLength);
Log.v(Constants.TAG, "mInfo.mTotalBytes: " + mInfo.mTotalBytes);
}
} else {
// Ignore content-length with transfer-encoding - 2616 4.4 3
if (Constants.LOGVV) {
Log.v(Constants.TAG,
"ignoring content-length because of xfer-encoding");
}
}
// if (Constants.LOGVV) {
Log.v(Constants.TAG, "Content-Disposition: " +
innerState.mHeaderContentDisposition);
Log.v(Constants.TAG, "Content-Length: " + innerState.mHeaderContentLength);
Log.v(Constants.TAG, "Content-Location: " + innerState.mHeaderContentLocation);
Log.v(Constants.TAG, "Content-Type: " + state.mMimeType);
Log.v(Constants.TAG, "ETag: " + state.mHeaderETag);
Log.v(Constants.TAG, "Transfer-Encoding: " + headerTransferEncoding);
// }
boolean noSizeInfo = innerState.mHeaderContentLength == null
&& (headerTransferEncoding == null
|| !headerTransferEncoding.equalsIgnoreCase("chunked"));
/*
if (!mInfo.mNoIntegrity && noSizeInfo) {
throw new StopRequestException(Downloads.Impl.STATUS_HTTP_DATA_ERROR,
"can't know size of download, giving up");
}
*/
/// M: Add this for OMA_DL
/// OMA_DL HLD: 4.4 Installation Failure: in the case of retrieval errors
/// If MimeType is not same with .dd file description, throw exception
ATTRIBUTE_MISMATCH exception
/// && !state.mMimeType.equals("audio/mp3") @{
if (Downloads.Impl.MTK_OMA_DOWNLOAD_SUPPORT && state.mOmaDownload == 1 &&
!state.mMimeType.equalsIgnoreCase("application/vnd.oma.dd+xml")) {
header = response.getFirstHeader("Content-Type");
if (header != null) {
String mimeType = sanitizeMimeType(header.getValue());
Xlog.d(Constants.LOG_OMA_DL, "DownloadThread:readResponseHeader():" +
" header mimeType is:" + mimeType
+ "state.mMimeType is :" + state.mMimeType);
if (Helpers.isMtkDRMFile(mimeType)) {
state.mMimeType = mimeType;
return;
}
if (((state.mMimeType.equals("audio/mp3") || state.mMimeType.equals("audio/mpeg")) &&
(mimeType.equals("audio/mp3") || mimeType.equals("audio/mpeg")))) {
return;
}
// This means ATTRIBUTE_MISMATCH
if (!mimeType.equals(state.mMimeType)) {
ContentValues values = new ContentValues();
values.put(Downloads.Impl.COLUMN_OMA_DOWNLOAD_STATUS,
Downloads.Impl.OMADL_STATUS_ERROR_ATTRIBUTE_MISMATCH);
mContext.getContentResolver().update(mInfo.getAllDownloadsUri(), values, null, null);
state.mOmaDownloadStatus = Downloads.Impl.OMADL_STATUS_ERROR_ATTRIBUTE_MISMATCH;
throw new StopRequestException(Downloads.Impl.OMADL_STATUS_ERROR_ATTRIBUTE_MISMATCH,
Downloads.Impl.OMADL_OCCUR_ERROR_NEED_NOTIFY);
}
}
}
/// @}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top