From 2c6d009657a872decbb7b3aeab2e435dc57b158d Mon Sep 17 00:00:00 2001 From: agnostic-apollo Date: Mon, 18 Oct 2021 15:34:23 +0500 Subject: [PATCH] Added: Add uid to app info --- .../termux/shared/packages/PackageUtils.java | 22 +++++++++++++++++++ .../termux/shared/termux/AndroidUtils.java | 1 + 2 files changed, 23 insertions(+) diff --git a/termux-shared/src/main/java/com/termux/shared/packages/PackageUtils.java b/termux-shared/src/main/java/com/termux/shared/packages/PackageUtils.java index de1aae98..fea70624 100644 --- a/termux-shared/src/main/java/com/termux/shared/packages/PackageUtils.java +++ b/termux-shared/src/main/java/com/termux/shared/packages/PackageUtils.java @@ -204,6 +204,28 @@ public class PackageUtils { + /** + * Get the uid for the package associated with the {@code context}. + * + * @param context The {@link Context} for the package. + * @return Returns the uid. + */ + public static int getUidForPackage(@NonNull final Context context) { + return getUidForPackage(context.getApplicationInfo()); + } + + /** + * Get the uid for the package associated with the {@code applicationInfo}. + * + * @param applicationInfo The {@link ApplicationInfo} for the package. + * @return Returns the uid. + */ + public static int getUidForPackage(@NonNull final ApplicationInfo applicationInfo) { + return applicationInfo.uid; + } + + + /** * Get the {@code targetSdkVersion} for the package associated with the {@code context}. * diff --git a/termux-shared/src/main/java/com/termux/shared/termux/AndroidUtils.java b/termux-shared/src/main/java/com/termux/shared/termux/AndroidUtils.java index 80e4f130..6b595985 100644 --- a/termux-shared/src/main/java/com/termux/shared/termux/AndroidUtils.java +++ b/termux-shared/src/main/java/com/termux/shared/termux/AndroidUtils.java @@ -74,6 +74,7 @@ public class AndroidUtils { AndroidUtils.appendPropertyToMarkdown(markdownString,"PACKAGE_NAME", PackageUtils.getPackageNameForPackage(applicationInfo)); AndroidUtils.appendPropertyToMarkdown(markdownString,"VERSION_NAME", PackageUtils.getVersionNameForPackage(context, packageName)); AndroidUtils.appendPropertyToMarkdown(markdownString,"VERSION_CODE", PackageUtils.getVersionCodeForPackage(context, packageName)); + AndroidUtils.appendPropertyToMarkdown(markdownString,"UID", PackageUtils.getUidForPackage(applicationInfo)); AndroidUtils.appendPropertyToMarkdown(markdownString,"TARGET_SDK", PackageUtils.getTargetSDKForPackage(applicationInfo)); AndroidUtils.appendPropertyToMarkdown(markdownString,"IS_DEBUGGABLE_BUILD", PackageUtils.isAppForPackageADebuggableBuild(applicationInfo));