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

Commit 6a27f501 authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Mitigate IPC calls from MultiUserSwitcher

Reduce the calls to UserManager#hasUserRestriction when checking if the
switcher should be shown by reordering the conditions. In most cases,
the switcher is disabled (from settings) and it will short circuit.

TODO: actually remove the call from main thread

Test: manual, when device does not have multiple users, there are no
calls to UserManager
Bug: 138640355
Bug: 138661450

Change-Id: I35905d4d8a7194866f55009b86dff0a2a4214e1a
parent 11d2f965
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -103,10 +103,11 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener
        final boolean userSwitcherEnabled = Settings.Global.getInt(mContext.getContentResolver(),
                Settings.Global.USER_SWITCHER_ENABLED, 0) != 0;

        if (!UserManager.supportsMultipleUsers()
                || mUserManager.hasUserRestriction(UserManager.DISALLOW_USER_SWITCH)
        // TODO(b/138661450) Move IPC calls to background
        if (!userSwitcherEnabled
                || !UserManager.supportsMultipleUsers()
                || UserManager.isDeviceInDemoMode(mContext)
                || !userSwitcherEnabled) {
                || mUserManager.hasUserRestriction(UserManager.DISALLOW_USER_SWITCH)) {
            return false;
        }