当前位置: 首页>>代码示例>>Java>>正文


Java Constants.LOGVV属性代码示例

本文整理汇总了Java中com.google.android.vending.expansion.downloader.Constants.LOGVV属性的典型用法代码示例。如果您正苦于以下问题:Java Constants.LOGVV属性的具体用法?Java Constants.LOGVV怎么用?Java Constants.LOGVV使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.google.android.vending.expansion.downloader.Constants的用法示例。


在下文中一共展示了Constants.LOGVV属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reportProgress

/**
 * Report download progress through the database if necessary.
 */
private void reportProgress(State state, InnerState innerState) {
    long now = System.currentTimeMillis();
    if (innerState.mBytesSoFar - innerState.mBytesNotified
            > Constants.MIN_PROGRESS_STEP
            && now - innerState.mTimeLastNotification
            > Constants.MIN_PROGRESS_TIME) {
        // we store progress updates to the database here
        mInfo.mCurrentBytes = innerState.mBytesSoFar;
        mDB.updateDownloadCurrentBytes(mInfo);

        innerState.mBytesNotified = innerState.mBytesSoFar;
        innerState.mTimeLastNotification = now;

        long totalBytesSoFar = innerState.mBytesThisSession + mService.mBytesSoFar;

        if (Constants.LOGVV) {
            Log.v(Constants.TAG, "downloaded " + mInfo.mCurrentBytes + " out of "
                    + mInfo.mTotalBytes);
            Log.v(Constants.TAG, "     total " + totalBytesSoFar + " out of "
                    + mService.mTotalLength);
        }

        mService.notifyUpdateBytes(totalBytesSoFar);
    }
}
 
开发者ID:snoozinsquatch,项目名称:unity-obb-downloader,代码行数:28,代码来源:DownloadThread.java

示例2: handleServiceUnavailable

/**
 * Handle a 503 Service Unavailable status by processing the Retry-After
 * header.
 */
private void handleServiceUnavailable(State state, HttpURLConnection connection) throws StopRequest {
    if (Constants.LOGVV) {
        Log.v(Constants.TAG, "got HTTP response code 503");
    }
    state.mCountRetry = true;
    String retryAfterValue = connection.getHeaderField("Retry-After");
    if (retryAfterValue != null) {
        try {
            if (Constants.LOGVV) {
                Log.v(Constants.TAG, "Retry-After :" + retryAfterValue);
            }
            state.mRetryAfter = Integer.parseInt(retryAfterValue);
            if (state.mRetryAfter < 0) {
                state.mRetryAfter = 0;
            } else {
                if (state.mRetryAfter < Constants.MIN_RETRY_AFTER) {
                    state.mRetryAfter = Constants.MIN_RETRY_AFTER;
                } else if (state.mRetryAfter > Constants.MAX_RETRY_AFTER) {
                    state.mRetryAfter = Constants.MAX_RETRY_AFTER;
                }
                state.mRetryAfter += Helpers.sRandom.nextInt(Constants.MIN_RETRY_AFTER + 1);
                state.mRetryAfter *= 1000;
            }
        } catch (NumberFormatException ex) {
            // ignored - retryAfter stays 0 in this case.
        }
    }
    throw new StopRequest(DownloaderService.STATUS_WAITING_TO_RETRY,
            "got 503 Service Unavailable, will retry later");
}
 
开发者ID:snoozinsquatch,项目名称:unity-obb-downloader,代码行数:34,代码来源:DownloadThread.java

示例3: updateNetworkState

private void updateNetworkState(NetworkInfo info) {
    boolean isConnected = mIsConnected;
    boolean isFailover = mIsFailover;
    boolean isCellularConnection = mIsCellularConnection;
    boolean isRoaming = mIsRoaming;
    boolean isAtLeast3G = mIsAtLeast3G;
    if (null != info) {
        mIsRoaming = info.isRoaming();
        mIsFailover = info.isFailover();
        mIsConnected = info.isConnected();
        updateNetworkType(info.getType(), info.getSubtype());
    } else {
        mIsRoaming = false;
        mIsFailover = false;
        mIsConnected = false;
        updateNetworkType(-1, -1);
    }
    mStateChanged = (mStateChanged || isConnected != mIsConnected
            || isFailover != mIsFailover
            || isCellularConnection != mIsCellularConnection
            || isRoaming != mIsRoaming || isAtLeast3G != mIsAtLeast3G);
    if (Constants.LOGVV) {
        if (mStateChanged) {
            Log.v(LOG_TAG, "Network state changed: ");
            Log.v(LOG_TAG, "Starting State: " +
                    (isConnected ? "Connected " : "Not Connected ") +
                    (isCellularConnection ? "Cellular " : "WiFi ") +
                    (isRoaming ? "Roaming " : "Local ") +
                    (isAtLeast3G ? "3G+ " : "<3G "));
            Log.v(LOG_TAG, "Ending State: " +
                    (mIsConnected ? "Connected " : "Not Connected ") +
                    (mIsCellularConnection ? "Cellular " : "WiFi ") +
                    (mIsRoaming ? "Roaming " : "Local ") +
                    (mIsAtLeast3G ? "3G+ " : "<3G "));

            if (isServiceRunning()) {
                if (mIsRoaming) {
                    mStatus = STATUS_WAITING_FOR_NETWORK;
                    mControl = CONTROL_PAUSED;
                } else if (mIsCellularConnection) {
                    DownloadsDB db = DownloadsDB.getDB(this);
                    int flags = db.getFlags();
                    if (0 == (flags & FLAGS_DOWNLOAD_OVER_CELLULAR)) {
                        mStatus = STATUS_QUEUED_FOR_WIFI;
                        mControl = CONTROL_PAUSED;
                    }
                }
            }

        }
    }
}
 
开发者ID:snoozinsquatch,项目名称:unity-obb-downloader,代码行数:52,代码来源:DownloaderService.java

示例4: handleRedirect

/**
 * Handle a 3xx redirect status.
 */
private void handleRedirect(State state, HttpResponse response, int statusCode)
        throws StopRequest, RetryDownload {
    if (Constants.LOGVV) {
        Log.v(Constants.TAG, "got HTTP redirect " + statusCode);
    }
    if (state.mRedirectCount >= Constants.MAX_REDIRECTS) {
        throw new StopRequest(DownloaderService.STATUS_TOO_MANY_REDIRECTS, "too many redirects");
    }
    Header header = response.getFirstHeader("Location");
    if (header == null) {
        return;
    }
    if (Constants.LOGVV) {
        Log.v(Constants.TAG, "Location :" + header.getValue());
    }

    String newUri;
    try {
        newUri = new URI(mInfo.mUri).resolve(new URI(header.getValue())).toString();
    } catch (URISyntaxException ex) {
        if (Constants.LOGV) {
            Log.d(Constants.TAG, "Couldn't resolve redirect URI " + header.getValue()
                    + " for " + mInfo.mUri);
        }
        throw new StopRequest(DownloaderService.STATUS_HTTP_DATA_ERROR,
                "Couldn't resolve redirect URI");
    }
    ++state.mRedirectCount;
    state.mRequestUri = newUri;
    if (statusCode == 301 || statusCode == 303) {
        // use the new URI for all future requests (should a retry/resume be
        // necessary)
        state.mNewUri = newUri;
    }
    throw new RetryDownload();
}
 
开发者ID:SlotNSlot,项目名称:SlotNSlot_Android,代码行数:39,代码来源:DownloadThread.java

示例5: handleServiceUnavailable

/**
 * Handle a 503 Service Unavailable status by processing the Retry-After
 * header.
 */
private void handleServiceUnavailable(State state, HttpResponse response) throws StopRequest {
    if (Constants.LOGVV) {
        Log.v(Constants.TAG, "got HTTP response code 503");
    }
    state.mCountRetry = true;
    Header header = response.getFirstHeader("Retry-After");
    if (header != null) {
        try {
            if (Constants.LOGVV) {
                Log.v(Constants.TAG, "Retry-After :" + header.getValue());
            }
            state.mRetryAfter = Integer.parseInt(header.getValue());
            if (state.mRetryAfter < 0) {
                state.mRetryAfter = 0;
            } else {
                if (state.mRetryAfter < Constants.MIN_RETRY_AFTER) {
                    state.mRetryAfter = Constants.MIN_RETRY_AFTER;
                } else if (state.mRetryAfter > Constants.MAX_RETRY_AFTER) {
                    state.mRetryAfter = Constants.MAX_RETRY_AFTER;
                }
                state.mRetryAfter += Helpers.sRandom.nextInt(Constants.MIN_RETRY_AFTER + 1);
                state.mRetryAfter *= 1000;
            }
        } catch (NumberFormatException ex) {
            // ignored - retryAfter stays 0 in this case.
        }
    }
    throw new StopRequest(DownloaderService.STATUS_WAITING_TO_RETRY,
            "got 503 Service Unavailable, will retry later");
}
 
开发者ID:SlotNSlot,项目名称:SlotNSlot_Android,代码行数:34,代码来源:DownloadThread.java

示例6: handleRedirect

/**
 * Handle a 3xx redirect status.
 */
private void handleRedirect(State state, HttpResponse response, int statusCode)
        throws StopRequest, RetryDownload {
    if (Constants.LOGVV) {
        Log.v(Constants.TAG, "got HTTP redirect " + statusCode);
    }
    if (state.mRedirectCount >= Constants.MAX_REDIRECTS) {
        throw new StopRequest(DownloaderService.STATUS_TOO_MANY_REDIRECTS, "too many redirects");
    }
    Header header = response.getFirstHeader("Location");
    if (header == null) {
        return;
    }
    if (Constants.LOGVV) {
        Log.v(Constants.TAG, "Location :" + header.getValue());
    }

    String newUri;
    try {
        newUri = new URI(mInfo.mUri).resolve(new URI(header.getValue())).toString();
    } catch (URISyntaxException ex) {
        if (Constants.LOGV) {
            Log.d(Constants.TAG, "Couldn't resolve redirect URI " + header.getValue()
                    + " for " + mInfo.mUri);
        }
        throw new StopRequest(DownloaderService.STATUS_HTTP_DATA_ERROR,
                "Couldn't resolve redirect URI");
    }
    ++state.mRedirectCount;
    state.mRequestUri = newUri;
    throw new RetryDownload();
}
 
开发者ID:CmdrStardust,项目名称:Alite,代码行数:34,代码来源:DownloadThread.java

示例7: readResponseHeaders

/**
 * Read headers from the HTTP response and store them into local state.
 */
private void readResponseHeaders(State state, InnerState innerState, HttpURLConnection response)
        throws StopRequest {
    String value = response.getHeaderField("Content-Disposition");
    if (value != null) {
        innerState.mHeaderContentDisposition = value;
    }
    value = response.getHeaderField("Content-Location");
    if (value != null) {
        innerState.mHeaderContentLocation = value;
    }
    value = response.getHeaderField("ETag");
    if (value != null) {
        innerState.mHeaderETag = value;
    }
    String headerTransferEncoding = null;
    value = response.getHeaderField("Transfer-Encoding");
    if (value != null) {
        headerTransferEncoding = value;
    }
    String headerContentType = null;
    value = response.getHeaderField("Content-Type");
    if (value != null) {
        headerContentType = value;
        if (!headerContentType.equals("application/vnd.android.obb")) {
            throw new StopRequest(DownloaderService.STATUS_FILE_DELIVERED_INCORRECTLY,
                    "file delivered with incorrect Mime type");
        }
    }

    if (headerTransferEncoding == null) {
        long contentLength = response.getContentLength();
        if (value != null) {
            // this is always set from Market
            if (contentLength != -1 && contentLength != mInfo.mTotalBytes) {
                // we're most likely on a bad wifi connection -- we should
                // probably
                // also look at the mime type --- but the size mismatch is
                // enough
                // to tell us that something is wrong here
                Log.e(Constants.TAG, "Incorrect file size delivered.");
            } else {
                innerState.mHeaderContentLength = Long.toString(contentLength);
            }
        }
    } 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, "ETag: " + innerState.mHeaderETag);
        Log.v(Constants.TAG, "Transfer-Encoding: " + headerTransferEncoding);
    }

    boolean noSizeInfo = innerState.mHeaderContentLength == null
            && (headerTransferEncoding == null
            || !headerTransferEncoding.equalsIgnoreCase("chunked"));
    if (noSizeInfo) {
        throw new StopRequest(DownloaderService.STATUS_HTTP_DATA_ERROR,
                "can't know size of download, giving up");
    }
}
 
开发者ID:snoozinsquatch,项目名称:unity-obb-downloader,代码行数:71,代码来源:DownloadThread.java

示例8: readResponseHeaders

/**
 * Read headers from the HTTP response and store them into local state.
 */
private void readResponseHeaders(State state, InnerState innerState, HttpResponse response)
        throws StopRequest {
    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();
    }
    header = response.getFirstHeader("ETag");
    if (header != null) {
        innerState.mHeaderETag = header.getValue();
    }
    String headerTransferEncoding = null;
    header = response.getFirstHeader("Transfer-Encoding");
    if (header != null) {
        headerTransferEncoding = header.getValue();
    }
    String headerContentType = null;
    header = response.getFirstHeader("Content-Type");
    if (header != null) {
        headerContentType = header.getValue();
        if (!headerContentType.equals("application/vnd.android.obb")) {
            throw new StopRequest(DownloaderService.STATUS_FILE_DELIVERED_INCORRECTLY,
                    "file delivered with incorrect Mime type");
        }
    }

    if (headerTransferEncoding == null) {
        header = response.getFirstHeader("Content-Length");
        if (header != null) {
            innerState.mHeaderContentLength = header.getValue();
            // this is always set from Market
            long contentLength = Long.parseLong(innerState.mHeaderContentLength);
            if (contentLength != -1 && contentLength != mInfo.mTotalBytes) {
                // we're most likely on a bad wifi connection -- we should
                // probably
                // also look at the mime type --- but the size mismatch is
                // enough
                // to tell us that something is wrong here
                Log.e(Constants.TAG, "Incorrect file size delivered.");
            }
        }
    } 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, "ETag: " + innerState.mHeaderETag);
        Log.v(Constants.TAG, "Transfer-Encoding: " + headerTransferEncoding);
    }

    boolean noSizeInfo = innerState.mHeaderContentLength == null
            && (headerTransferEncoding == null
            || !headerTransferEncoding.equalsIgnoreCase("chunked"));
    if (noSizeInfo) {
        throw new StopRequest(DownloaderService.STATUS_HTTP_DATA_ERROR,
                "can't know size of download, giving up");
    }
}
 
开发者ID:SlotNSlot,项目名称:SlotNSlot_Android,代码行数:71,代码来源:DownloadThread.java


注:本文中的com.google.android.vending.expansion.downloader.Constants.LOGVV属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。