blob: 6038eff5cfda0da2e5c5dcd95c14e08a0bb8bb5c [file] [log] [blame]
/*
* Copyright (C) 2020 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.
*/
package com.android.build.shrinker.usages
import com.android.build.shrinker.obfuscation.ObfuscatedClasses
import java.util.function.Predicate
internal object AppCompat {
// Known AppCompat classes which use Resources.getIdentifier but should not trigger mode that
// tries to find used resources based on collected strings.
internal val APP_COMPAT_CLASSES_ALLOWED_FOR_GET_IDENTIFIER = setOf(
"android.support.v7.widget.SuggestionsAdapter",
"android.support.v7.internal.widget.ResourcesWrapper",
"android.support.v7.widget.ResourcesWrapper",
"android.support.v7.widget.TintContextWrapper\$TintResources"
)
internal fun isAppCompatClass(name: String, obfuscation: ObfuscatedClasses): Boolean =
APP_COMPAT_CLASSES_ALLOWED_FOR_GET_IDENTIFIER.contains(obfuscation.resolveOriginalClass(name))
fun getRequiredClassNamesPredicate(): Predicate<String> {
return Predicate {
className -> APP_COMPAT_CLASSES_ALLOWED_FOR_GET_IDENTIFIER.contains(className)
}
}
}