Skip to content

Commit

Permalink
Merge branch 'master' of YangSen-qn:qiniu/android-sdk
Browse files Browse the repository at this point in the history
# Conflicts:
#	library/src/main/java/com/qiniu/android/common/AutoZone.java
#	library/src/main/java/com/qiniu/android/common/Config.java
#	library/src/main/java/com/qiniu/android/common/Zone.java
#	library/src/main/java/com/qiniu/android/common/ZoneInfo.java
#	library/src/main/java/com/qiniu/android/http/ResponseInfo.java
#	library/src/main/java/com/qiniu/android/http/dns/DnsPrefetchTransaction.java
#	library/src/main/java/com/qiniu/android/http/dns/DnsPrefetcher.java
#	library/src/main/java/com/qiniu/android/http/serverRegion/UploadDomainRegion.java
#	library/src/main/java/com/qiniu/android/storage/Configuration.java
  • Loading branch information
YangSen-qn committed May 24, 2024
2 parents 0b32ed1 + 37e573e commit 96e5b12
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 8 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/version-check.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
android.useAndroidX=true
android.disableAutomaticComponentCreation=true

VERSION_NAME=
VERSION_CODE=
Expand Down
17 changes: 14 additions & 3 deletions library/src/main/java/com/qiniu/android/common/AutoZone.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
});
Expand Down Expand Up @@ -258,8 +267,10 @@ private String makeCacheKey(Configuration configuration, String akAndBucket) {

private RequestTransaction createUploadRequestTransaction(Configuration configuration, UpToken token) {
List<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 96e5b12

Please sign in to comment.