MD5 校验值:8d01bad3385dcb060a6dcda2da0f8dbf
w.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package x0; 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.io.InputStream; import java.nio.channels.FileChannel; import java.util.List; import v0.i0; public final class w extends b { private final Context f26831e; private k f26832f; private AssetFileDescriptor f26833g; private InputStream f26834h; private long f26835i; private boolean f26836j; public static class a extends h { @Deprecated public a(String str) { super(str, null, 2000); } public a(String str, Throwable th, int i10) { super(str, th, i10); } } public w(Context context) { super(false); this.f26831e = context.getApplicationContext(); } @Deprecated public static Uri buildRawResourceUri(int i10) { return Uri.parse("rawresource:///" + i10); } private static AssetFileDescriptor w(Context context, k kVar) { String str; Resources resourcesForApplication; int identifier; AssetFileDescriptor openRawResourceFd; Uri normalizeScheme = kVar.f26755a.normalizeScheme(); try { if (TextUtils.equals("rawresource", normalizeScheme.getScheme())) { resourcesForApplication = context.getResources(); List<String> pathSegments = normalizeScheme.getPathSegments(); if (pathSegments.size() != 1) { throw new a("rawresource:// URI must have exactly one path element, found " + pathSegments.size()); } str = pathSegments.get(0); } else { if (!TextUtils.equals("android.resource", normalizeScheme.getScheme())) { throw new a("Unsupported URI scheme (" + normalizeScheme.getScheme() + "). Only android.resource is supported.", null, 1004); } str = (String) v0.a.e(normalizeScheme.getPath()); if (str.startsWith("/")) { str = str.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 e10) { throw new a("Package in android.resource:// URI not found. Check http://g.co/dev/packagevisibility.", e10, 2005); } } if (!str.matches("\\d+")) { identifier = resourcesForApplication.getIdentifier(packageName + ":" + str, "raw", null); if (identifier == 0) { throw new a("Resource not found.", null, 2005); } openRawResourceFd = resourcesForApplication.openRawResourceFd(identifier); if (openRawResourceFd == null) { return openRawResourceFd; } throw new a("Resource is compressed: " + normalizeScheme, null, 2000); } } openRawResourceFd = resourcesForApplication.openRawResourceFd(identifier); if (openRawResourceFd == null) { } } catch (Resources.NotFoundException e11) { throw new a(null, e11, 2005); } identifier = x(str); } private static int x(String str) { try { return Integer.parseInt(str); } catch (NumberFormatException unused) { throw new a("Resource identifier must be an integer.", null, 1004); } } @Override public void close() { this.f26832f = null; try { try { InputStream inputStream = this.f26834h; if (inputStream != null) { inputStream.close(); } this.f26834h = null; try { try { AssetFileDescriptor assetFileDescriptor = this.f26833g; if (assetFileDescriptor != null) { assetFileDescriptor.close(); } } finally { this.f26833g = null; if (this.f26836j) { this.f26836j = false; t(); } } } catch (IOException e10) { throw new a(null, e10, 2000); } } catch (IOException e11) { throw new a(null, e11, 2000); } } catch (Throwable th) { this.f26834h = null; try { try { AssetFileDescriptor assetFileDescriptor2 = this.f26833g; if (assetFileDescriptor2 != null) { assetFileDescriptor2.close(); } this.f26833g = null; if (this.f26836j) { this.f26836j = false; t(); } throw th; } catch (IOException e12) { throw new a(null, e12, 2000); } } finally { this.f26833g = null; if (this.f26836j) { this.f26836j = false; t(); } } } } @Override public Uri getUri() { k kVar = this.f26832f; if (kVar != null) { return kVar.f26755a; } return null; } @Override public long r(k kVar) { this.f26832f = kVar; u(kVar); AssetFileDescriptor w10 = w(this.f26831e, kVar); this.f26833g = w10; long length = w10.getLength(); FileInputStream fileInputStream = new FileInputStream(this.f26833g.getFileDescriptor()); this.f26834h = fileInputStream; if (length != -1) { try { if (kVar.f26761g > length) { throw new a(null, null, 2008); } } catch (a e10) { throw e10; } catch (IOException e11) { throw new a(null, e11, 2000); } } long startOffset = this.f26833g.getStartOffset(); long skip = fileInputStream.skip(kVar.f26761g + startOffset) - startOffset; if (skip != kVar.f26761g) { throw new a(null, null, 2008); } if (length == -1) { FileChannel channel = fileInputStream.getChannel(); if (channel.size() == 0) { this.f26835i = -1L; } else { long size = channel.size() - channel.position(); this.f26835i = size; if (size < 0) { throw new a(null, null, 2008); } } } else { long j10 = length - skip; this.f26835i = j10; if (j10 < 0) { throw new h(2008); } } long j11 = kVar.f26762h; if (j11 != -1) { long j12 = this.f26835i; if (j12 != -1) { j11 = Math.min(j12, j11); } this.f26835i = j11; } this.f26836j = true; v(kVar); long j13 = kVar.f26762h; return j13 != -1 ? j13 : this.f26835i; } @Override public int read(byte[] bArr, int i10, int i11) { if (i11 == 0) { return 0; } long j10 = this.f26835i; if (j10 == 0) { return -1; } if (j10 != -1) { try { i11 = (int) Math.min(j10, i11); } catch (IOException e10) { throw new a(null, e10, 2000); } } int read = ((InputStream) i0.i(this.f26834h)).read(bArr, i10, i11); if (read == -1) { if (this.f26835i == -1) { return -1; } throw new a("End of stream reached having not read sufficient data.", new EOFException(), 2000); } long j11 = this.f26835i; if (j11 != -1) { this.f26835i = j11 - read; } s(read); return read; } }