Skip to content

Commit f68dae1

Browse files
committed
Catch more broadly exceptions when trying to use Play Services #1284
1 parent 38598d1 commit f68dae1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

app/src/main/java/li/klass/fhem/connection/backend/FHEMWEBConnection.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ class FHEMWEBConnection(fhemServerSpec: FHEMServerSpec, applicationProperties: A
6262
get() = serverSpec?.password ?: ""
6363

6464
override fun executeCommand(command: String, context: Context): RequestResult<String> {
65-
LOG.info("executeTask command " + command)
65+
LOG.info("executeTask command $command")
6666
try {
6767
ProviderInstaller.installIfNeeded(context);
68-
} catch (e: GooglePlayServicesRepairableException) {
68+
} catch (e: Exception) {
6969
LOG.error("cannot install play providers", e)
7070
}
7171

@@ -81,7 +81,7 @@ class FHEMWEBConnection(fhemServerSpec: FHEMServerSpec, applicationProperties: A
8181
reader = InputStreamReader(response.content, Charsets.UTF_8)
8282
val content = CharStreams.toString(reader)
8383
if (content.contains("<title>") || content.contains("<div id=")) {
84-
LOG.error("found strange content: " + content)
84+
LOG.error("found strange content: $content")
8585
ErrorHolder.setError("found strange content in URL $urlSuffix: \r\n\r\n$content")
8686
return RequestResult(INVALID_CONTENT)
8787
}
@@ -116,7 +116,7 @@ class FHEMWEBConnection(fhemServerSpec: FHEMServerSpec, applicationProperties: A
116116

117117
val url = serverUrl + if (urlSuffix?.contains("cmd=") == true) {
118118
val csrfToken = findCsrfToken(serverUrl) ?: ""
119-
urlSuffix + "&fwcsrf=" + csrfToken
119+
"$urlSuffix&fwcsrf=$csrfToken"
120120
} else urlSuffix
121121
LOG.info("accessing URL {}", url)
122122

@@ -143,7 +143,7 @@ class FHEMWEBConnection(fhemServerSpec: FHEMServerSpec, applicationProperties: A
143143

144144
private fun findCsrfToken(serverUrl: String): String? {
145145
try {
146-
val response = doGet(serverUrl + "?room=notExistingJustToLoadCsrfToken")
146+
val response = doGet("$serverUrl?room=notExistingJustToLoadCsrfToken")
147147
val value = response.headers.getFirstHeaderStringValue("X-FHEM-csrfToken")
148148
response.content.close()
149149
return value

0 commit comments

Comments
 (0)