diff --git a/.github/workflows/version-check.yml b/.github/workflows/version-check.yml new file mode 100644 index 00000000..7104ef3d --- /dev/null +++ b/.github/workflows/version-check.yml @@ -0,0 +1,20 @@ +name: Android SDK Version Check +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" +jobs: + linux: + name: Version Check + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Set env + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV + - name: Check + run: | + set -e + grep -qF "## ${RELEASE_VERSION}" CHANGELOG.md + grep -qF "${RELEASE_VERSION}" README.md + grep -qF "public static final String VERSION = \"${RELEASE_VERSION}\";" library/src/main/java/com/qiniu/android/common/Constants.java diff --git a/gradle.properties b/gradle.properties index 53f812a1..0531fb47 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,4 @@ android.useAndroidX=true -android.disableAutomaticComponentCreation=true VERSION_NAME= VERSION_CODE= diff --git a/library/src/main/java/com/qiniu/android/common/AutoZone.java b/library/src/main/java/com/qiniu/android/common/AutoZone.java index 39e787d1..07205945 100644 --- a/library/src/main/java/com/qiniu/android/common/AutoZone.java +++ b/library/src/main/java/com/qiniu/android/common/AutoZone.java @@ -6,6 +6,7 @@ import com.qiniu.android.http.request.RequestTransaction; import com.qiniu.android.storage.Configuration; import com.qiniu.android.storage.UpToken; +import com.qiniu.android.storage.UploadOptions; import com.qiniu.android.utils.Cache; import com.qiniu.android.utils.ListUtils; import com.qiniu.android.utils.SingleFlight; @@ -135,7 +136,15 @@ public void preQuery(final UpToken token, final QueryHandler completeHandler) { @Override public void complete(ResponseInfo responseInfo, UploadRegionRequestMetrics metrics, ZonesInfo zonesInfo) { if (completeHandler != null) { - completeHandler.complete(responseInfo != null ? responseInfo.statusCode : ResponseInfo.NetworkError, responseInfo, metrics); + int code = ResponseInfo.NetworkError; + if (responseInfo != null) { + if (responseInfo.isOK()) { + code = 0; + } else { + code = responseInfo.statusCode; + } + } + completeHandler.complete(code, responseInfo, metrics); } } }); @@ -258,8 +267,10 @@ private String makeCacheKey(Configuration configuration, String akAndBucket) { private RequestTransaction createUploadRequestTransaction(Configuration configuration, UpToken token) { List hosts = getUcServerList(); - - RequestTransaction transaction = new RequestTransaction(configuration, null, + if (configuration == null) { + configuration = new Configuration.Builder().build(); + } + RequestTransaction transaction = new RequestTransaction(configuration, UploadOptions.defaultOptions(), hosts, ZoneInfo.EmptyRegionId, null, token); transactions.add(transaction); return transaction; diff --git a/library/src/main/java/com/qiniu/android/http/request/HttpRegionRequest.java b/library/src/main/java/com/qiniu/android/http/request/HttpRegionRequest.java index 9071ebfa..bcee5798 100644 --- a/library/src/main/java/com/qiniu/android/http/request/HttpRegionRequest.java +++ b/library/src/main/java/com/qiniu/android/http/request/HttpRegionRequest.java @@ -91,7 +91,7 @@ private void performRequest(final IUploadServer server, final RequestProgressHandler progressHandler, final RequestCompleteHandler completeHandler) { - if (server == null || server.getHost() == null || server.getHost().length() == 0) { + if (server == null || StringUtils.isNullOrEmpty(server.getHost())) { ResponseInfo responseInfo = ResponseInfo.sdkInteriorError("server error"); completeAction(responseInfo, null, completeHandler); return; diff --git a/library/src/main/java/com/qiniu/android/http/request/HttpSingleRequest.java b/library/src/main/java/com/qiniu/android/http/request/HttpSingleRequest.java index 81ff9266..1ece9646 100644 --- a/library/src/main/java/com/qiniu/android/http/request/HttpSingleRequest.java +++ b/library/src/main/java/com/qiniu/android/http/request/HttpSingleRequest.java @@ -86,7 +86,7 @@ private void retryRequest(final Request request, @Override public boolean checkCancel() { boolean isCancelled = requestState.isUserCancel(); - if (!isCancelled && uploadOption.cancellationSignal != null) { + if (!isCancelled && uploadOption != null && uploadOption.cancellationSignal != null) { isCancelled = uploadOption.cancellationSignal.isCancelled(); } return isCancelled; diff --git a/library/src/main/java/com/qiniu/android/http/request/RequestTransaction.java b/library/src/main/java/com/qiniu/android/http/request/RequestTransaction.java index b6f23209..fac9802f 100644 --- a/library/src/main/java/com/qiniu/android/http/request/RequestTransaction.java +++ b/library/src/main/java/com/qiniu/android/http/request/RequestTransaction.java @@ -129,7 +129,7 @@ private void initData(IUploadRegion targetRegion, IUploadRegion currentRegion) { this.requestState = new UploadRequestState(); - this.requestState.setCouldUseHttp3(config.requestClient != null); + this.requestState.setCouldUseHttp3(config != null && config.requestClient != null); this.requestInfo = new UploadRequestInfo(); this.requestInfo.targetRegionId = targetRegion.getZoneInfo().getRegionId(); this.requestInfo.currentRegionId = currentRegion.getZoneInfo().getRegionId(); diff --git a/library/src/main/java/com/qiniu/android/http/request/httpclient/SystemHttpClient.java b/library/src/main/java/com/qiniu/android/http/request/httpclient/SystemHttpClient.java index 58f6347a..bc51a23b 100644 --- a/library/src/main/java/com/qiniu/android/http/request/httpclient/SystemHttpClient.java +++ b/library/src/main/java/com/qiniu/android/http/request/httpclient/SystemHttpClient.java @@ -501,7 +501,7 @@ private void handleResponse(Request request, if (responseBody == null) { errorMessage = response.message(); - } else if (responseContentType(response) != "application/json") { + } else if (!responseContentType(response).equals("application/json")) { String responseString = new String(responseBody); if (!responseString.isEmpty()) { try {