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

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

Merge "Revert "Do not display clone apps in launcher work tab."" into udc-dev

parents 2e1ce4c7 8ef1845c
Loading
Loading
Loading
Loading
+1 −34
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ 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.config.FeatureFlags;
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.testing.shared.TestProtocol;
@@ -53,7 +52,6 @@ import com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.function.Predicate;

@@ -97,15 +95,7 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP
            StatsLogManager statsLogManager) {
        mUserManager = userManager;
        mAllApps = allApps;
        boolean cloningChanges = FeatureFlags.ENABLE_APP_CLONING_CHANGES_IN_LAUNCHER.get();
        if (TestProtocol.sDebugTracing) {
            Log.d(WORK_TAB_MISSING, "matcher flag: " + cloningChanges);
        }
        if (cloningChanges) {
            mMatcher = ofWorkProfileUser(userManager);
        } else {
        mMatcher = mAllApps.mPersonalMatcher.negate();
        }
        mStatsLogManager = statsLogManager;
    }

@@ -280,27 +270,4 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP
            }
        };
    }

    /**
     * Filter to only display apps in managed profile in work tab.
     */
    private Predicate<ItemInfo> ofWorkProfileUser(UserManager um) {
        return info -> info != null && isManagedProfile(um, info.user.hashCode());
    }


    private static boolean isManagedProfile(UserManager um, int userId) {
        try {
            // isManagedProfile is a @SystemApi.
            String methodName = "isManagedProfile";
            Method method = um.getClass().getDeclaredMethod(methodName, int.class);
            Object result = method.invoke(um, userId);
            if (result instanceof Boolean) {
                return (boolean) result;
            }
        } catch (Exception e) {
            Log.e(TAG, "Failed to call #isManagedProfile via reflection from Launcher");
        }
        return false;
    }
}
+0 −5
Original line number Diff line number Diff line
@@ -213,11 +213,6 @@ public final class FeatureFlags {
    public static final BooleanFlag ENABLE_TRANSIENT_TASKBAR = getDebugFlag(270395798,
            "ENABLE_TRANSIENT_TASKBAR", ENABLED, "Enables transient taskbar.");

    // TODO(Block 15): Clean up flags
    public static final BooleanFlag ENABLE_APP_CLONING_CHANGES_IN_LAUNCHER = getDebugFlag(266177840,
            "ENABLE_APP_CLONING_CHANGES_IN_LAUNCHER", DISABLED,
            "Removes clone apps from the work profile tab.");

    // TODO(Block 16): Clean up flags
    // When enabled the promise icon is visible in all apps while installation an app.
    public static final BooleanFlag PROMISE_APPS_IN_ALL_APPS = getDebugFlag(270390012,