[#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,18 +27,23 @@ class StatusOkHttpClientFactory implements OkHttpClientFactory {
X509Certificate cert = null; X509Certificate cert = null;
HandshakeCertificates clientCertificates; HandshakeCertificates clientCertificates;
String certPem = ""; 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 = getCertificatePem();
} catch(Exception e) {
Log.e(TAG, "Could not getImageTLSCert",e);
}
// Get TLS PEM certificate from status-go if (certPem.isEmpty()) {
try { Log.e(TAG, "Certificate is empty, cannot create OkHttpClient without a valid certificate");
// induce half second sleep because sometimes a cert is not immediately available return null;
// TODO : remove sleep if App no longer crashes on Android 10 devices with }
// java.lang.RuntimeException: Could not invoke WebSocketModule.connect
Thread.sleep(500); // Convert PEM certificate string to X509Certificate object
certPem = StatusPackage.getImageTLSCert();
} catch(Exception e) {
Log.e(TAG, "Could not getImageTLSCert",e);
}
// Convert PEM certificate string to X509Certificate object
try { try {
// induce half second sleep because sometimes a cert is not immediately available // induce half second sleep because sometimes a cert is not immediately available
// TODO : remove sleep if App no longer crashes on Android 10 devices // TODO : remove sleep if App no longer crashes on Android 10 devices
@ -74,4 +79,17 @@ class StatusOkHttpClientFactory implements OkHttpClientFactory {
return null; 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)))] {:keys [key-uid]} (first (sort-by :timestamp > (vals profiles)))]
(rf/merge cofx (rf/merge cofx
(navigation/init-root :profiles) (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, ;;we check if biometric is available, and try to login with it,
;;if succeed "node.login" signal will be triggered ;;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))) (navigation/init-root cofx :intro)))
(rf/defn update-setting-from-backup (rf/defn update-setting-from-backup

View File

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