Merge "Device management info: Refer to current user, not primary user" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
57a0771bf5
@@ -20,6 +20,7 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
|
||||
import java.util.List;
|
||||
@@ -37,7 +38,7 @@ public abstract class AppCounter extends AsyncTask<Void, Void, Integer> {
|
||||
@Override
|
||||
protected Integer doInBackground(Void... params) {
|
||||
int count = 0;
|
||||
for (UserInfo user : getUsersToCount()) {
|
||||
for (UserInfo user : mUm.getProfiles(UserHandle.myUserId())) {
|
||||
final List<ApplicationInfo> list =
|
||||
mPm.getInstalledApplicationsAsUser(PackageManager.GET_DISABLED_COMPONENTS
|
||||
| PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS
|
||||
@@ -62,6 +63,5 @@ public abstract class AppCounter extends AsyncTask<Void, Void, Integer> {
|
||||
}
|
||||
|
||||
protected abstract void onCountComplete(int num);
|
||||
protected abstract List<UserInfo> getUsersToCount();
|
||||
protected abstract boolean includeInCount(ApplicationInfo info);
|
||||
}
|
||||
|
@@ -40,8 +40,8 @@ public interface ApplicationFeatureProvider {
|
||||
View view);
|
||||
|
||||
/**
|
||||
* Calculates the total number of apps installed on the device via policy across all users
|
||||
* and managed profiles.
|
||||
* Calculates the total number of apps installed on the device via policy in the current user
|
||||
* and all its managed profiles.
|
||||
*
|
||||
* @param async Whether to count asynchronously in a background thread
|
||||
* @param callback The callback to invoke with the result
|
||||
@@ -49,9 +49,8 @@ public interface ApplicationFeatureProvider {
|
||||
void calculateNumberOfPolicyInstalledApps(boolean async, NumberOfAppsCallback callback);
|
||||
|
||||
/**
|
||||
* Asynchronously calculates the total number of apps installed on the device, across all users
|
||||
* and managed profiles, that have been granted one or more of the given permissions by the
|
||||
* admin.
|
||||
* Asynchronously calculates the total number of apps installed in the current user and all its
|
||||
* managed profiles that have been granted one or more of the given permissions by the admin.
|
||||
*
|
||||
* @param permissions Only consider apps that have been granted one or more of these permissions
|
||||
* by the admin, either at run-time or install-time
|
||||
|
@@ -22,7 +22,6 @@ import android.content.Intent;
|
||||
import android.content.pm.ComponentInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
@@ -65,8 +64,8 @@ public class ApplicationFeatureProviderImpl implements ApplicationFeatureProvide
|
||||
|
||||
@Override
|
||||
public void calculateNumberOfPolicyInstalledApps(boolean async, NumberOfAppsCallback callback) {
|
||||
final AllUserPolicyInstalledAppCounter counter =
|
||||
new AllUserPolicyInstalledAppCounter(mContext, mPm, callback);
|
||||
final CurrentUserAndManagedProfilePolicyInstalledAppCounter counter =
|
||||
new CurrentUserAndManagedProfilePolicyInstalledAppCounter(mContext, mPm, callback);
|
||||
if (async) {
|
||||
counter.execute();
|
||||
} else {
|
||||
@@ -77,9 +76,9 @@ public class ApplicationFeatureProviderImpl implements ApplicationFeatureProvide
|
||||
@Override
|
||||
public void calculateNumberOfAppsWithAdminGrantedPermissions(String[] permissions,
|
||||
boolean async, NumberOfAppsCallback callback) {
|
||||
final AllUserAppWithAdminGrantedPermissionsCounter counter =
|
||||
new AllUserAppWithAdminGrantedPermissionsCounter(mContext, permissions, mPm, mPms,
|
||||
mDpm, callback);
|
||||
final CurrentUserAndManagedProfileAppWithAdminGrantedPermissionsCounter counter =
|
||||
new CurrentUserAndManagedProfileAppWithAdminGrantedPermissionsCounter(mContext,
|
||||
permissions, mPm, mPms, mDpm, callback);
|
||||
if (async) {
|
||||
counter.execute();
|
||||
} else {
|
||||
@@ -120,11 +119,12 @@ public class ApplicationFeatureProviderImpl implements ApplicationFeatureProvide
|
||||
return activities;
|
||||
}
|
||||
|
||||
private static class AllUserPolicyInstalledAppCounter extends InstalledAppCounter {
|
||||
private static class CurrentUserAndManagedProfilePolicyInstalledAppCounter
|
||||
extends InstalledAppCounter {
|
||||
private NumberOfAppsCallback mCallback;
|
||||
|
||||
AllUserPolicyInstalledAppCounter(Context context, PackageManagerWrapper packageManager,
|
||||
NumberOfAppsCallback callback) {
|
||||
CurrentUserAndManagedProfilePolicyInstalledAppCounter(Context context,
|
||||
PackageManagerWrapper packageManager, NumberOfAppsCallback callback) {
|
||||
super(context, PackageManager.INSTALL_REASON_POLICY, packageManager);
|
||||
mCallback = callback;
|
||||
}
|
||||
@@ -133,19 +133,15 @@ public class ApplicationFeatureProviderImpl implements ApplicationFeatureProvide
|
||||
protected void onCountComplete(int num) {
|
||||
mCallback.onNumberOfAppsResult(num);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<UserInfo> getUsersToCount() {
|
||||
return mUm.getUsers(true /* excludeDying */);
|
||||
}
|
||||
}
|
||||
|
||||
private static class AllUserAppWithAdminGrantedPermissionsCounter extends
|
||||
AppWithAdminGrantedPermissionsCounter {
|
||||
private static class CurrentUserAndManagedProfileAppWithAdminGrantedPermissionsCounter
|
||||
extends AppWithAdminGrantedPermissionsCounter {
|
||||
private NumberOfAppsCallback mCallback;
|
||||
|
||||
AllUserAppWithAdminGrantedPermissionsCounter(Context context, String[] permissions,
|
||||
PackageManagerWrapper packageManager, IPackageManagerWrapper packageManagerService,
|
||||
CurrentUserAndManagedProfileAppWithAdminGrantedPermissionsCounter(Context context,
|
||||
String[] permissions, PackageManagerWrapper packageManager,
|
||||
IPackageManagerWrapper packageManagerService,
|
||||
DevicePolicyManagerWrapper devicePolicyManager, NumberOfAppsCallback callback) {
|
||||
super(context, permissions, packageManager, packageManagerService, devicePolicyManager);
|
||||
mCallback = callback;
|
||||
@@ -155,10 +151,5 @@ public class ApplicationFeatureProviderImpl implements ApplicationFeatureProvide
|
||||
protected void onCountComplete(int num) {
|
||||
mCallback.onNumberOfAppsResult(num);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<UserInfo> getUsersToCount() {
|
||||
return mUm.getUsers(true /* excludeDying */);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@ import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageItemInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.icu.text.AlphabeticIndex;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
@@ -1404,11 +1403,6 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
||||
mLoader.setSummary(SummaryProvider.this,
|
||||
mContext.getString(R.string.apps_summary, num));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<UserInfo> getUsersToCount() {
|
||||
return mUm.getProfiles(UserHandle.myUserId());
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
}
|
||||
|
@@ -18,16 +18,11 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.SummaryLoader;
|
||||
import com.android.settings.notification.NotificationBackend;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Extension of ManageApplications with no changes other than having its own
|
||||
* SummaryProvider.
|
||||
@@ -56,11 +51,6 @@ public class NotificationApps extends ManageApplications {
|
||||
updateSummary(num);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<UserInfo> getUsersToCount() {
|
||||
return mUm.getProfiles(UserHandle.myUserId());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean includeInCount(ApplicationInfo info) {
|
||||
return mNotificationBackend.getNotificationsBanned(info.packageName,
|
||||
|
@@ -21,13 +21,13 @@ import com.android.settings.core.DynamicAvailabilityPreferenceController;
|
||||
import com.android.settings.core.lifecycle.Lifecycle;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
public class AlwaysOnVpnPrimaryUserPreferenceController
|
||||
public class AlwaysOnVpnCurrentUserPreferenceController
|
||||
extends DynamicAvailabilityPreferenceController {
|
||||
|
||||
private static final String KEY_ALWAYS_ON_VPN_PRIMARY_USER = "always_on_vpn_primary_user";
|
||||
private final EnterprisePrivacyFeatureProvider mFeatureProvider;
|
||||
|
||||
public AlwaysOnVpnPrimaryUserPreferenceController(Context context, Lifecycle lifecycle) {
|
||||
public AlwaysOnVpnCurrentUserPreferenceController(Context context, Lifecycle lifecycle) {
|
||||
super(context, lifecycle);
|
||||
mFeatureProvider = FeatureFactory.getFactory(context)
|
||||
.getEnterprisePrivacyFeatureProvider(context);
|
||||
@@ -42,7 +42,7 @@ public class AlwaysOnVpnPrimaryUserPreferenceController
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return mFeatureProvider.isAlwaysOnVpnSetInPrimaryUser();
|
||||
return mFeatureProvider.isAlwaysOnVpnSetInCurrentUser();
|
||||
}
|
||||
|
||||
@Override
|
@@ -51,13 +51,6 @@ public interface DevicePolicyManagerWrapper {
|
||||
*/
|
||||
ComponentName getDeviceOwnerComponentOnAnyUser();
|
||||
|
||||
/**
|
||||
* Calls {@code DevicePolicyManager.getDeviceOwnerUserId()}.
|
||||
*
|
||||
* @see android.app.admin.DevicePolicyManager#getDeviceOwnerUserId
|
||||
*/
|
||||
int getDeviceOwnerUserId();
|
||||
|
||||
/**
|
||||
* Calls {@code DevicePolicyManager.getProfileOwnerAsUser()}.
|
||||
*
|
||||
|
@@ -46,11 +46,6 @@ public class DevicePolicyManagerWrapperImpl implements DevicePolicyManagerWrappe
|
||||
return mDpm.getDeviceOwnerComponentOnAnyUser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDeviceOwnerUserId() {
|
||||
return mDpm.getDeviceOwnerUserId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ComponentName getProfileOwnerAsUser(final int userId) {
|
||||
return mDpm.getProfileOwnerAsUser(userId);
|
||||
|
@@ -32,9 +32,9 @@ public interface EnterprisePrivacyFeatureProvider {
|
||||
boolean isInCompMode();
|
||||
|
||||
/**
|
||||
* Returns the name of the organization managing the device via a Device Owner app. If the device
|
||||
* is not managed by a Device Owner app or the name of the managing organization was not set,
|
||||
* returns {@code null}.
|
||||
* Returns the name of the organization managing the device via a Device Owner app. If the
|
||||
* device is not managed by a Device Owner app or the name of the managing organization was not
|
||||
* set, returns {@code null}.
|
||||
*/
|
||||
String getDeviceOwnerOrganizationName();
|
||||
|
||||
@@ -74,12 +74,13 @@ public interface EnterprisePrivacyFeatureProvider {
|
||||
boolean isNetworkLoggingEnabled();
|
||||
|
||||
/**
|
||||
* Returns whether the Device Owner in the primary user set an always-on VPN.
|
||||
* Returns whether the Device Owner or Profile Owner in the current user set an always-on VPN.
|
||||
*/
|
||||
boolean isAlwaysOnVpnSetInPrimaryUser();
|
||||
boolean isAlwaysOnVpnSetInCurrentUser();
|
||||
|
||||
/**
|
||||
* Returns whether the Profile Owner in the managed profile (if any) set an always-on VPN.
|
||||
* Returns whether the Profile Owner in the current user's managed profile (if any) set an
|
||||
* always-on VPN.
|
||||
*/
|
||||
boolean isAlwaysOnVpnSetInManagedProfile();
|
||||
|
||||
@@ -89,10 +90,10 @@ public interface EnterprisePrivacyFeatureProvider {
|
||||
boolean isGlobalHttpProxySet();
|
||||
|
||||
/**
|
||||
* Returns the number of failed login attempts that the Device Owner allows before the entire
|
||||
* device is wiped, or zero if no such limit is set.
|
||||
* Returns the number of failed login attempts that the Device Owner or Profile Owner allows
|
||||
* before the current user is wiped, or zero if no such limit is set.
|
||||
*/
|
||||
int getMaximumFailedPasswordsBeforeWipeInPrimaryUser();
|
||||
int getMaximumFailedPasswordsBeforeWipeInCurrentUser();
|
||||
|
||||
/**
|
||||
* Returns the number of failed login attempts that the Profile Owner allows before the current
|
||||
|
@@ -142,7 +142,7 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlwaysOnVpnSetInPrimaryUser() {
|
||||
public boolean isAlwaysOnVpnSetInCurrentUser() {
|
||||
return VpnUtils.isAlwaysOnVpnSet(mCm, MY_USER_ID);
|
||||
}
|
||||
|
||||
@@ -159,12 +159,12 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumFailedPasswordsBeforeWipeInPrimaryUser() {
|
||||
final ComponentName deviceOwner = mDpm.getDeviceOwnerComponentOnAnyUser();
|
||||
if (deviceOwner == null) {
|
||||
public int getMaximumFailedPasswordsBeforeWipeInCurrentUser() {
|
||||
final ComponentName profileOwner = mDpm.getProfileOwnerAsUser(MY_USER_ID);
|
||||
if (profileOwner == null) {
|
||||
return 0;
|
||||
}
|
||||
return mDpm.getMaximumFailedPasswordsForWipe(deviceOwner, mDpm.getDeviceOwnerUserId());
|
||||
return mDpm.getMaximumFailedPasswordsForWipe(profileOwner, MY_USER_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -70,11 +70,11 @@ public class EnterprisePrivacySettings extends DashboardFragment {
|
||||
controllers.add(new AdminGrantedCameraPermissionPreferenceController(context, lifecycle,
|
||||
async));
|
||||
controllers.add(new EnterpriseSetDefaultAppsPreferenceController(context, lifecycle));
|
||||
controllers.add(new AlwaysOnVpnPrimaryUserPreferenceController(context, lifecycle));
|
||||
controllers.add(new AlwaysOnVpnCurrentUserPreferenceController(context, lifecycle));
|
||||
controllers.add(new AlwaysOnVpnManagedProfilePreferenceController(context, lifecycle));
|
||||
controllers.add(new GlobalHttpProxyPreferenceController(context, lifecycle));
|
||||
controllers.add(new CaCertsPreferenceController(context, lifecycle));
|
||||
controllers.add(new FailedPasswordWipePrimaryUserPreferenceController(context, lifecycle));
|
||||
controllers.add(new FailedPasswordWipeCurrentUserPreferenceController(context, lifecycle));
|
||||
controllers.add(new FailedPasswordWipeManagedProfilePreferenceController(context,
|
||||
lifecycle));
|
||||
controllers.add(new ImePreferenceController(context, lifecycle));
|
||||
|
@@ -17,23 +17,23 @@ import android.content.Context;
|
||||
|
||||
import com.android.settings.core.lifecycle.Lifecycle;
|
||||
|
||||
public class FailedPasswordWipePrimaryUserPreferenceController
|
||||
public class FailedPasswordWipeCurrentUserPreferenceController
|
||||
extends FailedPasswordWipePreferenceControllerBase {
|
||||
|
||||
private static final String KEY_FAILED_PASSWORD_WIPE_PRIMARY_USER
|
||||
= "failed_password_wipe_primary_user";
|
||||
private static final String KEY_FAILED_PASSWORD_WIPE_CURRENT_USER
|
||||
= "failed_password_wipe_current_user";
|
||||
|
||||
public FailedPasswordWipePrimaryUserPreferenceController(Context context, Lifecycle lifecycle) {
|
||||
public FailedPasswordWipeCurrentUserPreferenceController(Context context, Lifecycle lifecycle) {
|
||||
super(context, lifecycle);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMaximumFailedPasswordsBeforeWipe() {
|
||||
return mFeatureProvider.getMaximumFailedPasswordsBeforeWipeInPrimaryUser();
|
||||
return mFeatureProvider.getMaximumFailedPasswordsBeforeWipeInCurrentUser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_FAILED_PASSWORD_WIPE_PRIMARY_USER;
|
||||
return KEY_FAILED_PASSWORD_WIPE_CURRENT_USER;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user