package com.tencent.mm.plugin.wenote.model.nativenote.manager;

import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.model.aw;
import com.tencent.mm.model.c;
import com.tencent.mm.plugin.wenote.model.a.q;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.storage.ac.a;
import com.tencent.ytcommon.BuildConfig;

public class h {
    private static volatile h uPE = null;
    private q uPF = null;

    private h() {
    }

    public static h deH() {
        AppMethodBeat.i(26780);
        if (uPE == null) {
            synchronized (h.class) {
                try {
                    if (uPE == null) {
                        uPE = new h();
                    }
                } catch (Throwable th) {
                    while (true) {
                        AppMethodBeat.o(26780);
                    }
                }
            }
        }
        h hVar = uPE;
        AppMethodBeat.o(26780);
        return hVar;
    }

    public final q deI() {
        AppMethodBeat.i(26781);
        q qVar;
        if (this.uPF != null) {
            qVar = this.uPF;
            AppMethodBeat.o(26781);
            return qVar;
        }
        aw.ZK();
        String str = (String) c.Ry().get(a.xRQ, BuildConfig.FLAVOR);
        ab.d("WNNoteKeepTopManager", "getCurrentTopItem itemStr: %s", new Object[]{str});
        if (bo.isNullOrNil(str)) {
            AppMethodBeat.o(26781);
            return null;
        }
        byte[] anf = bo.anf(str);
        if (anf.length <= 0) {
            AppMethodBeat.o(26781);
            return null;
        }
        this.uPF = bF(anf);
        String str2 = "WNNoteKeepTopManager";
        String str3 = "getCurrentTopItem item: %s";
        Object[] objArr = new Object[1];
        objArr[0] = this.uPF != null ? this.uPF.ddR() : "null";
        ab.d(str2, str3, objArr);
        qVar = this.uPF;
        AppMethodBeat.o(26781);
        return qVar;
    }

    public final void a(q qVar) {
        AppMethodBeat.i(26782);
        this.uPF = qVar;
        byte[] b = b(this.uPF);
        String str = BuildConfig.FLAVOR;
        if (b != null && b.length > 0) {
            str = bo.cd(b);
        }
        String str2 = "WNNoteKeepTopManager";
        String str3 = "setCurrentTopItem item: %s";
        Object[] objArr = new Object[1];
        objArr[0] = this.uPF != null ? this.uPF.ddR() : "null";
        ab.i(str2, str3, objArr);
        ab.i("WNNoteKeepTopManager", "setCurrentTopItem itemStr: %s", new Object[]{str});
        aw.ZK();
        c.Ry().set(a.xRQ, bo.nullAsNil(str));
        AppMethodBeat.o(26782);
    }

    /* JADX WARNING: Removed duplicated region for block: B:21:0x004f A:{SYNTHETIC, Splitter:B:21:0x004f} */
    /* JADX WARNING: Removed duplicated region for block: B:24:0x0054 A:{Catch:{ Exception -> 0x0059 }} */
    /* JADX WARNING: Removed duplicated region for block: B:21:0x004f A:{SYNTHETIC, Splitter:B:21:0x004f} */
    /* JADX WARNING: Removed duplicated region for block: B:24:0x0054 A:{Catch:{ Exception -> 0x0059 }} */
    /* JADX WARNING: Removed duplicated region for block: B:31:0x006e A:{SYNTHETIC, Splitter:B:31:0x006e} */
    /* JADX WARNING: Removed duplicated region for block: B:34:0x0073 A:{Catch:{ Exception -> 0x007a }} */
    /* JADX WARNING: Removed duplicated region for block: B:31:0x006e A:{SYNTHETIC, Splitter:B:31:0x006e} */
    /* JADX WARNING: Removed duplicated region for block: B:34:0x0073 A:{Catch:{ Exception -> 0x007a }} */
    private static com.tencent.mm.plugin.wenote.model.a.q bF(byte[] r11) {
        /*
        r1 = 0;
        r10 = 26783; // 0x689f float:3.7531E-41 double:1.32326E-319;
        r9 = 1;
        r8 = 0;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r10);
        if (r11 == 0) goto L_0x000d;
    L_0x000a:
        r0 = r11.length;
        if (r0 > 0) goto L_0x0012;
    L_0x000d:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r10);
        r0 = r1;
    L_0x0011:
        return r0;
    L_0x0012:
        r3 = new java.io.ByteArrayInputStream;	 Catch:{ Exception -> 0x003b, all -> 0x0069 }
        r3.<init>(r11);	 Catch:{ Exception -> 0x003b, all -> 0x0069 }
        r2 = new java.io.ObjectInputStream;	 Catch:{ Exception -> 0x008e, all -> 0x0089 }
        r2.<init>(r3);	 Catch:{ Exception -> 0x008e, all -> 0x0089 }
        r0 = r2.readObject();	 Catch:{ Exception -> 0x0091 }
        r0 = (com.tencent.mm.plugin.wenote.model.a.q) r0;	 Catch:{ Exception -> 0x0091 }
        r2.close();	 Catch:{ Exception -> 0x002c }
        r3.close();	 Catch:{ Exception -> 0x002c }
    L_0x0028:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r10);
        goto L_0x0011;
    L_0x002c:
        r1 = move-exception;
        r2 = "WNNoteKeepTopManager";
        r3 = "toObject close exception:%s";
        r4 = new java.lang.Object[r9];
        r4[r8] = r1;
        com.tencent.mm.sdk.platformtools.ab.e(r2, r3, r4);
        goto L_0x0028;
    L_0x003b:
        r0 = move-exception;
        r2 = r1;
        r3 = r1;
    L_0x003e:
        r4 = "WNNoteKeepTopManager";
        r5 = "toObject exception:%s";
        r6 = 1;
        r6 = new java.lang.Object[r6];	 Catch:{ all -> 0x008c }
        r7 = 0;
        r6[r7] = r0;	 Catch:{ all -> 0x008c }
        com.tencent.mm.sdk.platformtools.ab.e(r4, r5, r6);	 Catch:{ all -> 0x008c }
        if (r2 == 0) goto L_0x0052;
    L_0x004f:
        r2.close();	 Catch:{ Exception -> 0x0059 }
    L_0x0052:
        if (r3 == 0) goto L_0x0057;
    L_0x0054:
        r3.close();	 Catch:{ Exception -> 0x0059 }
    L_0x0057:
        r0 = r1;
        goto L_0x0028;
    L_0x0059:
        r0 = move-exception;
        r2 = "WNNoteKeepTopManager";
        r3 = "toObject close exception:%s";
        r4 = new java.lang.Object[r9];
        r4[r8] = r0;
        com.tencent.mm.sdk.platformtools.ab.e(r2, r3, r4);
        r0 = r1;
        goto L_0x0028;
    L_0x0069:
        r0 = move-exception;
        r2 = r1;
        r3 = r1;
    L_0x006c:
        if (r2 == 0) goto L_0x0071;
    L_0x006e:
        r2.close();	 Catch:{ Exception -> 0x007a }
    L_0x0071:
        if (r3 == 0) goto L_0x0076;
    L_0x0073:
        r3.close();	 Catch:{ Exception -> 0x007a }
    L_0x0076:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r10);
        throw r0;
    L_0x007a:
        r1 = move-exception;
        r2 = "WNNoteKeepTopManager";
        r3 = "toObject close exception:%s";
        r4 = new java.lang.Object[r9];
        r4[r8] = r1;
        com.tencent.mm.sdk.platformtools.ab.e(r2, r3, r4);
        goto L_0x0076;
    L_0x0089:
        r0 = move-exception;
        r2 = r1;
        goto L_0x006c;
    L_0x008c:
        r0 = move-exception;
        goto L_0x006c;
    L_0x008e:
        r0 = move-exception;
        r2 = r1;
        goto L_0x003e;
    L_0x0091:
        r0 = move-exception;
        goto L_0x003e;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.wenote.model.nativenote.manager.h.bF(byte[]):com.tencent.mm.plugin.wenote.model.a.q");
    }

    /* JADX WARNING: Removed duplicated region for block: B:20:0x004f A:{SYNTHETIC, Splitter:B:20:0x004f} */
    /* JADX WARNING: Removed duplicated region for block: B:23:0x0054 A:{Catch:{ Exception -> 0x0058 }} */
    /* JADX WARNING: Removed duplicated region for block: B:29:0x006c A:{SYNTHETIC, Splitter:B:29:0x006c} */
    /* JADX WARNING: Removed duplicated region for block: B:32:0x0071 A:{Catch:{ Exception -> 0x0078 }} */
    /* JADX WARNING: Removed duplicated region for block: B:29:0x006c A:{SYNTHETIC, Splitter:B:29:0x006c} */
    /* JADX WARNING: Removed duplicated region for block: B:32:0x0071 A:{Catch:{ Exception -> 0x0078 }} */
    private static byte[] b(com.tencent.mm.plugin.wenote.model.a.q r11) {
        /*
        r0 = 0;
        r10 = 26784; // 0x68a0 float:3.7532E-41 double:1.3233E-319;
        r9 = 1;
        r8 = 0;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r10);
        if (r11 != 0) goto L_0x000e;
    L_0x000a:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r10);
    L_0x000d:
        return r0;
    L_0x000e:
        r3 = new java.io.ByteArrayOutputStream;	 Catch:{ Exception -> 0x003b, all -> 0x0067 }
        r3.<init>();	 Catch:{ Exception -> 0x003b, all -> 0x0067 }
        r2 = new java.io.ObjectOutputStream;	 Catch:{ Exception -> 0x008d, all -> 0x0087 }
        r2.<init>(r3);	 Catch:{ Exception -> 0x008d, all -> 0x0087 }
        r2.writeObject(r11);	 Catch:{ Exception -> 0x0090 }
        r2.flush();	 Catch:{ Exception -> 0x0090 }
        r0 = r3.toByteArray();	 Catch:{ Exception -> 0x0090 }
        r2.close();	 Catch:{ Exception -> 0x002c }
        r3.close();	 Catch:{ Exception -> 0x002c }
    L_0x0028:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r10);
        goto L_0x000d;
    L_0x002c:
        r1 = move-exception;
        r2 = "WNNoteKeepTopManager";
        r3 = "toByteArray close exception:%s";
        r4 = new java.lang.Object[r9];
        r4[r8] = r1;
        com.tencent.mm.sdk.platformtools.ab.e(r2, r3, r4);
        goto L_0x0028;
    L_0x003b:
        r1 = move-exception;
        r2 = r0;
        r3 = r0;
    L_0x003e:
        r4 = "WNNoteKeepTopManager";
        r5 = "toByteArray exception:%s";
        r6 = 1;
        r6 = new java.lang.Object[r6];	 Catch:{ all -> 0x008a }
        r7 = 0;
        r6[r7] = r1;	 Catch:{ all -> 0x008a }
        com.tencent.mm.sdk.platformtools.ab.e(r4, r5, r6);	 Catch:{ all -> 0x008a }
        if (r2 == 0) goto L_0x0052;
    L_0x004f:
        r2.close();	 Catch:{ Exception -> 0x0058 }
    L_0x0052:
        if (r3 == 0) goto L_0x0028;
    L_0x0054:
        r3.close();	 Catch:{ Exception -> 0x0058 }
        goto L_0x0028;
    L_0x0058:
        r1 = move-exception;
        r2 = "WNNoteKeepTopManager";
        r3 = "toByteArray close exception:%s";
        r4 = new java.lang.Object[r9];
        r4[r8] = r1;
        com.tencent.mm.sdk.platformtools.ab.e(r2, r3, r4);
        goto L_0x0028;
    L_0x0067:
        r1 = move-exception;
        r2 = r0;
        r3 = r0;
    L_0x006a:
        if (r2 == 0) goto L_0x006f;
    L_0x006c:
        r2.close();	 Catch:{ Exception -> 0x0078 }
    L_0x006f:
        if (r3 == 0) goto L_0x0074;
    L_0x0071:
        r3.close();	 Catch:{ Exception -> 0x0078 }
    L_0x0074:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r10);
        throw r1;
    L_0x0078:
        r0 = move-exception;
        r2 = "WNNoteKeepTopManager";
        r3 = "toByteArray close exception:%s";
        r4 = new java.lang.Object[r9];
        r4[r8] = r0;
        com.tencent.mm.sdk.platformtools.ab.e(r2, r3, r4);
        goto L_0x0074;
    L_0x0087:
        r1 = move-exception;
        r2 = r0;
        goto L_0x006a;
    L_0x008a:
        r0 = move-exception;
        r1 = r0;
        goto L_0x006a;
    L_0x008d:
        r1 = move-exception;
        r2 = r0;
        goto L_0x003e;
    L_0x0090:
        r1 = move-exception;
        goto L_0x003e;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.wenote.model.nativenote.manager.h.b(com.tencent.mm.plugin.wenote.model.a.q):byte[]");
    }
}
