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

Commit 0056992c authored by Anna Zhuravleva's avatar Anna Zhuravleva
Browse files

Allow not Home system apps access hidden profile.

Some system apps need to call Launcher Apps APIs for private profile
(e.g. to power Launcher apps suggestion) but can't have the HOME role.

This change relaxes the restriction and only requires the privileged permission.

Bug: 329839558
Test: atest LauncherAppsForHiddenProfilesTest
Flag: android.multiuser.enable_launcher_apps_hidden_profile_checksi
DEVELOPMENT

Change-Id: If2305a49c0ce5fabaea00ed035290fce916c699a
parent 7b9df00f
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -18,12 +18,12 @@ package com.android.server.pm;

import static android.Manifest.permission.READ_FRAME_BUFFER;
import static android.app.ActivityOptions.KEY_SPLASH_SCREEN_THEME;
import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED;
import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED;
import static android.app.AppOpsManager.MODE_ALLOWED;
import static android.app.AppOpsManager.MODE_IGNORED;
import static android.app.AppOpsManager.OP_ARCHIVE_ICON_OVERLAY;
import static android.app.AppOpsManager.OP_UNARCHIVAL_CONFIRMATION;
import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED;
import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED;
import static android.app.PendingIntent.FLAG_IMMUTABLE;
import static android.app.PendingIntent.FLAG_MUTABLE;
import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
@@ -555,12 +555,6 @@ public class LauncherAppsService extends SystemService {
                    return false;
                }

                if (!mRoleManager
                        .getRoleHoldersAsUser(
                                RoleManager.ROLE_HOME, UserHandle.getUserHandleForUid(callingUid))
                        .contains(callingPackage.getPackageName())) {
                    return false;
                }
                if (mContext.checkPermission(
                                Manifest.permission.ACCESS_HIDDEN_PROFILES_FULL,
                                callingPid,
@@ -569,6 +563,13 @@ public class LauncherAppsService extends SystemService {
                    return true;
                }

                if (!mRoleManager
                        .getRoleHoldersAsUser(
                                RoleManager.ROLE_HOME, UserHandle.getUserHandleForUid(callingUid))
                        .contains(callingPackage.getPackageName())) {
                    return false;
                }

                // TODO(b/321988638): add option to disable with a flag
                return mContext.checkPermission(
                                android.Manifest.permission.ACCESS_HIDDEN_PROFILES,