- 易迪拓培训,专注于微波、射频、天线设计工程师的培养
访问浏览器时.由于can't know size of download,giving up的原因而导致下载失败的 ...
录入:edatop.com 点击:
[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);
}
}
}
/// @}
访问浏览器时.无法下载某些文件的解决方法
[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);
}
}
}
/// @}
申明:网友回复良莠不齐,仅供参考。如需专业帮助,请学习易迪拓培训专家讲授的ADS视频培训课程。
上一篇:如何修改默认小时制
下一篇:synplify2018.09破解问题
ADS培训课程推荐详情>>
国内最全面、最专业的Agilent ADS培训课程,可以帮助您从零开始,全面系统学习ADS设计应用【More..】
- Agilent ADS教学培训课程套装
- 两周学会ADS2011、ADS2013视频教程
- ADS2012、ADS2013射频电路设计详解
- ADS高低阻抗线微带滤波器设计培训教程
- ADS混频器仿真分析实例视频培训课程
- ADS Momentum电磁仿真设计视频课程
- ADS射频电路与通信系统设计高级培训
- ADS Layout和电磁仿真设计培训视频
- ADS Workspace and Simulators Training Course
- ADS Circuit Simulation Training Course
- ADS Layout and EM Simulation Training Course
- Agilent ADS 内部原版培训教材合集