diff options
author | 2024-11-28 19:31:49 +0000 | |
---|---|---|
committer | 2024-11-28 19:34:02 +0000 | |
commit | 6b2a4aa10e9ddf2ca29f0f6dd53e753d80ecbf5d (patch) | |
tree | 809044f620f566b92c5548d4734adb4d269c119f | |
parent | 5518e7f2952a31f5387941fca414c7b204b8a670 (diff) |
Temporarily disable supervision when supervision app is no longer the profile owner, making the sync fully 1:1 with DPM.
This is being done to enable the migration of platform code to use SupervisionService while I find out the best way to enable supervision without requiring profile ownership.
Change-Id: Iff01812421fb8b1ad1cadb466e4544b35eaabfaf
Bug: 377261590
Flag: android.app.supervision.flags.enable_sync_with_dpm
Test: atest SupervisionServiceTest
-rw-r--r-- | services/supervision/java/com/android/server/supervision/SupervisionService.java | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/services/supervision/java/com/android/server/supervision/SupervisionService.java b/services/supervision/java/com/android/server/supervision/SupervisionService.java index 55bd8df3c82e..3093c424e8b2 100644 --- a/services/supervision/java/com/android/server/supervision/SupervisionService.java +++ b/services/supervision/java/com/android/server/supervision/SupervisionService.java @@ -72,13 +72,6 @@ public class SupervisionService extends ISupervisionManager.Stub { mUserManagerInternal.addUserLifecycleListener(new UserLifecycleListener()); } - private void syncStateWithDevicePolicyManager(@UserIdInt int userId) { - // Ensure that supervision is enabled when supervision app is the profile owner. - if (Flags.enableSyncWithDpm() && isProfileOwner(userId)) { - setSupervisionEnabledForUser(userId, true); - } - } - @Override public boolean isSupervisionEnabledForUser(@UserIdInt int userId) { synchronized (getLockObject()) { @@ -140,6 +133,18 @@ public class SupervisionService extends ISupervisionManager.Stub { } } + /** Ensures that supervision is enabled when supervision app is the profile owner. */ + private void syncStateWithDevicePolicyManager(@UserIdInt int userId) { + if (isProfileOwner(userId)) { + setSupervisionEnabledForUser(userId, true); + } else { + // TODO(b/381428475): Avoid disabling supervision when the app is not the profile owner. + // This might only be possible after introducing specific and public APIs to enable + // supervision. + setSupervisionEnabledForUser(userId, false); + } + } + /** Returns whether the supervision app has profile owner status. */ private boolean isProfileOwner(@UserIdInt int userId) { ComponentName profileOwner = mDpmInternal.getProfileOwnerAsUser(userId); @@ -189,7 +194,7 @@ public class SupervisionService extends ISupervisionManager.Stub { @Override public void onUserStarting(@NonNull TargetUser user) { - if (!user.isPreCreated()) { + if (Flags.enableSyncWithDpm() && !user.isPreCreated()) { mSupervisionService.syncStateWithDevicePolicyManager(user.getUserIdentifier()); } } |