kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
fix packet display in debug panel
make the test work with any non US default Locale remove java-lite usage fix a testpull/180/head
rodzic
f9e39b66a4
commit
336d283c82
|
|
@ -92,14 +92,15 @@ androidExtensions {
|
||||||
// per protobuf-gradle-plugin docs, this is recommended for android
|
// per protobuf-gradle-plugin docs, this is recommended for android
|
||||||
protobuf {
|
protobuf {
|
||||||
protoc {
|
protoc {
|
||||||
artifact = 'com.google.protobuf:protoc:3.9.0'
|
artifact = 'com.google.protobuf:protoc:3.13.0'
|
||||||
}
|
}
|
||||||
generateProtoTasks {
|
generateProtoTasks {
|
||||||
all().each { task ->
|
all().each { task ->
|
||||||
task.builtins {
|
task.builtins {
|
||||||
java {
|
java {
|
||||||
|
// turned off for now so I can use json printing in debug panel
|
||||||
// use the smaller android version of the library
|
// use the smaller android version of the library
|
||||||
option "lite"
|
//option "lite"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -145,11 +146,8 @@ dependencies {
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
|
||||||
|
|
||||||
// You need to depend on the lite runtime library, not protobuf-java
|
|
||||||
// For now I'm not using javalite, because I want JSON printing
|
// For now I'm not using javalite, because I want JSON printing
|
||||||
//implementation 'com.google.protobuf:protobuf-java:3.11.1'
|
implementation ('com.google.protobuf:protobuf-java:3.13.0')
|
||||||
//implementation 'com.google.protobuf:protobuf-java-util:3.11.1'
|
|
||||||
implementation 'com.google.protobuf:protobuf-javalite:3.13.0'
|
|
||||||
|
|
||||||
// For UART access
|
// For UART access
|
||||||
// implementation 'com.google.android.things:androidthings:1.0'
|
// implementation 'com.google.android.things:androidthings:1.0'
|
||||||
|
|
|
||||||
|
|
@ -26,18 +26,21 @@
|
||||||
-keepclassmembernames class kotlinx.** { volatile <fields>; }
|
-keepclassmembernames class kotlinx.** { volatile <fields>; }
|
||||||
|
|
||||||
# Needed for protobufs
|
# Needed for protobufs
|
||||||
|
-keepclassmembers class * extends com.google.protobuf.GeneratedMessageV3 { <fields>; }
|
||||||
|
-keep class com.geeksville.mesh.**{*;}
|
||||||
-keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite { <fields>; }
|
-keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite { <fields>; }
|
||||||
|
|
||||||
# for kotlinx.serialization
|
# for kotlinx.serialization
|
||||||
-keepattributes *Annotation*, InnerClasses
|
-keepattributes *Annotation*, InnerClasses
|
||||||
-dontnote kotlinx.serialization.SerializationKt
|
-dontnote kotlinx.serialization.SerializationKt
|
||||||
-keep,includedescriptorclasses class com.yourcompany.yourpackage.**$$serializer { *; } # <-- change package name to your app's
|
-keep,includedescriptorclasses class com.geeksville.mesh.**$$serializer { *; }
|
||||||
-keepclassmembers class com.geeksville.mesh.** { # <-- change package name to your app's
|
-keepclassmembers class com.geeksville.mesh.** {
|
||||||
*** Companion;
|
*** Companion;
|
||||||
}
|
}
|
||||||
-keepclasseswithmembers class com.geeksville.mesh.** { # <-- change package name to your app's
|
-keepclasseswithmembers class com.geeksville.mesh.** {
|
||||||
kotlinx.serialization.KSerializer serializer(...);
|
kotlinx.serialization.KSerializer serializer(...);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Our app is opensource no need to obsfucate
|
# Our app is opensource no need to obsfucate
|
||||||
-dontobfuscate
|
-dontobfuscate
|
||||||
|
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*,!code/allocation/variable
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package com.geeksville.mesh
|
package com.geeksville.mesh
|
||||||
|
|
||||||
|
|
||||||
import androidx.compose.frames.open
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import com.geeksville.mesh.model.Channel
|
import com.geeksville.mesh.model.Channel
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
|
|
@ -12,11 +10,9 @@ import org.junit.runner.RunWith
|
||||||
class ChannelTest {
|
class ChannelTest {
|
||||||
@Test
|
@Test
|
||||||
fun channelUrlGood() {
|
fun channelUrlGood() {
|
||||||
open() // Needed to make Compose think we are inside a Frame
|
|
||||||
val ch = Channel.emulated
|
val ch = Channel.emulated
|
||||||
|
|
||||||
Assert.assertTrue(ch.getChannelUrl().toString().startsWith(Channel.prefix))
|
Assert.assertTrue(ch.getChannelUrl().toString().startsWith(Channel.prefix))
|
||||||
Assert.assertEquals(Channel(ch.getChannelUrl()), ch)
|
Assert.assertEquals(Channel(ch.getChannelUrl()), ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -972,7 +972,12 @@ class MeshService : Service(), Logging {
|
||||||
// debug("Recieved: $packet")
|
// debug("Recieved: $packet")
|
||||||
val p = packet.decoded
|
val p = packet.decoded
|
||||||
|
|
||||||
val packetToSave = Packet(UUID.randomUUID().toString(), "packet", System.currentTimeMillis(), packet.toString())
|
val packetToSave = Packet(
|
||||||
|
UUID.randomUUID().toString(),
|
||||||
|
"packet",
|
||||||
|
System.currentTimeMillis(),
|
||||||
|
packet.toString()
|
||||||
|
)
|
||||||
insertPacket(packetToSave)
|
insertPacket(packetToSave)
|
||||||
// If the rxTime was not set by the device (because device software was old), guess at a time
|
// If the rxTime was not set by the device (because device software was old), guess at a time
|
||||||
val rxTime = if (packet.rxTime != 0) packet.rxTime else currentSecond()
|
val rxTime = if (packet.rxTime != 0) packet.rxTime else currentSecond()
|
||||||
|
|
@ -1246,7 +1251,12 @@ class MeshService : Service(), Logging {
|
||||||
|
|
||||||
|
|
||||||
private fun handleRadioConfig(radio: MeshProtos.RadioConfig) {
|
private fun handleRadioConfig(radio: MeshProtos.RadioConfig) {
|
||||||
val packetToSave = Packet(UUID.randomUUID().toString(), "RadioConfig", System.currentTimeMillis(), radio.toString())
|
val packetToSave = Packet(
|
||||||
|
UUID.randomUUID().toString(),
|
||||||
|
"RadioConfig",
|
||||||
|
System.currentTimeMillis(),
|
||||||
|
radio.toString()
|
||||||
|
)
|
||||||
insertPacket(packetToSave)
|
insertPacket(packetToSave)
|
||||||
radioConfig = radio
|
radioConfig = radio
|
||||||
}
|
}
|
||||||
|
|
@ -1276,7 +1286,12 @@ class MeshService : Service(), Logging {
|
||||||
private fun handleNodeInfo(info: MeshProtos.NodeInfo) {
|
private fun handleNodeInfo(info: MeshProtos.NodeInfo) {
|
||||||
debug("Received nodeinfo num=${info.num}, hasUser=${info.hasUser()}, hasPosition=${info.hasPosition()}")
|
debug("Received nodeinfo num=${info.num}, hasUser=${info.hasUser()}, hasPosition=${info.hasPosition()}")
|
||||||
|
|
||||||
val packetToSave = Packet(UUID.randomUUID().toString(), "NodeInfo", System.currentTimeMillis(), info.toString())
|
val packetToSave = Packet(
|
||||||
|
UUID.randomUUID().toString(),
|
||||||
|
"NodeInfo",
|
||||||
|
System.currentTimeMillis(),
|
||||||
|
info.toString()
|
||||||
|
)
|
||||||
insertPacket(packetToSave)
|
insertPacket(packetToSave)
|
||||||
|
|
||||||
logAssert(newNodes.size <= 256) // Sanity check to make sure a device bug can't fill this list forever
|
logAssert(newNodes.size <= 256) // Sanity check to make sure a device bug can't fill this list forever
|
||||||
|
|
@ -1288,7 +1303,12 @@ class MeshService : Service(), Logging {
|
||||||
* Update the nodeinfo (called from either new API version or the old one)
|
* Update the nodeinfo (called from either new API version or the old one)
|
||||||
*/
|
*/
|
||||||
private fun handleMyInfo(myInfo: MeshProtos.MyNodeInfo) {
|
private fun handleMyInfo(myInfo: MeshProtos.MyNodeInfo) {
|
||||||
val packetToSave = Packet(UUID.randomUUID().toString(), "MyNodeInfo", System.currentTimeMillis(), myInfo.toString())
|
val packetToSave = Packet(
|
||||||
|
UUID.randomUUID().toString(),
|
||||||
|
"MyNodeInfo",
|
||||||
|
System.currentTimeMillis(),
|
||||||
|
myInfo.toString()
|
||||||
|
)
|
||||||
insertPacket(packetToSave)
|
insertPacket(packetToSave)
|
||||||
|
|
||||||
setFirmwareUpdateFilename(myInfo)
|
setFirmwareUpdateFilename(myInfo)
|
||||||
|
|
@ -1338,7 +1358,12 @@ class MeshService : Service(), Logging {
|
||||||
private fun handleConfigComplete(configCompleteId: Int) {
|
private fun handleConfigComplete(configCompleteId: Int) {
|
||||||
if (configCompleteId == configNonce) {
|
if (configCompleteId == configNonce) {
|
||||||
|
|
||||||
val packetToSave = Packet(UUID.randomUUID().toString(), "ConfigComplete", System.currentTimeMillis(), configCompleteId.toString())
|
val packetToSave = Packet(
|
||||||
|
UUID.randomUUID().toString(),
|
||||||
|
"ConfigComplete",
|
||||||
|
System.currentTimeMillis(),
|
||||||
|
configCompleteId.toString()
|
||||||
|
)
|
||||||
insertPacket(packetToSave)
|
insertPacket(packetToSave)
|
||||||
|
|
||||||
// This was our config request
|
// This was our config request
|
||||||
|
|
|
||||||
|
|
@ -1,68 +1,84 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/adapterPacketLayout"
|
||||||
|
style="@style/Widget.App.CardView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:clipToPadding="false">
|
android:layout_margin="4dp">
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
style="@style/Widget.App.CardView"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:layout_margin="4dp">
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<TextView
|
||||||
|
android:id="@+id/type"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/cloudDownloadIcon"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/cloudDownloadIcon"
|
||||||
|
tools:text="NodeInfo" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/dateReceived"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/cloudDownloadIcon"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/cloudDownloadIcon"
|
||||||
|
tools:text="9/27/20 21:00:58" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/rawMessage"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:fontFamily="monospace"
|
||||||
|
android:singleLine="false"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
android:textIsSelectable="true"
|
||||||
|
android:textSize="8sp"
|
||||||
|
android:typeface="monospace"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/cloudDownloadIcon"
|
||||||
|
app:layout_constraintVertical_weight="1"
|
||||||
|
tools:text="# com.geeksville.mesh.MeshProtos$MeshPacket@1b1ea594\n
|
||||||
|
decoded {\n
|
||||||
|
position {\n
|
||||||
|
altitude: 60\n
|
||||||
|
battery_level: 81\n
|
||||||
|
latitude_i: 411111136\n
|
||||||
|
longitude_i: -711111805\n
|
||||||
|
time: 1600390966\n
|
||||||
|
}\n
|
||||||
|
}\n
|
||||||
|
from: -1409794164\n
|
||||||
|
hop_limit: 3\n
|
||||||
|
id: 1737414295\n
|
||||||
|
rx_snr: 9.5\n
|
||||||
|
rx_time: 316400569\n
|
||||||
|
to: -1409790708" />
|
||||||
|
|
||||||
<TextView
|
<ImageView
|
||||||
android:id="@+id/type"
|
android:id="@+id/cloudDownloadIcon"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:text="node_info"
|
android:alpha="0.4"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintEnd_toStartOf="@+id/dateReceived"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:srcCompat="@drawable/cloud_download_outline_24" />
|
||||||
|
|
||||||
<TextView
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
android:id="@+id/dateReceived"
|
</com.google.android.material.card.MaterialCardView>
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginEnd="8dp"
|
|
||||||
android:text="09-17 21:00:58.641"
|
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/cloudDownloadIcon"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="@+id/cloudDownloadIcon" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/rawMessage"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:fontFamily="monospace"
|
|
||||||
android:text="TextView"
|
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
|
||||||
android:textIsSelectable="true"
|
|
||||||
android:textSize="8sp"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/type" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/cloudDownloadIcon"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:layout_marginEnd="8dp"
|
|
||||||
android:alpha="0.4"
|
|
||||||
app:layout_constraintEnd_toStartOf="@+id/dateReceived"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:srcCompat="@drawable/cloud_download_outline_24" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
@ -11,11 +11,14 @@
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
|
android:scrollbarAlwaysDrawVerticalTrack="true"
|
||||||
android:scrollbars="vertical"
|
android:scrollbars="vertical"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/clearButton" />
|
app:layout_constraintTop_toBottomOf="@+id/clearButton"
|
||||||
|
tools:itemCount="8"
|
||||||
|
tools:listitem="@layout/adapter_packet_layout" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/clearButton"
|
android:id="@+id/clearButton"
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,30 @@
|
||||||
package com.geeksville.mesh
|
package com.geeksville.mesh
|
||||||
|
|
||||||
|
import androidx.core.os.LocaleListCompat
|
||||||
|
import org.junit.After
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
class NodeInfoTest {
|
class NodeInfoTest {
|
||||||
val ni1 = NodeInfo(4, MeshUser("+one", "User One", "U1"), Position(37.1, 121.1, 35))
|
val ni1 = NodeInfo(4, MeshUser("+one", "User One", "U1"), Position(37.1, 121.1, 35))
|
||||||
val ni2 = NodeInfo(5, MeshUser("+two", "User Two", "U2"), Position(37.11, 121.1, 40))
|
val ni2 = NodeInfo(5, MeshUser("+two", "User Two", "U2"), Position(37.11, 121.1, 40))
|
||||||
val ni3 = NodeInfo(6, MeshUser("+three", "User Three", "U3"), Position(37.101, 121.1, 40))
|
val ni3 = NodeInfo(6, MeshUser("+three", "User Three", "U3"), Position(37.101, 121.1, 40))
|
||||||
|
|
||||||
|
private val currentDefaultLocale = LocaleListCompat.getDefault().get(0)
|
||||||
|
|
||||||
|
@Before
|
||||||
|
fun setup()
|
||||||
|
{
|
||||||
|
Locale.setDefault(Locale.US)
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
fun tearDown() {
|
||||||
|
Locale.setDefault(currentDefaultLocale)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun distanceGood() {
|
fun distanceGood() {
|
||||||
Assert.assertEquals(ni1.distance(ni2), 1111)
|
Assert.assertEquals(ni1.distance(ni2), 1111)
|
||||||
|
|
|
||||||
Ładowanie…
Reference in New Issue