diff --git a/Android.bp b/Android.bp index d9112808..eba85fd6 100644 --- a/Android.bp +++ b/Android.bp @@ -8,12 +8,18 @@ android_app { srcs: [ "app/src/main/java/**/*.kt", "app/src/main/java/**/*.java", + "app/src/main/proto/*.proto", ], resource_dirs: [ "app/src/main/res", ], + proto: { + type: "lite", + local_include_dirs: ["app/src/main/proto"], + }, static_libs: [ "kotlin-stdlib-jdk8", + "libprotobuf-kotlin-lite", "androidx.core_core-ktx", "androidx.fragment_fragment-ktx", "androidx.activity_activity-ktx", diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 985822f3..421fb697 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -3,12 +3,14 @@ // SPDX-License-Identifier: Apache-2.0 // +import com.google.protobuf.gradle.id import org.gradle.api.tasks.testing.logging.TestExceptionFormat import java.io.ByteArrayOutputStream plugins { alias(libs.plugins.android.application) alias(libs.plugins.jetbrains.kotlin.android) + alias(libs.plugins.google.protobuf) } 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 { abortOnError = true @@ -132,6 +160,7 @@ dependencies { implementation(libs.androidx.work.runtime.ktx) implementation(libs.google.material) + implementation(libs.google.protobuf.kotlin.lite) implementation(libs.google.tink.android) /** diff --git a/app/src/main/proto/snapshot.proto b/app/src/main/proto/snapshot.proto new file mode 100644 index 00000000..e5e20823 --- /dev/null +++ b/app/src/main/proto/snapshot.proto @@ -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 apps = 8; + repeated bytes iconChunkIds = 9; + map 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; + } + +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e4c40d10..65b43704 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -93,6 +93,7 @@ thirdegg-lint-rules = { module = "com.github.thirdegg:lint-rules", version.ref = # Google dependencies 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-kotlin-lite = { module = 'com.google.protobuf:protobuf-kotlin-lite', version.ref = 'protobuf' } google-material = { module = 'com.google.android.material:material', version.ref = 'material' } # Coroutines dependencies diff --git a/storage/lib/build.gradle.kts b/storage/lib/build.gradle.kts index 5ada1faa..9719b4b8 100644 --- a/storage/lib/build.gradle.kts +++ b/storage/lib/build.gradle.kts @@ -48,12 +48,12 @@ android { protobuf { protoc { - if ("aarch64" == System.getProperty("os.arch")) { + artifact = if ("aarch64" == System.getProperty("os.arch")) { // 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 { // other - artifact = "com.google.protobuf:protoc:${libs.versions.protobuf.get()}" + "com.google.protobuf:protoc:${libs.versions.protobuf.get()}" } } generateProtoTasks {