From 790481b8027d245bcd8180e95ca3aa42d2c045fc Mon Sep 17 00:00:00 2001 From: agnostic-apollo Date: Sat, 11 Jun 2022 14:12:58 +0500 Subject: [PATCH] Added: Add functions to `PackageUtils` to get base APK path of package --- .../termux/shared/android/PackageUtils.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/termux-shared/src/main/java/com/termux/shared/android/PackageUtils.java b/termux-shared/src/main/java/com/termux/shared/android/PackageUtils.java index a11ffb6c..a9ecb902 100644 --- a/termux-shared/src/main/java/com/termux/shared/android/PackageUtils.java +++ b/termux-shared/src/main/java/com/termux/shared/android/PackageUtils.java @@ -375,6 +375,28 @@ public class PackageUtils { + /** + * Get the base apk path for the package associated with the {@code context}. + * + * @param context The {@link Context} for the package. + * @return Returns the base apk path. + */ + public static String getBaseAPKPathForPackage(@NonNull final Context context) { + return getBaseAPKPathForPackage(context.getApplicationInfo()); + } + + /** + * Get the base apk path for the package associated with the {@code applicationInfo}. + * + * @param applicationInfo The {@link ApplicationInfo} for the package. + * @return Returns the base apk path. + */ + public static String getBaseAPKPathForPackage(@NonNull final ApplicationInfo applicationInfo) { + return applicationInfo.publicSourceDir; + } + + + /** * Check if the app associated with the {@code context} has {@link ApplicationInfo#FLAG_DEBUGGABLE} * set.