package defpackage;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.attribute.AclEntry;
import java.nio.file.attribute.AclEntryFlag;
import java.nio.file.attribute.AclEntryPermission;
import java.nio.file.attribute.AclEntryType;
import java.nio.file.attribute.FileAttribute;
import java.util.EnumSet;
import java.util.Objects;
import java.util.Set;

/* JADX INFO: loaded from: classes2.dex */
@dz3
@ri2
@sw4
abstract class fk9 {
    public static final fk9 a;

    public static final class b extends fk9 {
        @Override // defpackage.fk9
        public final File a() {
            return File.createTempFile("FileBackedOutputStream", null, null);
        }
    }

    @fh4
    public static final class c extends fk9 {
        public static final a b;
        public static final a c = null;

        @fh4
        public interface a {
            FileAttribute get();
        }

        static {
            dj1 dj1Var;
            Set<String> setSupportedFileAttributeViews = FileSystems.getDefault().supportedFileAttributeViews();
            if (setSupportedFileAttributeViews.contains("posix")) {
                b = new p21(10);
                return;
            }
            if (!setSupportedFileAttributeViews.contains("acl")) {
                b = new p21(11);
                return;
            }
            try {
                dj1Var = new dj1(new gk9(bj4.r(AclEntry.newBuilder().setType(AclEntryType.ALLOW).setPrincipal(FileSystems.getDefault().getUserPrincipalLookupService().lookupPrincipalByName(b())).setPermissions(EnumSet.allOf(AclEntryPermission.class)).setFlags(AclEntryFlag.DIRECTORY_INHERIT, AclEntryFlag.FILE_INHERIT).build())), 5);
            } catch (IOException e) {
                dj1Var = new dj1(e, 6);
            }
            b = dj1Var;
        }

        public static String b() {
            String property = System.getProperty("user.name");
            Objects.requireNonNull(property);
            try {
                Class<?> cls = Class.forName("java.lang.ProcessHandle");
                Class<?> cls2 = Class.forName("java.lang.ProcessHandle$Info");
                Class<?> cls3 = Class.forName("java.util.Optional");
                Method method = cls.getMethod("current", null);
                Method method2 = cls.getMethod("info", null);
                Object objInvoke = cls3.getMethod("orElse", Object.class).invoke(cls2.getMethod("user", null).invoke(method2.invoke(method.invoke(null, null), null), null), property);
                Objects.requireNonNull(objInvoke);
                return (String) objInvoke;
            } catch (ClassNotFoundException | IllegalAccessException | NoSuchMethodException unused) {
                return property;
            } catch (InvocationTargetException e) {
                vm9.a(e.getCause());
                return property;
            }
        }

        @Override // defpackage.fk9
        public final File a() {
            return Files.createTempFile(Paths.get(System.getProperty("java.io.tmpdir"), new String[0]), "FileBackedOutputStream", null, b.get()).toFile();
        }
    }

    public static final class d extends fk9 {
        @Override // defpackage.fk9
        public final File a() throws IOException {
            throw new IOException("Guava cannot securely create temporary files or directories under SDK versions before Jelly Bean. You can create one yourself, either in the insecure default directory or in a more secure directory, such as context.getCacheDir(). For more information, see the Javadoc for Files.createTempDir().");
        }
    }

    static {
        fk9 dVar;
        try {
            try {
                dVar = new c();
            } catch (ClassNotFoundException unused) {
                dVar = ((Integer) Class.forName("android.os.Build$VERSION").getField("SDK_INT").get(null)).intValue() < ((Integer) Class.forName("android.os.Build$VERSION_CODES").getField("JELLY_BEAN").get(null)).intValue() ? new d() : new b();
            }
        } catch (ClassNotFoundException unused2) {
            dVar = new d();
        } catch (IllegalAccessException unused3) {
            dVar = new d();
        } catch (NoSuchFieldException unused4) {
            dVar = new d();
        }
        a = dVar;
    }

    public abstract File a();
}
