导航菜单

页面标题

页面副标题

Bhakti v5.4.0 - C4830B.java 源代码

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

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


package h3;

import Qn.AbstractC1148b;
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 e3.AbstractC4268C;
import j.AbstractC5459e;
import java.io.EOFException;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.util.List;

public final class C4830B extends AbstractC4838c {

    public final Context f55328e;

    public m f55329f;

    public AssetFileDescriptor f55330g;

    public FileInputStream f55331h;

    public long f55332i;

    public boolean f55333j;

    public C4830B(Context context) {
        super(false);
        this.f55328e = context.getApplicationContext();
    }

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

    @Override
    public final void close() {
        this.f55329f = null;
        try {
            try {
                FileInputStream fileInputStream = this.f55331h;
                if (fileInputStream != null) {
                    fileInputStream.close();
                }
                this.f55331h = null;
                try {
                    try {
                        AssetFileDescriptor assetFileDescriptor = this.f55330g;
                        if (assetFileDescriptor != null) {
                            assetFileDescriptor.close();
                        }
                    } catch (IOException e4) {
                        throw new C4829A(null, 2000, e4);
                    }
                } finally {
                    this.f55330g = null;
                    if (this.f55333j) {
                        this.f55333j = false;
                        e();
                    }
                }
            } catch (IOException e10) {
                throw new C4829A(null, 2000, e10);
            }
        } catch (Throwable th2) {
            this.f55331h = null;
            try {
                try {
                    AssetFileDescriptor assetFileDescriptor2 = this.f55330g;
                    if (assetFileDescriptor2 != null) {
                        assetFileDescriptor2.close();
                    }
                    this.f55330g = null;
                    if (this.f55333j) {
                        this.f55333j = false;
                        e();
                    }
                    throw th2;
                } catch (IOException e11) {
                    throw new C4829A(null, 2000, e11);
                }
            } finally {
                this.f55330g = null;
                if (this.f55333j) {
                    this.f55333j = false;
                    e();
                }
            }
        }
    }

    @Override
    public final long i(m mVar) {
        Resources resourcesForApplication;
        int parseInt;
        int i10;
        Resources resources;
        this.f55329f = mVar;
        h();
        Uri normalizeScheme = mVar.f55389a.normalizeScheme();
        boolean equals = TextUtils.equals("rawresource", normalizeScheme.getScheme());
        Context context = this.f55328e;
        if (equals) {
            resources = context.getResources();
            List<String> pathSegments = normalizeScheme.getPathSegments();
            if (pathSegments.size() != 1) {
                throw new C4829A("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 C4829A("Resource identifier must be an integer.", 1004, null);
            }
        } else {
            if (!TextUtils.equals("android.resource", normalizeScheme.getScheme())) {
                throw new C4829A("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 C4829A("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 C4829A("Resource identifier must be an integer.", 1004, null);
                }
            } else {
                parseInt = resourcesForApplication.getIdentifier(AbstractC5459e.f(packageName, ":", path), "raw", null);
                if (parseInt == 0) {
                    throw new C4829A("Resource not found.", 2005, null);
                }
            }
            i10 = parseInt;
            resources = resourcesForApplication;
        }
        try {
            AssetFileDescriptor openRawResourceFd = resources.openRawResourceFd(i10);
            if (openRawResourceFd == null) {
                throw new C4829A(AbstractC1148b.m(normalizeScheme, "Resource is compressed: "), 2000, null);
            }
            this.f55330g = openRawResourceFd;
            long length = openRawResourceFd.getLength();
            FileInputStream fileInputStream = new FileInputStream(this.f55330g.getFileDescriptor());
            this.f55331h = fileInputStream;
            long j10 = mVar.f55394f;
            try {
                if (length != -1 && j10 > length) {
                    throw new C4829A(null, 2008, null);
                }
                long startOffset = this.f55330g.getStartOffset();
                long skip = fileInputStream.skip(startOffset + j10) - startOffset;
                if (skip != j10) {
                    throw new C4829A(null, 2008, null);
                }
                if (length == -1) {
                    FileChannel channel = fileInputStream.getChannel();
                    if (channel.size() == 0) {
                        this.f55332i = -1L;
                    } else {
                        long size = channel.size() - channel.position();
                        this.f55332i = size;
                        if (size < 0) {
                            throw new C4829A(null, 2008, null);
                        }
                    }
                } else {
                    long j11 = length - skip;
                    this.f55332i = j11;
                    if (j11 < 0) {
                        throw new C4845j(2008);
                    }
                }
                long j12 = mVar.f55395g;
                if (j12 != -1) {
                    long j13 = this.f55332i;
                    this.f55332i = j13 == -1 ? j12 : Math.min(j13, j12);
                }
                this.f55333j = true;
                j(mVar);
                return j12 != -1 ? j12 : this.f55332i;
            } catch (C4829A e10) {
                throw e10;
            } catch (IOException e11) {
                throw new C4829A(null, 2000, e11);
            }
        } catch (Resources.NotFoundException e12) {
            throw new C4829A(null, 2005, e12);
        }
    }

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

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