Skip to content
Permalink
Browse files

Catch all exceptions from Google Play services

Avoid any uncaught exceptions from Google Play services
  • Loading branch information...
ianhanniballake committed Oct 20, 2019
1 parent 46e0a08 commit 51ec4e170c80e7c1fed73b3fc64de54d2920769a
@@ -36,8 +36,6 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.tasks.await
import java.io.ByteArrayOutputStream
import java.util.concurrent.ExecutionException
import java.util.concurrent.TimeoutException

/**
* Controller for updating Android Wear devices with new wallpapers.
@@ -72,13 +70,7 @@ class WearableController(private val context: Context) : DefaultLifecycleObserve
Log.w(TAG, "onConnectionFailed: $connectionResult", e.cause)
}
return
} catch (e: ExecutionException) {
Log.w(TAG, "Unable to check for Wear API availability", e)
return
} catch (e: InterruptedException) {
Log.w(TAG, "Unable to check for Wear API availability", e)
return
} catch (e: TimeoutException) {
} catch (e: Exception) {
Log.w(TAG, "Unable to check for Wear API availability", e)
return
}
@@ -96,9 +88,7 @@ class WearableController(private val context: Context) : DefaultLifecycleObserve
}
try {
dataClient.putDataItem(dataMapRequest.asPutDataRequest().setUrgent()).await()
} catch (e: ExecutionException) {
Log.w(TAG, "Error uploading artwork to Wear", e)
} catch (e: InterruptedException) {
} catch (e: Exception) {
Log.w(TAG, "Error uploading artwork to Wear", e)
}
}
@@ -49,7 +49,6 @@ import com.google.firebase.analytics.FirebaseAnalytics
import kotlinx.coroutines.tasks.await
import net.nurik.roman.muzei.R
import java.util.TreeSet
import java.util.concurrent.ExecutionException
import java.util.concurrent.TimeoutException

class ActivateMuzeiIntentService : IntentService(TAG) {
@@ -179,10 +178,7 @@ class ActivateMuzeiIntentService : IntentService(TAG) {
val capabilityClient = Wearable.getCapabilityClient(context)
val nodes: Set<Node> = try {
capabilityClient.getCapability("activate_muzei", capability).await().nodes
} catch (e: ExecutionException) {
Log.e(TAG, "Error getting all capability info", e)
TreeSet()
} catch (e: InterruptedException) {
} catch (e: Exception) {
Log.e(TAG, "Error getting all capability info", e)
TreeSet()
}
@@ -37,7 +37,6 @@ import java.io.FileInputStream
import java.io.FileNotFoundException
import java.io.InputStream
import java.util.TreeSet
import java.util.concurrent.ExecutionException

/**
* Provider handling art from a connected phone
@@ -70,10 +69,7 @@ class DataLayerArtProvider : MuzeiArtProvider() {
// older versions of Muzei's phone app
capabilityClient.getCapability("activate_muzei",
CapabilityClient.FILTER_REACHABLE).await().nodes
} catch (e: ExecutionException) {
Log.e(TAG, "Error getting reachable capability info", e)
TreeSet()
} catch (e: InterruptedException) {
} catch (e: Exception) {
Log.e(TAG, "Error getting reachable capability info", e)
TreeSet()
}
@@ -34,7 +34,6 @@ import net.nurik.roman.muzei.BuildConfig
import net.nurik.roman.muzei.BuildConfig.DATA_LAYER_AUTHORITY
import java.io.FileOutputStream
import java.io.IOException
import java.util.concurrent.ExecutionException

/**
* Load artwork from the Wear Data Layer, writing it into [DataLayerArtProvider].
@@ -110,10 +109,7 @@ class DataLayerLoadWorker(
}
}
return Result.success()
} catch (e: ExecutionException) {
Log.w(TAG, "Error getting artwork from Wear Data Layer", e)
return Result.failure()
} catch (e: InterruptedException) {
} catch (e: Exception) {
Log.w(TAG, "Error getting artwork from Wear Data Layer", e)
return Result.failure()
}

0 comments on commit 51ec4e1

Please sign in to comment.
You can’t perform that action at this time.