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

Commit 7d56e6ea authored by Himanshu Gupta's avatar Himanshu Gupta Committed by Android (Google) Code Review
Browse files

Merge "Adding Prework for Private Space integration in Launcher" into main

parents fce687e6 9aab4d46
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_RESOURC

import static com.android.launcher3.LauncherAppState.ACTION_FORCE_ROLOAD;
import static com.android.launcher3.config.FeatureFlags.IS_STUDIO_BUILD;
import static com.android.launcher3.pm.UserCache.ACTION_PROFILE_AVAILABLE;
import static com.android.launcher3.pm.UserCache.ACTION_PROFILE_UNAVAILABLE;
import static com.android.launcher3.testing.shared.TestProtocol.sDebugTracing;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
@@ -326,6 +328,16 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi
        } else if (UserCache.ACTION_PROFILE_ADDED.equals(action)
                || UserCache.ACTION_PROFILE_REMOVED.equals(action)) {
            forceReload();
        } else if (ACTION_PROFILE_AVAILABLE.equals(action)
                || ACTION_PROFILE_UNAVAILABLE.equals(action)) {
            /*
             * This broadcast is only available when android.os.Flags.allowPrivateProfile() is set.
             * For Work-profile this broadcast will be sent in addition to
             * ACTION_MANAGED_PROFILE_AVAILABLE/UNAVAILABLE.
             * So effectively, this if block only handles the non-work profile case.
             */
            enqueueModelUpdateTask(new PackageUpdatedTask(
                    PackageUpdatedTask.OP_USER_AVAILABILITY_CHANGE, user));
        }
    }

+4 −1
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.keyboard.FocusedItemDecorator;
import com.android.launcher3.model.StringCache;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.pm.UserCache;
import com.android.launcher3.recyclerview.AllAppsRecyclerViewPool;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.Themes;
@@ -203,7 +204,9 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>

        mWorkManager = new WorkProfileManager(
                mActivityContext.getSystemService(UserManager.class),
                this, mActivityContext.getStatsLogManager());
                this,
                mActivityContext.getStatsLogManager(),
                UserCache.INSTANCE.get(mActivityContext));
        mAH = Arrays.asList(null, null, null);
        mNavBarScrimPaint = new Paint();
        mNavBarScrimPaint.setColor(Themes.getNavBarScrimColor(mActivityContext));
+3 −0
Original line number Diff line number Diff line
@@ -124,6 +124,9 @@ public class AllAppsStore<T extends Context & ActivityContext> {
     * @see com.android.launcher3.model.BgDataModel.Callbacks#FLAG_QUIET_MODE_ENABLED
     * @see com.android.launcher3.model.BgDataModel.Callbacks#FLAG_HAS_SHORTCUT_PERMISSION
     * @see com.android.launcher3.model.BgDataModel.Callbacks#FLAG_QUIET_MODE_CHANGE_PERMISSION
     * @see com.android.launcher3.model.BgDataModel.Callbacks#FLAG_WORK_PROFILE_QUIET_MODE_ENABLED
     * @see
     * com.android.launcher3.model.BgDataModel.Callbacks#FLAG_PRIVATE_PROFILE_QUIET_MODE_ENABLED
     */
    public boolean hasModelFlag(int mask) {
        return (mModelFlags & mask) != 0;
+19 −8
Original line number Diff line number Diff line
@@ -25,10 +25,10 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_HAS_SHORTCUT_PERMISSION;
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_QUIET_MODE_CHANGE_PERMISSION;
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_QUIET_MODE_ENABLED;
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_WORK_PROFILE_QUIET_MODE_ENABLED;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;

import android.os.Build;
import android.os.Process;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
@@ -40,12 +40,14 @@ import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.recyclerview.widget.RecyclerView;

import com.android.launcher3.Flags;
import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.allapps.BaseAllAppsAdapter.AdapterItem;
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.pm.UserCache;
import com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip;

import java.lang.annotation.Retention;
@@ -84,16 +86,19 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP

    private WorkModeSwitch mWorkModeSwitch;

    private final UserCache mUserCache;

    @WorkProfileState
    private int mCurrentState;

    public WorkProfileManager(
            UserManager userManager, ActivityAllAppsContainerView allApps,
            StatsLogManager statsLogManager) {
            StatsLogManager statsLogManager, UserCache userCache) {
        mUserManager = userManager;
        mAllApps = allApps;
        mMatcher = mAllApps.mPersonalMatcher.negate();
        mStatsLogManager = statsLogManager;
        mUserCache = userCache;
        mMatcher = info -> info != null && mUserCache.getUserInfo(info.user).isWork();
    }

    /**
@@ -103,11 +108,11 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP
    public void setWorkProfileEnabled(boolean enabled) {
        updateCurrentState(STATE_TRANSITION);
        UI_HELPER_EXECUTOR.post(() -> {
            for (UserHandle userProfile : mUserManager.getUserProfiles()) {
                if (Process.myUserHandle().equals(userProfile)) {
                    continue;
                }
            for (UserHandle userProfile : mUserCache.getUserProfiles()) {
                if (mUserCache.getUserInfo(userProfile).isWork()) {
                    mUserManager.requestQuietModeEnabled(!enabled, userProfile);
                    break;
                }
            }
        });
    }
@@ -131,7 +136,13 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP
     * Requests work profile state from {@link AllAppsStore} and updates work profile related views
     */
    public void reset() {
        boolean isEnabled = !mAllApps.getAppsStore().hasModelFlag(FLAG_QUIET_MODE_ENABLED);
        int quietModeFlag;
        if (Flags.enablePrivateSpace()) {
            quietModeFlag = FLAG_WORK_PROFILE_QUIET_MODE_ENABLED;
        } else {
            quietModeFlag = FLAG_QUIET_MODE_ENABLED;
        }
        boolean isEnabled = !mAllApps.getAppsStore().hasModelFlag(quietModeFlag);
        updateCurrentState(isEnabled ? STATE_ENABLED : STATE_DISABLED);
        if (mWorkModeSwitch != null) {
            // reset the position of the button and clear IME insets.
+2 −0
Original line number Diff line number Diff line
@@ -79,6 +79,8 @@ public class AllAppsList {
     * @see Callbacks#FLAG_HAS_SHORTCUT_PERMISSION
     * @see Callbacks#FLAG_QUIET_MODE_ENABLED
     * @see Callbacks#FLAG_QUIET_MODE_CHANGE_PERMISSION
     * @see Callbacks#FLAG_WORK_PROFILE_QUIET_MODE_ENABLED
     * @see Callbacks#FLAG_PRIVATE_PROFILE_QUIET_MODE_ENABLED
     */
    private int mFlags;

Loading