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

Commit 2eeb4fb5 authored by Himanshu Gupta's avatar Himanshu Gupta
Browse files

Blocking home screen items for Private Profile

In this Cl we block:
1. Widgets
2. User Added App Shortcuts

Bug: 287975131
Test: atest FrameworksServicesTests
Flag: ACONFIG android.multiuser.disable_private_space_items_on_home
DEVELOPMENT

Change-Id: Ie15e067266447d170dc7dc8272997bd44317c90f
parent 2f13be7c
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -115,6 +115,11 @@ public abstract class ShortcutServiceInternal {
    public abstract boolean hasShortcutHostPermission(int launcherUserId,
            @NonNull String callingPackage, int callingPid, int callingUid);

    /**
     * Returns whether or not Shortcuts are supported on Launcher Home Screen.
     */
    public abstract boolean areShortcutsSupportedOnHomeScreen(@UserIdInt int userId);

    public abstract void setShortcutHostPackage(@NonNull String type, @Nullable String packageName,
            int userId);

+7 −0
Original line number Diff line number Diff line
@@ -156,3 +156,10 @@ flag {
    description: "Set power mode during a user switch."
    bug: "325249845"
}

flag {
    name: "disable_private_space_items_on_home"
    namespace: "profile_experiences"
    description: "Disables adding items belonging to Private Space on Home Screen manually as well as automatically"
    bug: "287975131"
}
+10 −0
Original line number Diff line number Diff line
@@ -2413,6 +2413,16 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
        }

        AppWidgetProviderInfo info = createPartialProviderInfo(providerId, ri, existing);

        if (android.os.Flags.allowPrivateProfile()
                && android.multiuser.Flags.disablePrivateSpaceItemsOnHome()) {
            // Do not add widget providers for profiles with items restricted on home screen.
            if (mUserManager
                    .getUserProperties(info.getProfile()).areItemsRestrictedOnHomeScreen()) {
                return false;
            }
        }

        if (info != null) {
            if (existing != null) {
                if (existing.zombie && !mSafeMode) {
+12 −0
Original line number Diff line number Diff line
@@ -798,6 +798,10 @@ public class LauncherAppsService extends SystemService {
        public ParceledListSlice getShortcutConfigActivities(
                String callingPackage, String packageName, UserHandle user)
                throws RemoteException {
            // Not supported for user-profiles with items restricted on home screen.
            if (!mShortcutServiceInternal.areShortcutsSupportedOnHomeScreen(user.getIdentifier())) {
                return null;
            }
            return queryActivitiesForUser(callingPackage,
                    new Intent(Intent.ACTION_CREATE_SHORTCUT).setPackage(packageName), user);
        }
@@ -1256,6 +1260,14 @@ public class LauncherAppsService extends SystemService {
        @Override
        public void pinShortcuts(String callingPackage, String packageName, List<String> ids,
                UserHandle targetUser) {
            if (!mShortcutServiceInternal
                    .areShortcutsSupportedOnHomeScreen(targetUser.getIdentifier())) {
                // Requires strict ACCESS_SHORTCUTS permission for user-profiles with items
                // restricted on home screen.
                ensureStrictAccessShortcutsPermission(callingPackage);
            } else {
                ensureShortcutPermission(callingPackage);
            }
            ensureShortcutPermission(callingPackage);
            if (!canAccessProfile(targetUser.getIdentifier(), "Cannot pin shortcuts")) {
                return;
+4 −0
Original line number Diff line number Diff line
@@ -416,6 +416,10 @@ class ShortcutRequestPinProcessor {
    @VisibleForTesting
    Pair<ComponentName, Integer> getRequestPinConfirmationActivity(
            int callingUserId, int requestType) {
        // Pinning is not supported for user-profiles with items restricted on home screen.
        if (!mService.areShortcutsSupportedOnHomeScreen(callingUserId)) {
            return null;
        }
        // Find the default launcher.
        final int launcherUserId = mService.getParentOrSelfUserId(callingUserId);
        final String defaultLauncher = mService.getDefaultLauncher(launcherUserId);
Loading