Skip to content

Commit

Permalink
ISSUE-638: Added try/catch to InternalScreenshotMaker
Browse files Browse the repository at this point in the history
  • Loading branch information
devapro committed Sep 15, 2024
1 parent 9c94128 commit af7e440
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.Activity
import android.graphics.Bitmap
import android.graphics.Canvas
import android.os.Looper
import android.util.Log
import android.view.View
import com.kaspersky.kaspresso.device.activities.Activities
import com.kaspersky.kaspresso.params.ScreenshotParams
Expand Down Expand Up @@ -82,7 +83,7 @@ class InternalScreenshotMaker(
private fun drawBitmap(view: View): Bitmap {
view.layout(0, 0, view.measuredWidth, view.measuredHeight)
val bitmap = Bitmap.createBitmap(view.width, view.height, Bitmap.Config.ARGB_8888)
val bitmapHolder = Canvas(bitmap!!)
val bitmapHolder = Canvas(bitmap)
view.draw(bitmapHolder)
return bitmap
}
Expand All @@ -97,6 +98,8 @@ class InternalScreenshotMaker(
activity.runOnUiThread {
try {
activity.drawToBitmap(bitmap)
} catch (e: Exception) {
Log.e("InternalScreenshotMaker", "Unable to get screenshot ${file.absolutePath}")
} finally {
latch.countDown()
}
Expand Down

0 comments on commit af7e440

Please sign in to comment.