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

Commit d986fda1 authored by Anna Zhuravleva's avatar Anna Zhuravleva
Browse files

Do not show install shortcut for Settings

Private profile shares Settings with the main user,
this change disable showing "Install to private"
long-press shortcut for Settings.

Bug: 316118005
Test: long press on Settings app
Flag: ACONFIG com.android.launcher3.Flags.enable_private_space_install_shortcut DEVELOPMENT

Change-Id: Iecc0bdf60879ce5c74288942d39bbb3add68fd9c
parent 898b9af9
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -253,4 +253,10 @@

    <!--  Used for custom widgets  -->
    <array name="custom_widget_providers"/>


    <!-- Skip "Install to private" long-press shortcut packages name -->
    <string-array name="skip_private_profile_shortcut_packages" translatable="false">
        <item>com.android.settings</item>
    </string-array>
</resources>
+14 −4
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_WIDGETS_TAP;

import android.app.ActivityOptions;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.Rect;
@@ -34,6 +35,7 @@ import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.widget.WidgetsBottomSheet;

import java.util.Arrays;
import java.util.List;

/**
@@ -236,13 +238,21 @@ public abstract class SystemShortcut<T extends Context & ActivityContext> extend
                    return null;
                }
                // Do not show shortcut if an app is already installed to the space
                ComponentKey targetKey =
                        new ComponentKey(itemInfo.getTargetComponent(), privateProfileUser);
                if (launcher.getAppsView().getAppsStore().getApp(targetKey) != null) {
                ComponentName targetComponent = itemInfo.getTargetComponent();
                if (launcher.getAppsView()
                                .getAppsStore()
                                .getApp(new ComponentKey(targetComponent, privateProfileUser))
                        != null) {
                    return null;
                }

                // TODO(b/302666597): do not install app if it's in deny list (e.g. settings)
                // Do not show shortcut for settings
                String[] packagesToSkip =
                        launcher.getResources()
                                .getStringArray(R.array.skip_private_profile_shortcut_packages);
                if (Arrays.asList(packagesToSkip).contains(targetComponent.getPackageName())) {
                    return null;
                }

                return new InstallToPrivateProfile(
                        launcher, itemInfo, originalView, privateProfileUser);