导航菜单

页面标题

页面副标题

Bhakti v5.4.0 - C1651B.java 源代码

正在查看: Bhakti v5.4.0 应用的 C1651B.java JAVA 源代码文件

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


package h3;

import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.AssetFileDescriptor;
import android.content.res.Resources;
import android.net.Uri;
import android.text.TextUtils;
import java.io.EOFException;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.util.List;

public final class C1651B extends AbstractC1659c {

    public final Context f15393e;

    public m f15394f;

    public AssetFileDescriptor f15395g;

    public FileInputStream f15396h;

    public long f15397i;

    public boolean f15398j;

    public C1651B(Context context) {
        super(false);
        this.f15393e = context.getApplicationContext();
    }

    @Deprecated
    public static Uri buildRawResourceUri(int i10) {
        return Uri.parse("rawresource:///" + i10);
    }

    @Override
    public final void close() {
        this.f15394f = null;
        try {
            try {
                FileInputStream fileInputStream = this.f15396h;
                if (fileInputStream != null) {
                    fileInputStream.close();
                }
                this.f15396h = null;
                try {
                    try {
                        AssetFileDescriptor assetFileDescriptor = this.f15395g;
                        if (assetFileDescriptor != null) {
                            assetFileDescriptor.close();
                        }
                    } catch (IOException e4) {
                        throw new C1650A(null, 2000, e4);
                    }
                } finally {
                    this.f15395g = null;
                    if (this.f15398j) {
                        this.f15398j = false;
                        e();
                    }
                }
            } catch (IOException e10) {
                throw new C1650A(null, 2000, e10);
            }
        } catch (Throwable th2) {
            this.f15396h = null;
            try {
                try {
                    AssetFileDescriptor assetFileDescriptor2 = this.f15395g;
                    if (assetFileDescriptor2 != null) {
                        assetFileDescriptor2.close();
                    }
                    this.f15395g = null;
                    if (this.f15398j) {
                        this.f15398j = false;
                        e();
                    }
                    throw th2;
                } catch (IOException e11) {
                    throw new C1650A(null, 2000, e11);
                }
            } finally {
                this.f15395g = null;
                if (this.f15398j) {
                    this.f15398j = false;
                    e();
                }
            }
        }
    }

    @Override
    public final long i(m mVar) {
        Resources resourcesForApplication;
        int parseInt;
        int i10;
        Resources resources;
        this.f15394f = mVar;
        h();
        Uri normalizeScheme = mVar.a.normalizeScheme();
        boolean equals = TextUtils.equals("rawresource", normalizeScheme.getScheme());
        Context context = this.f15393e;
        if (equals) {
            resources = context.getResources();
            List<String> pathSegments = normalizeScheme.getPathSegments();
            if (pathSegments.size() != 1) {
                throw new C1650A("rawresource:// URI must have exactly one path element, found " + pathSegments.size(), 2000, null);
            }
            try {
                i10 = Integer.parseInt(pathSegments.get(0));
            } catch (NumberFormatException unused) {
                throw new C1650A("Resource identifier must be an integer.", 1004, null);
            }
        } else {
            if (!TextUtils.equals("android.resource", normalizeScheme.getScheme())) {
                throw new C1650A("Unsupported URI scheme (" + normalizeScheme.getScheme() + "). Only android.resource is supported.", 1004, null);
            }
            String path = normalizeScheme.getPath();
            path.getClass();
            if (path.startsWith("/")) {
                path = path.substring(1);
            }
            String packageName = TextUtils.isEmpty(normalizeScheme.getHost()) ? context.getPackageName() : normalizeScheme.getHost();
            if (packageName.equals(context.getPackageName())) {
                resourcesForApplication = context.getResources();
            } else {
                try {
                    resourcesForApplication = context.getPackageManager().getResourcesForApplication(packageName);
                } catch (PackageManager.NameNotFoundException e4) {
                    throw new C1650A("Package in android.resource:// URI not found. Check http://g.co/dev/packagevisibility.", 2005, e4);
                }
            }
            if (path.matches("\\d+")) {
                try {
                    parseInt = Integer.parseInt(path);
                } catch (NumberFormatException unused2) {
                    throw new C1650A("Resource identifier must be an integer.", 1004, null);
                }
            } else {
                parseInt = resourcesForApplication.getIdentifier(j.e.f(packageName, ":", path), "raw", null);
                if (parseInt == 0) {
                    throw new C1650A("Resource not found.", 2005, null);
                }
            }
            i10 = parseInt;
            resources = resourcesForApplication;
        }
        try {
            AssetFileDescriptor openRawResourceFd = resources.openRawResourceFd(i10);
            if (openRawResourceFd == null) {
                throw new C1650A(Qn.b.m(normalizeScheme, "Resource is compressed: "), 2000, null);
            }
            this.f15395g = openRawResourceFd;
            long length = openRawResourceFd.getLength();
            FileInputStream fileInputStream = new FileInputStream(this.f15395g.getFileDescriptor());
            this.f15396h = fileInputStream;
            long j10 = mVar.f15443f;
            try {
                if (length != -1 && j10 > length) {
                    throw new C1650A(null, 2008, null);
                }
                long startOffset = this.f15395g.getStartOffset();
                long skip = fileInputStream.skip(startOffset + j10) - startOffset;
                if (skip != j10) {
                    throw new C1650A(null, 2008, null);
                }
                if (length == -1) {
                    FileChannel channel = fileInputStream.getChannel();
                    if (channel.size() == 0) {
                        this.f15397i = -1L;
                    } else {
                        long size = channel.size() - channel.position();
                        this.f15397i = size;
                        if (size < 0) {
                            throw new C1650A(null, 2008, null);
                        }
                    }
                } else {
                    long j11 = length - skip;
                    this.f15397i = j11;
                    if (j11 < 0) {
                        throw new C1666j(2008);
                    }
                }
                long j12 = mVar.f15444g;
                if (j12 != -1) {
                    long j13 = this.f15397i;
                    this.f15397i = j13 == -1 ? j12 : Math.min(j13, j12);
                }
                this.f15398j = true;
                j(mVar);
                return j12 != -1 ? j12 : this.f15397i;
            } catch (C1650A e10) {
                throw e10;
            } catch (IOException e11) {
                throw new C1650A(null, 2000, e11);
            }
        } catch (Resources.NotFoundException e12) {
            throw new C1650A(null, 2005, e12);
        }
    }

    @Override
    public final Uri r() {
        m mVar = this.f15394f;
        if (mVar != null) {
            return mVar.a;
        }
        return null;
    }

    @Override
    public final int read(byte[] bArr, int i10, int i11) {
        if (i11 == 0) {
            return 0;
        }
        long j10 = this.f15397i;
        if (j10 == 0) {
            return -1;
        }
        if (j10 != -1) {
            try {
                i11 = (int) Math.min(j10, i11);
            } catch (IOException e4) {
                throw new C1650A(null, 2000, e4);
            }
        }
        FileInputStream fileInputStream = this.f15396h;
        int i12 = e3.C.a;
        int read = fileInputStream.read(bArr, i10, i11);
        if (read == -1) {
            if (this.f15397i == -1) {
                return -1;
            }
            throw new C1650A("End of stream reached having not read sufficient data.", 2000, new EOFException());
        }
        long j11 = this.f15397i;
        if (j11 != -1) {
            this.f15397i = j11 - read;
        }
        d(read);
        return read;
    }
}