Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions library/src/main/java/com/qiniu/android/collect/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ public final class Config {
* 默认使用当前应用的缓存目录: getCacheDir()
*/
public static String recordDir = null;

static {
try {
recordDir = ContextGetter.applicationContext().getCacheDir().getAbsolutePath();
} catch (Throwable e) {
e.fillInStackTrace();
}
}

/**
* 记录上传信息文件最大值,单位:字节。
* <p>
Expand All @@ -62,14 +71,6 @@ public final class Config {
*/
public static int interval = 10;

static {
try {
recordDir = ContextGetter.applicationContext().getCacheDir().getAbsolutePath();
} catch (Throwable e) {
e.fillInStackTrace();
}
}

/**
* 当网络切换到 wifi 下,切换到此设置
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.qiniu.android.collect;


import com.qiniu.android.http.UserAgent;
import com.qiniu.android.storage.UpToken;

Expand Down Expand Up @@ -198,7 +197,7 @@ public void run() {
singleServer.submit(taskRecord);

// 少几次上传没有影响
if (Config.isUpload && upToken != UpToken.NULL) {
if (Config.isUpload && !UpToken.isInvalid(upToken)) {
Runnable taskUpload = new Runnable() {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static ResponseInfo create(final JSONObject json, final int statusCode, f
final String ip = _ip.substring(Math.max(0, _ip.indexOf("/") + 1));
ResponseInfo res = new ResponseInfo(json, statusCode, reqId, xlog, xvia, host, path, ip,
port, duration, sent, error, upToken, totalSize);
if (Config.isRecord || upToken != null) {
if (Config.isRecord) {
final String _timeStamp = res.timeStamp + "";
UploadInfoCollector.handleHttp(upToken,
// 延迟序列化.如果判断不记录,则不执行序列化
Expand Down
4 changes: 4 additions & 0 deletions library/src/main/java/com/qiniu/android/storage/UpToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public static UpToken parse(String token) {
return new UpToken(obj.optString("returnUrl"), token, t[0]);
}

public static boolean isInvalid(UpToken token) {
return token == null || token == NULL;
}

public String toString() {
return token;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private static boolean areInvalidArg(final String key, byte[] data, File f, Stri
ResponseInfo info = null;
if (message != null) {
info = ResponseInfo.invalidArgument(message, decodedToken);
} else if (decodedToken == UpToken.NULL || decodedToken == null) {
} else if (UpToken.isInvalid(decodedToken)) {
info = ResponseInfo.invalidToken("invalid token");
} else if ((f != null && f.length() == 0) || (data != null && data.length == 0)) {
info = ResponseInfo.zeroSize(decodedToken);
Expand All @@ -82,7 +82,7 @@ private static ResponseInfo areInvalidArg(final String key, byte[] data, File f,
return ResponseInfo.invalidArgument(message, decodedToken);
}

if (decodedToken == UpToken.NULL || decodedToken == null) {
if (UpToken.isInvalid(decodedToken)) {
return ResponseInfo.invalidToken("invalid token");
}

Expand Down