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

Commit c6a38d85 authored by Evan Chen's avatar Evan Chen
Browse files

Add UID for logging CDM association actions

Test: make
Flag: EXEMPT test fix
Bug: 417492379
Change-Id: Idc9b0c832106ef3a84c91efe337d76ce45e11152
parent 66a34042
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -221,7 +221,7 @@ public class AssociationStore {
            Slog.i(TAG, "Done adding new association.");
        }

        logCreateAssociation(association.getDeviceProfile());
        logCreateAssociation(association, mContext);

        if (association.isActive()) {
            broadcastChange(CHANGE_TYPE_ADDED, association);
@@ -296,7 +296,7 @@ public class AssociationStore {
            Slog.i(TAG, "Done removing association.");
        }

        logRemoveAssociation(association.getDeviceProfile());
        logRemoveAssociation(association, mContext);

        if (association.isActive()) {
            broadcastChange(CHANGE_TYPE_REMOVED, association);
+13 −6
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ import static com.android.server.companion.utils.PackageUtils.PACKAGE_NOT_FOUND;
import static com.android.server.companion.utils.PackageUtils.getUidFromPackageName;


import android.companion.AssociationInfo;
import android.content.Context;

import java.util.Map;
@@ -143,21 +144,27 @@ public final class MetricUtils {
    /**
     * Log association creation
     */
    public static void logCreateAssociation(String profile) {
    public static void logCreateAssociation(AssociationInfo ai, Context context) {
        int uid = getUidFromPackageName(ai.getUserId(), context, ai.getPackageName());

        write(CDM_ASSOCIATION_ACTION,
                CDM_ASSOCIATION_ACTION__ACTION__CREATED,
                ASSOCIATION_ACTION_DEVICE_PROFILE.get(
                        profile == null ? DEVICE_PROFILE_NULL : profile));
                ASSOCIATION_ACTION_DEVICE_PROFILE.get(ai.getDeviceProfile() == null
                        ? DEVICE_PROFILE_NULL : ai.getDeviceProfile()),
                uid);
    }

    /**
     * Log association removal
     */
    public static void logRemoveAssociation(String profile) {
    public static void logRemoveAssociation(AssociationInfo ai, Context context) {
        int uid = getUidFromPackageName(ai.getUserId(), context, ai.getPackageName());

        write(CDM_ASSOCIATION_ACTION,
                CDM_ASSOCIATION_ACTION__ACTION__REMOVED,
                ASSOCIATION_ACTION_DEVICE_PROFILE.get(
                        profile == null ? DEVICE_PROFILE_NULL : profile));
                ASSOCIATION_ACTION_DEVICE_PROFILE.get(ai.getDeviceProfile() == null
                        ? DEVICE_PROFILE_NULL : ai.getDeviceProfile()),
                uid);
    }

    /**