remove java-lite usage

This commit is contained in:
Ludovic Goix 2020-10-01 15:40:02 -04:00
parent 7c829998e9
commit 9da37521d5
3 changed files with 41 additions and 15 deletions

View file

@ -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'

View file

@ -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

View file

@ -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