# Copyright 2024 Google LLC
#
# 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 prevents the names of native methods from being obfuscated and prevents
# UnsatisfiedLinkErrors.
-keepclasseswithmembernames,includedescriptorclasses class * {
    native <methods>;
}


# This file allows configuration of proguard via annotations. Apply them to
# the elements of your program not only to ensure correct proguard
# functionality, but to document non-obvious entry points to your code to make
# it survive refactorings.

# Annotations are implemented as attributes, so we have to explicitly keep them.
# Catch all which encompasses attributes like RuntimeVisibleParameterAnnotations
# and RuntimeVisibleTypeAnnotations
-keepattributes RuntimeVisible*Annotation*

# JNI is an entry point that's hard to keep track of, so there's
# an annotation to mark fields and methods used by native code.

# Keep the annotations that proguard needs to process.
-keep class com.google.android.nearby.presence.rust.UsedBy*

# Just because native code accesses members of a class, does not mean that the
# class itself needs to be annotated - only annotate classes that are
# referenced themselves in native code.
-keep @com.google.android.nearby.presence.rust.UsedBy* class * {
  <init>();
}
-keepclassmembers class * {
    @com.google.android.nearby.presence.rust.UsedBy* *;
}

-dontwarn java.**
-dontwarn androidx.**
-dontwarn com.google.android.cooperativecleaner.**
-dontwarn com.google.errorprone.**
-dontwarn org.checkerframework.**

# This exception only exists since Proguard will complain about a missing
# `int ordinal()` method otherwise, even though this always exists for all Java enums.
-dontwarn com.google.android.nearby.presence.rust.V1DataElement$ByteValuePrintFormat
