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

Commit a3d37c8f authored by Pavel Grafov's avatar Pavel Grafov
Browse files

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
parent fda9f3d4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ public class LauncherAppState implements SafeCloseable {
                Intent.ACTION_MANAGED_PROFILE_AVAILABLE,
                Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE,
                Intent.ACTION_MANAGED_PROFILE_UNLOCKED,
                Intent.ACTION_PROFILE_INACCESSIBLE,
                ACTION_DEVICE_POLICY_RESOURCE_UPDATED);
        if (FeatureFlags.IS_STUDIO_BUILD) {
            modelChangeReceiver.register(mContext, ACTION_FORCE_ROLOAD);
+7 −6
Original line number Diff line number Diff line
@@ -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)));
                }