Merge "Move to jarjaring health:health-services-client proto dependency" into androidx-main
diff --git a/health/health-services-client-external-protobuf/api/current.txt b/health/health-services-client-external-protobuf/api/current.txt
new file mode 100644
index 0000000..e6f50d0
--- /dev/null
+++ b/health/health-services-client-external-protobuf/api/current.txt
@@ -0,0 +1 @@
+// Signature format: 4.0
diff --git a/health/health-services-client-external-protobuf/api/restricted_current.txt b/health/health-services-client-external-protobuf/api/restricted_current.txt
new file mode 100644
index 0000000..e6f50d0
--- /dev/null
+++ b/health/health-services-client-external-protobuf/api/restricted_current.txt
@@ -0,0 +1 @@
+// Signature format: 4.0
diff --git a/health/health-services-client-external-protobuf/build.gradle b/health/health-services-client-external-protobuf/build.gradle
new file mode 100644
index 0000000..2df05b1
--- /dev/null
+++ b/health/health-services-client-external-protobuf/build.gradle
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This file was created using the `create_project.py` script located in the
+ * `<AndroidX root>/development/project-creator` directory.
+ *
+ * Please use that script when creating a new project, rather than copying an existing project and
+ * modifying its settings.
+ */
+import androidx.build.LibraryType
+
+plugins {
+    id("AndroidXPlugin")
+    id("AndroidXRepackagePlugin")
+    id("java-library")
+}
+
+repackage {
+    addRelocation {
+        sourcePackage = "com.google.protobuf"
+        targetPackage =  "androidx.health.services.client.proto"
+    }
+    artifactId = "health-services-client-external-protobuf"
+}
+
+dependencies {
+    repackage(libs.protobufLite)
+}
+
+androidx {
+    name = "Health Services Client External Protobuf"
+    type = LibraryType.PUBLISHED_LIBRARY
+    mavenVersion = LibraryVersions.HEALTH_SERVICES_CLIENT
+    inceptionYear = "2024"
+    description =  "Repackaged proto-lite dependency for use by health"
+    doNotDocumentReason = "Repackaging only"
+    license.name = "BSD-3-Clause"
+    license.url = "https://opensource.org/licenses/BSD-3-Clause"
+}
diff --git a/health/health-services-client-proto/build.gradle b/health/health-services-client-proto/build.gradle
new file mode 100644
index 0000000..95300ca
--- /dev/null
+++ b/health/health-services-client-proto/build.gradle
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This file was created using the `create_project.py` script located in the
+ * `<AndroidX root>/development/project-creator` directory.
+ *
+ * Please use that script when creating a new project, rather than copying an existing project and
+ * modifying its settings.
+ */
+
+import androidx.build.LibraryType
+import androidx.build.RunApiTasks
+
+plugins {
+    id("AndroidXPlugin")
+    id("AndroidXRepackagePlugin")
+    id("java-library")
+    id("com.google.protobuf")
+}
+
+repackage {
+    // Must match what is in health/health-services-client-external-protobuf/build.gradle
+    addRelocation {
+        sourcePackage = "com.google.protobuf"
+        targetPackage =  "androidx.health.services.client.proto"
+    }
+}
+
+dependencies {
+    implementation("androidx.annotation:annotation:1.8.1")
+    // Must be compileOnly to not bring in protobufLite in runtime
+    // Repackaged protobufLite brought in by
+    // project(":health:health-services-client-external-protobuf") and used at runtime
+    compileOnly(libs.protobufLite)
+    api(project(":health:health-services-client-external-protobuf"))
+}
+
+androidx {
+    name = "Health Services Client Proto"
+    type = LibraryType.PUBLISHED_PROTO_LIBRARY
+    mavenVersion = LibraryVersions.HEALTH_SERVICES_CLIENT
+    inceptionYear = "2022"
+    description = "Proto files for health-services-client"
+}
diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/proto/package-info.java b/health/health-services-client-proto/src/main/java/androidx/health/services/client/proto/package-info.java
similarity index 92%
rename from health/health-services-client/src/main/java/androidx/health/services/client/proto/package-info.java
rename to health/health-services-client-proto/src/main/java/androidx/health/services/client/proto/package-info.java
index 6d0b839..3bea376 100644
--- a/health/health-services-client/src/main/java/androidx/health/services/client/proto/package-info.java
+++ b/health/health-services-client-proto/src/main/java/androidx/health/services/client/proto/package-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2021 The Android Open Source Project
+ * Copyright 2024 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/health/health-services-client/src/main/proto/data.proto b/health/health-services-client-proto/src/main/proto/data.proto
similarity index 100%
rename from health/health-services-client/src/main/proto/data.proto
rename to health/health-services-client-proto/src/main/proto/data.proto
diff --git a/health/health-services-client/src/main/proto/events.proto b/health/health-services-client-proto/src/main/proto/events.proto
similarity index 100%
rename from health/health-services-client/src/main/proto/events.proto
rename to health/health-services-client-proto/src/main/proto/events.proto
diff --git a/health/health-services-client/src/main/proto/requests.proto b/health/health-services-client-proto/src/main/proto/requests.proto
similarity index 100%
rename from health/health-services-client/src/main/proto/requests.proto
rename to health/health-services-client-proto/src/main/proto/requests.proto
diff --git a/health/health-services-client/src/main/proto/responses.proto b/health/health-services-client-proto/src/main/proto/responses.proto
similarity index 100%
rename from health/health-services-client/src/main/proto/responses.proto
rename to health/health-services-client-proto/src/main/proto/responses.proto
diff --git a/health/health-services-client/build.gradle b/health/health-services-client/build.gradle
index 2c89200..f230ecb 100644
--- a/health/health-services-client/build.gradle
+++ b/health/health-services-client/build.gradle
@@ -26,7 +26,6 @@
 plugins {
     id("AndroidXPlugin")
     id("com.android.library")
-    id("com.google.protobuf")
     id("org.jetbrains.kotlin.android")
     id("androidx.stableaidl")
 }
@@ -39,7 +38,7 @@
     implementation(libs.guavaAndroid)
     implementation("androidx.core:core-ktx:1.7.0")
     implementation("androidx.concurrent:concurrent-futures-ktx:1.1.0")
-    implementation(libs.protobufLite)
+    implementation(project(":health:health-services-client-proto"))
 
     testImplementation(libs.junit)
     testImplementation(libs.kotlinReflect)
diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/BundlesUtil.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/BundlesUtil.kt
index 1d81efb..89d9e16 100644
--- a/health/health-services-client/src/main/java/androidx/health/services/client/data/BundlesUtil.kt
+++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/BundlesUtil.kt
@@ -17,8 +17,8 @@
 package androidx.health.services.client.data
 
 import android.os.Bundle
+import androidx.health.services.client.proto.ByteString
 import androidx.health.services.client.proto.DataProto
-import com.google.protobuf.ByteString
 
 /** Utility methods for working with Bundles. */
 internal object BundlesUtil {
diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/DataType.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/DataType.kt
index 2ecb8ec..cbeae5c 100644
--- a/health/health-services-client/src/main/java/androidx/health/services/client/data/DataType.kt
+++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/DataType.kt
@@ -19,11 +19,11 @@
 import android.util.Log
 import androidx.health.services.client.data.DataType.Companion.DISTANCE
 import androidx.health.services.client.data.DataType.TimeType
+import androidx.health.services.client.proto.ByteString
 import androidx.health.services.client.proto.DataProto
 import androidx.health.services.client.proto.DataProto.DataType.TimeType.TIME_TYPE_INTERVAL
 import androidx.health.services.client.proto.DataProto.DataType.TimeType.TIME_TYPE_SAMPLE
 import androidx.health.services.client.proto.DataProto.DataType.TimeType.TIME_TYPE_UNKNOWN
-import com.google.protobuf.ByteString
 
 /**
  * [DataType] that represents a granular, non-aggregated point in time. This will map to
diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/ProtoParcelable.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/ProtoParcelable.kt
index 4c98c731..01f6994 100644
--- a/health/health-services-client/src/main/java/androidx/health/services/client/data/ProtoParcelable.kt
+++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/ProtoParcelable.kt
@@ -20,7 +20,7 @@
 import android.os.Parcelable
 import android.os.Parcelable.Creator
 import androidx.annotation.RestrictTo
-import com.google.protobuf.MessageLite
+import androidx.health.services.client.proto.MessageLite
 
 /**
  * Base class for parcelables backed by Protocol Buffers.
diff --git a/settings.gradle b/settings.gradle
index 36aeee2..35b07da 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -739,6 +739,8 @@
 includeProject(":health:connect:connect-testing", [BuildType.MAIN])
 includeProject(":health:connect:connect-testing-samples", "health/connect/connect-testing/samples", [BuildType.MAIN])
 includeProject(":health:health-services-client", [BuildType.MAIN])
+includeProject(":health:health-services-client-proto", [BuildType.MAIN])
+includeProject(":health:health-services-client-external-protobuf", [BuildType.MAIN])
 includeProject(":heifwriter:heifwriter", [BuildType.MAIN])
 includeProject(":hilt:hilt-common", [BuildType.MAIN])
 includeProject(":hilt:hilt-compiler", [BuildType.MAIN])