Add protobuf definitions for snapshot

This commit is contained in:
Torsten Grote 2024-07-11 17:37:11 -03:00
parent 75797f93e7
commit b2307d94dd
No known key found for this signature in database
GPG key ID: 3E5F77D92CF891FF
5 changed files with 95 additions and 3 deletions

View file

@ -8,12 +8,18 @@ android_app {
srcs: [ srcs: [
"app/src/main/java/**/*.kt", "app/src/main/java/**/*.kt",
"app/src/main/java/**/*.java", "app/src/main/java/**/*.java",
"app/src/main/proto/*.proto",
], ],
resource_dirs: [ resource_dirs: [
"app/src/main/res", "app/src/main/res",
], ],
proto: {
type: "lite",
local_include_dirs: ["app/src/main/proto"],
},
static_libs: [ static_libs: [
"kotlin-stdlib-jdk8", "kotlin-stdlib-jdk8",
"libprotobuf-kotlin-lite",
"androidx.core_core-ktx", "androidx.core_core-ktx",
"androidx.fragment_fragment-ktx", "androidx.fragment_fragment-ktx",
"androidx.activity_activity-ktx", "androidx.activity_activity-ktx",

View file

@ -3,12 +3,14 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
import com.google.protobuf.gradle.id
import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
plugins { plugins {
alias(libs.plugins.android.application) alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android) alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.google.protobuf)
} }
val gitDescribe = { val gitDescribe = {
@ -93,6 +95,32 @@ android {
} }
} }
protobuf {
protoc {
artifact = if ("aarch64" == System.getProperty("os.arch")) {
// mac m1
"com.google.protobuf:protoc:${libs.versions.protobuf.get()}:osx-x86_64"
} else {
// other
"com.google.protobuf:protoc:${libs.versions.protobuf.get()}"
}
}
generateProtoTasks {
all().forEach { task ->
task.plugins {
id("java") {
option("lite")
}
}
task.builtins {
id("kotlin") {
option("lite")
}
}
}
}
}
lint { lint {
abortOnError = true abortOnError = true
@ -132,6 +160,7 @@ dependencies {
implementation(libs.androidx.work.runtime.ktx) implementation(libs.androidx.work.runtime.ktx)
implementation(libs.google.material) implementation(libs.google.material)
implementation(libs.google.protobuf.kotlin.lite)
implementation(libs.google.tink.android) implementation(libs.google.tink.android)
/** /**

View file

@ -0,0 +1,56 @@
syntax = "proto3";
package com.stevesoltys.seedvault.proto;
option java_multiple_files = true;
message Snapshot {
uint32 version = 1;
uint64 token = 2;
string name = 3;
string androidId = 4;
uint32 sdkInt = 5;
string androidIncremental = 6;
bool d2d = 7;
map<string, App> apps = 8;
repeated bytes iconChunkIds = 9;
map<string, Blob> blobs = 10;
message App {
uint64 time = 1;
string state = 2;
BackupType type = 3;
string name = 4;
bool system = 5;
bool launchableSystemApp = 6;
repeated bytes chunkIds = 7;
Apk apk = 8;
}
enum BackupType {
FULL = 0;
KV = 1;
}
message Apk {
/**
* Attention: Has default value of 0
*/
uint64 versionCode = 1;
string installer = 2;
repeated bytes signatures = 3;
repeated Split splits = 4;
}
message Split {
string name = 1;
repeated bytes chunkIds = 2;
}
message Blob {
bytes id = 1;
uint32 length = 2;
uint32 uncompressedLength = 3;
}
}

View file

@ -93,6 +93,7 @@ thirdegg-lint-rules = { module = "com.github.thirdegg:lint-rules", version.ref =
# Google dependencies # Google dependencies
google-tink-android = { module = "com.google.crypto.tink:tink-android", version.ref = "tink" } google-tink-android = { module = "com.google.crypto.tink:tink-android", version.ref = "tink" }
google-protobuf-javalite = { module = 'com.google.protobuf:protobuf-javalite', version.ref = 'protobuf' } google-protobuf-javalite = { module = 'com.google.protobuf:protobuf-javalite', version.ref = 'protobuf' }
google-protobuf-kotlin-lite = { module = 'com.google.protobuf:protobuf-kotlin-lite', version.ref = 'protobuf' }
google-material = { module = 'com.google.android.material:material', version.ref = 'material' } google-material = { module = 'com.google.android.material:material', version.ref = 'material' }
# Coroutines dependencies # Coroutines dependencies

View file

@ -48,12 +48,12 @@ android {
protobuf { protobuf {
protoc { protoc {
if ("aarch64" == System.getProperty("os.arch")) { artifact = if ("aarch64" == System.getProperty("os.arch")) {
// mac m1 // mac m1
artifact = "com.google.protobuf:protoc:${libs.versions.protobuf.get()}:osx-x86_64" "com.google.protobuf:protoc:${libs.versions.protobuf.get()}:osx-x86_64"
} else { } else {
// other // other
artifact = "com.google.protobuf:protoc:${libs.versions.protobuf.get()}" "com.google.protobuf:protoc:${libs.versions.protobuf.get()}"
} }
} }
generateProtoTasks { generateProtoTasks {