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

Commit 1c2dcbc6 authored by Evan Chen's avatar Evan Chen
Browse files

Use getApplicationInfoAsUser for get applicationInfo

Test: cst
Fix: 415422444
Flag: EXEMPT test fix
Change-Id: Ibf6daa753c72056223ca6ea6383c05761c7b045d
parent 5c9d7eeb
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");