Get profile parent's context in case of work profile

In the headless system user mode a non-system user can also have
a work profile.
Refactor DatabaseUtils to get the profile parent's context when
the user is a work profile.

Bug: 270039752
Test: make RunSettingsRoboTests
Change-Id: I1fb78c9d91d59d50880a1ea0dd5f83a3d11dd08f
This commit is contained in:
Nikhil Kumar
2023-02-20 18:38:13 +00:00
parent ae2c14a039
commit 846d1d26f4
2 changed files with 12 additions and 13 deletions

View File

@@ -181,7 +181,7 @@ public final class DataProcessor {
@Nullable
public static Map<Long, UsageEvents> getAppUsageEvents(Context context) {
final long start = System.currentTimeMillis();
context = DatabaseUtils.getOwnerContext(context);
context = DatabaseUtils.getParentContext(context);
if (context == null) {
return null;
}
@@ -212,7 +212,7 @@ public final class DataProcessor {
public static UsageEvents getAppUsageEventsForUser(
Context context, final int userID, final long startTimestampOfLevelData) {
final long start = System.currentTimeMillis();
context = DatabaseUtils.getOwnerContext(context);
context = DatabaseUtils.getParentContext(context);
if (context == null) {
return null;
}