导航菜单

页面标题

页面副标题

CallApp v2.226 - DropBoxHelper.java 源代码

正在查看: CallApp v2.226 应用的 DropBoxHelper.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.callapp.contacts.api.helper.backup;

import a1.d0;
import android.app.Activity;
import android.app.Application;
import android.content.pm.PackageManager;
import android.os.Bundle;
import com.callapp.contacts.CallAppApplication;
import com.callapp.contacts.R;
import com.callapp.contacts.manager.preferences.Prefs;
import com.callapp.contacts.manager.preferences.prefs.StringPref;
import com.callapp.contacts.util.Activities;
import com.callapp.contacts.util.CLog;
import com.callapp.contacts.util.serializer.string.Parser;
import com.callapp.framework.util.StringUtils;
import com.dropbox.core.InvalidAccessTokenException;
import com.dropbox.core.NetworkIOException;
import com.dropbox.core.e;
import com.dropbox.core.h;
import com.dropbox.core.k;
import com.dropbox.core.util.IOUtil;
import com.dropbox.core.v2.files.DeleteErrorException;
import com.dropbox.core.v2.files.GetMetadataErrorException;
import com.dropbox.core.v2.files.ListFolderErrorException;
import com.dropbox.core.v2.files.UploadErrorException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import dc.a;
import fc.a;
import hc.a;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.collections.q;
import kotlin.jvm.internal.Intrinsics;
import org.jetbrains.annotations.NotNull;
import qc.b0;
import qc.f1;
import qc.g3;
import qc.j;
import qc.m2;
import qc.n2;
import qc.u0;
import qc.y2;

@Metadata(d1 = {"\u0000 \n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0003\bÆ\u0002\u0018\u00002\u00020\u00012\u00020\u0002B\t\b\u0002¢\u0006\u0004\b\u0003\u0010\u0004J\u000f\u0010\u0006\u001a\u00020\u0005H\u0016¢\u0006\u0004\b\u0006\u0010\u0007J\u000f\u0010\t\u001a\u00020\bH\u0016¢\u0006\u0004\b\t\u0010\n¨\u0006\u000b"}, d2 = {"Lcom/callapp/contacts/api/helper/backup/DropBoxHelper;", "Lcom/callapp/contacts/api/helper/backup/BaseBackup;", "Landroid/app/Application$ActivityLifecycleCallbacks;", "<init>", "()V", "", "isLoggedIn", "()Z", "", "getName", "()Ljava/lang/String;", "callapp-client_playRelease"}, k = 1, mv = {2, 1, 0}, xi = 48)
public final class DropBoxHelper extends BaseBackup implements Application.ActivityLifecycleCallbacks {
    public static final DropBoxHelper c = new DropBoxHelper();
    public static final String d = "files.content.write";

    private DropBoxHelper() {
    }

    public static BackupMessageCode d(UploadErrorException uploadErrorException) {
        String reason;
        BackupMessageCode backupMessageCode = BackupMessageCode.UPLOAD_ERROR;
        try {
            DropBoxErrorResponse dropBoxErrorResponse = (DropBoxErrorResponse) Parser.b(uploadErrorException.a.toString(), new TypeReference<DropBoxErrorResponse>() {
            });
            if (dropBoxErrorResponse != null && (reason = dropBoxErrorResponse.getReason()) != null && reason.equals("insufficient_space")) {
                return BackupMessageCode.INSUFFICIENT_SPACE;
            }
        } catch (MismatchedInputException e) {
            CLog.f(StringUtils.I(DropBoxHelper.class), "unable to parse  error message " + e);
        }
        return backupMessageCode;
    }

    @Override
    public final void a() {
        if (isLoggedIn()) {
            try {
                new a(DropBoxConfigFactory.a.getRequestConfig(), DropBoxClientFactory.a.getDropBoxAccessToken()).b.a();
                DropBoxClientFactory.b = null;
                DropBoxClientFactory.c = null;
            } catch (Exception e) {
                CLog.f(StringUtils.I(DropBoxHelper.class), d0.C("log out exception ", e.getMessage()));
            }
            Prefs.U6.set(null);
        }
    }

    @Override
    public final BackUpResultData b(ArrayList arrayList) {
        j jVar;
        b0 b0Var;
        j jVar2;
        Intrinsics.checkNotNullParameter(arrayList, "backupDataList");
        ArrayList arrayList2 = new ArrayList();
        ArrayList arrayList3 = new ArrayList();
        StringPref stringPref = Prefs.U6;
        if (!(stringPref.isNotNull() && StringUtils.x(stringPref.get()))) {
            CLog.f(StringUtils.I(DropBoxHelper.class), "token error: token is null or empty");
            throw new DisconnectException("Dropbox token error - token is null or empty");
        }
        try {
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                BackUpData backUpData = (BackUpData) it.next();
                backUpData.getFolderName();
                StringUtils.I(DropBoxHelper.class);
                CLog.a();
                if (backUpData.getDeleteBeforeUpload()) {
                    try {
                        a client = DropBoxClientFactory.a.getClient();
                        if (client != null && (jVar = client.c) != null) {
                            jVar.a("/" + backUpData.getFolderName());
                        }
                        backUpData.getFolderName();
                        StringUtils.I(DropBoxHelper.class);
                        CLog.a();
                    } catch (DeleteErrorException e) {
                        CLog.f(StringUtils.I(DropBoxHelper.class), "Delete error: " + e.getMessage());
                    }
                } else {
                    e(backUpData, arrayList2).toString();
                    StringUtils.I(DropBoxHelper.class);
                    CLog.a();
                }
                for (BackUpFileData backUpFileData : CollectionsKt.F(backUpData.getFileData())) {
                    String filePath = backUpFileData.getFilePath();
                    File file = new File(filePath);
                    if (file.exists()) {
                        String fileName = backUpFileData.getFileName();
                        try {
                            FileInputStream fileInputStream = new FileInputStream(file);
                            try {
                                a client2 = DropBoxClientFactory.a.getClient();
                                if (client2 == null || (jVar2 = client2.c) == null) {
                                    b0Var = null;
                                } else {
                                    n2 n2Var = new n2(jVar2, new m2.a("/" + backUpData.getFolderName() + "/" + fileName));
                                    g3 g3Var = g3.d;
                                    m2.a aVar = n2Var.b;
                                    if (g3Var != null) {
                                        aVar.b = g3Var;
                                    } else {
                                        aVar.getClass();
                                        aVar.b = g3.c;
                                    }
                                    y2 a = n2Var.a();
                                    a.c cVar = ((h) a).a;
                                    try {
                                        try {
                                            try {
                                                cVar.d();
                                                cVar.e(fileInputStream);
                                                Object d2 = a.d();
                                                a.close();
                                                b0Var = (b0) d2;
                                            } catch (IOException e2) {
                                                throw new NetworkIOException(e2);
                                            }
                                        } catch (IOUtil.ReadException e3) {
                                            throw e3.a();
                                        }
                                    } catch (Throwable th) {
                                        a.close();
                                        throw th;
                                    }
                                }
                                if (b0Var != null) {
                                    StringUtils.I(DropBoxHelper.class);
                                    CLog.a();
                                    arrayList2.add(new BackupUploadFileData(filePath, BackupMessageCode.SUCCESSFUL, backUpData.getFileType()));
                                } else {
                                    arrayList3.add(new BackupUploadFileData(filePath, BackupMessageCode.FILE_ERROR, backUpData.getFileType()));
                                    StringUtils.I(DropBoxHelper.class);
                                    CLog.a();
                                    Unit unit = Unit.a;
                                }
                                fileInputStream.close();
                            } finally {
                            }
                        } catch (UploadErrorException e4) {
                            BackupMessageCode d3 = d(e4);
                            if (d3 == BackupMessageCode.INSUFFICIENT_SPACE) {
                                throw new NotEnoughSpaceException("dropbox not enough space");
                            }
                            arrayList3.add(new BackupUploadFileData(filePath, d3, backUpData.getFileType()));
                            CLog.f(StringUtils.I(DropBoxHelper.class), "Upload error: " + fileName + " " + e4.getMessage());
                            Unit unit2 = Unit.a;
                        } catch (Exception e5) {
                            CLog.f(StringUtils.I(DropBoxHelper.class), "Upload error: " + fileName + " " + e5.getMessage());
                            arrayList3.add(new BackupUploadFileData(filePath, BackupMessageCode.UNKNOWN_ERROR, backUpData.getFileType()));
                        }
                    } else {
                        CLog.f(StringUtils.I(DropBoxHelper.class), "Upload error: file not exist");
                    }
                }
            }
            ArrayList arrayList4 = new ArrayList();
            Iterator it2 = arrayList2.iterator();
            while (it2.hasNext()) {
                Object next = it2.next();
                if (((BackupUploadFileData) next).getCom.bytedance.sdk.component.pglcrypt.PglCryptUtils.KEY_MESSAGE java.lang.String() == BackupMessageCode.SUCCESSFUL) {
                    arrayList4.add(next);
                }
            }
            arrayList4.size();
            arrayList3.size();
            ArrayList arrayList5 = new ArrayList();
            Iterator it3 = arrayList2.iterator();
            while (it3.hasNext()) {
                Object next2 = it3.next();
                if (((BackupUploadFileData) next2).getCom.bytedance.sdk.component.pglcrypt.PglCryptUtils.KEY_MESSAGE java.lang.String() == BackupMessageCode.EXIST) {
                    arrayList5.add(next2);
                }
            }
            arrayList5.size();
            StringUtils.I(DropBoxHelper.class);
            CLog.a();
            return new BackUpResultData(arrayList2, arrayList3);
        } catch (InvalidAccessTokenException unused) {
            throw new DisconnectException("Dropbox invalid access token");
        }
    }

    public final void c(Activity activity) {
        Intrinsics.checkNotNullParameter(activity, "activity");
        if (isLoggedIn()) {
            BackupLoginCallBack loginListener = getLoginListener();
            if (loginListener != null) {
                Prefs.U6.get();
                loginListener.a();
            }
            this.loginListener = null;
            return;
        }
        DropBoxClientFactory.a.getClass();
        DropBoxClientFactory.b = null;
        DropBoxClientFactory.c = null;
        PackageManager packageManager = activity.getPackageManager();
        if (packageManager != null) {
            CallAppApplication.get().registerActivityLifecycleCallbacks(c);
            try {
                if (packageManager.getPackageInfo("com.dropbox.android", 1) != null) {
                    a.a aVar = dc.a.a;
                    CallAppApplication callAppApplication = CallAppApplication.get();
                    Intrinsics.checkNotNullExpressionValue(callAppApplication, "get(...)");
                    String string = Activities.getString(R.string.dropbox_app_key);
                    e requestConfig = DropBoxConfigFactory.a.getRequestConfig();
                    List c2 = q.c(d);
                    aVar.getClass();
                    Intrinsics.checkNotNullParameter(callAppApplication, "context");
                    Intrinsics.checkNotNullParameter(callAppApplication, "context");
                    if (requestConfig == null) {
                        throw new IllegalArgumentException("Invalid Dbx requestConfig for PKCE flow.");
                    }
                    a.a.a(callAppApplication, string, (String) null, k.OFFLINE, requestConfig, c2);
                }
            } catch (Exception unused) {
                a.a aVar2 = dc.a.a;
                CallAppApplication callAppApplication2 = CallAppApplication.get();
                Intrinsics.checkNotNullExpressionValue(callAppApplication2, "get(...)");
                String string2 = Activities.getString(R.string.dropbox_app_key);
                aVar2.getClass();
                Intrinsics.checkNotNullParameter(callAppApplication2, "context");
                Intrinsics.checkNotNullParameter(callAppApplication2, "context");
                Intrinsics.checkNotNullParameter(callAppApplication2, "context");
                a.a.a(callAppApplication2, string2, "www.dropbox.com", (k) null, (e) null, (Collection) null);
            }
        }
    }

    public final ArrayList e(BackUpData backUpData, ArrayList arrayList) {
        Object obj;
        j jVar;
        Intrinsics.checkNotNullParameter(backUpData, "backupData");
        Intrinsics.checkNotNullParameter(arrayList, "finishUploadList");
        ArrayList arrayList2 = new ArrayList();
        ArrayList arrayList3 = new ArrayList();
        try {
            hc.a client = DropBoxClientFactory.a.getClient();
            u0 b = (client == null || (jVar = client.c) == null) ? null : jVar.b("/" + backUpData.getFolderName());
            if (b != null) {
                List list = b.a;
                for (BackUpFileData backUpFileData : backUpData.getFileData()) {
                    Intrinsics.c(list);
                    Iterator it = list.iterator();
                    while (true) {
                        if (!it.hasNext()) {
                            obj = null;
                            break;
                        }
                        obj = it.next();
                        if (Intrinsics.a(((f1) obj).a(), backUpFileData.getFileName())) {
                            break;
                        }
                    }
                    f1 f1Var = (f1) obj;
                    if (f1Var != null) {
                        arrayList.add(new BackupUploadFileData(f1Var.b(), BackupMessageCode.EXIST, backUpData.getFileType()));
                        arrayList3.add(f1Var.a());
                    } else {
                        arrayList2.add(backUpFileData);
                    }
                }
                backUpData.setFileData(arrayList2);
                return arrayList3;
            }
        } catch (GetMetadataErrorException e) {
            CLog.f(StringUtils.I(DropBoxHelper.class), e.getMessage());
        } catch (ListFolderErrorException e2) {
            CLog.f(StringUtils.I(DropBoxHelper.class), e2.getMessage());
        }
        return arrayList3;
    }

    @Override
    @NotNull
    public String getName() {
        String string = Activities.getString(R.string.dropbox);
        Intrinsics.checkNotNullExpressionValue(string, "getString(...)");
        return string;
    }

    public boolean isLoggedIn() {
        StringPref stringPref = Prefs.U6;
        return stringPref.isNotNull() && StringUtils.x(stringPref.get());
    }

    @Override
    public final void onActivityCreated(Activity activity, Bundle bundle) {
        Intrinsics.checkNotNullParameter(activity, "activity");
    }

    @Override
    public final void onActivityDestroyed(android.app.Activity r9) {
        throw new UnsupportedOperationException("Method not decompiled: com.callapp.contacts.api.helper.backup.DropBoxHelper.onActivityDestroyed(android.app.Activity):void");
    }

    @Override
    public final void onActivityPaused(Activity activity) {
        Intrinsics.checkNotNullParameter(activity, "activity");
    }

    @Override
    public final void onActivityResumed(Activity activity) {
        Intrinsics.checkNotNullParameter(activity, "activity");
    }

    @Override
    public final void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
        Intrinsics.checkNotNullParameter(activity, "activity");
        Intrinsics.checkNotNullParameter(bundle, "outState");
    }

    @Override
    public final void onActivityStarted(Activity activity) {
        Intrinsics.checkNotNullParameter(activity, "activity");
    }

    @Override
    public final void onActivityStopped(Activity activity) {
        Intrinsics.checkNotNullParameter(activity, "activity");
    }
}