mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 04:28:35 +00:00
Move common gradle config into convention plugins.
This commit is contained in:
@@ -5,7 +5,7 @@ import kotlin.math.max
|
||||
|
||||
class AsciiArt {
|
||||
|
||||
private class Table (
|
||||
private class Table(
|
||||
private val columns: List<String>,
|
||||
private val rows: List<List<String>>
|
||||
) {
|
||||
|
||||
@@ -24,4 +24,4 @@ val Float.sp: Float get() = DimensionUnit.SP.toPixels(this)
|
||||
* Converts the given Int SP value into Pixels
|
||||
*/
|
||||
@get:Px
|
||||
val Int.sp: Int get() = this.toFloat().sp.toInt()
|
||||
val Int.sp: Int get() = this.toFloat().sp.toInt()
|
||||
|
||||
@@ -7,7 +7,6 @@ import android.graphics.Paint
|
||||
import android.graphics.PorterDuff
|
||||
import kotlin.math.abs
|
||||
|
||||
|
||||
object FontUtil {
|
||||
private const val SAMPLE_EMOJI = "\uD83C\uDF0D" // 🌍
|
||||
|
||||
@@ -37,4 +36,4 @@ object FontUtil {
|
||||
|
||||
return bitmap.getPixel(0, 0) != 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,4 +16,4 @@ fun <E> Optional<E>.isAbsent(): Boolean {
|
||||
|
||||
fun <E : Any> E?.toOptional(): Optional<E> {
|
||||
return Optional.ofNullable(this)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,5 +25,4 @@ object StringStringSerializer : StringSerializer<String?> {
|
||||
override fun deserialize(data: String): String {
|
||||
return data
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ object SqlUtil {
|
||||
@JvmStatic
|
||||
fun getForeignKeyDependencies(db: SupportSQLiteDatabase, table: String): Set<String> {
|
||||
return db.query("PRAGMA foreign_key_list($table)")
|
||||
.readToSet{ cursor ->
|
||||
.readToSet { cursor ->
|
||||
cursor.requireNonNullString("table")
|
||||
}
|
||||
}
|
||||
@@ -393,4 +393,4 @@ object SqlUtil {
|
||||
}
|
||||
|
||||
class Query(val where: String, val whereArgs: Array<String>)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,4 +37,4 @@ fun String.asListContains(item: String): Boolean {
|
||||
*/
|
||||
fun String.toSingleLine(): String {
|
||||
return this.trimIndent().split("\n").joinToString(separator = " ")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,13 +21,13 @@ class DeadlockDetector(private val handler: Handler, private val pollingInterval
|
||||
var lastThreadDumpTime: Long = -1
|
||||
|
||||
fun start() {
|
||||
Log.d(TAG, "Beginning deadlock monitoring.");
|
||||
Log.d(TAG, "Beginning deadlock monitoring.")
|
||||
running = true
|
||||
handler.postDelayed(this::poll, pollingInterval)
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
Log.d(TAG, "Ending deadlock monitoring.");
|
||||
Log.d(TAG, "Ending deadlock monitoring.")
|
||||
running = false
|
||||
handler.removeCallbacksAndMessages(null)
|
||||
}
|
||||
@@ -122,7 +122,6 @@ class DeadlockDetector(private val handler: Handler, private val pollingInterval
|
||||
for (entry in blocked) {
|
||||
stringBuilder.append("-- [${entry.key.id}] ${entry.key.name} | ${entry.key.state}\n")
|
||||
|
||||
|
||||
val callerThrowable: Throwable? = TracedThreads.callerStackTraces[entry.key.id]
|
||||
val stackTrace: Array<StackTraceElement> = if (callerThrowable != null) {
|
||||
ExceptionUtil.joinStackTrace(entry.value, callerThrowable.stackTrace)
|
||||
|
||||
@@ -31,25 +31,28 @@ internal class TracingExecutorService(val wrapped: ExecutorService) : ExecutorSe
|
||||
|
||||
val queue: Queue<Runnable>
|
||||
get() {
|
||||
return if (wrapped is ThreadPoolExecutor)
|
||||
return if (wrapped is ThreadPoolExecutor) {
|
||||
wrapped.queue
|
||||
else
|
||||
} else {
|
||||
LinkedBlockingQueue()
|
||||
}
|
||||
}
|
||||
|
||||
val activeCount: Int
|
||||
get() {
|
||||
return if (wrapped is ThreadPoolExecutor)
|
||||
return if (wrapped is ThreadPoolExecutor) {
|
||||
wrapped.activeCount
|
||||
else
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
val maximumPoolSize: Int
|
||||
get() {
|
||||
return if (wrapped is ThreadPoolExecutor)
|
||||
return if (wrapped is ThreadPoolExecutor) {
|
||||
wrapped.maximumPoolSize
|
||||
else
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,13 @@ import org.signal.core.util.ExceptionUtil
|
||||
/**
|
||||
* An uncaught exception handler that will combine a caller stack trace with the exception to print a more useful stack trace.
|
||||
*/
|
||||
internal class TracingUncaughtExceptionHandler (
|
||||
val originalHandler: Thread.UncaughtExceptionHandler?,
|
||||
private val callerStackTrace: Throwable) : Thread.UncaughtExceptionHandler {
|
||||
internal class TracingUncaughtExceptionHandler(
|
||||
val originalHandler: Thread.UncaughtExceptionHandler?,
|
||||
private val callerStackTrace: Throwable
|
||||
) : Thread.UncaughtExceptionHandler {
|
||||
|
||||
override fun uncaughtException(thread: Thread, exception: Throwable) {
|
||||
val updated = ExceptionUtil.joinStackTrace(exception, callerStackTrace)
|
||||
originalHandler?.uncaughtException(thread, updated)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,4 +21,4 @@ object PlatformCurrencyUtil {
|
||||
fun getAvailableCurrencyCodes(): Set<String> {
|
||||
return Currency.getAvailableCurrencies().map { it.currencyCode }.toSet()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class StringExtensions_asListContains(
|
||||
|
||||
arrayOf("a", "b", false),
|
||||
arrayOf("a", "abc", false),
|
||||
arrayOf("b", "a*", false),
|
||||
arrayOf("b", "a*", false)
|
||||
).toList()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,4 +51,4 @@ class StringUtilTest_endsWith {
|
||||
|
||||
assertEquals(expected, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,4 +48,4 @@ class StringUtilTest_replace {
|
||||
|
||||
assertEquals(expected.toString(), result.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,4 +51,4 @@ class StringUtilTest_startsWith {
|
||||
|
||||
assertEquals(expected, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user