导航菜单

页面标题

页面副标题

VIVI私密直播间 v1.0 - MTDataFilesProvider.java 源代码

正在查看: VIVI私密直播间 v1.0 应用的 MTDataFilesProvider.java JAVA 源代码文件

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


package bin.mt.file.content;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.ProviderInfo;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.os.CancellationSignal;
import android.os.ParcelFileDescriptor;
import android.provider.DocumentsProvider;
import android.system.Os;
import android.system.StructStat;
import android.webkit.MimeTypeMap;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

public class MTDataFilesProvider extends DocumentsProvider {
    public static final String[] g = {"root_id", "mime_types", "flags", "icon", "title", "summary", "document_id"};
    public static final String[] h = {"document_id", "mime_type", "_display_name", "last_modified", "flags", "_size", "mt_extras"};
    public String b;

    public File f2c;
    public File d;
    public File e;
    public File f;

    public static boolean a(java.io.File r5) {
        throw new UnsupportedOperationException("Method not decompiled: bin.mt.file.content.MTDataFilesProvider.a(java.io.File):boolean");
    }

    public static String c(File file) {
        if (file.isDirectory()) {
            return "vnd.android.document/directory";
        }
        String name = file.getName();
        int lastIndexOf = name.lastIndexOf(46);
        if (lastIndexOf < 0) {
            return "application/octet-stream";
        }
        String mimeTypeFromExtension = MimeTypeMap.getSingleton().getMimeTypeFromExtension(name.substring(lastIndexOf + 1).toLowerCase());
        return mimeTypeFromExtension != null ? mimeTypeFromExtension : "application/octet-stream";
    }

    @Override
    public final void attachInfo(Context context, ProviderInfo providerInfo) {
        super.attachInfo(context, providerInfo);
        this.b = context.getPackageName();
        File parentFile = context.getFilesDir().getParentFile();
        this.f2c = parentFile;
        String path = parentFile.getPath();
        if (path.startsWith("/data/user/")) {
            this.d = new File("/data/user_de/" + path.substring(11));
        }
        File externalFilesDir = context.getExternalFilesDir(null);
        if (externalFilesDir != null) {
            this.e = externalFilesDir.getParentFile();
        }
        this.f = context.getObbDir();
    }

    public final File b(String str, boolean z) {
        String substring;
        if (!str.startsWith(this.b)) {
            throw new FileNotFoundException(str.concat(" not found"));
        }
        String substring2 = str.substring(this.b.length());
        if (substring2.startsWith("/")) {
            substring2 = substring2.substring(1);
        }
        File file = null;
        if (substring2.isEmpty()) {
            return null;
        }
        int indexOf = substring2.indexOf(47);
        if (indexOf == -1) {
            substring = "";
        } else {
            String substring3 = substring2.substring(0, indexOf);
            substring = substring2.substring(indexOf + 1);
            substring2 = substring3;
        }
        if (substring2.equalsIgnoreCase("data")) {
            file = new File(this.f2c, substring);
        } else if (substring2.equalsIgnoreCase("android_data") && this.e != null) {
            file = new File(this.e, substring);
        } else if (substring2.equalsIgnoreCase("android_obb") && this.f != null) {
            file = new File(this.f, substring);
        } else if (substring2.equalsIgnoreCase("user_de_data") && this.d != null) {
            file = new File(this.d, substring);
        }
        if (file == null) {
            throw new FileNotFoundException(str.concat(" not found"));
        }
        if (z) {
            try {
                Os.lstat(file.getPath());
            } catch (Exception unused) {
                throw new FileNotFoundException(str.concat(" not found"));
            }
        }
        return file;
    }

    @Override
    public final android.os.Bundle call(java.lang.String r10, java.lang.String r11, android.os.Bundle r12) {
        throw new UnsupportedOperationException("Method not decompiled: bin.mt.file.content.MTDataFilesProvider.call(java.lang.String, java.lang.String, android.os.Bundle):android.os.Bundle");
    }

    @Override
    public final String createDocument(String str, String str2, String str3) {
        StringBuilder sb;
        File b = b(str, true);
        if (b != null) {
            File file = new File(b, str3);
            int i = 2;
            while (file.exists()) {
                file = new File(b, str3 + " (" + i + ")");
                i++;
            }
            try {
                if ("vnd.android.document/directory".equals(str2) ? file.mkdir() : file.createNewFile()) {
                    if (str.endsWith("/")) {
                        sb = new StringBuilder();
                        sb.append(str);
                        sb.append(file.getName());
                    } else {
                        sb = new StringBuilder();
                        sb.append(str);
                        sb.append("/");
                        sb.append(file.getName());
                    }
                    str = sb.toString();
                    return str;
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        throw new FileNotFoundException("Failed to create document in " + str + " with name " + str3);
    }

    public final void d(MatrixCursor matrixCursor, String str, File file) {
        int i;
        String name;
        if (file == null) {
            file = b(str, true);
        }
        boolean z = false;
        if (file == null) {
            MatrixCursor.RowBuilder newRow = matrixCursor.newRow();
            newRow.add("document_id", this.b);
            newRow.add("_display_name", this.b);
            newRow.add("_size", 0L);
            newRow.add("mime_type", "vnd.android.document/directory");
            newRow.add("last_modified", 0);
            newRow.add("flags", 0);
            return;
        }
        if (file.isDirectory()) {
            if (file.canWrite()) {
                i = 8;
            }
            i = 0;
        } else {
            if (file.canWrite()) {
                i = 2;
            }
            i = 0;
        }
        if (file.getParentFile().canWrite()) {
            i = i | 4 | 64;
        }
        String path = file.getPath();
        if (path.equals(this.f2c.getPath())) {
            name = "data";
        } else {
            File file2 = this.e;
            if (file2 == null || !path.equals(file2.getPath())) {
                File file3 = this.f;
                if (file3 == null || !path.equals(file3.getPath())) {
                    File file4 = this.d;
                    if (file4 == null || !path.equals(file4.getPath())) {
                        name = file.getName();
                        z = true;
                    } else {
                        name = "user_de_data";
                    }
                } else {
                    name = "android_obb";
                }
            } else {
                name = "android_data";
            }
        }
        MatrixCursor.RowBuilder newRow2 = matrixCursor.newRow();
        newRow2.add("document_id", str);
        newRow2.add("_display_name", name);
        newRow2.add("_size", Long.valueOf(file.length()));
        newRow2.add("mime_type", c(file));
        newRow2.add("last_modified", Long.valueOf(file.lastModified()));
        newRow2.add("flags", Integer.valueOf(i));
        newRow2.add("mt_path", file.getAbsolutePath());
        if (z) {
            try {
                StringBuilder sb = new StringBuilder();
                StructStat lstat = Os.lstat(path);
                sb.append(lstat.st_mode);
                sb.append("|");
                sb.append(lstat.st_uid);
                sb.append("|");
                sb.append(lstat.st_gid);
                if ((lstat.st_mode & 61440) == 40960) {
                    sb.append("|");
                    sb.append(Os.readlink(path));
                }
                newRow2.add("mt_extras", sb.toString());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    @Override
    public final void deleteDocument(String str) {
        File b = b(str, true);
        if (b == null || !a(b)) {
            throw new FileNotFoundException("Failed to delete document ".concat(str));
        }
    }

    @Override
    public final String getDocumentType(String str) {
        File b = b(str, true);
        return b == null ? "vnd.android.document/directory" : c(b);
    }

    @Override
    public final boolean isChildDocument(String str, String str2) {
        return str2.startsWith(str);
    }

    @Override
    public final String moveDocument(String str, String str2, String str3) {
        File b = b(str, true);
        File b2 = b(str3, true);
        if (b != null && b2 != null) {
            File file = new File(b2, b.getName());
            if (!file.exists() && b.renameTo(file)) {
                if (str3.endsWith("/")) {
                    return str3 + file.getName();
                }
                return str3 + "/" + file.getName();
            }
        }
        throw new FileNotFoundException("Filed to move document " + str + " to " + str3);
    }

    @Override
    public final boolean onCreate() {
        return true;
    }

    @Override
    public final ParcelFileDescriptor openDocument(String str, String str2, CancellationSignal cancellationSignal) {
        File b = b(str, false);
        if (b != null) {
            return ParcelFileDescriptor.open(b, ParcelFileDescriptor.parseMode(str2));
        }
        throw new FileNotFoundException(str.concat(" not found"));
    }

    @Override
    public final Cursor queryChildDocuments(String str, String[] strArr, String str2) {
        if (str.endsWith("/")) {
            str = str.substring(0, str.length() - 1);
        }
        if (strArr == null) {
            strArr = h;
        }
        MatrixCursor matrixCursor = new MatrixCursor(strArr);
        File b = b(str, true);
        if (b == null) {
            d(matrixCursor, str.concat("/data"), this.f2c);
            File file = this.e;
            if (file != null && file.exists()) {
                d(matrixCursor, str.concat("/android_data"), this.e);
            }
            File file2 = this.f;
            if (file2 != null && file2.exists()) {
                d(matrixCursor, str.concat("/android_obb"), this.f);
            }
            File file3 = this.d;
            if (file3 != null && file3.exists()) {
                d(matrixCursor, str.concat("/user_de_data"), this.d);
            }
        } else {
            File[] listFiles = b.listFiles();
            if (listFiles != null) {
                for (File file4 : listFiles) {
                    d(matrixCursor, str + "/" + file4.getName(), file4);
                }
            }
        }
        return matrixCursor;
    }

    @Override
    public final Cursor queryDocument(String str, String[] strArr) {
        if (strArr == null) {
            strArr = h;
        }
        MatrixCursor matrixCursor = new MatrixCursor(strArr);
        d(matrixCursor, str, null);
        return matrixCursor;
    }

    @Override
    public final Cursor queryRoots(String[] strArr) {
        ApplicationInfo applicationInfo = getContext().getApplicationInfo();
        String charSequence = applicationInfo.loadLabel(getContext().getPackageManager()).toString();
        if (strArr == null) {
            strArr = g;
        }
        MatrixCursor matrixCursor = new MatrixCursor(strArr);
        MatrixCursor.RowBuilder newRow = matrixCursor.newRow();
        newRow.add("root_id", this.b);
        newRow.add("document_id", this.b);
        newRow.add("summary", this.b);
        newRow.add("flags", 17);
        newRow.add("title", charSequence);
        newRow.add("mime_types", "*/*");
        newRow.add("icon", Integer.valueOf(applicationInfo.icon));
        return matrixCursor;
    }

    @Override
    public final void removeDocument(String str, String str2) {
        deleteDocument(str);
    }

    @Override
    public final String renameDocument(String str, String str2) {
        File b = b(str, true);
        if (b == null || !b.renameTo(new File(b.getParentFile(), str2))) {
            throw new FileNotFoundException("Failed to rename document " + str + " to " + str2);
        }
        return str.substring(0, str.lastIndexOf(47, str.length() - 2)) + "/" + str2;
    }
}