MD5 校验值:76664d4beb7b8d8b1df7e59ba4c77a12
y.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package zendesk.belvedere; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.pm.ResolveInfo; import android.database.Cursor; import android.net.Uri; import android.os.Build; import android.text.TextUtils; import android.util.Log; import android.webkit.MimeTypeMap; import androidx.core.content.FileProvider; import java.io.File; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Iterator; import java.util.Locale; class y { private File a(File file, String str, String str2) { StringBuilder sb2 = new StringBuilder(); sb2.append(str); if (TextUtils.isEmpty(str2)) { str2 = ""; } sb2.append(str2); return new File(file, sb2.toString()); } private File b(Context context, String str) { String str2; if (TextUtils.isEmpty(str)) { str2 = ""; } else { str2 = str + File.separator; } StringBuilder sb2 = new StringBuilder(); sb2.append(k(context)); String str3 = File.separator; sb2.append(str3); sb2.append("belvedere-data-v2"); sb2.append(str3); sb2.append(str2); File file = new File(sb2.toString()); if (!file.isDirectory()) { file.mkdirs(); } if (file.isDirectory()) { return file; } return null; } private static String c(Context context, Uri uri, boolean z10) { String lastPathSegment; int lastIndexOf; MimeTypeMap singleton = MimeTypeMap.getSingleton(); String scheme = uri.getScheme(); String extensionFromMimeType = "content".equals(scheme) ? singleton.getExtensionFromMimeType(context.getContentResolver().getType(uri)) : (!"file".equals(scheme) || (lastIndexOf = (lastPathSegment = uri.getLastPathSegment()).lastIndexOf(".")) == -1) ? "tmp" : lastPathSegment.substring(lastIndexOf + 1, lastPathSegment.length()); return z10 ? String.format(Locale.US, ".%s", extensionFromMimeType) : extensionFromMimeType; } private static String g(Context context, Uri uri) { String scheme = uri.getScheme(); if (!"content".equals(scheme)) { return "file".equals(scheme) ? uri.getLastPathSegment() : ""; } Cursor query = context.getContentResolver().query(uri, new String[]{"_display_name"}, null, null, null); if (query == null) { return ""; } try { return query.moveToFirst() ? query.getString(0) : ""; } finally { query.close(); } } public static r j(Context context, Uri uri) { String str; String str2; long j10; String str3 = ""; long j11 = -1; if ("content".equals(uri.getScheme())) { ContentResolver contentResolver = context.getContentResolver(); Cursor query = contentResolver.query(uri, new String[]{"_size", "_display_name"}, null, null, null); String type = contentResolver.getType(uri); if (query != null) { try { if (query.moveToFirst()) { long j12 = query.getLong(query.getColumnIndex("_size")); str3 = query.getString(query.getColumnIndex("_display_name")); j11 = j12; } } finally { query.close(); } } str = str3; j10 = j11; str2 = type; } else { str = ""; str2 = str; j10 = -1; } return new r(null, uri, uri, str, str2, j10, -1L, -1L); } private String k(Context context) { return context.getCacheDir().getAbsolutePath(); } public File d(Context context, String str, String str2) { String str3 = "user"; if (!TextUtils.isEmpty(str)) { str3 = "user" + File.separator + str; } File b10 = b(context, str3); if (b10 != null) { return a(b10, str2, null); } p.e("Belvedere", "Error creating cache directory"); return null; } public File e(Context context) { File b10 = b(context, "media"); if (b10 == null) { p.e("Belvedere", "Error creating cache directory"); return null; } Locale locale = Locale.US; return a(b10, String.format(locale, "camera_image_%s", new SimpleDateFormat("yyyyMMddHHmmssSSS", locale).format(new Date(System.currentTimeMillis()))), ".jpg"); } public File f(Context context, Uri uri, String str) { String str2; if (TextUtils.isEmpty(str)) { str2 = "media"; } else { str2 = "user" + File.separator + str; } File b10 = b(context, str2); String str3 = null; if (b10 == null) { p.e("Belvedere", "Error creating cache directory"); return null; } String g10 = g(context, uri); if (TextUtils.isEmpty(g10)) { Locale locale = Locale.US; g10 = String.format(locale, "attachment_%s", new SimpleDateFormat("yyyyMMddHHmmssSSS", locale).format(new Date(System.currentTimeMillis()))); str3 = c(context, uri, true); } return a(b10, g10, str3); } String h(Context context) { return String.format(Locale.US, "%s%s", context.getPackageName(), context.getString(w.f19632a)); } public Uri i(Context context, File file) { String h10 = h(context); try { return FileProvider.f(context, h10, file); } catch (IllegalArgumentException unused) { p.b("Belvedere", String.format(Locale.US, "The selected file can't be shared %s", file.toString())); return null; } catch (NullPointerException e10) { String format = String.format(Locale.US, "=====================\nFileProvider failed to retrieve file uri. There might be an issue with the FileProvider \nPlease make sure that manifest-merger is working, and that you have defined the applicationId (package name) in the build.gradle\nManifest merger: http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger\nIf your are not able to use gradle or the manifest merger, please add the following to your AndroidManifest.xml:\n <provider\n android:name=\"com.zendesk.belvedere.BelvedereFileProvider\"\n android:authorities=\"${applicationId}%s\"\n android:exported=\"false\"\n android:grantUriPermissions=\"true\">\n <meta-data\n android:name=\"android.support.FILE_PROVIDER_PATHS\"\n android:resource=\"@xml/belvedere_attachment_storage_v2\" />\n </provider>\n=====================", h10); Log.e("Belvedere", format, e10); p.c("Belvedere", format, e10); throw new RuntimeException("Please specify your application id"); } } public void l(Context context, Intent intent, Uri uri, int i10) { if (Build.VERSION.SDK_INT >= 23) { intent.addFlags(i10); return; } Iterator<ResolveInfo> it = context.getPackageManager().queryIntentActivities(intent, 65536).iterator(); while (it.hasNext()) { context.grantUriPermission(it.next().activityInfo.packageName, uri, i10); } } public void m(Context context, Uri uri, int i10) { context.revokeUriPermission(uri, i10); } }