@capgo/capacitor-updater 4.14.1 → 4.14.2
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.2";
|
|
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
|
);
|