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

Commit b8de10f1 authored by Vitor Carvalho's avatar Vitor Carvalho
Browse files

Replace usage of DPM supervision methods in UsageStatsService with calls to...

Replace usage of DPM supervision methods in UsageStatsService with calls to SupervisionManagerInternal. Part 2.

Bug: 382039122
Flag: android.app.supervision.flags.deprecate_dpm_supervision_apis
Test: atest UsageStatsServiceTest
Change-Id: I6b655e372e0214db8afac4c1bca1a763b95c769f
parent a5a17bf7
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -1869,10 +1869,18 @@ public class UsageStatsService extends SystemService implements
    }

    private boolean shouldDeleteObsoleteData(UserHandle userHandle) {
        if (android.app.supervision.flags.Flags.deprecateDpmSupervisionApis()) {
            final SupervisionManagerInternal smInternal = getSupervisionManagerInternal();
            // If supervision is not enabled for the given user, obsolete data should be deleted.
            return smInternal == null
                    || !smInternal.isSupervisionEnabledForUser(userHandle.getIdentifier());
        } else {
            final DevicePolicyManagerInternal dpmInternal = getDpmInternal();
            // If a profile owner is not defined for the given user, obsolete data should be deleted
            return dpmInternal == null
                || dpmInternal.getProfileOwnerOrDeviceOwnerSupervisionComponent(userHandle) == null;
                    || dpmInternal.getProfileOwnerOrDeviceOwnerSupervisionComponent(userHandle)
                            == null;
        }
    }

    private String buildFullToken(String packageName, String token) {