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

Commit 62df3efd authored by josephpv's avatar josephpv Committed by Joseph Vincent
Browse files

Handle listing of PS apps in Apps > Special App Access > Device Admin Apps

Currently Device Admin Apps page shows apps from Private space even
when PS is locked.  This change takes care to hide PS apps from the list
when private profile is in quiet mode and on disabling quiet mode PS
apps are shown in the list.
Also takes care to update the active apps summary count to not include
PS apps when private profile is in quiet mode.

Recording link : b/324311892#comment2

Bug: 324311892
Test: Manual
Change-Id: If4199ecad0a228c8e491778fb62c09c8b3f20604
parent 3f52a6c4
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.content.pm.ActivityInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.UserProperties;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
@@ -156,12 +157,23 @@ public class DeviceAdminListPreferenceController extends BasePreferenceControlle
        mAdmins.clear();
        final List<UserHandle> profiles = mUm.getUserProfiles();
        for (UserHandle profile : profiles) {
            if (shouldSkipProfile(profile)) {
                continue;
            }
            final int profileId = profile.getIdentifier();
            updateAvailableAdminsForProfile(profileId);
        }
        Collections.sort(mAdmins);
    }

    private boolean shouldSkipProfile(UserHandle profile) {
        return  android.os.Flags.allowPrivateProfile()
                && android.multiuser.Flags.handleInterleavedSettingsForPrivateSpace()
                && mUm.isQuietModeEnabled(profile)
                && mUm.getUserProperties(profile).getShowInQuietMode()
                        == UserProperties.SHOW_IN_QUIET_MODE_HIDDEN;
    }

    private void refreshUI() {
        if (mPreferenceGroup == null) {
            return;
+12 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
import android.content.pm.UserProperties;
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.VpnManager;
@@ -220,6 +221,9 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
    public int getNumberOfActiveDeviceAdminsForCurrentUserAndManagedProfile() {
        int activeAdmins = 0;
        for (final UserInfo userInfo : mUm.getProfiles(MY_USER_ID)) {
            if (shouldSkipProfile(userInfo)) {
                continue;
            }
            final List<ComponentName> activeAdminsForUser
                    = mDpm.getActiveAdminsAsUser(userInfo.id);
            if (activeAdminsForUser != null) {
@@ -250,6 +254,14 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
        return false;
    }

    private boolean shouldSkipProfile(UserInfo userInfo) {
        return android.os.Flags.allowPrivateProfile()
                && android.multiuser.Flags.handleInterleavedSettingsForPrivateSpace()
                && userInfo.isQuietModeEnabled()
                && mUm.getUserProperties(userInfo.getUserHandle()).getShowInQuietMode()
                        == UserProperties.SHOW_IN_QUIET_MODE_HIDDEN;
    }

    private Intent getParentalControlsIntent() {
        final ComponentName componentName =
                mDpm.getProfileOwnerOrDeviceOwnerSupervisionComponent(new UserHandle(MY_USER_ID));