package io.flutter.plugin.platform;

import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.res.AssetFileDescriptor;
import android.net.Uri;
import android.os.Build;
import android.view.View;
import androidx.annotation.Nullable;
import io.flutter.embedding.engine.systemchannels.PlatformChannel$ClipboardContentFormat;
import io.flutter.embedding.engine.systemchannels.PlatformChannel$HapticFeedbackType;
import io.flutter.embedding.engine.systemchannels.PlatformChannel$SystemUiMode;
import io.flutter.embedding.engine.systemchannels.PlatformChannel$SystemUiOverlay;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;

/* JADX INFO: loaded from: classes.dex */
public final class d implements dd.o {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ h f28208a;

    public d(h hVar) {
        this.f28208a = hVar;
    }

    public final void a(ArrayList arrayList) {
        h hVar = this.f28208a;
        hVar.getClass();
        int i10 = arrayList.size() == 0 ? 5894 : 1798;
        for (int i11 = 0; i11 < arrayList.size(); i11++) {
            int iOrdinal = ((PlatformChannel$SystemUiOverlay) arrayList.get(i11)).ordinal();
            if (iOrdinal == 0) {
                i10 &= -5;
            } else if (iOrdinal == 1) {
                i10 &= -515;
            }
        }
        hVar.f28219d = i10;
        hVar.d();
    }

    public final void b(PlatformChannel$SystemUiMode platformChannel$SystemUiMode) {
        int i10;
        h hVar = this.f28208a;
        hVar.getClass();
        if (platformChannel$SystemUiMode == PlatformChannel$SystemUiMode.LEAN_BACK) {
            i10 = 1798;
        } else if (platformChannel$SystemUiMode == PlatformChannel$SystemUiMode.IMMERSIVE) {
            i10 = 3846;
        } else if (platformChannel$SystemUiMode == PlatformChannel$SystemUiMode.IMMERSIVE_STICKY) {
            i10 = 5894;
        } else if (platformChannel$SystemUiMode != PlatformChannel$SystemUiMode.EDGE_TO_EDGE || Build.VERSION.SDK_INT < 29) {
            return;
        } else {
            i10 = 1792;
        }
        hVar.f28219d = i10;
        hVar.d();
    }

    public final void c(PlatformChannel$HapticFeedbackType platformChannel$HapticFeedbackType) {
        View decorView = this.f28208a.f28216a.getWindow().getDecorView();
        int i10 = f.f28213a[platformChannel$HapticFeedbackType.ordinal()];
        if (i10 == 1) {
            decorView.performHapticFeedback(0);
            return;
        }
        if (i10 == 2) {
            decorView.performHapticFeedback(1);
            return;
        }
        if (i10 == 3) {
            decorView.performHapticFeedback(3);
        } else if (i10 == 4) {
            decorView.performHapticFeedback(6);
        } else {
            if (i10 != 5) {
                return;
            }
            decorView.performHapticFeedback(4);
        }
    }

    @Override // dd.o
    public CharSequence getClipboardData(@Nullable PlatformChannel$ClipboardContentFormat platformChannel$ClipboardContentFormat) {
        Activity activity = this.f28208a.f28216a;
        ClipboardManager clipboardManager = (ClipboardManager) activity.getSystemService("clipboard");
        if (!clipboardManager.hasPrimaryClip()) {
            return null;
        }
        try {
            ClipData primaryClip = clipboardManager.getPrimaryClip();
            if (primaryClip == null) {
                return null;
            }
            if (platformChannel$ClipboardContentFormat != null && platformChannel$ClipboardContentFormat != PlatformChannel$ClipboardContentFormat.f28069a) {
                return null;
            }
            ClipData.Item itemAt = primaryClip.getItemAt(0);
            CharSequence text = itemAt.getText();
            if (text == null) {
                try {
                    Uri uri = itemAt.getUri();
                    if (uri != null && uri.getScheme().equals("content")) {
                        AssetFileDescriptor assetFileDescriptorOpenTypedAssetFileDescriptor = activity.getContentResolver().openTypedAssetFileDescriptor(uri, "text/*", null);
                        CharSequence charSequenceCoerceToText = itemAt.coerceToText(activity);
                        if (assetFileDescriptorOpenTypedAssetFileDescriptor != null) {
                            try {
                                assetFileDescriptorOpenTypedAssetFileDescriptor.close();
                            } catch (IOException unused) {
                            }
                        }
                        return charSequenceCoerceToText;
                    }
                    return null;
                } catch (IOException unused2) {
                }
            }
            return text;
        } catch (FileNotFoundException | IOException | SecurityException unused3) {
            return null;
        }
    }
}
