package com.ifpdos.debugmenu.action;

import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.IActivityManager;
import android.content.Context;
import android.os.RemoteException;
import android.util.Log;
import com.ifpdos.debugmenu.R;
import com.ifpdos.debugmenu.action.base.ItemSelectAction;
import com.seewo.vcommons.data.UserContentResolver;
import d.b.a.a.a;
import d.i.f.c.b;
import java.io.File;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public class BugreportAction extends ItemSelectAction {
    private static final String KEY_BUGREPORT = "KEY_BUGREPORT";
    private static final String TAG = "BugreportAction";

    public BugreportAction(Context context) {
        super(context);
    }

    /* JADX WARN: Removed duplicated region for block: B:44:0x0075 A[Catch: IOException -> 0x0071, TRY_LEAVE, TryCatch #3 {IOException -> 0x0071, blocks: (B:40:0x006d, B:44:0x0075), top: B:52:0x006d }] */
    /* JADX WARN: Removed duplicated region for block: B:52:0x006d A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static boolean copyFile(java.io.File r9, java.lang.String r10, java.lang.String r11) throws java.lang.Throwable {
        /*
            r0 = 0
            if (r9 == 0) goto L81
            if (r10 != 0) goto L7
            goto L81
        L7:
            java.io.File r1 = new java.io.File
            r1.<init>(r10, r11)
            boolean r10 = r1.exists()
            if (r10 == 0) goto L19
            boolean r10 = r1.delete()
            if (r10 != 0) goto L19
            return r0
        L19:
            boolean r10 = r1.createNewFile()     // Catch: java.io.IOException -> L7d
            if (r10 != 0) goto L20
            return r0
        L20:
            r10 = 0
            java.io.FileInputStream r11 = new java.io.FileInputStream     // Catch: java.lang.Throwable -> L57 java.io.IOException -> L5a
            r11.<init>(r9)     // Catch: java.lang.Throwable -> L57 java.io.IOException -> L5a
            java.nio.channels.FileChannel r9 = r11.getChannel()     // Catch: java.lang.Throwable -> L57 java.io.IOException -> L5a
            java.io.FileOutputStream r11 = new java.io.FileOutputStream     // Catch: java.lang.Throwable -> L4d java.io.IOException -> L52
            r11.<init>(r1)     // Catch: java.lang.Throwable -> L4d java.io.IOException -> L52
            java.nio.channels.FileChannel r10 = r11.getChannel()     // Catch: java.lang.Throwable -> L4d java.io.IOException -> L52
            r3 = 0
            long r5 = r9.size()     // Catch: java.lang.Throwable -> L4d java.io.IOException -> L52
            r2 = r9
            r7 = r10
            r2.transferTo(r3, r5, r7)     // Catch: java.lang.Throwable -> L4d java.io.IOException -> L52
            r0 = 1
            r9.close()     // Catch: java.io.IOException -> L48
            if (r10 == 0) goto L69
            r10.close()     // Catch: java.io.IOException -> L48
            goto L69
        L48:
            r9 = move-exception
            r9.printStackTrace()
            goto L69
        L4d:
            r11 = move-exception
            r8 = r10
            r10 = r9
            r9 = r8
            goto L6b
        L52:
            r11 = move-exception
            r8 = r10
            r10 = r9
            r9 = r8
            goto L5c
        L57:
            r11 = move-exception
            r9 = r10
            goto L6b
        L5a:
            r11 = move-exception
            r9 = r10
        L5c:
            r11.printStackTrace()     // Catch: java.lang.Throwable -> L6a
            if (r10 == 0) goto L64
            r10.close()     // Catch: java.io.IOException -> L48
        L64:
            if (r9 == 0) goto L69
            r9.close()     // Catch: java.io.IOException -> L48
        L69:
            return r0
        L6a:
            r11 = move-exception
        L6b:
            if (r10 == 0) goto L73
            r10.close()     // Catch: java.io.IOException -> L71
            goto L73
        L71:
            r9 = move-exception
            goto L79
        L73:
            if (r9 == 0) goto L7c
            r9.close()     // Catch: java.io.IOException -> L71
            goto L7c
        L79:
            r9.printStackTrace()
        L7c:
            throw r11
        L7d:
            r9 = move-exception
            r9.printStackTrace()
        L81:
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ifpdos.debugmenu.action.BugreportAction.copyFile(java.io.File, java.lang.String, java.lang.String):boolean");
    }

    @Override // com.ifpdos.debugmenu.action.base.ItemSelectAction
    public List<String> getEntryList(Context context) {
        return a.G(context, R.array.bugreport_type);
    }

    @Override // com.ifpdos.debugmenu.action.base.ItemSelectAction
    public int getSelectIndex(Context context) {
        return b.c(context, KEY_BUGREPORT, 0);
    }

    @Override // com.ifpdos.debugmenu.action.base.ItemSelectAction
    @SuppressLint({"CheckResult"})
    public void onSelect(Context context, int i2) throws Throwable {
        UserContentResolver userContentResolver = b.a;
        b.h(context.getContentResolver(), KEY_BUGREPORT, String.valueOf(i2));
        if (i2 == 1) {
            Log.v(TAG, "Taking full bugreport right away");
            try {
                ((IActivityManager) d.i.f.g.e.b.d((ActivityManager) this.mContext.getApplicationContext().getSystemService("activity")).b("getService", new Object[0]).f3661b).requestFullBugReport();
            } catch (RemoteException e2) {
                Log.e(TAG, "error taking bugreport (bugreportType=Full)", e2);
            }
        } else {
            Log.v(TAG, "Taking interactive bugreport right away");
            try {
                ((IActivityManager) d.i.f.g.e.b.d((ActivityManager) this.mContext.getApplicationContext().getSystemService("activity")).b("getService", new Object[0]).f3661b).requestInteractiveBugReport();
            } catch (RemoteException e3) {
                Log.e(TAG, "error taking bugreport (bugreportType=Full)", e3);
            }
        }
        copyFile(new File("/data/user_de/0/com.android.shell/files/bugreports"), "/storage/sda1/", "bugreports");
    }
}
