package io.flutter.plugin.platform; import android.app.Activity; import android.app.ActivityManager; import android.content.ClipData; import android.content.ClipDescription; import android.content.ClipboardManager; import android.graphics.Bitmap; import android.os.Build; import android.view.View; import android.view.Window; import androidx.core.view.WindowInsetsControllerCompat; import io.flutter.Log; import io.flutter.embedding.engine.systemchannels.PlatformChannel; import io.flutter.plugin.platform.PlatformPlugin; import java.io.FileNotFoundException; import java.util.List; import o.NHB; import org.bouncycastle.asn1.cmp.PKIFailureInfo; /* loaded from: classes6.dex */ public class PlatformPlugin { public static final int DEFAULT_SYSTEM_UI = 1280; private static final String TAG = "PlatformPlugin"; private final Activity activity; private PlatformChannel.SystemChromeStyle currentTheme; private int mEnabledOverlays; final PlatformChannel.PlatformMessageHandler mPlatformMessageHandler; private final PlatformChannel platformChannel; private final PlatformPluginDelegate platformPluginDelegate; /* loaded from: classes6.dex */ public interface PlatformPluginDelegate { boolean popSystemNavigator(); } public PlatformPlugin(Activity activity, PlatformChannel platformChannel) { this(activity, platformChannel, null); } public PlatformPlugin(Activity activity, PlatformChannel platformChannel, PlatformPluginDelegate platformPluginDelegate) { PlatformChannel.PlatformMessageHandler platformMessageHandler = new PlatformChannel.PlatformMessageHandler(this) { // from class: io.flutter.plugin.platform.PlatformPlugin.1 final PlatformPlugin this$0; { this.this$0 = this; } @Override // io.flutter.embedding.engine.systemchannels.PlatformChannel.PlatformMessageHandler public void playSystemSound(PlatformChannel.SoundType soundType) { this.this$0.playSystemSound(soundType); } @Override // io.flutter.embedding.engine.systemchannels.PlatformChannel.PlatformMessageHandler public void vibrateHapticFeedback(PlatformChannel.HapticFeedbackType hapticFeedbackType) { this.this$0.vibrateHapticFeedback(hapticFeedbackType); } @Override // io.flutter.embedding.engine.systemchannels.PlatformChannel.PlatformMessageHandler public void setPreferredOrientations(int i) { this.this$0.setSystemChromePreferredOrientations(i); } @Override // io.flutter.embedding.engine.systemchannels.PlatformChannel.PlatformMessageHandler public void setApplicationSwitcherDescription(PlatformChannel.AppSwitcherDescription appSwitcherDescription) { this.this$0.setSystemChromeApplicationSwitcherDescription(appSwitcherDescription); } @Override // io.flutter.embedding.engine.systemchannels.PlatformChannel.PlatformMessageHandler public void showSystemOverlays(List list) { this.this$0.setSystemChromeEnabledSystemUIOverlays(list); } @Override // io.flutter.embedding.engine.systemchannels.PlatformChannel.PlatformMessageHandler public void showSystemUiMode(PlatformChannel.SystemUiMode systemUiMode) { this.this$0.setSystemChromeEnabledSystemUIMode(systemUiMode); } @Override // io.flutter.embedding.engine.systemchannels.PlatformChannel.PlatformMessageHandler public void setSystemUiChangeListener() { this.this$0.setSystemChromeChangeListener(); } @Override // io.flutter.embedding.engine.systemchannels.PlatformChannel.PlatformMessageHandler public void restoreSystemUiOverlays() { this.this$0.restoreSystemChromeSystemUIOverlays(); } @Override // io.flutter.embedding.engine.systemchannels.PlatformChannel.PlatformMessageHandler public void setSystemUiOverlayStyle(PlatformChannel.SystemChromeStyle systemChromeStyle) { this.this$0.setSystemChromeSystemUIOverlayStyle(systemChromeStyle); } @Override // io.flutter.embedding.engine.systemchannels.PlatformChannel.PlatformMessageHandler public void popSystemNavigator() { this.this$0.popSystemNavigator(); } @Override // io.flutter.embedding.engine.systemchannels.PlatformChannel.PlatformMessageHandler public CharSequence getClipboardData(PlatformChannel.ClipboardContentFormat clipboardContentFormat) { return this.this$0.getClipboardData(clipboardContentFormat); } @Override // io.flutter.embedding.engine.systemchannels.PlatformChannel.PlatformMessageHandler public void setClipboardData(String str) { this.this$0.setClipboardData(str); } @Override // io.flutter.embedding.engine.systemchannels.PlatformChannel.PlatformMessageHandler public boolean clipboardHasStrings() { return this.this$0.clipboardHasStrings(); } }; this.mPlatformMessageHandler = platformMessageHandler; this.activity = activity; this.platformChannel = platformChannel; platformChannel.setPlatformMessageHandler(platformMessageHandler); this.platformPluginDelegate = platformPluginDelegate; this.mEnabledOverlays = DEFAULT_SYSTEM_UI; } public void destroy() { this.platformChannel.setPlatformMessageHandler(null); } /* JADX INFO: Access modifiers changed from: private */ public void playSystemSound(PlatformChannel.SoundType soundType) { if (soundType == PlatformChannel.SoundType.CLICK) { this.activity.getWindow().getDecorView().playSoundEffect(0); } } void vibrateHapticFeedback(PlatformChannel.HapticFeedbackType hapticFeedbackType) { View decorView = this.activity.getWindow().getDecorView(); int i = AnonymousClass3.$SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$HapticFeedbackType[hapticFeedbackType.ordinal()]; if (i == 1) { decorView.performHapticFeedback(0); return; } if (i == 2) { decorView.performHapticFeedback(1); return; } if (i == 3) { decorView.performHapticFeedback(3); } else if (i == 4) { decorView.performHapticFeedback(6); } else { if (i != 5) { return; } decorView.performHapticFeedback(4); } } /* JADX INFO: Access modifiers changed from: private */ public void setSystemChromePreferredOrientations(int i) { this.activity.setRequestedOrientation(i); } /* JADX INFO: Access modifiers changed from: private */ public void setSystemChromeApplicationSwitcherDescription(PlatformChannel.AppSwitcherDescription appSwitcherDescription) { if (Build.VERSION.SDK_INT < 28) { this.activity.setTaskDescription(new ActivityManager.TaskDescription(appSwitcherDescription.label, (Bitmap) null, appSwitcherDescription.color)); } if (Build.VERSION.SDK_INT >= 28) { this.activity.setTaskDescription(new ActivityManager.TaskDescription(appSwitcherDescription.label, 0, appSwitcherDescription.color)); } } /* JADX INFO: Access modifiers changed from: private */ public void setSystemChromeChangeListener() { View decorView = this.activity.getWindow().getDecorView(); decorView.setOnSystemUiVisibilityChangeListener(new AnonymousClass2(this, decorView)); } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: io.flutter.plugin.platform.PlatformPlugin$2, reason: invalid class name */ /* loaded from: classes6.dex */ public class AnonymousClass2 implements View.OnSystemUiVisibilityChangeListener { final PlatformPlugin this$0; final View val$decorView; AnonymousClass2(PlatformPlugin platformPlugin, View view) { this.this$0 = platformPlugin; this.val$decorView = view; } @Override // android.view.View.OnSystemUiVisibilityChangeListener public void onSystemUiVisibilityChange(final int i) { this.val$decorView.post(new Runnable(this, i) { // from class: io.flutter.plugin.platform.PlatformPlugin$2$$ExternalSyntheticLambda0 public final PlatformPlugin.AnonymousClass2 f$0; public final int f$1; { this.f$0 = this; this.f$1 = i; } @Override // java.lang.Runnable public final void run() { this.f$0.m335x970b83d5(this.f$1); } }); } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: lambda$onSystemUiVisibilityChange$0$io-flutter-plugin-platform-PlatformPlugin$2, reason: not valid java name */ public /* synthetic */ void m335x970b83d5(int i) { if ((i & 4) == 0) { this.this$0.platformChannel.systemChromeChanged(true); } else { this.this$0.platformChannel.systemChromeChanged(false); } } } /* JADX INFO: Access modifiers changed from: private */ public void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode systemUiMode) { int i; if (systemUiMode == PlatformChannel.SystemUiMode.LEAN_BACK) { i = 1798; } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE) { i = 3846; } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE_STICKY) { i = 5894; } else if (systemUiMode != PlatformChannel.SystemUiMode.EDGE_TO_EDGE || Build.VERSION.SDK_INT < 29) { return; } else { i = 1792; } this.mEnabledOverlays = i; updateSystemUiOverlays(); } /* JADX INFO: Access modifiers changed from: private */ public void setSystemChromeEnabledSystemUIOverlays(List list) { int i = list.size() == 0 ? 5894 : 1798; for (int i2 = 0; i2 < list.size(); i2++) { int i3 = AnonymousClass3.$SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$SystemUiOverlay[list.get(i2).ordinal()]; if (i3 == 1) { i &= -5; } else if (i3 == 2) { i &= -515; } } this.mEnabledOverlays = i; updateSystemUiOverlays(); } public void updateSystemUiOverlays() { this.activity.getWindow().getDecorView().setSystemUiVisibility(this.mEnabledOverlays); PlatformChannel.SystemChromeStyle systemChromeStyle = this.currentTheme; if (systemChromeStyle != null) { setSystemChromeSystemUIOverlayStyle(systemChromeStyle); } } /* JADX INFO: Access modifiers changed from: private */ public void restoreSystemChromeSystemUIOverlays() { updateSystemUiOverlays(); } /* JADX INFO: Access modifiers changed from: private */ public void setSystemChromeSystemUIOverlayStyle(PlatformChannel.SystemChromeStyle systemChromeStyle) { Window window = this.activity.getWindow(); WindowInsetsControllerCompat windowInsetsControllerCompat = new WindowInsetsControllerCompat(window, window.getDecorView()); if (Build.VERSION.SDK_INT < 30) { window.addFlags(PKIFailureInfo.systemUnavail); window.clearFlags(201326592); } if (systemChromeStyle.statusBarIconBrightness != null) { int i = AnonymousClass3.$SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$Brightness[systemChromeStyle.statusBarIconBrightness.ordinal()]; if (i == 1) { windowInsetsControllerCompat.e(true); } else if (i == 2) { windowInsetsControllerCompat.e(false); } } if (systemChromeStyle.statusBarColor != null) { window.setStatusBarColor(systemChromeStyle.statusBarColor.intValue()); } if (systemChromeStyle.systemStatusBarContrastEnforced != null && Build.VERSION.SDK_INT >= 29) { window.setStatusBarContrastEnforced(systemChromeStyle.systemStatusBarContrastEnforced.booleanValue()); } if (systemChromeStyle.systemNavigationBarIconBrightness != null) { int i2 = AnonymousClass3.$SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$Brightness[systemChromeStyle.systemNavigationBarIconBrightness.ordinal()]; if (i2 == 1) { windowInsetsControllerCompat.d(true); } else if (i2 == 2) { windowInsetsControllerCompat.d(false); } } if (systemChromeStyle.systemNavigationBarColor != null) { window.setNavigationBarColor(systemChromeStyle.systemNavigationBarColor.intValue()); } if (systemChromeStyle.systemNavigationBarDividerColor != null && Build.VERSION.SDK_INT >= 28) { window.setNavigationBarDividerColor(systemChromeStyle.systemNavigationBarDividerColor.intValue()); } if (systemChromeStyle.systemNavigationBarContrastEnforced != null && Build.VERSION.SDK_INT >= 29) { window.setNavigationBarContrastEnforced(systemChromeStyle.systemNavigationBarContrastEnforced.booleanValue()); } this.currentTheme = systemChromeStyle; } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: io.flutter.plugin.platform.PlatformPlugin$3, reason: invalid class name */ /* loaded from: classes6.dex */ public static /* synthetic */ class AnonymousClass3 { static final int[] $SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$Brightness; static final int[] $SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$HapticFeedbackType; static final int[] $SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$SystemUiOverlay; static { int[] iArr = new int[PlatformChannel.Brightness.values().length]; $SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$Brightness = iArr; try { iArr[PlatformChannel.Brightness.DARK.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { $SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$Brightness[PlatformChannel.Brightness.LIGHT.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } int[] iArr2 = new int[PlatformChannel.SystemUiOverlay.values().length]; $SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$SystemUiOverlay = iArr2; try { iArr2[PlatformChannel.SystemUiOverlay.TOP_OVERLAYS.ordinal()] = 1; } catch (NoSuchFieldError unused3) { } try { $SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$SystemUiOverlay[PlatformChannel.SystemUiOverlay.BOTTOM_OVERLAYS.ordinal()] = 2; } catch (NoSuchFieldError unused4) { } int[] iArr3 = new int[PlatformChannel.HapticFeedbackType.values().length]; $SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$HapticFeedbackType = iArr3; try { iArr3[PlatformChannel.HapticFeedbackType.STANDARD.ordinal()] = 1; } catch (NoSuchFieldError unused5) { } try { $SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$HapticFeedbackType[PlatformChannel.HapticFeedbackType.LIGHT_IMPACT.ordinal()] = 2; } catch (NoSuchFieldError unused6) { } try { $SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$HapticFeedbackType[PlatformChannel.HapticFeedbackType.MEDIUM_IMPACT.ordinal()] = 3; } catch (NoSuchFieldError unused7) { } try { $SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$HapticFeedbackType[PlatformChannel.HapticFeedbackType.HEAVY_IMPACT.ordinal()] = 4; } catch (NoSuchFieldError unused8) { } try { $SwitchMap$io$flutter$embedding$engine$systemchannels$PlatformChannel$HapticFeedbackType[PlatformChannel.HapticFeedbackType.SELECTION_CLICK.ordinal()] = 5; } catch (NoSuchFieldError unused9) { } } } /* JADX INFO: Access modifiers changed from: private */ /* JADX WARN: Multi-variable type inference failed */ public void popSystemNavigator() { PlatformPluginDelegate platformPluginDelegate = this.platformPluginDelegate; if (platformPluginDelegate == null || !platformPluginDelegate.popSystemNavigator()) { Activity activity = this.activity; if (activity instanceof NHB) { ((NHB) activity).getOnBackPressedDispatcher().a(); } else { activity.finish(); } } } /* JADX INFO: Access modifiers changed from: private */ public CharSequence getClipboardData(PlatformChannel.ClipboardContentFormat clipboardContentFormat) { ClipboardManager clipboardManager = (ClipboardManager) this.activity.getSystemService("clipboard"); if (!clipboardManager.hasPrimaryClip()) { return null; } try { ClipData primaryClip = clipboardManager.getPrimaryClip(); if (primaryClip == null) { return null; } if (clipboardContentFormat != null && clipboardContentFormat != PlatformChannel.ClipboardContentFormat.PLAIN_TEXT) { return null; } ClipData.Item itemAt = primaryClip.getItemAt(0); if (itemAt.getUri() != null) { this.activity.getContentResolver().openTypedAssetFileDescriptor(itemAt.getUri(), "text/*", null); } return itemAt.coerceToText(this.activity); } catch (FileNotFoundException unused) { return null; } catch (SecurityException e) { Log.w(TAG, "Attempted to get clipboard data that requires additional permission(s).\nSee the exception details for which permission(s) are required, and consider adding them to your Android Manifest as described in:\nhttps://developer.android.com/guide/topics/permissions/overview", e); return null; } } /* JADX INFO: Access modifiers changed from: private */ public void setClipboardData(String str) { ((ClipboardManager) this.activity.getSystemService("clipboard")).setPrimaryClip(ClipData.newPlainText("text label?", str)); } /* JADX INFO: Access modifiers changed from: private */ public boolean clipboardHasStrings() { ClipDescription primaryClipDescription; ClipboardManager clipboardManager = (ClipboardManager) this.activity.getSystemService("clipboard"); if (clipboardManager.hasPrimaryClip() && (primaryClipDescription = clipboardManager.getPrimaryClipDescription()) != null) { return primaryClipDescription.hasMimeType("text/*"); } return false; } }