Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ffa299c3 authored by Evan Chen's avatar Evan Chen Committed by Android (Google) Code Review
Browse files

Merge "Use getApplicationInfoAsUser for get applicationInfo" into main

parents 7cec7f99 1c2dcbc6
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -830,7 +830,8 @@ public class DevicePresenceProcessor implements AssociationStore.OnChangeListene
            Slog.e(TAG, "Package is NOT bound.");
            return;
        }
        logDevicePresenceEvent(mContext, deviceProfileOrUuid, packageName, event.getEvent());
        logDevicePresenceEvent(
                userId, mContext, deviceProfileOrUuid, packageName, event.getEvent());

        primaryServiceConnector.postOnDevicePresenceEvent(event);
    }
+3 −3
Original line number Diff line number Diff line
@@ -163,9 +163,9 @@ public final class MetricUtils {
    /**
     * Log device presence event changed.
     */
    public static void logDevicePresenceEvent(Context context, String deviceProfileOrUuid,
            String packageName, int event) {
        int uid = getUidFromPackageName(context, packageName);
    public static void logDevicePresenceEvent(int userId, Context context,
            String deviceProfileOrUuid, String packageName, int event) {
        int uid = getUidFromPackageName(userId, context, packageName);
        if (uid != PACKAGE_NOT_FOUND) {
            write(
                    DEVICE_PRESENCE_CHANGED,
+3 −2
Original line number Diff line number Diff line
@@ -270,10 +270,11 @@ public final class PackageUtils {
    /**
     * Get UID from a packageName. Return -1 if the package is not found.
     */
    public static int getUidFromPackageName(Context context, String packageName) {
    public static int getUidFromPackageName(int userId, Context context, String packageName) {
        PackageManager packageManager = context.getPackageManager();
        try {
            ApplicationInfo applicationInfo = packageManager.getApplicationInfo(packageName, 0);
            ApplicationInfo applicationInfo = packageManager.getApplicationInfoAsUser(
                    packageName, 0, userId);
            return applicationInfo.uid;
        } catch (PackageManager.NameNotFoundException e) {
            Slog.w(TAG, packageName + " is not found");