From 0ff9946abe9569808fb6b559aefb0c77f514c5ec Mon Sep 17 00:00:00 2001 From: Carmen Jackson Date: Thu, 9 Aug 2018 14:51:39 -0700 Subject: [PATCH] Pinner: Don't pin apps for work profile. Since the Home and Camera intents aren't set to relevant apps for the work profile, we don't want to pin those. However, the pinner will trigger on boot for the work profile, after the primary profile has pinned, and clear the currently pinned apps to try to pin the work profile apps. This change skips rerunning the pinner for the work profile. Bug: 112357464 Test: Added logging and tested device with a work profile. After reboot, saw that the apps for the primary profile are pinned and the ones for the work profile are not. Previously, apps for the work profile were attempted to be pinned. Change-Id: I0a7fdeab4287dcb6765c0fb47647ddc36db405b6 --- .../core/java/com/android/server/PinnerService.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/PinnerService.java b/services/core/java/com/android/server/PinnerService.java index a05a3e767d125..0deaee7f78782 100644 --- a/services/core/java/com/android/server/PinnerService.java +++ b/services/core/java/com/android/server/PinnerService.java @@ -43,6 +43,7 @@ import android.os.Looper; import android.os.Message; import android.os.RemoteException; import android.os.UserHandle; +import android.os.UserManager; import android.provider.MediaStore; import android.provider.Settings; import android.system.ErrnoException; @@ -104,6 +105,7 @@ public final class PinnerService extends SystemService { private final Context mContext; private final ActivityManagerInternal mAmInternal; private final IActivityManager mAm; + private final UserManager mUserManager; /** The list of the statically pinned files. */ @GuardedBy("this") @@ -165,6 +167,8 @@ public final class PinnerService extends SystemService { mAmInternal = LocalServices.getService(ActivityManagerInternal.class); mAm = ActivityManager.getService(); + mUserManager = mContext.getSystemService(UserManager.class); + IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_PACKAGE_REPLACED); filter.addDataScheme("package"); @@ -195,12 +199,16 @@ public final class PinnerService extends SystemService { */ @Override public void onSwitchUser(int userHandle) { - sendPinAppsMessage(userHandle); + if (!mUserManager.isManagedProfile(userHandle)) { + sendPinAppsMessage(userHandle); + } } @Override public void onUnlockUser(int userHandle) { - sendPinAppsMessage(userHandle); + if (!mUserManager.isManagedProfile(userHandle)) { + sendPinAppsMessage(userHandle); + } } /**