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

Commit c2a2b86e authored by Himanshu Gupta's avatar Himanshu Gupta
Browse files

Fixing work widgets tab in WidgetsFullSheet.

Currently the work widget matcher matches against all
non-foreground user profiles, due to which the work
tab is incorrectly shown in widgets full screen, when
PS is present.
This was missed in ag/25129268 where a bunch of work
matcher fixes were done.

Flag: ACONFIG com.android.launcher3.Flags.enable_private_space DEVELOPMENT
Bug: 312900122
Test: Launcher3 tests
Change-Id: I80d33e851ea3366dc3897bb1f5cc17fcd6b34520
parent eabb3782
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import static com.android.launcher3.testing.shared.TestProtocol.NORMAL_STATE_ORD

import android.animation.Animator;
import android.content.Context;
import android.content.pm.LauncherApps;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Rect;
@@ -106,9 +105,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet
    private final UserHandle mCurrentUser = Process.myUserHandle();
    private final Predicate<WidgetsListBaseEntry> mPrimaryWidgetsFilter =
            entry -> mCurrentUser.equals(entry.mPkgItem.user);
    private final Predicate<WidgetsListBaseEntry> mWorkWidgetsFilter =
            entry -> !mCurrentUser.equals(entry.mPkgItem.user)
                    && !mUserManagerState.isUserQuiet(entry.mPkgItem.user);
    private final Predicate<WidgetsListBaseEntry> mWorkWidgetsFilter;
    protected final boolean mHasWorkProfile;
    protected boolean mHasRecommendedWidgets;
    protected final SparseArray<AdapterHolder> mAdapters = new SparseArray();
@@ -182,20 +179,23 @@ public class WidgetsFullSheet extends BaseWidgetSheet
    public WidgetsFullSheet(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        mDeviceProfile = mActivityContext.getDeviceProfile();
        mHasWorkProfile = context.getSystemService(LauncherApps.class).getProfiles().size() > 1;
        mOrientation = context.getResources().getConfiguration().orientation;
        mUserCache = UserCache.INSTANCE.get(context);
        mHasWorkProfile = mUserCache.getUserProfiles()
                .stream()
                .anyMatch(user -> mUserCache.getUserInfo(user).isWork());
        mWorkWidgetsFilter = entry -> mHasWorkProfile
                && mUserCache.getUserInfo(entry.mPkgItem.user).isWork();
        mAdapters.put(AdapterHolder.PRIMARY, new AdapterHolder(AdapterHolder.PRIMARY));
        mAdapters.put(AdapterHolder.WORK, new AdapterHolder(AdapterHolder.WORK));
        mAdapters.put(AdapterHolder.SEARCH, new AdapterHolder(AdapterHolder.SEARCH));

        Resources resources = getResources();
        mUserManagerState.init(UserCache.INSTANCE.get(context),
                context.getSystemService(UserManager.class));
        mTabsHeight = mHasWorkProfile
                ? resources.getDimensionPixelSize(R.dimen.all_apps_header_pill_height)
                : 0;

        mUserCache = UserCache.INSTANCE.get(context);
        mUserManagerState.init(UserCache.INSTANCE.get(context),
                context.getSystemService(UserManager.class));
    }

    public WidgetsFullSheet(Context context, AttributeSet attrs) {