@capgo/capacitor-updater 4.14.1 → 4.14.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -11,10 +11,12 @@ import android.os.Bundle;
|
|
|
11
11
|
import android.util.Base64;
|
|
12
12
|
import android.util.Log;
|
|
13
13
|
import com.android.volley.BuildConfig;
|
|
14
|
+
import com.android.volley.NetworkResponse;
|
|
14
15
|
import com.android.volley.Request;
|
|
15
16
|
import com.android.volley.RequestQueue;
|
|
16
17
|
import com.android.volley.Response;
|
|
17
18
|
import com.android.volley.VolleyError;
|
|
19
|
+
import com.android.volley.toolbox.HttpHeaderParser;
|
|
18
20
|
import com.android.volley.toolbox.JsonObjectRequest;
|
|
19
21
|
import com.getcapacitor.JSObject;
|
|
20
22
|
import com.getcapacitor.plugin.WebView;
|
|
@@ -27,6 +29,7 @@ import java.io.FileOutputStream;
|
|
|
27
29
|
import java.io.FilenameFilter;
|
|
28
30
|
import java.io.IOException;
|
|
29
31
|
import java.io.InputStream;
|
|
32
|
+
import java.io.UnsupportedEncodingException;
|
|
30
33
|
import java.net.URL;
|
|
31
34
|
import java.net.URLConnection;
|
|
32
35
|
import java.security.GeneralSecurityException;
|
|
@@ -60,7 +63,7 @@ public class CapacitorUpdater {
|
|
|
60
63
|
private static final String bundleDirectory = "versions";
|
|
61
64
|
|
|
62
65
|
public static final String TAG = "Capacitor-updater";
|
|
63
|
-
public static final String pluginVersion = "4.14.
|
|
66
|
+
public static final String pluginVersion = "4.14.3";
|
|
64
67
|
|
|
65
68
|
public SharedPreferences.Editor editor;
|
|
66
69
|
public SharedPreferences prefs;
|
|
@@ -672,6 +675,29 @@ public class CapacitorUpdater {
|
|
|
672
675
|
return json;
|
|
673
676
|
}
|
|
674
677
|
|
|
678
|
+
private JSObject createError(String message, VolleyError error) {
|
|
679
|
+
NetworkResponse response = error.networkResponse;
|
|
680
|
+
final JSObject retError = new JSObject();
|
|
681
|
+
retError.put("error", "response_error");
|
|
682
|
+
if (response != null) {
|
|
683
|
+
try {
|
|
684
|
+
String json = new String(
|
|
685
|
+
response.data,
|
|
686
|
+
HttpHeaderParser.parseCharset(response.headers)
|
|
687
|
+
);
|
|
688
|
+
Log.e(TAG, message + ": " + json);
|
|
689
|
+
retError.put("message", message + ": " + json);
|
|
690
|
+
} catch (UnsupportedEncodingException e) {
|
|
691
|
+
Log.e(TAG, message + ": " + e.toString());
|
|
692
|
+
retError.put("message", message + ": " + e.toString());
|
|
693
|
+
}
|
|
694
|
+
} else {
|
|
695
|
+
Log.e(TAG, message + ": " + error.toString());
|
|
696
|
+
retError.put("message", message + ": " + error.toString());
|
|
697
|
+
}
|
|
698
|
+
return retError;
|
|
699
|
+
}
|
|
700
|
+
|
|
675
701
|
public void getLatest(final String updateUrl, final Callback callback) {
|
|
676
702
|
JSONObject json = null;
|
|
677
703
|
try {
|
|
@@ -717,11 +743,9 @@ public class CapacitorUpdater {
|
|
|
717
743
|
new Response.ErrorListener() {
|
|
718
744
|
@Override
|
|
719
745
|
public void onErrorResponse(VolleyError error) {
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
retError.put("error", "response_error");
|
|
724
|
-
callback.callback(retError);
|
|
746
|
+
callback.callback(
|
|
747
|
+
CapacitorUpdater.this.createError("Error get latest", error)
|
|
748
|
+
);
|
|
725
749
|
}
|
|
726
750
|
}
|
|
727
751
|
);
|
|
@@ -784,11 +808,9 @@ public class CapacitorUpdater {
|
|
|
784
808
|
new Response.ErrorListener() {
|
|
785
809
|
@Override
|
|
786
810
|
public void onErrorResponse(VolleyError error) {
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
retError.put("error", "response_error");
|
|
791
|
-
callback.callback(retError);
|
|
811
|
+
callback.callback(
|
|
812
|
+
CapacitorUpdater.this.createError("Error set channel", error)
|
|
813
|
+
);
|
|
792
814
|
}
|
|
793
815
|
}
|
|
794
816
|
);
|
|
@@ -846,11 +868,9 @@ public class CapacitorUpdater {
|
|
|
846
868
|
new Response.ErrorListener() {
|
|
847
869
|
@Override
|
|
848
870
|
public void onErrorResponse(VolleyError error) {
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
retError.put("error", "response_error");
|
|
853
|
-
callback.callback(retError);
|
|
871
|
+
callback.callback(
|
|
872
|
+
CapacitorUpdater.this.createError("Error get channel", error)
|
|
873
|
+
);
|
|
854
874
|
}
|
|
855
875
|
}
|
|
856
876
|
);
|
|
@@ -888,7 +908,7 @@ public class CapacitorUpdater {
|
|
|
888
908
|
new Response.ErrorListener() {
|
|
889
909
|
@Override
|
|
890
910
|
public void onErrorResponse(VolleyError error) {
|
|
891
|
-
|
|
911
|
+
CapacitorUpdater.this.createError("Error send stats", error);
|
|
892
912
|
}
|
|
893
913
|
}
|
|
894
914
|
);
|
|
@@ -420,8 +420,8 @@ extension CustomError: LocalizedError {
|
|
|
420
420
|
latest.sessionKey = sessionKey
|
|
421
421
|
}
|
|
422
422
|
case let .failure(error):
|
|
423
|
-
print("\(self.TAG) Error getting Latest", error )
|
|
424
|
-
latest.message = "Error getting Latest \(
|
|
423
|
+
print("\(self.TAG) Error getting Latest", response.value, error )
|
|
424
|
+
latest.message = "Error getting Latest \(response.value)"
|
|
425
425
|
latest.error = "fail_response"
|
|
426
426
|
}
|
|
427
427
|
semaphore.signal()
|
|
@@ -471,7 +471,7 @@ extension CustomError: LocalizedError {
|
|
|
471
471
|
mainError = error as NSError
|
|
472
472
|
}
|
|
473
473
|
case let .failure(error):
|
|
474
|
-
print("\(self.TAG) download error", error)
|
|
474
|
+
print("\(self.TAG) download error", response.value!, error)
|
|
475
475
|
mainError = error as NSError
|
|
476
476
|
}
|
|
477
477
|
}
|
|
@@ -645,8 +645,8 @@ extension CustomError: LocalizedError {
|
|
|
645
645
|
setChannel.message = message
|
|
646
646
|
}
|
|
647
647
|
case let .failure(error):
|
|
648
|
-
print("\(self.TAG) Error set Channel", error)
|
|
649
|
-
setChannel.message = "Error set Channel \(
|
|
648
|
+
print("\(self.TAG) Error set Channel", response.value, error)
|
|
649
|
+
setChannel.message = "Error set Channel \(String(describing: response.value))"
|
|
650
650
|
setChannel.error = "fail_response"
|
|
651
651
|
}
|
|
652
652
|
semaphore.signal()
|
|
@@ -683,8 +683,8 @@ extension CustomError: LocalizedError {
|
|
|
683
683
|
getChannel.allowSet = allowSet
|
|
684
684
|
}
|
|
685
685
|
case let .failure(error):
|
|
686
|
-
print("\(self.TAG) Error get Channel", error
|
|
687
|
-
getChannel.message = "Error get Channel \(
|
|
686
|
+
print("\(self.TAG) Error get Channel", response.value, error)
|
|
687
|
+
getChannel.message = "Error get Channel \(String(describing: response.value)))"
|
|
688
688
|
getChannel.error = "fail_response"
|
|
689
689
|
}
|
|
690
690
|
semaphore.signal()
|
|
@@ -706,7 +706,7 @@ extension CustomError: LocalizedError {
|
|
|
706
706
|
case .success:
|
|
707
707
|
print("\(self.TAG) Stats send for \(action), version \(versionName)")
|
|
708
708
|
case let .failure(error):
|
|
709
|
-
print("\(self.TAG) Error sending stats: ", error
|
|
709
|
+
print("\(self.TAG) Error sending stats: ", response.value, error)
|
|
710
710
|
}
|
|
711
711
|
}
|
|
712
712
|
}
|