A separate entry for work profile CA cert
We mixed both primary and work profile CA certs into single entry previously which is not aligned with the CTS requirement. Separate them from now. Test: m -j RoboSettingsTest Test: Run related manual test in CtsVerifier Bug: 64567417 Change-Id: Iaff2d9f25ef15b96c11727e7075bdae8e90ec8ce
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.support.annotation.VisibleForTesting;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
public class CaCertsCurrentUserPreferenceController extends CaCertsPreferenceControllerBase {
|
||||
|
||||
@VisibleForTesting
|
||||
static final String CA_CERTS_CURRENT_USER = "ca_certs_current_user";
|
||||
|
||||
public CaCertsCurrentUserPreferenceController(Context context,
|
||||
Lifecycle lifecycle) {
|
||||
super(context, lifecycle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return CA_CERTS_CURRENT_USER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
preference.setTitle(mFeatureProvider.isInCompMode()
|
||||
? R.string.enterprise_privacy_ca_certs_personal
|
||||
: R.string.enterprise_privacy_ca_certs_device);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNumberOfCaCerts() {
|
||||
return mFeatureProvider.getNumberOfOwnerInstalledCaCertsForCurrentUser();
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.support.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
public class CaCertsManagedProfilePreferenceController extends CaCertsPreferenceControllerBase {
|
||||
|
||||
@VisibleForTesting
|
||||
static final String CA_CERTS_MANAGED_PROFILE = "ca_certs_managed_profile";
|
||||
|
||||
public CaCertsManagedProfilePreferenceController(Context context,
|
||||
Lifecycle lifecycle) {
|
||||
super(context, lifecycle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return CA_CERTS_MANAGED_PROFILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNumberOfCaCerts() {
|
||||
return mFeatureProvider.getNumberOfOwnerInstalledCaCertsForManagedProfile();
|
||||
}
|
||||
}
|
@@ -15,7 +15,6 @@
|
||||
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;
|
||||
@@ -23,12 +22,12 @@ import com.android.settings.core.DynamicAvailabilityPreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
public class CaCertsPreferenceController extends DynamicAvailabilityPreferenceController {
|
||||
public abstract class CaCertsPreferenceControllerBase
|
||||
extends DynamicAvailabilityPreferenceController {
|
||||
|
||||
private static final String CA_CERTS = "ca_certs";
|
||||
private final EnterprisePrivacyFeatureProvider mFeatureProvider;
|
||||
protected final EnterprisePrivacyFeatureProvider mFeatureProvider;
|
||||
|
||||
public CaCertsPreferenceController(Context context, Lifecycle lifecycle) {
|
||||
public CaCertsPreferenceControllerBase(Context context, Lifecycle lifecycle) {
|
||||
super(context, lifecycle);
|
||||
mFeatureProvider = FeatureFactory.getFactory(context)
|
||||
.getEnterprisePrivacyFeatureProvider(context);
|
||||
@@ -36,23 +35,17 @@ public class CaCertsPreferenceController extends DynamicAvailabilityPreferenceCo
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
final int certs =
|
||||
mFeatureProvider.getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile();
|
||||
final int certs = getNumberOfCaCerts();
|
||||
preference.setSummary(mContext.getResources().getQuantityString(
|
||||
R.plurals.enterprise_privacy_number_ca_certs, certs, certs));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
final boolean available =
|
||||
mFeatureProvider.getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile()
|
||||
> 0;
|
||||
final boolean available = getNumberOfCaCerts() > 0;
|
||||
notifyOnAvailabilityUpdate(available);
|
||||
return available;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return CA_CERTS;
|
||||
}
|
||||
protected abstract int getNumberOfCaCerts();
|
||||
}
|
@@ -109,9 +109,15 @@ public interface EnterprisePrivacyFeatureProvider {
|
||||
|
||||
/**
|
||||
* Returns the number of CA certificates that the Device Owner or Profile Owner installed in
|
||||
* the current user and the user's managed profile (if any).
|
||||
* current user.
|
||||
*/
|
||||
int getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile();
|
||||
int getNumberOfOwnerInstalledCaCertsForCurrentUser();
|
||||
|
||||
/**
|
||||
* Returns the number of CA certificates that the Device Owner or Profile Owner installed in
|
||||
* the current user's managed profile (if any).
|
||||
*/
|
||||
int getNumberOfOwnerInstalledCaCertsForManagedProfile();
|
||||
|
||||
/**
|
||||
* Returns the number of Device Admin apps active in the current user and the user's managed
|
||||
|
@@ -200,20 +200,25 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile() {
|
||||
int num = 0;
|
||||
List<String> certs = mDpm.getOwnerInstalledCaCerts(new UserHandle(MY_USER_ID));
|
||||
if (certs != null) {
|
||||
num += certs.size();
|
||||
public int getNumberOfOwnerInstalledCaCertsForCurrentUser() {
|
||||
final List<String> certs = mDpm.getOwnerInstalledCaCerts(new UserHandle(MY_USER_ID));
|
||||
if (certs == null) {
|
||||
return 0;
|
||||
}
|
||||
return certs.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfOwnerInstalledCaCertsForManagedProfile() {
|
||||
final int userId = getManagedProfileUserId();
|
||||
if (userId != UserHandle.USER_NULL) {
|
||||
certs = mDpm.getOwnerInstalledCaCerts(new UserHandle(userId));
|
||||
if (certs != null) {
|
||||
num += certs.size();
|
||||
}
|
||||
if (userId == UserHandle.USER_NULL) {
|
||||
return 0;
|
||||
}
|
||||
return num;
|
||||
final List<String> certs = mDpm.getOwnerInstalledCaCerts(new UserHandle(userId));
|
||||
if (certs == null) {
|
||||
return 0;
|
||||
}
|
||||
return certs.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -82,7 +82,10 @@ public class EnterprisePrivacySettings extends DashboardFragment {
|
||||
exposureChangesCategoryControllers.add(new ImePreferenceController(context, lifecycle));
|
||||
exposureChangesCategoryControllers.add(new GlobalHttpProxyPreferenceController(context,
|
||||
lifecycle));
|
||||
exposureChangesCategoryControllers.add(new CaCertsPreferenceController(context, lifecycle));
|
||||
exposureChangesCategoryControllers.add(new CaCertsCurrentUserPreferenceController(
|
||||
context, lifecycle));
|
||||
exposureChangesCategoryControllers.add(new CaCertsManagedProfilePreferenceController(
|
||||
context, lifecycle));
|
||||
controllers.addAll(exposureChangesCategoryControllers);
|
||||
controllers.add(new ExposureChangesCategoryPreferenceController(context, lifecycle,
|
||||
exposureChangesCategoryControllers, async));
|
||||
|
Reference in New Issue
Block a user