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

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

Merge "Add UID for logging CDM association actions" into main

parents 39550834 c6a38d85
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);
    }

    /**