Files
rr3-apk/decompiled/sources/com/google/firebase/crashlytics/ndk/JniNativeApi.java
Daniel Elliott f9d20bb3fc Add decompiled APK source code (JADX)
- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-18 14:52:23 -08:00

137 lines
5.5 KiB
Java

package com.google.firebase.crashlytics.ndk;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.os.Build;
import android.text.TextUtils;
import com.google.firebase.crashlytics.internal.Logger;
import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/* loaded from: classes3.dex */
class JniNativeApi implements NativeApi {
public static final FilenameFilter APK_FILTER = new FilenameFilter() { // from class: com.google.firebase.crashlytics.ndk.JniNativeApi$$ExternalSyntheticLambda0
@Override // java.io.FilenameFilter
public final boolean accept(File file, String str) {
boolean lambda$static$0;
lambda$static$0 = JniNativeApi.lambda$static$0(file, str);
return lambda$static$0;
}
};
public static final boolean LIB_CRASHLYTICS_LOADED;
public final Context context;
public static int getPackageInfoFlags() {
return 9216;
}
public static boolean isAtLeastLollipop() {
return true;
}
private native boolean nativeInit(String[] strArr, Object obj);
static {
boolean z;
try {
System.loadLibrary("crashlytics");
z = true;
} catch (UnsatisfiedLinkError e) {
Logger.getLogger().e("libcrashlytics could not be loaded. This APK may not have been compiled for this device's architecture. NDK crashes will not be reported to Crashlytics:\n" + e.getLocalizedMessage());
z = false;
}
LIB_CRASHLYTICS_LOADED = z;
}
public static /* synthetic */ boolean lambda$static$0(File file, String str) {
return str.toLowerCase().endsWith(".apk");
}
public JniNativeApi(Context context) {
this.context = context;
}
public static String getVersionCodeAsString(PackageInfo packageInfo) {
long longVersionCode;
if (Build.VERSION.SDK_INT >= 28) {
longVersionCode = packageInfo.getLongVersionCode();
return Long.toString(longVersionCode);
}
return Integer.toString(packageInfo.versionCode);
}
public static void addSplitSourceDirs(List list, PackageInfo packageInfo) {
ApplicationInfo applicationInfo = packageInfo.applicationInfo;
String[] strArr = applicationInfo.splitSourceDirs;
if (strArr != null) {
Collections.addAll(list, strArr);
}
File file = new File(applicationInfo.dataDir, String.format("files/splitcompat/%s/verified-splits", getVersionCodeAsString(packageInfo)));
if (!file.exists()) {
Logger.getLogger().d("No dynamic features found at " + file.getAbsolutePath());
return;
}
File[] listFiles = file.listFiles(APK_FILTER);
if (listFiles == null) {
listFiles = new File[0];
}
Logger.getLogger().d("Found " + listFiles.length + " APKs in " + file.getAbsolutePath());
for (File file2 : listFiles) {
Logger.getLogger().d("Adding " + file2.getName() + " to classpath.");
list.add(file2.getAbsolutePath());
}
}
public String[] makePackagePaths(String str) {
try {
PackageInfo packageInfo = this.context.getPackageManager().getPackageInfo(this.context.getPackageName(), getPackageInfoFlags());
ArrayList<String> arrayList = new ArrayList(10);
arrayList.add(packageInfo.applicationInfo.sourceDir);
if (isAtLeastLollipop()) {
addSplitSourceDirs(arrayList, packageInfo);
}
String[] strArr = packageInfo.applicationInfo.sharedLibraryFiles;
if (strArr != null) {
Collections.addAll(arrayList, strArr);
}
ArrayList arrayList2 = new ArrayList(10);
File parentFile = new File(packageInfo.applicationInfo.nativeLibraryDir).getParentFile();
if (parentFile != null) {
arrayList2.add(new File(parentFile, str).getPath());
if (str.startsWith("arm64")) {
arrayList2.add(new File(parentFile, "arm64").getPath());
} else if (str.startsWith("arm")) {
arrayList2.add(new File(parentFile, "arm").getPath());
}
}
for (String str2 : arrayList) {
if (str2.endsWith(".apk")) {
arrayList2.add(str2 + "!/lib/" + str);
}
}
arrayList2.add(System.getProperty("java.library.path"));
arrayList2.add(packageInfo.applicationInfo.nativeLibraryDir);
String str3 = File.pathSeparator;
return new String[]{TextUtils.join(str3, arrayList), TextUtils.join(str3, arrayList2)};
} catch (PackageManager.NameNotFoundException e) {
Logger.getLogger().e("Unable to compose package paths", e);
throw new RuntimeException(e);
}
}
@Override // com.google.firebase.crashlytics.ndk.NativeApi
public boolean initialize(String str, AssetManager assetManager) {
String[] makePackagePaths = makePackagePaths(Build.CPU_ABI);
if (makePackagePaths.length < 2) {
return false;
}
return LIB_CRASHLYTICS_LOADED && nativeInit(new String[]{makePackagePaths[0], makePackagePaths[1], str}, assetManager);
}
}