Use PROFILE_INACCESSIBLE to track locked profile

Pre-U ACTION_MANAGED_PROFILE_UNAVAILABLE broadcast meant the user was
shutting down, and could be used to track when the user can be treated
as locked. In Android U work profile in quiet mode remains running, so
to track when the user gets locked this CL swithces to
ACTION_PROFILE_INACCESSIBLE instead, which is sent when the user is shut
down.

+ formatting fix to satisfy lint

Bug: 277715473
Test: manual, with TestDPC and work contact shortcut
Change-Id: I258df006e2d87f69bbbac82d20ad72ddce625425
This commit is contained in:
Pavel Grafov
2023-05-11 15:35:56 +01:00
parent fda9f3d430
commit a3d37c8faa
2 changed files with 8 additions and 6 deletions

View File

@@ -289,9 +289,10 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi
if (Intent.ACTION_LOCALE_CHANGED.equals(action)) {
// If we have changed locale we need to clear out the labels in all apps/workspace.
forceReload();
} else if (Intent.ACTION_MANAGED_PROFILE_AVAILABLE.equals(action) ||
Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE.equals(action) ||
Intent.ACTION_MANAGED_PROFILE_UNLOCKED.equals(action)) {
} else if (Intent.ACTION_MANAGED_PROFILE_AVAILABLE.equals(action)
|| Intent.ACTION_PROFILE_INACCESSIBLE.equals(action)
|| Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE.equals(action)
|| Intent.ACTION_MANAGED_PROFILE_UNLOCKED.equals(action)) {
UserHandle user = intent.getParcelableExtra(Intent.EXTRA_USER);
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.WORK_TAB_MISSING, "onBroadcastIntent intentAction: " + action +
@@ -304,10 +305,10 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi
PackageUpdatedTask.OP_USER_AVAILABILITY_CHANGE, user));
}
// ACTION_MANAGED_PROFILE_UNAVAILABLE sends the profile back to locked mode, so
// ACTION_PROFILE_INACCESSIBLE sends the profile back to locked mode, so
// we need to run the state change task again.
if (Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE.equals(action) ||
Intent.ACTION_MANAGED_PROFILE_UNLOCKED.equals(action)) {
if (Intent.ACTION_PROFILE_INACCESSIBLE.equals(action)
|| Intent.ACTION_MANAGED_PROFILE_UNLOCKED.equals(action)) {
enqueueModelUpdateTask(new UserLockStateChangedTask(
user, Intent.ACTION_MANAGED_PROFILE_UNLOCKED.equals(action)));
}