mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-17 03:17:17 +01:00
102 lines
3.8 KiB
Java
102 lines
3.8 KiB
Java
package androidx.webkit.internal;
|
|
|
|
import android.content.ComponentName;
|
|
import android.content.Context;
|
|
import android.content.pm.PackageInfo;
|
|
import android.content.pm.PackageManager;
|
|
import android.content.pm.ServiceInfo;
|
|
import android.os.Build;
|
|
import android.os.Bundle;
|
|
import androidx.annotation.VisibleForTesting;
|
|
import androidx.webkit.WebViewCompat;
|
|
import java.util.Collections;
|
|
import java.util.HashSet;
|
|
import java.util.Set;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes14.dex */
|
|
public abstract class StartupApiFeature {
|
|
static final /* synthetic */ boolean $assertionsDisabled = false;
|
|
|
|
@VisibleForTesting
|
|
public static final String METADATA_HOLDER_SERVICE_NAME = "org.chromium.android_webview.services.StartupFeatureMetadataHolder";
|
|
private static final Set<StartupApiFeature> sValues = new HashSet();
|
|
private final String mInternalFeatureValue;
|
|
private final String mPublicFeatureValue;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class NoFramework extends StartupApiFeature {
|
|
public NoFramework(String str, String str2) {
|
|
super(str, str2);
|
|
}
|
|
|
|
@Override // androidx.webkit.internal.StartupApiFeature
|
|
public final boolean isSupportedByFramework() {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class P extends StartupApiFeature {
|
|
public P(String str, String str2) {
|
|
super(str, str2);
|
|
}
|
|
|
|
@Override // androidx.webkit.internal.StartupApiFeature
|
|
public final boolean isSupportedByFramework() {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public StartupApiFeature(String str, String str2) {
|
|
this.mPublicFeatureValue = str;
|
|
this.mInternalFeatureValue = str2;
|
|
sValues.add(this);
|
|
}
|
|
|
|
private static Bundle getMetaDataFromWebViewManifestOrNull(Context context) {
|
|
PackageInfo currentWebViewPackage = WebViewCompat.getCurrentWebViewPackage(context);
|
|
if (currentWebViewPackage == null) {
|
|
return null;
|
|
}
|
|
ComponentName componentName = new ComponentName(currentWebViewPackage.packageName, METADATA_HOLDER_SERVICE_NAME);
|
|
if (Build.VERSION.SDK_INT < 33) {
|
|
try {
|
|
return getServiceInfo(context, componentName, 640).metaData;
|
|
} catch (PackageManager.NameNotFoundException unused) {
|
|
return null;
|
|
}
|
|
}
|
|
try {
|
|
return ApiHelperForTiramisu.getServiceInfo(context.getPackageManager(), componentName, ApiHelperForTiramisu.of(640L)).metaData;
|
|
} catch (PackageManager.NameNotFoundException unused2) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
private static ServiceInfo getServiceInfo(Context context, ComponentName componentName, int i) throws PackageManager.NameNotFoundException {
|
|
return context.getPackageManager().getServiceInfo(componentName, i);
|
|
}
|
|
|
|
public static Set<StartupApiFeature> values() {
|
|
return Collections.unmodifiableSet(sValues);
|
|
}
|
|
|
|
public String getPublicFeatureName() {
|
|
return this.mPublicFeatureValue;
|
|
}
|
|
|
|
public boolean isSupported(Context context) {
|
|
return isSupportedByFramework() || isSupportedByWebView(context);
|
|
}
|
|
|
|
public abstract boolean isSupportedByFramework();
|
|
|
|
public boolean isSupportedByWebView(Context context) {
|
|
Bundle metaDataFromWebViewManifestOrNull = getMetaDataFromWebViewManifestOrNull(context);
|
|
if (metaDataFromWebViewManifestOrNull == null) {
|
|
return false;
|
|
}
|
|
return metaDataFromWebViewManifestOrNull.containsKey(this.mInternalFeatureValue);
|
|
}
|
|
}
|