package com.seewo.vcommons.helper;

import android.content.Context;
import android.os.Environment;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.storage.DiskInfo;
import android.os.storage.IMountService;
import android.os.storage.StorageManager;
import android.os.storage.VolumeInfo;
import android.text.TextUtils;
import android.util.Log;
import com.seewo.vcommons.data.PreferencesUtils;
import com.seewo.vcommons.utils.BoardTypeUtils;
import com.seewo.vcommons.utils.reflect.StorageManagerInsider;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;

/* JADX INFO: loaded from: classes.dex */
public class StorageHelper {
    private static final String DEV_PATH = "/dev/block/";
    private static final String SDCARD_PREFIX = "mmcblk";
    private static final String SDCARD_ROOT_PATH = Environment.getExternalStorageDirectory().getPath();
    private static final String TAG = "Storage";
    private static volatile StorageHelper mInstance;
    private Context mContext;
    private StorageBase mCurrentStorage;

    public enum PathType {
        LOCAL_PATH,
        CLOUD_PATH,
        REMOTE_PATH,
        OTHER
    }

    public enum SubType {
        DEFAULT,
        LOCAL_PATH_RECENT,
        LOCAL_PATH_PUBLIC,
        LOCAL_PATH_USER,
        LOCAL_PATH_USB,
        LOCAL_PATH_SDCARD,
        CLOUD_PATH_GOOGLE,
        CLOUD_PATH_DRIVE,
        CLOUD_PATH_USER_GOOGLE,
        CLOUD_PATH_USER_DRIVE,
        REMOTE_PATH_SAMBA,
        REMOTE_PATH_FTP,
        OTHER
    }

    public static class StorageItem {
        public String mAliasPath;
        public String mInternalPath;
        public String mLabel;
        public String mPath;
        public PathType mPathType;
        public int mResId;
        public String mSavePath;
        public SubType mSubType = SubType.DEFAULT;

        public StorageItem() {
        }

        public StorageItem(String str) {
            this.mPath = str;
        }

        public StorageItem(String str, String str2) {
            this.mPath = str;
            this.mLabel = str2;
        }

        public PathType getPathType() {
            PathType pathType = this.mPathType;
            return pathType == null ? PathType.LOCAL_PATH : pathType;
        }

        public SubType getSubType() {
            SubType subType = this.mSubType;
            return subType == null ? SubType.DEFAULT : subType;
        }

        public String toString() {
            return this.mLabel;
        }

        public boolean equals(Object obj) {
            if (obj == null || getClass() != obj.getClass()) {
                return false;
            }
            return this.mPath.equals(((StorageItem) obj).mPath);
        }

        public int hashCode() {
            return this.mPath.hashCode();
        }
    }

    private StorageHelper() {
        initBordType();
    }

    public void init(Context context) {
        this.mContext = context;
    }

    /* JADX INFO: renamed from: com.seewo.vcommons.helper.StorageHelper$1, reason: invalid class name */
    static /* synthetic */ class AnonymousClass1 {
        static final /* synthetic */ int[] $SwitchMap$com$seewo$vcommons$utils$BoardTypeUtils$BoardType;

        static {
            int[] iArr = new int[BoardTypeUtils.BoardType.values().length];
            $SwitchMap$com$seewo$vcommons$utils$BoardTypeUtils$BoardType = iArr;
            try {
                iArr[BoardTypeUtils.BoardType.MTK5508.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                $SwitchMap$com$seewo$vcommons$utils$BoardTypeUtils$BoardType[BoardTypeUtils.BoardType.RK3288.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                $SwitchMap$com$seewo$vcommons$utils$BoardTypeUtils$BoardType[BoardTypeUtils.BoardType.HISI_V510.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                $SwitchMap$com$seewo$vcommons$utils$BoardTypeUtils$BoardType[BoardTypeUtils.BoardType.HISI_V551.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                $SwitchMap$com$seewo$vcommons$utils$BoardTypeUtils$BoardType[BoardTypeUtils.BoardType.HISI_V811.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                $SwitchMap$com$seewo$vcommons$utils$BoardTypeUtils$BoardType[BoardTypeUtils.BoardType.HISI_V620.ordinal()] = 6;
            } catch (NoSuchFieldError unused6) {
            }
            try {
                $SwitchMap$com$seewo$vcommons$utils$BoardTypeUtils$BoardType[BoardTypeUtils.BoardType.RK3399.ordinal()] = 7;
            } catch (NoSuchFieldError unused7) {
            }
            try {
                $SwitchMap$com$seewo$vcommons$utils$BoardTypeUtils$BoardType[BoardTypeUtils.BoardType.MSD638.ordinal()] = 8;
            } catch (NoSuchFieldError unused8) {
            }
            try {
                $SwitchMap$com$seewo$vcommons$utils$BoardTypeUtils$BoardType[BoardTypeUtils.BoardType.MSD608.ordinal()] = 9;
            } catch (NoSuchFieldError unused9) {
            }
            try {
                $SwitchMap$com$seewo$vcommons$utils$BoardTypeUtils$BoardType[BoardTypeUtils.BoardType.MSD6369.ordinal()] = 10;
            } catch (NoSuchFieldError unused10) {
            }
            try {
                $SwitchMap$com$seewo$vcommons$utils$BoardTypeUtils$BoardType[BoardTypeUtils.BoardType.MSD8386.ordinal()] = 11;
            } catch (NoSuchFieldError unused11) {
            }
            try {
                $SwitchMap$com$seewo$vcommons$utils$BoardTypeUtils$BoardType[BoardTypeUtils.BoardType.V972.ordinal()] = 12;
            } catch (NoSuchFieldError unused12) {
            }
            try {
                $SwitchMap$com$seewo$vcommons$utils$BoardTypeUtils$BoardType[BoardTypeUtils.BoardType.V982.ordinal()] = 13;
            } catch (NoSuchFieldError unused13) {
            }
            try {
                $SwitchMap$com$seewo$vcommons$utils$BoardTypeUtils$BoardType[BoardTypeUtils.BoardType.MTK9950.ordinal()] = 14;
            } catch (NoSuchFieldError unused14) {
            }
        }
    }

    private void initBordType() {
        AnonymousClass1 anonymousClass1 = null;
        switch (AnonymousClass1.$SwitchMap$com$seewo$vcommons$utils$BoardTypeUtils$BoardType[BoardTypeUtils.getBoardType().ordinal()]) {
            case 1:
                this.mCurrentStorage = new Storage5508(this, anonymousClass1);
                break;
            case 2:
                this.mCurrentStorage = new Storage3288(this, anonymousClass1);
                break;
            case 3:
            case 4:
                this.mCurrentStorage = new Storage551();
                break;
            case 5:
                this.mCurrentStorage = new Storage811();
                break;
            case 6:
                this.mCurrentStorage = new Storage620(this, anonymousClass1);
                break;
            case 7:
                this.mCurrentStorage = new Storage3399(this, anonymousClass1);
                break;
            case 8:
            case 9:
            case 10:
                this.mCurrentStorage = new DefaultStorage(this, anonymousClass1);
                break;
            case 11:
                this.mCurrentStorage = new Storage8386(this, anonymousClass1);
                break;
            case 12:
                this.mCurrentStorage = new Storage972();
                break;
            case 13:
            case 14:
                this.mCurrentStorage = new Storage9950();
                break;
            default:
                this.mCurrentStorage = new Storage9950();
                break;
        }
    }

    public static StorageHelper getInstance() {
        if (mInstance == null) {
            synchronized (StorageHelper.class) {
                if (mInstance == null) {
                    mInstance = new StorageHelper();
                }
            }
        }
        return mInstance;
    }

    public String getUsbRootPath() {
        return this.mCurrentStorage.getUsbRootPath();
    }

    public StorageItem getSdcardItem() {
        return this.mCurrentStorage.getSdcardItem();
    }

    public String getExternalSdcardRootPath() {
        return this.mCurrentStorage.getExternalSdcardRootPath();
    }

    public StorageItem getExternalSDCardItem() {
        return this.mCurrentStorage.getExternalSDCardItem();
    }

    public List<StorageItem> getUsbItems() {
        return this.mCurrentStorage.getUsbItems();
    }

    public List<StorageItem> getStorageItems() {
        return this.mCurrentStorage.getStorageItems();
    }

    public String getCurrentUserRootPath() {
        return this.mCurrentStorage.getCurrentUserRootPath();
    }

    private abstract class StorageBase {
        private StorageBase() {
        }

        /* synthetic */ StorageBase(StorageHelper storageHelper, AnonymousClass1 anonymousClass1) {
            this();
        }

        public List<StorageItem> getStorageItems() {
            ArrayList arrayList = new ArrayList();
            arrayList.add(getSdcardItem());
            if (isNeedAddExternalSdcard()) {
                arrayList.add(getExternalSDCardItem());
            }
            arrayList.addAll(getUsbItems());
            return arrayList;
        }

        private boolean isNeedAddExternalSdcard() {
            File[] fileArrListFiles;
            File file = new File(getExternalSdcardRootPath());
            return file.exists() && (fileArrListFiles = file.listFiles()) != null && fileArrListFiles.length > 0;
        }

        protected String getExternalSdcardRootPath() {
            return "/mnt/external_sd";
        }

        protected String getUsbRootPath() {
            return "/mnt/usb";
        }

        protected String getSdcardRootPath() {
            return StorageHelper.SDCARD_ROOT_PATH;
        }

        protected String getUsbName(IMountService iMountService, String str) {
            String volumeLabel;
            try {
                volumeLabel = iMountService.getVolumeLabel(str);
            } catch (RemoteException e) {
                Log.e(StorageHelper.TAG, "getVolumeLabel error", e);
                volumeLabel = null;
            }
            return volumeLabel != null ? volumeLabel.trim() : volumeLabel;
        }

        protected boolean isStoragePlugged(String str) {
            File file = new File(str);
            return file.isDirectory() && file.canRead();
        }

        protected boolean isUsbPlugged(String str) {
            return isStoragePlugged(str);
        }

        protected StorageItem getSdcardItem() {
            StorageItem storageItem = new StorageItem();
            storageItem.mPath = getSdcardRootPath();
            storageItem.mLabel = StorageHelper.TAG;
            storageItem.mSavePath = getSdcardRootPath();
            storageItem.mAliasPath = StorageHelper.TAG;
            return storageItem;
        }

        protected StorageItem getExternalSDCardItem() {
            StorageItem storageItem = new StorageItem();
            storageItem.mPath = getExternalSdcardRootPath();
            storageItem.mLabel = "Sdcard";
            storageItem.mSavePath = getExternalSdcardRootPath();
            storageItem.mAliasPath = "Sdcard";
            return storageItem;
        }

        protected StorageItem getUsbItem(String str) {
            StorageItem storageItem = new StorageItem();
            storageItem.mPath = str;
            return storageItem;
        }

        protected List<StorageItem> getUsbItems() {
            IMountService iMountServiceAsInterface = IMountService.Stub.asInterface(ServiceManager.getService("mount"));
            ArrayList arrayList = new ArrayList();
            String usbRootPath = getUsbRootPath();
            if (isStoragePlugged(usbRootPath)) {
                int i = 0;
                for (File file : new File(usbRootPath).listFiles()) {
                    String absolutePath = file.getAbsolutePath();
                    if (isUsbPlugged(absolutePath)) {
                        StorageItem usbItem = getUsbItem(absolutePath);
                        String usbName = getUsbName(iMountServiceAsInterface, absolutePath);
                        if (usbName == null) {
                            i++;
                            usbName = "USB" + i;
                        }
                        usbItem.mLabel = usbName;
                        usbItem.mSavePath = absolutePath;
                        usbItem.mAliasPath = usbName;
                        arrayList.add(usbItem);
                    }
                }
            }
            return arrayList;
        }

        public String getCurrentUserRootPath() {
            if (StorageHelper.this.mContext != null) {
                return PreferencesUtils.getCurrentRootPath(StorageHelper.this.mContext);
            }
            return getSdcardRootPath();
        }
    }

    private class Storage5508 extends StorageBase {
        private Storage5508() {
            super(StorageHelper.this, null);
        }

        /* synthetic */ Storage5508(StorageHelper storageHelper, AnonymousClass1 anonymousClass1) {
            this();
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        protected List<StorageItem> getUsbItems() {
            IMountService iMountServiceAsInterface = IMountService.Stub.asInterface(ServiceManager.getService("mount"));
            ArrayList arrayList = new ArrayList();
            String usbRootPath = getUsbRootPath();
            int i = 0;
            for (File file : new File("/dev/block/vold").listFiles()) {
                String name = file.getName();
                if (name.startsWith("sd")) {
                    String str = "/mnt/media_rw/" + name;
                    String str2 = usbRootPath + "/" + name;
                    StorageItem storageItem = new StorageItem();
                    storageItem.mPath = str2;
                    String usbName = getUsbName(iMountServiceAsInterface, str);
                    if (usbName == null) {
                        i++;
                        usbName = "USB" + i;
                    }
                    storageItem.mLabel = usbName;
                    storageItem.mSavePath = str2;
                    storageItem.mAliasPath = usbName;
                    arrayList.add(storageItem);
                }
            }
            return arrayList;
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        public String getUsbRootPath() {
            return "/storage";
        }
    }

    private class Storage3288 extends StorageBase {
        private Storage3288() {
            super(StorageHelper.this, null);
        }

        /* synthetic */ Storage3288(StorageHelper storageHelper, AnonymousClass1 anonymousClass1) {
            this();
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        protected String getUsbRootPath() {
            return "/mnt/usb_storage";
        }
    }

    private class Storage510 extends StorageBase {
        private Storage510() {
            super(StorageHelper.this, null);
        }

        /* synthetic */ Storage510(StorageHelper storageHelper, AnonymousClass1 anonymousClass1) {
            this();
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        protected String getUsbRootPath() {
            return "/mnt";
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        protected boolean isUsbPlugged(String str) {
            String name = new File(str).getName();
            return !"sdcard".equals(name) && (name.startsWith("sd") || name.startsWith(StorageHelper.SDCARD_PREFIX)) && isStoragePlugged(str);
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        protected List<StorageItem> getUsbItems() {
            IMountService iMountServiceAsInterface = IMountService.Stub.asInterface(ServiceManager.getService("mount"));
            ArrayList arrayList = new ArrayList();
            String usbRootPath = getUsbRootPath();
            if (isStoragePlugged(usbRootPath)) {
                int i = 0;
                for (File file : new File(usbRootPath).listFiles()) {
                    String absolutePath = file.getAbsolutePath();
                    String name = file.getName();
                    if (name.length() > 2) {
                        if (!name.startsWith(StorageHelper.SDCARD_PREFIX)) {
                            name = name.substring(0, 3);
                        }
                        File file2 = new File(StorageHelper.DEV_PATH + name);
                        if (isUsbPlugged(absolutePath) && file2.exists()) {
                            StorageItem usbItem = getUsbItem(absolutePath);
                            String usbName = getUsbName(iMountServiceAsInterface, absolutePath);
                            if (usbName == null) {
                                i++;
                                usbName = "USB" + i;
                            }
                            usbItem.mLabel = usbName;
                            usbItem.mSavePath = absolutePath;
                            usbItem.mAliasPath = usbName;
                            arrayList.add(usbItem);
                        }
                    }
                }
            }
            return arrayList;
        }
    }

    private class Storage620 extends StorageBase {
        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        protected String getUsbName(IMountService iMountService, String str) {
            return null;
        }

        private Storage620() {
            super(StorageHelper.this, null);
        }

        /* synthetic */ Storage620(StorageHelper storageHelper, AnonymousClass1 anonymousClass1) {
            this();
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        protected String getUsbRootPath() {
            return "/mnt";
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        protected boolean isUsbPlugged(String str) {
            String name = new File(str).getName();
            return !"sdcard".equals(name) && name.startsWith("sd") && isStoragePlugged(str);
        }
    }

    private class DefaultStorage extends StorageBase {
        private DefaultStorage() {
            super(StorageHelper.this, null);
        }

        /* synthetic */ DefaultStorage(StorageHelper storageHelper, AnonymousClass1 anonymousClass1) {
            this();
        }
    }

    private class Storage3399 extends StorageBase {
        private Storage3399() {
            super(StorageHelper.this, null);
        }

        /* synthetic */ Storage3399(StorageHelper storageHelper, AnonymousClass1 anonymousClass1) {
            this();
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        protected List<StorageItem> getUsbItems() {
            ArrayList arrayList = new ArrayList();
            int i = 0;
            for (String str : StorageHelper.getUSBPaths(StorageHelper.this.mContext)) {
                StorageItem storageItem = new StorageItem();
                storageItem.mPath = str;
                i++;
                String str2 = "USB" + i;
                storageItem.mLabel = str2;
                storageItem.mSavePath = str;
                storageItem.mAliasPath = str2;
                storageItem.mInternalPath = str;
                arrayList.add(storageItem);
            }
            return arrayList.isEmpty() ? StorageHelper.this.getUsbItemsByStorageService() : arrayList;
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        protected String getUsbRootPath() {
            return "/mnt/media_rw";
        }
    }

    private class Storage8386 extends StorageBase {
        private Storage8386() {
            super(StorageHelper.this, null);
        }

        /* synthetic */ Storage8386(StorageHelper storageHelper, AnonymousClass1 anonymousClass1) {
            this();
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        protected List<StorageItem> getUsbItems() {
            ArrayList arrayList = new ArrayList();
            String usbRootPath = getUsbRootPath();
            int i = 0;
            for (File file : new File(getUsbRootPath()).listFiles()) {
                if (isUsbOrSdCardExit(file)) {
                    String str = usbRootPath + File.separator + file.getName();
                    StorageItem storageItem = new StorageItem();
                    storageItem.mPath = str;
                    i++;
                    String str2 = "USB" + i;
                    storageItem.mLabel = str2;
                    storageItem.mSavePath = str;
                    storageItem.mAliasPath = str2;
                    arrayList.add(storageItem);
                }
            }
            return arrayList;
        }

        private boolean isUsbOrSdCardExit(File file) {
            String name = file.getName();
            File file2 = new File(StorageHelper.DEV_PATH + (name.startsWith("sd") ? name.substring(0, 3) : name));
            return (name.startsWith("sd") && file2.exists()) || (name.startsWith(StorageHelper.SDCARD_PREFIX) && file2.exists());
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        protected String getUsbRootPath() {
            return "/mnt/usb";
        }
    }

    public static List<String> getUSBPaths(Context context) {
        ArrayList arrayList = new ArrayList();
        try {
            String uSBPath = PreferencesUtils.getUSBPath(context);
            if (TextUtils.isEmpty(uSBPath)) {
                return arrayList;
            }
            JSONArray jSONArray = new JSONArray(uSBPath);
            int length = jSONArray.length();
            for (int i = 0; i < length; i++) {
                arrayList.add(jSONArray.get(i).toString());
            }
            return arrayList;
        } catch (JSONException e) {
            Log.e(TAG, "JSONException", e);
            return arrayList;
        }
    }

    public class Storage551 extends StorageBase {
        public Storage551() {
            super(StorageHelper.this, null);
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        public /* bridge */ /* synthetic */ String getCurrentUserRootPath() {
            return super.getCurrentUserRootPath();
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        public /* bridge */ /* synthetic */ List getStorageItems() {
            return super.getStorageItems();
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        protected List<StorageItem> getUsbItems() {
            String str;
            ArrayList arrayList = new ArrayList();
            String usbRootPath = getUsbRootPath();
            int i = 0;
            int i2 = 0;
            for (File file : new File(getUsbRootPath()).listFiles()) {
                if (isUsbOrSdCardExit(file)) {
                    String str2 = usbRootPath + File.separator + file.getName();
                    StorageItem storageItem = new StorageItem();
                    storageItem.mPath = str2;
                    if (file.getName().startsWith(StorageHelper.SDCARD_PREFIX)) {
                        i2++;
                        str = "SD" + i2;
                    } else {
                        i++;
                        str = "USB" + i;
                    }
                    storageItem.mLabel = str;
                    storageItem.mSavePath = str2;
                    storageItem.mAliasPath = str;
                    arrayList.add(storageItem);
                }
            }
            return arrayList;
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        protected String getUsbRootPath() {
            return "/storage";
        }

        private boolean isUsbOrSdCardExit(File file) {
            String name = file.getName();
            return (name.startsWith("sd") || name.startsWith(StorageHelper.SDCARD_PREFIX)) && new File(new StringBuilder(StorageHelper.DEV_PATH).append(name.startsWith("sd") ? name.substring(0, 3) : name).toString()).exists();
        }
    }

    public class Storage972 extends StorageBase {
        private static final String MOUNT_PATH = "/mnt/media_rw/";

        public Storage972() {
            super(StorageHelper.this, null);
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        public /* bridge */ /* synthetic */ String getCurrentUserRootPath() {
            return super.getCurrentUserRootPath();
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        public /* bridge */ /* synthetic */ List getStorageItems() {
            return super.getStorageItems();
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        protected List<StorageItem> getUsbItems() {
            ArrayList arrayList = new ArrayList();
            String usbRootPath = getUsbRootPath();
            File[] fileArrListFiles = new File(usbRootPath).listFiles();
            if (fileArrListFiles != null) {
                int i = 0;
                for (File file : fileArrListFiles) {
                    if (!"self".equalsIgnoreCase(file.getName()) && !"emulated".equalsIgnoreCase(file.getName()) && isUsbOrSdCardExit(file)) {
                        String str = usbRootPath + File.separator + file.getName();
                        StorageItem storageItem = new StorageItem();
                        storageItem.mPath = str;
                        i++;
                        String str2 = "USB" + i;
                        storageItem.mLabel = str2;
                        storageItem.mSavePath = str;
                        storageItem.mAliasPath = str2;
                        arrayList.add(storageItem);
                    }
                }
            }
            return arrayList;
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        protected String getUsbRootPath() {
            return "/storage";
        }

        private boolean isUsbOrSdCardExit(File file) {
            return new File(MOUNT_PATH + file.getName()).exists();
        }
    }

    public class Storage811 extends StorageBase {
        private static final String MOUNT_PATH = "/mnt/media_rw/";

        public Storage811() {
            super(StorageHelper.this, null);
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        public /* bridge */ /* synthetic */ String getCurrentUserRootPath() {
            return super.getCurrentUserRootPath();
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        public /* bridge */ /* synthetic */ List getStorageItems() {
            return super.getStorageItems();
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        protected List<StorageItem> getUsbItems() {
            String str;
            ArrayList arrayList = new ArrayList();
            String usbRootPath = getUsbRootPath();
            int i = 0;
            int i2 = 0;
            for (File file : new File(getUsbRootPath()).listFiles()) {
                if (isUsbOrSdCardExit(file)) {
                    String str2 = usbRootPath + File.separator + file.getName();
                    StorageItem storageItem = new StorageItem();
                    storageItem.mPath = str2;
                    if (file.getName().startsWith(StorageHelper.SDCARD_PREFIX)) {
                        i2++;
                        str = "SD" + i2;
                    } else {
                        i++;
                        str = "USB" + i;
                    }
                    storageItem.mLabel = str;
                    storageItem.mSavePath = str2;
                    storageItem.mAliasPath = str;
                    arrayList.add(storageItem);
                }
            }
            return arrayList;
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        protected String getUsbRootPath() {
            return "/storage";
        }

        private boolean isUsbOrSdCardExit(File file) {
            String name = file.getName();
            String strSubstring = name.startsWith("sd") ? name.substring(0, 3) : name;
            File file2 = new File(MOUNT_PATH + name);
            File file3 = new File(StorageHelper.DEV_PATH + strSubstring);
            return (name.startsWith("sd") && file3.exists() && file2.exists()) || (name.startsWith(StorageHelper.SDCARD_PREFIX) && file3.exists());
        }
    }

    public class Storage9950 extends StorageBase {
        public Storage9950() {
            super(StorageHelper.this, null);
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        public /* bridge */ /* synthetic */ String getCurrentUserRootPath() {
            return super.getCurrentUserRootPath();
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        public /* bridge */ /* synthetic */ List getStorageItems() {
            return super.getStorageItems();
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        protected List<StorageItem> getUsbItems() {
            return StorageHelper.this.getUsbItemsByStorageService();
        }

        @Override // com.seewo.vcommons.helper.StorageHelper.StorageBase
        protected String getUsbRootPath() {
            return "/storage";
        }
    }

    public List<StorageItem> getUsbItemsByStorageService() {
        String string;
        StringBuilder sbAppend;
        ArrayList arrayList = new ArrayList();
        List<VolumeInfo> volumes = StorageManagerInsider.getVolumes((StorageManager) this.mContext.getSystemService("storage"));
        if (volumes != null && !volumes.isEmpty()) {
            int i = 0;
            int i2 = 0;
            for (VolumeInfo volumeInfo : volumes) {
                DiskInfo disk = volumeInfo.getDisk();
                if (volumeInfo.isMountedReadable() && disk != null) {
                    StorageItem storageItem = new StorageItem();
                    storageItem.mPath = volumeInfo.path;
                    storageItem.mInternalPath = volumeInfo.internalPath;
                    if (TextUtils.isEmpty(volumeInfo.fsLabel)) {
                        if (disk.isSd()) {
                            i2++;
                            sbAppend = new StringBuilder("SD").append(i2);
                        } else {
                            i++;
                            sbAppend = new StringBuilder("USB").append(i);
                        }
                        string = sbAppend.toString();
                    } else {
                        string = volumeInfo.fsLabel;
                    }
                    storageItem.mLabel = string;
                    storageItem.mSavePath = volumeInfo.path;
                    storageItem.mAliasPath = string;
                    arrayList.add(storageItem);
                }
            }
        }
        return arrayList;
    }
}
