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

Commit bcd4bddc authored by Ricky Wai's avatar Ricky Wai Committed by Android (Google) Code Review
Browse files

Merge "Allow work profile DPC app to hide itself in primary profile"

parents 4ef7a11a 87577278
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -430,6 +430,9 @@ public class LauncherAppsService extends SystemService {
            if (!mVouchedSignaturesByUser.containsKey(user)) {
                initVouchedSignatures(user);
            }
            if (isManagedProfileAdmin(user, appInfo.packageName)) {
                return false;
            }
            if (mVouchProviders.contains(appInfo.packageName)) {
                // If it's a vouching packages then we must show hidden app
                return true;
@@ -453,6 +456,24 @@ public class LauncherAppsService extends SystemService {
            return true;
        }

        private boolean isManagedProfileAdmin(UserHandle user, String packageName) {
            final List<UserInfo> userInfoList = mUm.getProfiles(user.getIdentifier());
            for (int i = 0; i < userInfoList.size(); i++) {
                UserInfo userInfo = userInfoList.get(i);
                if (!userInfo.isManagedProfile()) {
                    continue;
                }
                ComponentName componentName = mDpm.getProfileOwnerAsUser(userInfo.getUserHandle());
                if (componentName == null) {
                    continue;
                }
                if (componentName.getPackageName().equals(packageName)) {
                    return true;
                }
            }
            return false;
        }

        @VisibleForTesting
        static String computePackageCertDigest(Signature signature) {
            MessageDigest messageDigest;