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

Commit 4a196252 authored by Bartosz Fabianowski's avatar Bartosz Fabianowski
Browse files

DO Disclosures: Combine personal and work CA cert

It was decided that rather than having two separate items for CA certs
in the personal and work spaces, we should have just one item that
lists the sum of installed certs.

Bug: 32692748
Test: m RunSettingsRoboTests

Change-Id: Ic8a3db214a07992e3970262c2ce91f3df8a87773
parent 479f32e0
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -8243,10 +8243,8 @@
    <string name="enterprise_privacy_always_on_vpn_work">Always-on VPN turned on in your work profile</string>
    <!-- Label explaining that a global HTTP proxy was set by the admin. [CHAR LIMIT=NONE] -->
    <string name="enterprise_privacy_global_http_proxy">Global HTTP proxy set</string>
    <!-- Label explaining that the admin installed trusted CA certificates for the current user. [CHAR LIMIT=NONE] -->
    <string name="enterprise_privacy_ca_certs_user">Trusted credentials</string>
    <!-- Label explaining that the admin installed trusted CA certificates for the personal profile. [CHAR LIMIT=NONE] -->
    <string name="enterprise_privacy_ca_certs_personal">Trusted credentials in your personal profile</string>
    <!-- Label explaining that the admin installed trusted CA certificates. [CHAR LIMIT=NONE] -->
    <string name="enterprise_privacy_ca_certs">Trusted credentials</string>
    <!-- Summary indicating the number of trusted CA certificates installed by the admin. [CHAR LIMIT=NONE] -->
    <plurals name="enterprise_privacy_number_ca_certs">
        <item quantity="one"><xliff:g id="count">%d</xliff:g> CA certificate</item>
@@ -8257,8 +8255,6 @@
        <item quantity="one"><xliff:g id="count">%d</xliff:g> CA certificate. Tap to view.</item>
        <item quantity="other"><xliff:g id="count">%d</xliff:g> CA certificates. Tap to view.</item>
    </plurals>
    <!-- Label explaining that the admin installed trusted CA certificates for the work profile. [CHAR LIMIT=NONE] -->
    <string name="enterprise_privacy_ca_certs_work">Trusted credentials in your work profile</string>
    <!-- Label explaining that the admin can lock the device and change the user's password. [CHAR LIMIT=NONE] -->
    <string name="enterprise_privacy_lock_device">Admin can lock the device and reset password</string>
    <!-- Label explaining that the admin can wipe the device remotely. [CHAR LIMIT=NONE] -->
+2 −5
Original line number Diff line number Diff line
@@ -90,11 +90,8 @@
                android:title="@string/enterprise_privacy_global_http_proxy"
                settings:multiLine="true"/>
        <com.android.settings.DividerPreference
                android:key="ca_certs_current_user"
                settings:multiLine="true"/>
        <com.android.settings.DividerPreference
                android:key="ca_certs_managed_profile"
                android:title="@string/enterprise_privacy_ca_certs_work"
                android:key="ca_certs"
                android:title="@string/enterprise_privacy_ca_certs"
                settings:multiLine="true"/>
    </PreferenceCategory>

+0 −60
Original line number Diff line number Diff line
/*
 * 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;
    }
}
+6 −5
Original line number Diff line number Diff line
@@ -22,12 +22,12 @@ import com.android.settings.R;
import com.android.settings.core.PreferenceController;
import com.android.settings.overlay.FeatureFactory;

public class CaCertsManagedProfilePreferenceController extends PreferenceController {
public class CaCertsPreferenceController extends PreferenceController {

    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) {
    public CaCertsPreferenceController(Context context) {
        super(context);
        mFeatureProvider = FeatureFactory.getFactory(context)
                .getEnterprisePrivacyFeatureProvider(context);
@@ -35,7 +35,8 @@ public class CaCertsManagedProfilePreferenceController extends PreferenceControl

    @Override
    public void updateState(Preference preference) {
        final int certs = mFeatureProvider.getNumberOfOwnerInstalledCaCertsInManagedProfile();
        final int certs =
                mFeatureProvider.getNumberOfOwnerInstalledCaCertsForCurrentUserAndManagedProfile();
        if (certs == 0) {
            preference.setVisible(false);
            return;
@@ -52,6 +53,6 @@ public class CaCertsManagedProfilePreferenceController extends PreferenceControl

    @Override
    public String getPreferenceKey() {
        return KEY_CA_CERTS_MANAGED_PROFILE;
        return CA_CERTS;
    }
}
+2 −8
Original line number Diff line number Diff line
@@ -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
Loading