|
|
@@ -5,7 +5,6 @@ import static android.content.Context.POWER_SERVICE;
|
|
|
import android.content.Context;
|
|
|
import android.database.Cursor;
|
|
|
import android.database.sqlite.SQLiteDatabase;
|
|
|
-import android.graphics.Bitmap;
|
|
|
import android.graphics.BitmapFactory;
|
|
|
import android.net.Uri;
|
|
|
import android.os.CancellationSignal;
|
|
|
@@ -19,6 +18,7 @@ import androidx.databinding.Bindable;
|
|
|
import com.atmob.common.crypto.CryptoUtils;
|
|
|
import com.atmob.common.runtime.ContextUtil;
|
|
|
import com.datarecovery.master.BR;
|
|
|
+import com.datarecovery.master.module.member.MemberType;
|
|
|
import com.datarecovery.master.utils.filedetect.FileScanHelper;
|
|
|
import com.datarecovery.master.utils.xfile.XFile;
|
|
|
import com.datarecovery.master.utils.xfile.XFileSearch;
|
|
|
@@ -38,7 +38,6 @@ import java.nio.ByteOrder;
|
|
|
import java.nio.MappedByteBuffer;
|
|
|
import java.nio.channels.FileChannel;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
import java.util.UUID;
|
|
|
@@ -66,7 +65,7 @@ public class ImageDeepDetector {
|
|
|
private static final int HUAWEI_GALLERY_CACHE = 9;
|
|
|
|
|
|
|
|
|
- public static Flowable<List<ImageFile>> detect(Context context) {
|
|
|
+ public static Flowable<List<ImageFile>> detect(Context context, @MemberType String type) {
|
|
|
BitmapFactory.Options options = new BitmapFactory.Options();
|
|
|
options.inJustDecodeBounds = true;
|
|
|
return Flowable.create((FlowableOnSubscribe<XFile>) emitter -> {
|
|
|
@@ -77,7 +76,11 @@ public class ImageDeepDetector {
|
|
|
|
|
|
@Override
|
|
|
public boolean acceptFile(XFile file) {
|
|
|
- return isAcceptFile(file);
|
|
|
+ if (Objects.equals(MemberType.APP_IMAGE_RECOVER, type)) {
|
|
|
+ return isRecoverAcceptFile(file);
|
|
|
+ } else {
|
|
|
+ return isClearAcceptFile(file);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -308,7 +311,37 @@ public class ImageDeepDetector {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- public static boolean isAcceptFile(XFile file) {
|
|
|
+ public static boolean isClearAcceptFile(XFile file) {
|
|
|
+ try {
|
|
|
+ if (file.length() == 0) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } catch (Exception ignore) {
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (file.getMineType() != null && file.getMineType().startsWith("image/")) {
|
|
|
+ file.setTag(IMAGE_SUFFIX);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ } catch (Exception ignore) {
|
|
|
+
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String name = file.getName();
|
|
|
+ if (isImageSuffix(name)) {
|
|
|
+ file.setTag(IMAGE_SUFFIX);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ } catch (Exception ignore) {
|
|
|
+ }
|
|
|
+ if (hasImgMagic(file)) {
|
|
|
+ file.setTag(IMG_MAGIC);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static boolean isRecoverAcceptFile(XFile file) {
|
|
|
try {
|
|
|
if (file.length() == 0) {
|
|
|
return false;
|