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
This commit is contained in:
@@ -32,6 +32,7 @@ import android.content.pm.ActivityInfo;
|
|||||||
import android.content.pm.IPackageManager;
|
import android.content.pm.IPackageManager;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.content.pm.UserProperties;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
@@ -156,12 +157,23 @@ public class DeviceAdminListPreferenceController extends BasePreferenceControlle
|
|||||||
mAdmins.clear();
|
mAdmins.clear();
|
||||||
final List<UserHandle> profiles = mUm.getUserProfiles();
|
final List<UserHandle> profiles = mUm.getUserProfiles();
|
||||||
for (UserHandle profile : profiles) {
|
for (UserHandle profile : profiles) {
|
||||||
|
if (shouldSkipProfile(profile)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
final int profileId = profile.getIdentifier();
|
final int profileId = profile.getIdentifier();
|
||||||
updateAvailableAdminsForProfile(profileId);
|
updateAvailableAdminsForProfile(profileId);
|
||||||
}
|
}
|
||||||
Collections.sort(mAdmins);
|
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() {
|
private void refreshUI() {
|
||||||
if (mPreferenceGroup == null) {
|
if (mPreferenceGroup == null) {
|
||||||
return;
|
return;
|
||||||
|
@@ -26,6 +26,7 @@ import android.content.Intent;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
|
import android.content.pm.UserProperties;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.VpnManager;
|
import android.net.VpnManager;
|
||||||
@@ -220,6 +221,9 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
|
|||||||
public int getNumberOfActiveDeviceAdminsForCurrentUserAndManagedProfile() {
|
public int getNumberOfActiveDeviceAdminsForCurrentUserAndManagedProfile() {
|
||||||
int activeAdmins = 0;
|
int activeAdmins = 0;
|
||||||
for (final UserInfo userInfo : mUm.getProfiles(MY_USER_ID)) {
|
for (final UserInfo userInfo : mUm.getProfiles(MY_USER_ID)) {
|
||||||
|
if (shouldSkipProfile(userInfo)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
final List<ComponentName> activeAdminsForUser
|
final List<ComponentName> activeAdminsForUser
|
||||||
= mDpm.getActiveAdminsAsUser(userInfo.id);
|
= mDpm.getActiveAdminsAsUser(userInfo.id);
|
||||||
if (activeAdminsForUser != null) {
|
if (activeAdminsForUser != null) {
|
||||||
@@ -250,6 +254,14 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
|
|||||||
return false;
|
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() {
|
private Intent getParentalControlsIntent() {
|
||||||
final ComponentName componentName =
|
final ComponentName componentName =
|
||||||
mDpm.getProfileOwnerOrDeviceOwnerSupervisionComponent(new UserHandle(MY_USER_ID));
|
mDpm.getProfileOwnerOrDeviceOwnerSupervisionComponent(new UserHandle(MY_USER_ID));
|
||||||
|
Reference in New Issue
Block a user