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

Commit 904a86f2 authored by Varun Shah's avatar Varun Shah
Browse files

Don't report global usage events twice for the same user.

Fixes: 138748086
Bug: 138323439
Test: atest android.app.usage.cts.UsageStatsTest#testInteractiveEvents
Change-Id: Ia9c88f19d59adc0a6c87904ad2011d1f213ac2e6
parent 9543bf36
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -7901,11 +7901,14 @@ public class ActivityManagerService extends IActivityManager.Stub
    }
    void reportGlobalUsageEventLocked(int event) {
        mUsageStatsService.reportEvent(Event.DEVICE_EVENT_PACKAGE_NAME,
                mUserController.getCurrentUserId(), event);
        final int currentUserId = mUserController.getCurrentUserId();
        mUsageStatsService.reportEvent(Event.DEVICE_EVENT_PACKAGE_NAME, currentUserId, event);
        int[] profiles = mUserController.getCurrentProfileIds();
        if (profiles != null) {
            for (int i = profiles.length - 1; i >= 0; i--) {
                if (profiles[i] == currentUserId) {
                    continue;
                }
                mUsageStatsService.reportEvent(Event.DEVICE_EVENT_PACKAGE_NAME, profiles[i], event);
            }
        }