package com.ss.android.ugc.aweme.story.record.recordcontrol;

import X.4N2;
import X.80k;
import X.8Kc;
import X.8r0;
import X.8r1;
import X.C38316eL;
import X.C45806qQ;
import X.C45976qh;
import X.C45996qj;
import X.C46026qm;
import X.M12;
import android.os.Parcel;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.ies.abmock.SettingsManager;
import com.ss.android.ugc.aweme.creative.CreativeInfo;
import com.ss.android.ugc.aweme.shortvideo.WorkSpace.Workspace;
import com.ss.android.ugc.aweme.shortvideo.WorkSpace.WorkspaceImpl;
import java.io.File;
import kotlin.h.b.n;

public final class StoryWorkspaceImpl implements WorkspaceImpl, C45996qj {
    public static final C45976qh CREATOR = new C45976qh((byte) 0);
    public static int LJIILL;
    public static int LJIILLIIL;
    public String LIZ;
    public String LIZIZ;
    public String LIZJ;
    public String LIZLLL;
    public String LJ;
    public String LJFF;
    public String LJI;
    public String LJII;
    public String LJIIIIZZ;
    public String LJIIIZ;
    public String LJIIJ;
    public String LJIIJJI;
    public String LJIIL;
    public Workspace LJIILIIL;
    public final CreativeInfo LJIILJJIL;

    static {
        Covode.recordClassIndex(118157);
    }

    public final int describeContents() {
        return 0;
    }

    public final String LJ() {
        return this.LJ;
    }

    public final void LJI() {
        this.LJ = null;
        this.LJIIL = null;
    }

    public final File LJFF() {
        String str = this.LIZ;
        if (str == null || str.length() == 0) {
            return null;
        }
        return new File(this.LIZ);
    }

    public final void LJIIIIZZ() {
        File LJFF2 = LJFF();
        if (LJFF2 != null && LJFF2.exists()) {
            80k.LIZ(LJFF());
        }
        LJII();
    }

    public final File LJIIIZ() {
        if (this.LJII == null) {
            File LIZJ2 = LIZJ();
            C45806qQ r2 = new C45806qQ();
            String path = LIZJ2.getPath();
            n.LIZIZ(path, "");
            this.LJII = r2.LIZ(path);
        }
        String str = this.LJII;
        if (str == null) {
            n.LIZIZ();
        }
        return new File(str);
    }

    public final File LJIIJ() {
        if (this.LJIIIIZZ == null) {
            File LIZLLL2 = LIZLLL();
            C45806qQ r2 = new C45806qQ();
            String path = LIZLLL2.getPath();
            n.LIZIZ(path, "");
            this.LJIIIIZZ = r2.LIZIZ(path);
        }
        String str = this.LJIIIIZZ;
        if (str == null) {
            n.LIZIZ();
        }
        return new File(str);
    }

    public final File LJIIJJI() {
        if (this.LJIIIZ == null) {
            File LIZJ2 = LIZJ();
            C45806qQ r2 = new C45806qQ();
            String path = LIZJ2.getPath();
            n.LIZIZ(path, "");
            this.LJIIIZ = r2.LIZJ(path);
        }
        String str = this.LJIIIZ;
        if (str == null) {
            n.LIZIZ();
        }
        return new File(str);
    }

    public final File LIZJ() {
        String str = this.LIZIZ;
        if (str == null || str.length() == 0) {
            StringBuilder sb = new StringBuilder();
            sb.append(C38316eL.LIZ().LIZIZ(this.LJIILJJIL));
            StringBuilder sb2 = new StringBuilder("-");
            int i = LJIILL;
            LJIILL = i + 1;
            sb2.append(i);
            sb2.append("-concat-v");
            sb.append(C46026qm.LIZIZ(sb2.toString()));
            this.LIZIZ = sb.toString();
        }
        String str2 = this.LIZIZ;
        if (str2 == null) {
            n.LIZIZ();
        }
        return new File(str2);
    }

    public final File LIZLLL() {
        String str = this.LIZJ;
        if (str == null || str.length() == 0) {
            StringBuilder sb = new StringBuilder();
            sb.append(C38316eL.LIZ().LIZIZ(this.LJIILJJIL));
            StringBuilder sb2 = new StringBuilder("-");
            int i = LJIILLIIL;
            LJIILLIIL = i + 1;
            sb2.append(i);
            sb2.append("-concat-a");
            sb.append(C46026qm.LIZIZ(sb2.toString()));
            this.LIZJ = sb.toString();
        }
        String str2 = this.LIZJ;
        if (str2 == null) {
            n.LIZIZ();
        }
        return new File(str2);
    }

    public final void LJII() {
        if (this.LJI == null) {
            this.LJI = new File(this.LJ + ".wav").getPath();
        }
        String str = this.LJI;
        if (str == null) {
            n.LIZIZ();
        }
        File file = new File(str);
        if (file.exists()) {
            LIZ(file);
        }
        if (this.LJFF == null) {
            this.LJFF = new File(C38316eL.LIZ().LIZIZ(this.LJIILJJIL), "mix.wav").getPath();
        }
        String str2 = this.LJFF;
        if (str2 == null) {
            n.LIZIZ();
        }
        File file2 = new File(str2);
        if (file2.exists()) {
            LIZ(file2);
        }
    }

    public final void LIZ(Workspace workspace) {
        M12.LIZ(workspace);
        this.LJIILIIL = workspace;
    }

    public final void LIZIZ(String str) {
        LJI();
        this.LJ = str;
    }

    public final void LIZ(String str) {
        if (str == null) {
            str = this.LIZ;
        }
        this.LIZ = str;
    }

    public StoryWorkspaceImpl(CreativeInfo creativeInfo) {
        M12.LIZ(creativeInfo);
        this.LJIILJJIL = creativeInfo;
        this.LIZ = C38316eL.LIZ().LJFF(creativeInfo);
    }

    public final File LIZJ(String str) {
        M12.LIZ(str);
        String LIZLLL2 = C38316eL.LIZ().LIZLLL(this.LJIILJJIL);
        if (!80k.LIZ(LIZLLL2)) {
            80k.LIZ(LIZLLL2, false);
        }
        this.LJIIJ = LIZLLL2 + C46026qm.LIZIZ("-bgv-v");
        String str2 = this.LJIIJ;
        if (str2 == null) {
            n.LIZIZ();
        }
        return new File(str2);
    }

    public final File LIZLLL(String str) {
        M12.LIZ(str);
        String LIZLLL2 = C38316eL.LIZ().LIZLLL(this.LJIILJJIL);
        if (!80k.LIZ(LIZLLL2)) {
            80k.LIZ(LIZLLL2, false);
        }
        this.LJIIJJI = LIZLLL2 + C46026qm.LIZIZ("-bgv-a");
        String str2 = this.LJIIJJI;
        if (str2 == null) {
            n.LIZIZ();
        }
        return new File(str2);
    }

    /* JADX WARNING: Illegal instructions before constructor call */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public StoryWorkspaceImpl(android.os.Parcel r8) {
        /*
            r7 = this;
            X.M12.LIZ(r8)
            java.lang.Class<com.ss.android.ugc.aweme.creative.CreativeInfo> r0 = com.ss.android.ugc.aweme.creative.CreativeInfo.class
            java.lang.ClassLoader r0 = r0.getClassLoader()
            android.os.Parcelable r1 = r8.readParcelable(r0)
            com.ss.android.ugc.aweme.creative.CreativeInfo r1 = (com.ss.android.ugc.aweme.creative.CreativeInfo) r1
            if (r1 != 0) goto L_0x001e
            com.ss.android.ugc.aweme.creative.CreativeInfo r1 = new com.ss.android.ugc.aweme.creative.CreativeInfo
            r2 = 0
            r3 = 0
            java.lang.String r4 = X.C31646Ks.LIZ()
            r5 = 3
            r6 = 0
            r1.<init>(r2, r3, r4, r5, r6)
        L_0x001e:
            java.lang.String r0 = ""
            kotlin.h.b.n.LIZIZ(r1, r0)
            r7.<init>((com.ss.android.ugc.aweme.creative.CreativeInfo) r1)
            java.lang.String r0 = r8.readString()
            r7.LIZIZ = r0
            java.lang.String r0 = r8.readString()
            r7.LIZJ = r0
            java.lang.String r0 = r8.readString()
            r7.LIZLLL = r0
            java.lang.String r0 = r8.readString()
            r7.LJ = r0
            java.lang.String r0 = r8.readString()
            r7.LJI = r0
            java.lang.String r0 = r8.readString()
            r7.LJFF = r0
            java.lang.String r0 = r8.readString()
            r7.LJII = r0
            java.lang.String r0 = r8.readString()
            r7.LJIIL = r0
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.story.record.recordcontrol.StoryWorkspaceImpl.<init>(android.os.Parcel):void");
    }

    public static boolean LIZ(File file) {
        8r1 r3;
        MethodCollector.i(6376);
        try {
            if (8Kc.LIZIZ()) {
                r3 = (8r1) SettingsManager.LIZ().LIZ("storage_intercepter_key", 8r1.class, 4N2.LIZ);
            } else {
                r3 = 4N2.LIZ;
            }
            if (8r0.LIZ(file.getAbsolutePath(), r3)) {
                8r0.LIZ(file, new RuntimeException(), "exception_delete_log", 8r0.LIZ(r3));
            }
            if (8r0.LIZJ(file.getAbsolutePath(), r3)) {
                8r0.LIZ(file, new RuntimeException(), "exception_handle", 8r0.LIZ(r3));
                MethodCollector.o(6376);
                return false;
            }
        } catch (Throwable unused) {
        }
        boolean delete = file.delete();
        MethodCollector.o(6376);
        return delete;
    }

    public final void writeToParcel(Parcel parcel, int i) {
        M12.LIZ(parcel);
        parcel.writeParcelable(this.LJIILJJIL, i);
        parcel.writeString(this.LIZIZ);
        parcel.writeString(this.LIZJ);
        parcel.writeString(this.LIZLLL);
        parcel.writeString(this.LJ);
        parcel.writeString(this.LJI);
        parcel.writeString(this.LJFF);
        parcel.writeString(this.LJII);
        parcel.writeString(this.LJIIL);
    }
}
