package com.tencent.mm.plugin.dbbackup;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.PowerManager;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.at.o;
import com.tencent.mm.cd.f;
import com.tencent.mm.compatible.e.q;
import com.tencent.mm.kernel.g;
import com.tencent.mm.model.at;
import com.tencent.mm.model.aw;
import com.tencent.mm.plugin.report.service.h;
import com.tencent.mm.sdk.b.c;
import com.tencent.mm.sdk.e.k.a;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ah;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.storage.ac;
import com.tencent.mm.storage.z;
import com.tencent.mm.ui.MMAppMgr;
import com.tencent.mm.vfs.b;
import com.tencent.mm.vfs.e;
import com.tencent.wcdb.Cursor;
import com.tencent.wcdb.database.SQLiteCipherSpec;
import com.tencent.wcdb.database.SQLiteDatabase;
import com.tencent.wcdb.database.SQLiteDirectCursor;
import com.tencent.wcdb.repair.BackupKit;
import com.tencent.wcdb.repair.RecoverKit;
import com.tencent.wcdb.repair.RepairKit;
import com.tencent.wcdb.repair.RepairKit.MasterInfo;
import com.tencent.ytcommon.BuildConfig;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;

public final class d implements at {
    private static final SQLiteCipherSpec kIB = new SQLiteCipherSpec().setPageSize(1024).setSQLCipherVersion(1);
    private boolean jZS = false;
    private boolean jZT = true;
    private BroadcastReceiver jZU;
    private Runnable jZV;
    private c kIA;
    private volatile BackupKit kIn;
    private volatile RecoverKit kIo;
    private volatile RepairKit kIp;
    private volatile boolean kIq = false;
    private boolean kIr = false;
    private boolean kIs = false;
    private long kIt = 0;
    private long kIu = 600000;
    private long kIv = 0;
    private int kIw = 10;
    private boolean kIx = false;
    final SimpleDateFormat kIy = new SimpleDateFormat("HH:mm:ss.SSS");
    private a kIz;

    public d() {
        AppMethodBeat.i(18982);
        AppMethodBeat.o(18982);
    }

    static /* synthetic */ void bhU() {
        AppMethodBeat.i(19000);
        bhQ();
        AppMethodBeat.o(19000);
    }

    static {
        AppMethodBeat.i(19001);
        AppMethodBeat.o(19001);
    }

    private static long[] a(SQLiteDatabase sQLiteDatabase) {
        long j;
        long j2;
        long j3;
        long j4 = -1;
        AppMethodBeat.i(18983);
        Cursor rawQueryWithFactory = sQLiteDatabase.rawQueryWithFactory(SQLiteDirectCursor.FACTORY, "SELECT max(msgId) FROM message;", null, null);
        if (rawQueryWithFactory.moveToFirst()) {
            j = rawQueryWithFactory.getLong(0);
        } else {
            j = -1;
        }
        rawQueryWithFactory.close();
        Cursor rawQueryWithFactory2 = sQLiteDatabase.rawQueryWithFactory(SQLiteDirectCursor.FACTORY, "SELECT max(id) FROM ImgInfo2;", null, null);
        if (rawQueryWithFactory2.moveToFirst()) {
            j2 = rawQueryWithFactory2.getLong(0);
        } else {
            j2 = -1;
        }
        rawQueryWithFactory2.close();
        Cursor rawQueryWithFactory3 = sQLiteDatabase.rawQueryWithFactory(SQLiteDirectCursor.FACTORY, "SELECT max(rowid) FROM videoinfo2;", null, null);
        if (rawQueryWithFactory3.moveToFirst()) {
            j3 = rawQueryWithFactory3.getLong(0);
        } else {
            j3 = -1;
        }
        rawQueryWithFactory3.close();
        rawQueryWithFactory3 = sQLiteDatabase.rawQueryWithFactory(SQLiteDirectCursor.FACTORY, "SELECT max(rowid) FROM EmojiInfo;", null, null);
        if (rawQueryWithFactory3.moveToFirst()) {
            j4 = rawQueryWithFactory3.getLong(0);
        }
        rawQueryWithFactory3.close();
        long[] jArr = new long[]{j, j2, j3, j4};
        AppMethodBeat.o(18983);
        return jArr;
    }

    /* JADX WARNING: Removed duplicated region for block: B:31:0x0085 A:{SYNTHETIC, Splitter:B:31:0x0085} */
    /* JADX WARNING: Removed duplicated region for block: B:25:0x0079 A:{SYNTHETIC, Splitter:B:25:0x0079} */
    private static long[] Ie(java.lang.String r13) {
        /*
        r1 = 0;
        r4 = 0;
        r12 = 18984; // 0x4a28 float:2.6602E-41 double:9.3793E-320;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r12);
        r2 = new java.io.BufferedReader;	 Catch:{ Exception -> 0x0066, all -> 0x0081 }
        r0 = new com.tencent.mm.vfs.g;	 Catch:{ Exception -> 0x0066, all -> 0x0081 }
        r3 = new java.lang.StringBuilder;	 Catch:{ Exception -> 0x0066, all -> 0x0081 }
        r3.<init>();	 Catch:{ Exception -> 0x0066, all -> 0x0081 }
        r3 = r3.append(r13);	 Catch:{ Exception -> 0x0066, all -> 0x0081 }
        r6 = ".bcur";
        r3 = r3.append(r6);	 Catch:{ Exception -> 0x0066, all -> 0x0081 }
        r3 = r3.toString();	 Catch:{ Exception -> 0x0066, all -> 0x0081 }
        r0.<init>(r3);	 Catch:{ Exception -> 0x0066, all -> 0x0081 }
        r2.<init>(r0);	 Catch:{ Exception -> 0x0066, all -> 0x0081 }
        r0 = r2.readLine();	 Catch:{ Exception -> 0x0094 }
        if (r0 == 0) goto L_0x009a;
    L_0x002c:
        r6 = java.lang.Long.parseLong(r0);	 Catch:{ Exception -> 0x0094 }
        r10 = r6;
    L_0x0031:
        r0 = r2.readLine();	 Catch:{ Exception -> 0x0094 }
        if (r0 == 0) goto L_0x0098;
    L_0x0037:
        r6 = java.lang.Long.parseLong(r0);	 Catch:{ Exception -> 0x0094 }
        r8 = r6;
    L_0x003c:
        r0 = r2.readLine();	 Catch:{ Exception -> 0x0094 }
        if (r0 == 0) goto L_0x0096;
    L_0x0042:
        r6 = java.lang.Long.parseLong(r0);	 Catch:{ Exception -> 0x0094 }
    L_0x0046:
        r0 = r2.readLine();	 Catch:{ Exception -> 0x0094 }
        if (r0 == 0) goto L_0x0050;
    L_0x004c:
        r4 = java.lang.Long.parseLong(r0);	 Catch:{ Exception -> 0x0094 }
    L_0x0050:
        r0 = 4;
        r0 = new long[r0];	 Catch:{ Exception -> 0x0094 }
        r3 = 0;
        r0[r3] = r10;	 Catch:{ Exception -> 0x0094 }
        r3 = 1;
        r0[r3] = r8;	 Catch:{ Exception -> 0x0094 }
        r3 = 2;
        r0[r3] = r6;	 Catch:{ Exception -> 0x0094 }
        r3 = 3;
        r0[r3] = r4;	 Catch:{ Exception -> 0x0094 }
        r2.close();	 Catch:{ IOException -> 0x008c }
    L_0x0062:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r12);
    L_0x0065:
        return r0;
    L_0x0066:
        r0 = move-exception;
        r2 = r1;
    L_0x0068:
        r3 = "MicroMsg.SubCoreDBBackup";
        r4 = "Failed to read previous cursor '%s'";
        r5 = 1;
        r5 = new java.lang.Object[r5];	 Catch:{ all -> 0x0092 }
        r6 = 0;
        r5[r6] = r13;	 Catch:{ all -> 0x0092 }
        com.tencent.mm.sdk.platformtools.ab.printErrStackTrace(r3, r0, r4, r5);	 Catch:{ all -> 0x0092 }
        if (r2 == 0) goto L_0x007c;
    L_0x0079:
        r2.close();	 Catch:{ IOException -> 0x008e }
    L_0x007c:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r12);
        r0 = r1;
        goto L_0x0065;
    L_0x0081:
        r0 = move-exception;
        r2 = r1;
    L_0x0083:
        if (r2 == 0) goto L_0x0088;
    L_0x0085:
        r2.close();	 Catch:{ IOException -> 0x0090 }
    L_0x0088:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r12);
        throw r0;
    L_0x008c:
        r1 = move-exception;
        goto L_0x0062;
    L_0x008e:
        r0 = move-exception;
        goto L_0x007c;
    L_0x0090:
        r1 = move-exception;
        goto L_0x0088;
    L_0x0092:
        r0 = move-exception;
        goto L_0x0083;
    L_0x0094:
        r0 = move-exception;
        goto L_0x0068;
    L_0x0096:
        r6 = r4;
        goto L_0x0046;
    L_0x0098:
        r8 = r4;
        goto L_0x003c;
    L_0x009a:
        r10 = r4;
        goto L_0x0031;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.dbbackup.d.Ie(java.lang.String):long[]");
    }

    /* JADX WARNING: Removed duplicated region for block: B:16:0x005f A:{SYNTHETIC, Splitter:B:16:0x005f} */
    /* JADX WARNING: Removed duplicated region for block: B:22:0x006b A:{SYNTHETIC, Splitter:B:22:0x006b} */
    private static boolean a(java.lang.String r9, long[] r10) {
        /*
        r0 = 1;
        r1 = 0;
        r8 = 18985; // 0x4a29 float:2.6604E-41 double:9.38E-320;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r8);
        r3 = 0;
        r2 = new com.tencent.mm.vfs.h;	 Catch:{ IOException -> 0x004c, all -> 0x0067 }
        r4 = new java.lang.StringBuilder;	 Catch:{ IOException -> 0x004c, all -> 0x0067 }
        r4.<init>();	 Catch:{ IOException -> 0x004c, all -> 0x0067 }
        r4 = r4.append(r9);	 Catch:{ IOException -> 0x004c, all -> 0x0067 }
        r5 = ".bcur";
        r4 = r4.append(r5);	 Catch:{ IOException -> 0x004c, all -> 0x0067 }
        r4 = r4.toString();	 Catch:{ IOException -> 0x004c, all -> 0x0067 }
        r2.<init>(r4);	 Catch:{ IOException -> 0x004c, all -> 0x0067 }
        r4 = r10.length;	 Catch:{ IOException -> 0x007a }
        r3 = r1;
    L_0x0023:
        if (r3 >= r4) goto L_0x0045;
    L_0x0025:
        r6 = r10[r3];	 Catch:{ IOException -> 0x007a }
        r5 = new java.lang.StringBuilder;	 Catch:{ IOException -> 0x007a }
        r5.<init>();	 Catch:{ IOException -> 0x007a }
        r6 = java.lang.Long.toString(r6);	 Catch:{ IOException -> 0x007a }
        r5 = r5.append(r6);	 Catch:{ IOException -> 0x007a }
        r6 = "\n";
        r5 = r5.append(r6);	 Catch:{ IOException -> 0x007a }
        r5 = r5.toString();	 Catch:{ IOException -> 0x007a }
        r2.write(r5);	 Catch:{ IOException -> 0x007a }
        r3 = r3 + 1;
        goto L_0x0023;
    L_0x0045:
        r2.close();	 Catch:{ IOException -> 0x0072 }
    L_0x0048:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r8);
    L_0x004b:
        return r0;
    L_0x004c:
        r0 = move-exception;
        r2 = r3;
    L_0x004e:
        r3 = "MicroMsg.SubCoreDBBackup";
        r4 = "Failed to write previous cursor '%s'";
        r5 = 1;
        r5 = new java.lang.Object[r5];	 Catch:{ all -> 0x0078 }
        r6 = 0;
        r5[r6] = r9;	 Catch:{ all -> 0x0078 }
        com.tencent.mm.sdk.platformtools.ab.printErrStackTrace(r3, r0, r4, r5);	 Catch:{ all -> 0x0078 }
        if (r2 == 0) goto L_0x0062;
    L_0x005f:
        r2.close();	 Catch:{ IOException -> 0x0074 }
    L_0x0062:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r8);
        r0 = r1;
        goto L_0x004b;
    L_0x0067:
        r0 = move-exception;
        r2 = r3;
    L_0x0069:
        if (r2 == 0) goto L_0x006e;
    L_0x006b:
        r2.close();	 Catch:{ IOException -> 0x0076 }
    L_0x006e:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r8);
        throw r0;
    L_0x0072:
        r1 = move-exception;
        goto L_0x0048;
    L_0x0074:
        r0 = move-exception;
        goto L_0x0062;
    L_0x0076:
        r1 = move-exception;
        goto L_0x006e;
    L_0x0078:
        r0 = move-exception;
        goto L_0x0069;
    L_0x007a:
        r0 = move-exception;
        goto L_0x004e;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.dbbackup.d.a(java.lang.String, long[]):boolean");
    }

    private static String[] a(long[] jArr, long[] jArr2) {
        AppMethodBeat.i(18986);
        String[] strArr;
        if (jArr2 == null || jArr2.length < 4) {
            strArr = new String[]{"message", "msgId <= " + jArr[0], "ImgInfo2", "id <= " + jArr[1], "videoinfo2", "rowid <= " + jArr[2], "EmojiInfo", "rowid <= " + jArr[3], "conversation", null, "rconversation", null};
            AppMethodBeat.o(18986);
            return strArr;
        }
        strArr = new String[12];
        strArr[0] = "message";
        strArr[1] = String.format("msgId > %d AND msgId <= %d", new Object[]{Long.valueOf(jArr2[0]), Long.valueOf(jArr[0])});
        strArr[2] = "ImgInfo2";
        strArr[3] = String.format("id > %d AND id <= %d", new Object[]{Long.valueOf(jArr2[1]), Long.valueOf(jArr[1])});
        strArr[4] = "videoinfo2";
        strArr[5] = String.format("rowid > %d AND rowid <= %d", new Object[]{Long.valueOf(jArr2[2]), Long.valueOf(jArr[2])});
        strArr[6] = "EmojiInfo";
        strArr[7] = String.format("rowid > %d AND rowid <= %d", new Object[]{Long.valueOf(jArr2[3]), Long.valueOf(jArr[3])});
        strArr[8] = "conversation";
        strArr[9] = null;
        strArr[10] = "rconversation";
        strArr[11] = null;
        AppMethodBeat.o(18986);
        return strArr;
    }

    private static boolean b(SQLiteDatabase sQLiteDatabase) {
        AppMethodBeat.i(18987);
        String str = sQLiteDatabase.getPath() + ".sm";
        String str2 = str + ".tmp";
        z Ry = g.RP().Ry();
        long Mm = Ry.Mm(237569);
        long currentTimeMillis = System.currentTimeMillis();
        b bVar = new b(str);
        if (!bVar.exists() || currentTimeMillis - Mm >= 86400000) {
            Mm = System.nanoTime();
            StringBuilder append = new StringBuilder().append(q.LK());
            aw.ZK();
            boolean save = MasterInfo.save(sQLiteDatabase, str2, com.tencent.mm.a.g.y(append.append(com.tencent.mm.model.c.QF()).toString().getBytes()));
            b bVar2 = new b(str2);
            if (save) {
                bVar.delete();
                save = bVar2.o(bVar);
                Ry.setLong(237569, currentTimeMillis);
                Ry.dsb();
            } else {
                bVar2.delete();
            }
            Mm = System.nanoTime() - Mm;
            String str3 = "MicroMsg.SubCoreDBBackup";
            String str4 = "Master table backup %s, elapsed %.3f";
            Object[] objArr = new Object[2];
            objArr[0] = save ? "SUCCEEDED" : "FAILED";
            objArr[1] = Float.valueOf(((float) Mm) / 1.0E9f);
            ab.i(str3, str4, objArr);
            h.pYm.a(181, save ? 24 : 25, 1, false);
            AppMethodBeat.o(18987);
            return save;
        }
        AppMethodBeat.o(18987);
        return true;
    }

    public final boolean a(boolean z, b bVar) {
        AppMethodBeat.i(18988);
        if (this.kIq) {
            ab.i("MicroMsg.SubCoreDBBackup", "Backup or recover task is in progress, %s canceled", new Object[]{"backup"});
            AppMethodBeat.o(18988);
            return false;
        }
        boolean z2;
        int i;
        com.tencent.mm.model.c ZK = aw.ZK();
        String Rw = com.tencent.mm.model.c.Rw();
        SQLiteDatabase dvx = com.tencent.mm.model.c.Ru().dvx();
        String str = Rw + ".bak";
        String str2 = str + ".tmp";
        String str3 = Rw + ".sm";
        String str4 = str3 + ".tmp";
        int i2 = 8;
        if (z) {
            if (e.ct(str)) {
                i2 = 24;
                e.y(str, str2);
            } else {
                z = false;
            }
        }
        long[] a = a(dvx);
        long[] Ie = z ? Ie(Rw) : null;
        String[] a2 = a(a, Ie);
        if (Ie == null) {
            z2 = false;
        } else {
            z2 = z;
        }
        if (this.kIx) {
            i = i2 | 3;
        } else {
            i = i2;
        }
        1 1 = new 1(this, bVar, ZK, str3, z2, dvx, str4, Rw, str2, Ie, a, i, a2, str);
        this.kIq = true;
        com.tencent.mm.sdk.g.d.post(1, "DB Backup");
        AppMethodBeat.o(18988);
        return true;
    }

    public final synchronized boolean bhP() {
        boolean z = false;
        synchronized (this) {
            AppMethodBeat.i(18989);
            this.kIq = false;
            if (this.kIn == null) {
                AppMethodBeat.o(18989);
            } else {
                this.kIn.onCancel();
                z = true;
                AppMethodBeat.o(18989);
            }
        }
        return z;
    }

    @Deprecated
    public final synchronized int a(String str, b bVar) {
        AppMethodBeat.i(18990);
        2 2 = new 2(this, aw.ZK(), str, bo.dpD(), bVar);
        this.kIq = true;
        aw.RS().Bn();
        aw.RS().ae(2);
        AppMethodBeat.o(18990);
        return 0;
    }

    @Deprecated
    public final synchronized int b(String str, b bVar) {
        int i = 0;
        synchronized (this) {
            b bVar2;
            AppMethodBeat.i(18991);
            com.tencent.mm.model.c ZK = aw.ZK();
            if (str == null) {
                str = com.tencent.mm.model.c.Rs();
            }
            long dpD = bo.dpD();
            if (str == null) {
                bVar2 = null;
            } else {
                bVar2 = new b(str);
            }
            if (bVar2 == null || !bVar2.canRead()) {
                i = -3;
                AppMethodBeat.o(18991);
            } else {
                ab.i("MicroMsg.SubCoreDBBackup", "[Repair] inFileSize: %d, diskFreeSpace: %d", new Object[]{Long.valueOf(bVar2.length()), Long.valueOf(dpD)});
                if (((float) dpD) < ((float) bVar2.length()) * 1.5f) {
                    i = -2;
                    AppMethodBeat.o(18991);
                } else {
                    3 3 = new 3(this, ZK, str, bVar);
                    this.kIq = true;
                    aw.RS().Bn();
                    aw.RS().ae(3);
                    AppMethodBeat.o(18991);
                }
            }
        }
        return i;
    }

    @Deprecated
    public final int a(b bVar) {
        AppMethodBeat.i(18992);
        aw.ZK();
        String Rs = com.tencent.mm.model.c.Rs();
        if (Rs == null || Rs.isEmpty()) {
            AppMethodBeat.o(18992);
            return -3;
        }
        b bVar2 = new b(Rs);
        if (bVar2.canRead()) {
            StringBuilder append = new StringBuilder().append(q.LK());
            aw.ZK();
            String substring = com.tencent.mm.a.g.x(append.append(com.tencent.mm.model.c.QF()).toString().getBytes()).substring(0, 7);
            ab.i("MicroMsg.SubCoreDBBackup", "db recover needSize : %d blockSize:%d", new Object[]{Long.valueOf(bVar2.length() * 2), Long.valueOf(bo.dpD())});
            if (bo.dpD() < bVar2.length() * 2) {
                AppMethodBeat.o(18992);
                return -2;
            }
            aw.RS().Bn();
            aw.RS().ae(new 4(this, bVar2, substring, bVar));
            AppMethodBeat.o(18992);
            return 0;
        }
        AppMethodBeat.o(18992);
        return -3;
    }

    public final HashMap<Integer, com.tencent.mm.cd.h.d> Jx() {
        return null;
    }

    public final void iy(int i) {
    }

    public final void bz(boolean z) {
        AppMethodBeat.i(18993);
        aw.ZK();
        z Ry = com.tencent.mm.model.c.Ry();
        SQLiteDatabase dvx = com.tencent.mm.model.c.Ru().dvx();
        this.kIv = Ry.Mm(237569);
        this.kIw = Ry.getInt(237570, 10);
        this.kIx = Ry.getInt(237571, 0) != 0;
        Context context = ah.getContext();
        Intent registerReceiver = context.registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED"));
        if (registerReceiver != null) {
            boolean z2;
            int intExtra = registerReceiver.getIntExtra("status", -1);
            if (intExtra == 2 || intExtra == 5) {
                z2 = true;
            } else {
                z2 = false;
            }
            this.jZS = z2;
        } else {
            this.jZS = false;
        }
        this.jZT = ((PowerManager) context.getSystemService("power")).isScreenOn();
        this.kIz = new 7(this);
        com.tencent.mm.model.c.c.abi().c(this.kIz);
        bhQ();
        this.kIA = new 8(this);
        com.tencent.mm.sdk.b.a.xxA.c(this.kIA);
        this.jZU = new 9(this);
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("android.intent.action.SCREEN_ON");
        intentFilter.addAction("android.intent.action.SCREEN_OFF");
        intentFilter.addAction("android.intent.action.ACTION_POWER_CONNECTED");
        intentFilter.addAction("android.intent.action.ACTION_POWER_DISCONNECTED");
        context.registerReceiver(this.jZU, intentFilter);
        com.tencent.mm.pluginsdk.cmd.b.a(new c(this), new String[]{"//recover-old", "//recover", "//post-recover", "//backupdb", "//recoverdb", "//repairdb", "//corruptdb", "//iotracedb", "//recover-status", "//dbbusy"});
        String str = "MicroMsg.SubCoreDBBackup";
        String str2 = "Auto database backup %s. Device status:%s interactive,%s charging.";
        Object[] objArr = new Object[3];
        objArr[0] = this.kIs ? "enabled" : "disabled";
        objArr[1] = this.jZT ? BuildConfig.FLAVOR : " not";
        objArr[2] = this.jZS ? BuildConfig.FLAVOR : " not";
        ab.i(str, str2, objArr);
        b(dvx);
        com.tencent.mm.plugin.dbbackup.a.b.Ii(q.LK());
        e.deleteFile(g.RP().eJM + "dbback/EnMicroMsg.db.bak");
        e.deleteFile(g.RP().eJM + "dbback/corrupted/EnMicroMsg.db.bak");
        e.deleteFile(g.RP().cachePath + "EnMicroMsg.db.bak");
        e.deleteFile(g.RP().cachePath + "corrupted/EnMicroMsg.db.bak");
        aw.RS().m(new 6(this, com.tencent.mm.model.c.Rt()), 60000);
        AppMethodBeat.o(18993);
    }

    public final void bA(boolean z) {
    }

    public final void onAccountRelease() {
        AppMethodBeat.i(18994);
        bhP();
        this.kIr = false;
        if (this.jZV != null) {
            aw.RS().doN().removeCallbacks(this.jZV);
            this.jZV = null;
        }
        if (this.kIA != null) {
            com.tencent.mm.sdk.b.a.xxA.d(this.kIA);
            this.kIA = null;
        }
        if (this.jZU != null) {
            ah.getContext().unregisterReceiver(this.jZU);
            this.jZU = null;
        }
        com.tencent.mm.pluginsdk.cmd.b.N(new String[]{"//recover-old", "//recover", "//post-recover", "//backupdb", "//recoverdb", "//repairdb", "//corruptdb", "//iotracedb", "//recover-status", "//dbbusy"});
        AppMethodBeat.o(18994);
    }

    private static void bhQ() {
        AppMethodBeat.i(18995);
        com.tencent.mm.storage.c ll = com.tencent.mm.model.c.c.abi().ll("100274");
        if (ll.isValid()) {
            Map dru = ll.dru();
            HashMap hashMap = new HashMap();
            hashMap.put("flags", Integer.valueOf(bo.getInt((String) dru.get("flags"), 0)));
            hashMap.put("acp", Integer.valueOf(bo.getInt((String) dru.get("acp"), 100)));
            f.aV(hashMap);
        }
        AppMethodBeat.o(18995);
    }

    static void bhR() {
        AppMethodBeat.i(18996);
        com.tencent.mm.plugin.messenger.foundation.a.a.h XO = com.tencent.mm.model.c.XO();
        XO.bOz();
        XO.bOB();
        XO.bOA();
        com.tencent.mm.model.c.XR().dsL();
        o.ahl().agT();
        z Ry = com.tencent.mm.model.c.Ry();
        Ry.set(ac.a.xJw, Integer.valueOf(0));
        Ry.set(ac.a.xJx, Integer.valueOf(0));
        Ry.set(ac.a.xJy, Integer.valueOf(0));
        AppMethodBeat.o(18996);
    }

    public static void dB(Context context) {
        AppMethodBeat.i(18997);
        MMAppMgr.k(context, true);
        AppMethodBeat.o(18997);
    }

    public static void bhS() {
        AppMethodBeat.i(18998);
        MMAppMgr.pQ(true);
        AppMethodBeat.o(18998);
    }
}
