1 /* 2 * Copyright 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.window.core 18 19 import android.util.Log 20 import androidx.annotation.IntRange 21 import androidx.window.core.VerificationMode.LOG 22 import androidx.window.extensions.WindowExtensionsProvider 23 24 internal object ExtensionsUtil { 25 26 private val TAG = ExtensionsUtil::class.simpleName 27 28 @get:IntRange(from = 0) 29 val safeVendorApiLevel: Int 30 get() { 31 return try { 32 WindowExtensionsProvider.getWindowExtensions().vendorApiLevel 33 } catch (e: NoClassDefFoundError) { 34 if (BuildConfig.verificationMode == LOG) { 35 Log.d(TAG, "Embedding extension version not found") 36 } 37 0 38 } catch (e: UnsupportedOperationException) { 39 if (BuildConfig.verificationMode == LOG) { 40 Log.d(TAG, "Stub Extension") 41 } 42 0 43 } 44 } 45 } 46