Merge changes I54360698,Ic8a3db21
* changes: Finish removing N/A DO disclosures from search index DO Disclosures: Combine personal and work CA cert
This commit is contained in:
committed by
Android (Google) Code Review
commit
ca3997d27e
@@ -54,9 +54,10 @@ public interface ApplicationFeatureProvider {
|
||||
*
|
||||
* @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
|
||||
* @param async Whether to count asynchronously in a background thread
|
||||
* @param callback The callback to invoke with the result
|
||||
*/
|
||||
void calculateNumberOfAppsWithAdminGrantedPermissions(String[] permissions,
|
||||
void calculateNumberOfAppsWithAdminGrantedPermissions(String[] permissions, boolean async,
|
||||
NumberOfAppsCallback callback);
|
||||
|
||||
/**
|
||||
|
@@ -69,9 +69,15 @@ public class ApplicationFeatureProviderImpl implements ApplicationFeatureProvide
|
||||
|
||||
@Override
|
||||
public void calculateNumberOfAppsWithAdminGrantedPermissions(String[] permissions,
|
||||
NumberOfAppsCallback callback) {
|
||||
new AllUserAppWithAdminGrantedPermissionsCounter(mContext, permissions, mPm, mPms, mDpm,
|
||||
callback).execute();
|
||||
boolean async, NumberOfAppsCallback callback) {
|
||||
final AllUserAppWithAdminGrantedPermissionsCounter counter =
|
||||
new AllUserAppWithAdminGrantedPermissionsCounter(mContext, permissions, mPm, mPms,
|
||||
mDpm, callback);
|
||||
if (async) {
|
||||
counter.execute();
|
||||
} else {
|
||||
counter.executeInForeground();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -17,14 +17,18 @@ package com.android.settings.enterprise;
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.core.lifecycle.Lifecycle;
|
||||
|
||||
public class AdminGrantedCameraPermissionPreferenceController extends
|
||||
AdminGrantedPermissionsPreferenceControllerBase {
|
||||
|
||||
private static final String KEY_ENTERPRISE_PRIVACY_NUMBER_CAMERA_ACCESS_PACKAGES
|
||||
= "enterprise_privacy_number_camera_access_packages";
|
||||
|
||||
public AdminGrantedCameraPermissionPreferenceController(Context context) {
|
||||
super(context, new String[] {Manifest.permission.CAMERA}, Manifest.permission_group.CAMERA);
|
||||
public AdminGrantedCameraPermissionPreferenceController(Context context, Lifecycle lifecycle,
|
||||
boolean async) {
|
||||
super(context, lifecycle, async, new String[] {Manifest.permission.CAMERA},
|
||||
Manifest.permission_group.CAMERA);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -17,14 +17,17 @@ package com.android.settings.enterprise;
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.core.lifecycle.Lifecycle;
|
||||
|
||||
public class AdminGrantedLocationPermissionsPreferenceController extends
|
||||
AdminGrantedPermissionsPreferenceControllerBase {
|
||||
|
||||
private static final String KEY_ENTERPRISE_PRIVACY_NUMBER_LOCATION_ACCESS_PACKAGES
|
||||
= "enterprise_privacy_number_location_access_packages";
|
||||
|
||||
public AdminGrantedLocationPermissionsPreferenceController(Context context) {
|
||||
super(context, new String[] {Manifest.permission.ACCESS_COARSE_LOCATION,
|
||||
public AdminGrantedLocationPermissionsPreferenceController(Context context, Lifecycle lifecycle,
|
||||
boolean async) {
|
||||
super(context, lifecycle, async, new String[] {Manifest.permission.ACCESS_COARSE_LOCATION,
|
||||
Manifest.permission.ACCESS_FINE_LOCATION}, Manifest.permission_group.LOCATION);
|
||||
}
|
||||
|
||||
|
@@ -17,14 +17,17 @@ package com.android.settings.enterprise;
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.core.lifecycle.Lifecycle;
|
||||
|
||||
public class AdminGrantedMicrophonePermissionPreferenceController extends
|
||||
AdminGrantedPermissionsPreferenceControllerBase {
|
||||
|
||||
private static final String KEY_ENTERPRISE_PRIVACY_NUMBER_MICROPHONE_ACCESS_PACKAGES
|
||||
= "enterprise_privacy_number_microphone_access_packages";
|
||||
|
||||
public AdminGrantedMicrophonePermissionPreferenceController(Context context) {
|
||||
super(context, new String[] {Manifest.permission.RECORD_AUDIO},
|
||||
public AdminGrantedMicrophonePermissionPreferenceController(Context context,
|
||||
Lifecycle lifecycle, boolean async) {
|
||||
super(context, lifecycle, async, new String[] {Manifest.permission.RECORD_AUDIO},
|
||||
Manifest.permission_group.MICROPHONE);
|
||||
}
|
||||
|
||||
|
@@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
@@ -20,28 +21,32 @@ import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.core.PreferenceController;
|
||||
import com.android.settings.core.DynamicAvailabilityPreferenceController;
|
||||
import com.android.settings.core.lifecycle.Lifecycle;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
public abstract class AdminGrantedPermissionsPreferenceControllerBase extends PreferenceController {
|
||||
public abstract class AdminGrantedPermissionsPreferenceControllerBase
|
||||
extends DynamicAvailabilityPreferenceController {
|
||||
|
||||
private final String[] mPermissions;
|
||||
private final String mPermissionGroup;
|
||||
private final ApplicationFeatureProvider mFeatureProvider;
|
||||
private final boolean mAsync;
|
||||
|
||||
public AdminGrantedPermissionsPreferenceControllerBase(Context context,
|
||||
String[] permissions,
|
||||
String permissionGroup) {
|
||||
super(context);
|
||||
public AdminGrantedPermissionsPreferenceControllerBase(Context context, Lifecycle lifecycle,
|
||||
boolean async, String[] permissions, String permissionGroup) {
|
||||
super(context, lifecycle);
|
||||
mPermissions = permissions;
|
||||
mPermissionGroup = permissionGroup;
|
||||
mFeatureProvider = FeatureFactory.getFactory(context)
|
||||
.getApplicationFeatureProvider(context);
|
||||
mAsync = async;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
mFeatureProvider.calculateNumberOfAppsWithAdminGrantedPermissions(mPermissions,
|
||||
true /* async */,
|
||||
(num) -> {
|
||||
if (num == 0) {
|
||||
preference.setVisible(false);
|
||||
@@ -55,7 +60,22 @@ public abstract class AdminGrantedPermissionsPreferenceControllerBase extends Pr
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
if (mAsync) {
|
||||
// When called on the main UI thread, we must not block. Since calculating the number of
|
||||
// apps that the admin has granted a given permissions takes a bit of time, we always
|
||||
// return true here and determine the pref's actual visibility asynchronously in
|
||||
// updateState().
|
||||
return true;
|
||||
}
|
||||
|
||||
// When called by the search indexer, we are on a background thread that we can block. Also,
|
||||
// changes to the pref's visibility made in updateState() would not be seen by the indexer.
|
||||
// We block and return synchronously whether the admin has granted the given permissions to
|
||||
// any apps or not.
|
||||
final Boolean[] haveAppsWithAdminGrantedPermissions = { null };
|
||||
mFeatureProvider.calculateNumberOfAppsWithAdminGrantedPermissions(mPermissions,
|
||||
false /* async */, (num) -> haveAppsWithAdminGrantedPermissions[0] = num > 0);
|
||||
return haveAppsWithAdminGrantedPermissions[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -14,30 +14,26 @@
|
||||
package com.android.settings.enterprise;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.core.PreferenceController;
|
||||
import com.android.settings.core.DynamicAvailabilityPreferenceController;
|
||||
import com.android.settings.core.lifecycle.Lifecycle;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
public class AlwaysOnVpnManagedProfilePreferenceController extends PreferenceController {
|
||||
public class AlwaysOnVpnManagedProfilePreferenceController
|
||||
extends DynamicAvailabilityPreferenceController {
|
||||
|
||||
private static final String KEY_ALWAYS_ON_VPN_MANAGED_PROFILE = "always_on_vpn_managed_profile";
|
||||
private final EnterprisePrivacyFeatureProvider mFeatureProvider;
|
||||
|
||||
public AlwaysOnVpnManagedProfilePreferenceController(Context context) {
|
||||
super(context);
|
||||
public AlwaysOnVpnManagedProfilePreferenceController(Context context, Lifecycle lifecycle) {
|
||||
super(context, lifecycle);
|
||||
mFeatureProvider = FeatureFactory.getFactory(context)
|
||||
.getEnterprisePrivacyFeatureProvider(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
preference.setVisible(mFeatureProvider.isAlwaysOnVpnSetInManagedProfile());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
return mFeatureProvider.isAlwaysOnVpnSetInManagedProfile();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -17,16 +17,18 @@ import android.content.Context;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceController;
|
||||
import com.android.settings.core.DynamicAvailabilityPreferenceController;
|
||||
import com.android.settings.core.lifecycle.Lifecycle;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
public class AlwaysOnVpnPrimaryUserPreferenceController extends PreferenceController {
|
||||
public class AlwaysOnVpnPrimaryUserPreferenceController
|
||||
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) {
|
||||
super(context);
|
||||
public AlwaysOnVpnPrimaryUserPreferenceController(Context context, Lifecycle lifecycle) {
|
||||
super(context, lifecycle);
|
||||
mFeatureProvider = FeatureFactory.getFactory(context)
|
||||
.getEnterprisePrivacyFeatureProvider(context);
|
||||
}
|
||||
@@ -36,12 +38,11 @@ public class AlwaysOnVpnPrimaryUserPreferenceController extends PreferenceContro
|
||||
preference.setTitle(mFeatureProvider.isInCompMode()
|
||||
? R.string.enterprise_privacy_always_on_vpn_personal
|
||||
: R.string.enterprise_privacy_always_on_vpn_device);
|
||||
preference.setVisible(mFeatureProvider.isAlwaysOnVpnSetInPrimaryUser());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
return mFeatureProvider.isAlwaysOnVpnSetInPrimaryUser();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.enterprise;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
public class CaCertsCurrentUserPreferenceController extends PreferenceController {
|
||||
|
||||
private static final String CA_CERTS_CURRENT_USER = "ca_certs_current_user";
|
||||
private final EnterprisePrivacyFeatureProvider mFeatureProvider;
|
||||
|
||||
public CaCertsCurrentUserPreferenceController(Context context) {
|
||||
super(context);
|
||||
mFeatureProvider = FeatureFactory.getFactory(context)
|
||||
.getEnterprisePrivacyFeatureProvider(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
final int certs = mFeatureProvider.getNumberOfOwnerInstalledCaCertsInCurrentUser();
|
||||
if (certs == 0) {
|
||||
preference.setVisible(false);
|
||||
return;
|
||||
}
|
||||
preference.setTitle(mFeatureProvider.isInCompMode()
|
||||
? R.string.enterprise_privacy_ca_certs_personal
|
||||
: R.string.enterprise_privacy_ca_certs_user);
|
||||
preference.setSummary(mContext.getResources().getQuantityString(
|
||||
R.plurals.enterprise_privacy_number_ca_certs, certs, certs));
|
||||
preference.setVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return CA_CERTS_CURRENT_USER;
|
||||
}
|
||||
}
|
@@ -19,39 +19,37 @@ import android.content.res.Resources;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceController;
|
||||
import com.android.settings.core.DynamicAvailabilityPreferenceController;
|
||||
import com.android.settings.core.lifecycle.Lifecycle;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
public class CaCertsManagedProfilePreferenceController extends PreferenceController {
|
||||
public class CaCertsPreferenceController extends DynamicAvailabilityPreferenceController {
|
||||
|
||||
private static final String KEY_CA_CERTS_MANAGED_PROFILE = "ca_certs_managed_profile";
|
||||
private static final String CA_CERTS = "ca_certs";
|
||||
private final EnterprisePrivacyFeatureProvider mFeatureProvider;
|
||||
|
||||
public CaCertsManagedProfilePreferenceController(Context context) {
|
||||
super(context);
|
||||
public CaCertsPreferenceController(Context context, Lifecycle lifecycle) {
|
||||
super(context, lifecycle);
|
||||
mFeatureProvider = FeatureFactory.getFactory(context)
|
||||
.getEnterprisePrivacyFeatureProvider(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
final int certs = mFeatureProvider.getNumberOfOwnerInstalledCaCertsInManagedProfile();
|
||||
if (certs == 0) {
|
||||
preference.setVisible(false);
|
||||
return;
|
||||
}
|
||||
final int certs =
|
||||
mFeatureProvider.getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile();
|
||||
preference.setSummary(mContext.getResources().getQuantityString(
|
||||
R.plurals.enterprise_privacy_number_ca_certs, certs, certs));
|
||||
preference.setVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
return mFeatureProvider.getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile()
|
||||
> 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_CA_CERTS_MANAGED_PROFILE;
|
||||
return CA_CERTS;
|
||||
}
|
||||
}
|
@@ -98,15 +98,9 @@ public interface EnterprisePrivacyFeatureProvider {
|
||||
|
||||
/**
|
||||
* Returns the number of CA certificates that the Device Owner or Profile Owner installed in
|
||||
* the current user.
|
||||
* the current user and the user's managed profile (if any).
|
||||
*/
|
||||
int getNumberOfOwnerInstalledCaCertsInCurrentUser();
|
||||
|
||||
/**
|
||||
* Returns the number of CA certificates that the Profile Owner installed in the current user's
|
||||
* managed profile (if any).
|
||||
*/
|
||||
int getNumberOfOwnerInstalledCaCertsInManagedProfile();
|
||||
int getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile();
|
||||
|
||||
/**
|
||||
* Returns the number of Device Admin apps active in the current user and the user's managed
|
||||
|
@@ -189,19 +189,20 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfOwnerInstalledCaCertsInCurrentUser() {
|
||||
final List<String> certs = mDpm.getOwnerInstalledCaCerts(new UserHandle(MY_USER_ID));
|
||||
return certs != null ? certs.size() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfOwnerInstalledCaCertsInManagedProfile() {
|
||||
final int userId = getManagedProfileUserId();
|
||||
if (userId == UserHandle.USER_NULL) {
|
||||
return 0;
|
||||
public int getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile() {
|
||||
int num = 0;
|
||||
List<String> certs = mDpm.getOwnerInstalledCaCerts(new UserHandle(MY_USER_ID));
|
||||
if (certs != null) {
|
||||
num += certs.size();
|
||||
}
|
||||
final List<String> certs = mDpm.getOwnerInstalledCaCerts(new UserHandle(userId));
|
||||
return certs != null ? certs.size() : 0;
|
||||
final int userId = getManagedProfileUserId();
|
||||
if (userId != UserHandle.USER_NULL) {
|
||||
certs = mDpm.getOwnerInstalledCaCerts(new UserHandle(userId));
|
||||
if (certs != null) {
|
||||
num += certs.size();
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -64,18 +64,21 @@ public class EnterprisePrivacySettings extends DashboardFragment {
|
||||
controllers.add(new SecurityLogsPreferenceController(context));
|
||||
controllers.add(new EnterpriseInstalledPackagesPreferenceController(context, lifecycle,
|
||||
async));
|
||||
controllers.add(new AdminGrantedLocationPermissionsPreferenceController(context));
|
||||
controllers.add(new AdminGrantedMicrophonePermissionPreferenceController(context));
|
||||
controllers.add(new AdminGrantedCameraPermissionPreferenceController(context));
|
||||
controllers.add(new AdminGrantedLocationPermissionsPreferenceController(context, lifecycle,
|
||||
async));
|
||||
controllers.add(new AdminGrantedMicrophonePermissionPreferenceController(context, lifecycle,
|
||||
async));
|
||||
controllers.add(new AdminGrantedCameraPermissionPreferenceController(context, lifecycle,
|
||||
async));
|
||||
controllers.add(new EnterpriseSetDefaultAppsPreferenceController(context, lifecycle));
|
||||
controllers.add(new AlwaysOnVpnPrimaryUserPreferenceController(context));
|
||||
controllers.add(new AlwaysOnVpnManagedProfilePreferenceController(context));
|
||||
controllers.add(new GlobalHttpProxyPreferenceController(context));
|
||||
controllers.add(new CaCertsCurrentUserPreferenceController(context));
|
||||
controllers.add(new CaCertsManagedProfilePreferenceController(context));
|
||||
controllers.add(new FailedPasswordWipePrimaryUserPreferenceController(context));
|
||||
controllers.add(new FailedPasswordWipeManagedProfilePreferenceController(context));
|
||||
controllers.add(new ImePreferenceController(context));
|
||||
controllers.add(new AlwaysOnVpnPrimaryUserPreferenceController(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 FailedPasswordWipeManagedProfilePreferenceController(context,
|
||||
lifecycle));
|
||||
controllers.add(new ImePreferenceController(context, lifecycle));
|
||||
return controllers;
|
||||
}
|
||||
|
||||
|
@@ -14,6 +14,7 @@
|
||||
package com.android.settings.enterprise;
|
||||
|
||||
import android.content.Context;
|
||||
import com.android.settings.core.lifecycle.Lifecycle;
|
||||
|
||||
public class FailedPasswordWipeManagedProfilePreferenceController
|
||||
extends FailedPasswordWipePreferenceControllerBase {
|
||||
@@ -21,8 +22,9 @@ public class FailedPasswordWipeManagedProfilePreferenceController
|
||||
private static final String KEY_FAILED_PASSWORD_WIPE_MANAGED_PROFILE
|
||||
= "failed_password_wipe_managed_profile";
|
||||
|
||||
public FailedPasswordWipeManagedProfilePreferenceController(Context context) {
|
||||
super(context);
|
||||
public FailedPasswordWipeManagedProfilePreferenceController(Context context,
|
||||
Lifecycle lifecycle) {
|
||||
super(context, lifecycle);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -19,15 +19,17 @@ import android.content.res.Resources;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceController;
|
||||
import com.android.settings.core.DynamicAvailabilityPreferenceController;
|
||||
import com.android.settings.core.lifecycle.Lifecycle;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
public abstract class FailedPasswordWipePreferenceControllerBase extends PreferenceController {
|
||||
public abstract class FailedPasswordWipePreferenceControllerBase
|
||||
extends DynamicAvailabilityPreferenceController {
|
||||
|
||||
protected final EnterprisePrivacyFeatureProvider mFeatureProvider;
|
||||
|
||||
public FailedPasswordWipePreferenceControllerBase(Context context) {
|
||||
super(context);
|
||||
public FailedPasswordWipePreferenceControllerBase(Context context, Lifecycle lifecycle) {
|
||||
super(context, lifecycle);
|
||||
mFeatureProvider = FeatureFactory.getFactory(context)
|
||||
.getEnterprisePrivacyFeatureProvider(context);
|
||||
}
|
||||
@@ -37,18 +39,13 @@ public abstract class FailedPasswordWipePreferenceControllerBase extends Prefere
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
final int failedPasswordsBeforeWipe = getMaximumFailedPasswordsBeforeWipe();
|
||||
if (failedPasswordsBeforeWipe == 0) {
|
||||
preference.setVisible(false);
|
||||
} else {
|
||||
preference.setVisible(true);
|
||||
preference.setSummary(mContext.getResources().getQuantityString(
|
||||
R.plurals.enterprise_privacy_number_failed_password_wipe,
|
||||
failedPasswordsBeforeWipe, failedPasswordsBeforeWipe));
|
||||
}
|
||||
preference.setSummary(mContext.getResources().getQuantityString(
|
||||
R.plurals.enterprise_privacy_number_failed_password_wipe,
|
||||
failedPasswordsBeforeWipe, failedPasswordsBeforeWipe));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
return getMaximumFailedPasswordsBeforeWipe() > 0;
|
||||
}
|
||||
}
|
||||
|
@@ -15,14 +15,16 @@ package com.android.settings.enterprise;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.core.lifecycle.Lifecycle;
|
||||
|
||||
public class FailedPasswordWipePrimaryUserPreferenceController
|
||||
extends FailedPasswordWipePreferenceControllerBase {
|
||||
|
||||
private static final String KEY_FAILED_PASSWORD_WIPE_PRIMARY_USER
|
||||
= "failed_password_wipe_primary_user";
|
||||
|
||||
public FailedPasswordWipePrimaryUserPreferenceController(Context context) {
|
||||
super(context);
|
||||
public FailedPasswordWipePrimaryUserPreferenceController(Context context, Lifecycle lifecycle) {
|
||||
super(context, lifecycle);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -14,30 +14,25 @@
|
||||
package com.android.settings.enterprise;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.core.PreferenceController;
|
||||
import com.android.settings.core.DynamicAvailabilityPreferenceController;
|
||||
import com.android.settings.core.lifecycle.Lifecycle;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
public class GlobalHttpProxyPreferenceController extends PreferenceController {
|
||||
public class GlobalHttpProxyPreferenceController extends DynamicAvailabilityPreferenceController {
|
||||
|
||||
private static final String KEY_GLOBAL_HTTP_PROXY = "global_http_proxy";
|
||||
private final EnterprisePrivacyFeatureProvider mFeatureProvider;
|
||||
|
||||
public GlobalHttpProxyPreferenceController(Context context) {
|
||||
super(context);
|
||||
public GlobalHttpProxyPreferenceController(Context context, Lifecycle lifecycle) {
|
||||
super(context, lifecycle);
|
||||
mFeatureProvider = FeatureFactory.getFactory(context)
|
||||
.getEnterprisePrivacyFeatureProvider(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
preference.setVisible(mFeatureProvider.isGlobalHttpProxySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
return mFeatureProvider.isGlobalHttpProxySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -19,35 +19,31 @@ import android.content.res.Resources;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceController;
|
||||
import com.android.settings.core.DynamicAvailabilityPreferenceController;
|
||||
import com.android.settings.core.lifecycle.Lifecycle;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
public class ImePreferenceController extends PreferenceController {
|
||||
public class ImePreferenceController extends DynamicAvailabilityPreferenceController {
|
||||
|
||||
private static final String KEY_INPUT_METHOD = "input_method";
|
||||
private final EnterprisePrivacyFeatureProvider mFeatureProvider;
|
||||
|
||||
public ImePreferenceController(Context context) {
|
||||
super(context);
|
||||
public ImePreferenceController(Context context, Lifecycle lifecycle) {
|
||||
super(context, lifecycle);
|
||||
mFeatureProvider = FeatureFactory.getFactory(context)
|
||||
.getEnterprisePrivacyFeatureProvider(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
final String ownerSetIme = mFeatureProvider.getImeLabelIfOwnerSet();
|
||||
if (ownerSetIme == null) {
|
||||
preference.setVisible(false);
|
||||
return;
|
||||
}
|
||||
preference.setSummary(mContext.getResources().getString(
|
||||
R.string.enterprise_privacy_input_method_name, ownerSetIme));
|
||||
preference.setVisible(true);
|
||||
R.string.enterprise_privacy_input_method_name,
|
||||
mFeatureProvider.getImeLabelIfOwnerSet()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
return mFeatureProvider.getImeLabelIfOwnerSet() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user