mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-21 13:23:22 +01:00
105 lines
3.9 KiB
Java
105 lines
3.9 KiB
Java
package androidx.camera.extensions.internal;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.VisibleForTesting;
|
|
import androidx.camera.core.Logger;
|
|
import androidx.camera.extensions.impl.ExtensionVersionImpl;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes.dex */
|
|
public abstract class ExtensionVersion {
|
|
private static final String TAG = "ExtenderVersion";
|
|
private static volatile ExtensionVersion sExtensionVersion;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class DefaultExtenderVersioning extends ExtensionVersion {
|
|
@Override // androidx.camera.extensions.internal.ExtensionVersion
|
|
public Version getVersionObject() {
|
|
return null;
|
|
}
|
|
|
|
@Override // androidx.camera.extensions.internal.ExtensionVersion
|
|
public boolean isAdvancedExtenderSupportedInternal() {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class VendorExtenderVersioning extends ExtensionVersion {
|
|
private static ExtensionVersionImpl sImpl;
|
|
private Version mRuntimeVersion;
|
|
|
|
public VendorExtenderVersioning() {
|
|
if (sImpl == null) {
|
|
sImpl = new ExtensionVersionImpl();
|
|
}
|
|
Version parse = Version.parse(sImpl.checkApiVersion(ClientVersion.getCurrentVersion().toVersionString()));
|
|
if (parse != null && ClientVersion.getCurrentVersion().getVersion().getMajor() == parse.getMajor()) {
|
|
this.mRuntimeVersion = parse;
|
|
}
|
|
Logger.d(ExtensionVersion.TAG, "Selected vendor runtime: " + this.mRuntimeVersion);
|
|
}
|
|
|
|
@Override // androidx.camera.extensions.internal.ExtensionVersion
|
|
public Version getVersionObject() {
|
|
return this.mRuntimeVersion;
|
|
}
|
|
|
|
@Override // androidx.camera.extensions.internal.ExtensionVersion
|
|
public boolean isAdvancedExtenderSupportedInternal() {
|
|
try {
|
|
return sImpl.isAdvancedExtenderImplemented();
|
|
} catch (NoSuchMethodError unused) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
private static ExtensionVersion getInstance() {
|
|
if (sExtensionVersion != null) {
|
|
return sExtensionVersion;
|
|
}
|
|
synchronized (ExtensionVersion.class) {
|
|
if (sExtensionVersion == null) {
|
|
try {
|
|
sExtensionVersion = new VendorExtenderVersioning();
|
|
} catch (NoClassDefFoundError unused) {
|
|
Logger.d(TAG, "No versioning extender found. Falling back to default.");
|
|
sExtensionVersion = new DefaultExtenderVersioning();
|
|
}
|
|
}
|
|
}
|
|
return sExtensionVersion;
|
|
}
|
|
|
|
@Nullable
|
|
public static Version getRuntimeVersion() {
|
|
return getInstance().getVersionObject();
|
|
}
|
|
|
|
@VisibleForTesting
|
|
public static void injectInstance(@Nullable ExtensionVersion extensionVersion) {
|
|
sExtensionVersion = extensionVersion;
|
|
}
|
|
|
|
public static boolean isAdvancedExtenderSupported() {
|
|
return getInstance().isAdvancedExtenderSupportedInternal();
|
|
}
|
|
|
|
public static boolean isExtensionVersionSupported() {
|
|
return getInstance().getVersionObject() != null;
|
|
}
|
|
|
|
public static boolean isMaximumCompatibleVersion(@NonNull Version version) {
|
|
return getRuntimeVersion().compareTo(version.getMajor(), version.getMinor()) <= 0;
|
|
}
|
|
|
|
public static boolean isMinimumCompatibleVersion(@NonNull Version version) {
|
|
return getRuntimeVersion().compareTo(version.getMajor(), version.getMinor()) >= 0;
|
|
}
|
|
|
|
public abstract Version getVersionObject();
|
|
|
|
public abstract boolean isAdvancedExtenderSupportedInternal();
|
|
}
|