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

Commit c74bbcd3 authored by Tony Mak's avatar Tony Mak
Browse files

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
parent 6c9a1262
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -8878,8 +8878,12 @@
    <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. [CHAR LIMIT=NONE] -->
    <string name="enterprise_privacy_ca_certs">Trusted credentials</string>
    <!-- Label explaining that the admin installed trusted CA certificates for the entire device. [CHAR LIMIT=NONE] -->
    <string name="enterprise_privacy_ca_certs_device">Trusted credentials</string>
    <!-- Label explaining that the admin installed trusted CA certificates in 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 in work profile. [CHAR LIMIT=NONE] -->
    <string name="enterprise_privacy_ca_certs_work">Trusted credentials in your work profile</string>
    <!-- Summary indicating the number of trusted CA certificates installed by the admin. The number shown is a minimum as there may be additional CA certificates we do not know about. [CHAR LIMIT=NONE] -->
    <plurals name="enterprise_privacy_number_ca_certs">
        <item quantity="one">Minimum <xliff:g id="count">%d</xliff:g> CA certificate</item>
+5 −2
Original line number Diff line number Diff line
@@ -77,8 +77,11 @@
        <Preference android:key="global_http_proxy"
                    android:title="@string/enterprise_privacy_global_http_proxy"
                    android:selectable="false"/>
        <Preference android:key="ca_certs"
                    android:title="@string/enterprise_privacy_ca_certs"
        <Preference android:key="ca_certs_current_user"
                    android:title="@string/enterprise_privacy_ca_certs_personal"
                    android:selectable="false"/>
        <Preference android:key="ca_certs_managed_profile"
                    android:title="@string/enterprise_privacy_ca_certs_work"
                    android:selectable="false"/>
    </PreferenceCategory>

+52 −0
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.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();
    }
}
+41 −0
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.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();
    }
}
+7 −14
Original line number Diff line number Diff line
@@ -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();
}
Loading