[#17909] fix: unhandled error when app launched in offline mode (#17973)

This commit is contained in:
Mohsen 2023-12-04 17:48:45 +03:00 committed by GitHub
parent 7c45b1e075
commit f695dbf115
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 18 deletions

View File

@ -27,17 +27,22 @@ class StatusOkHttpClientFactory implements OkHttpClientFactory {
X509Certificate cert = null;
HandshakeCertificates clientCertificates;
String certPem = "";
// Get TLS PEM certificate from status-go
try {
// induce half second sleep because sometimes a cert is not immediately available
// TODO : remove sleep if App no longer crashes on Android 10 devices with
// java.lang.RuntimeException: Could not invoke WebSocketModule.connect
Thread.sleep(500);
certPem = StatusPackage.getImageTLSCert();
certPem = getCertificatePem();
} catch(Exception e) {
Log.e(TAG, "Could not getImageTLSCert",e);
}
if (certPem.isEmpty()) {
Log.e(TAG, "Certificate is empty, cannot create OkHttpClient without a valid certificate");
return null;
}
// Convert PEM certificate string to X509Certificate object
try {
// induce half second sleep because sometimes a cert is not immediately available
@ -74,4 +79,17 @@ class StatusOkHttpClientFactory implements OkHttpClientFactory {
return null;
}
}
private String getCertificatePem() {
try {
String certPem = StatusPackage.getImageTLSCert();
if (certPem == null || certPem.trim().isEmpty()) {
Log.e(TAG, "Certificate PEM string is null or empty");
return "";
}
return certPem;
} catch (Exception e) {
Log.e(TAG, "Could not getImageTLSCert", e);
return "";
}
}
}

View File

@ -43,10 +43,10 @@
{:keys [key-uid]} (first (sort-by :timestamp > (vals profiles)))]
(rf/merge cofx
(navigation/init-root :profiles)
(init-profiles-overview profiles key-uid)
(when key-uid (init-profiles-overview profiles key-uid))
;;we check if biometric is available, and try to login with it,
;;if succeed "node.login" signal will be triggered
(profile.login/login-with-biometric-if-available key-uid)))
(when key-uid (profile.login/login-with-biometric-if-available key-uid))))
(navigation/init-root cofx :intro)))
(rf/defn update-setting-from-backup

View File

@ -5,8 +5,10 @@
(defn rpc->profiles-overview
[{:keys [customizationColor keycard-pairing] :as profile}]
(if (map? profile)
(-> profile
(dissoc :customizationColor)
(assoc :customization-color (keyword customizationColor))
(assoc :ens-name? (utils.ens/is-valid-eth-name? (:name profile)))
(assoc :keycard-pairing (when-not (string/blank? keycard-pairing) keycard-pairing))))
(assoc :keycard-pairing (when-not (string/blank? keycard-pairing) keycard-pairing)))
profile))