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

Commit 87577278 authored by Ricky Wai's avatar Ricky Wai
Browse files

Allow work profile DPC app to hide itself in primary profile

Test: Able to boot, TestDPC in PO is not showing in launcher
Bug: 120537579
Change-Id: I47eca87d6bc4512d375f960f776dde2cb4b4cc77
parent a75a6ee0
Loading
Loading
Loading
Loading
+21 −0
Original line number Original line Diff line number Diff line
@@ -430,6 +430,9 @@ public class LauncherAppsService extends SystemService {
            if (!mVouchedSignaturesByUser.containsKey(user)) {
            if (!mVouchedSignaturesByUser.containsKey(user)) {
                initVouchedSignatures(user);
                initVouchedSignatures(user);
            }
            }
            if (isManagedProfileAdmin(user, appInfo.packageName)) {
                return false;
            }
            if (mVouchProviders.contains(appInfo.packageName)) {
            if (mVouchProviders.contains(appInfo.packageName)) {
                // If it's a vouching packages then we must show hidden app
                // If it's a vouching packages then we must show hidden app
                return true;
                return true;
@@ -453,6 +456,24 @@ public class LauncherAppsService extends SystemService {
            return true;
            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
        @VisibleForTesting
        static String computePackageCertDigest(Signature signature) {
        static String computePackageCertDigest(Signature signature) {
            MessageDigest messageDigest;
            MessageDigest messageDigest;