Cleanups and added logging

This commit is contained in:
Arjan Schrijver
2025-12-25 14:45:08 +01:00
committed by Arjan Schrijver
parent d431d73dc3
commit 8cff524005
3 changed files with 12 additions and 12 deletions
@@ -27,7 +27,6 @@ import android.os.ParcelFileDescriptor
import android.webkit.PermissionRequest
import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.Toast
import androidx.core.net.toUri
import com.android.volley.Request
@@ -119,6 +118,7 @@ class RebbleAppStoreActivity : AbstractGBActivity() {
),
Toast.LENGTH_LONG, GB.ERROR
)
LOG.error("Received content-type $contentType but expected application/octet-stream or application/zip")
return
}
val inputStream = ParcelFileDescriptor.AutoCloseInputStream(response.body)
@@ -142,6 +142,7 @@ class RebbleAppStoreActivity : AbstractGBActivity() {
Toast.LENGTH_LONG,
GB.ERROR
)
LOG.error("Failed downloading file: $message")
}
})
}
@@ -167,6 +168,7 @@ class RebbleAppStoreActivity : AbstractGBActivity() {
error
), Toast.LENGTH_LONG, GB.ERROR
)
LOG.error("Failed fetching download file URL", error)
}
)
requestQueue.add(jsonObjectRequest)
@@ -185,6 +187,7 @@ class RebbleAppStoreActivity : AbstractGBActivity() {
),
Toast.LENGTH_LONG, GB.ERROR
)
LOG.error("Received content-type $contentType but expected application/json")
return
}
val inputStream = ParcelFileDescriptor.AutoCloseInputStream(response.body)
@@ -205,6 +208,7 @@ class RebbleAppStoreActivity : AbstractGBActivity() {
message
), Toast.LENGTH_LONG, GB.ERROR
)
LOG.error("Error downloading file: $message")
}
})
}
@@ -244,6 +248,7 @@ class RebbleAppStoreActivity : AbstractGBActivity() {
val installHandler: InstallHandler? = mGBDevice?.deviceCoordinator?.findInstallHandler(file.toUri(), applicationContext)
if (installHandler == null) {
GB.toast(getString(R.string.fwinstaller_file_not_compatible_to_device), Toast.LENGTH_LONG, GB.ERROR)
LOG.error("Installable file not compatible with device")
return
}
val startIntent = Intent(applicationContext, installHandler.getInstallActivity())
@@ -256,13 +261,12 @@ class RebbleAppStoreActivity : AbstractGBActivity() {
@SuppressLint("SetJavaScriptEnabled")
private fun initViews() {
webView = findViewById(R.id.webview)
webView!!.webViewClient = WebViewClient()
val settings = webView!!.settings
settings.javaScriptEnabled = true
settings.loadWithOverviewMode = true
settings.useWideViewPort = true
webView!!.webViewClient = object : GBWebClient(GBWebClient.REQUEST_TYPE_PEBBLE_APP_STORE) {
webView!!.webViewClient = object : GBWebClient(REQUEST_TYPE_PEBBLE_APP_STORE) {
override fun shouldOverrideUrlLoading(
wv: WebView,
request: WebResourceRequest
@@ -293,11 +297,7 @@ class RebbleAppStoreActivity : AbstractGBActivity() {
description: String?,
failingUrl: String?
) {
GB.toast(
"Error: $description",
Toast.LENGTH_SHORT,
GB.ERROR
)
LOG.error(description)
view.loadUrl("about:blank")
}
}
@@ -236,7 +236,6 @@ public class PebbleCoordinator extends AbstractBLClassicDeviceCoordinator {
return PebbleSupport.class;
}
@Override
@StringRes
public int getDeviceNameResource() {
@@ -96,6 +96,7 @@ object InternetHelperSingleton {
val httpGetRequest = HttpGetRequest(webRequest.toString(), httpHeaders)
val latch = CountDownLatch(1)
val internetResponseCapsule = Capsule<WebResourceResponse?>()
LOG.debug("Forwarding GET request to {} to internet helper app", webRequest)
try {
internetHelper?.get(httpGetRequest, object : IHttpCallback.Stub() {
@Throws(RemoteException::class)
@@ -137,16 +138,16 @@ object InternetHelperSingleton {
@Throws(RemoteException::class)
override fun onException(message: String?) {
throw RuntimeException(message)
LOG.error("Error during GET request: $message")
}
})
} catch (e: RemoteException) {
throw RuntimeException(e)
LOG.error("Error during GET request", e)
}
try {
latch.await()
} catch (e: InterruptedException) {
throw RuntimeException(e)
LOG.error("Error during GET request", e)
}
return internetResponseCapsule.get()