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

Commit 5ec27474 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add CA certs Privacy Settings page"

parents a8855922 732d6959
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -8185,6 +8185,21 @@
    <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] -->
    <plurals name="enterprise_privacy_ca_certs_user">
        <item quantity="one"><xliff:g id="count">%d</xliff:g> trusted CA certificate installed</item>
        <item quantity="other"><xliff:g id="count">%d</xliff:g> trusted CA certificates installed</item>
    </plurals>
    <!-- Label explaining that the admin installed trusted CA certificates for the personal profile. [CHAR LIMIT=NONE] -->
    <plurals name="enterprise_privacy_ca_certs_personal">
        <item quantity="one"><xliff:g id="count">%d</xliff:g> trusted CA certificate installed in the personal profile</item>
        <item quantity="other"><xliff:g id="count">%d</xliff:g> trusted CA certificates installed in the personal profile</item>
    </plurals>
    <!-- Label explaining that the admin installed trusted CA certificates for the work profile. [CHAR LIMIT=NONE] -->
    <plurals name="enterprise_privacy_ca_certs_work">
        <item quantity="one"><xliff:g id="count">%d</xliff:g> trusted CA certificate installed in the work profile</item>
        <item quantity="other"><xliff:g id="count">%d</xliff:g> trusted CA certificates installed in the work profile</item>
    </plurals>
    <!-- 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 device and reset password</string>
    <!-- Label explaining that the admin can wipe the device remotely. [CHAR LIMIT=NONE] -->
+8 −0
Original line number Diff line number Diff line
@@ -97,6 +97,14 @@
                android:title="@string/enterprise_privacy_global_http_proxy"
                settings:allowDividerBelow="true"
                settings:multiLine="true"/>
        <com.android.settings.DividerPreference
                android:key="ca_certs_current_user"
                settings:allowDividerBelow="true"
                settings:multiLine="true"/>
        <com.android.settings.DividerPreference
                android:key="ca_certs_managed_profile"
                settings:allowDividerBelow="true"
                settings:multiLine="true"/>
    </PreferenceCategory>

    <PreferenceCategory android:title="@string/enterprise_privacy_device_access_category">
+58 −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.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(mContext.getResources().getQuantityString(
                mFeatureProvider.isInCompMode() ? R.plurals.enterprise_privacy_ca_certs_personal
                        : R.plurals.enterprise_privacy_ca_certs_user, certs, certs));
        preference.setVisible(true);
    }

    @Override
    public boolean isAvailable() {
        return true;
    }

    @Override
    public String getPreferenceKey() {
        return CA_CERTS_CURRENT_USER;
    }
}
+57 −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.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 CaCertsManagedProfilePreferenceController extends PreferenceController {

    private static final String KEY_CA_CERTS_MANAGED_PROFILE = "ca_certs_managed_profile";
    private final EnterprisePrivacyFeatureProvider mFeatureProvider;

    public CaCertsManagedProfilePreferenceController(Context context) {
        super(context);
        mFeatureProvider = FeatureFactory.getFactory(context)
                .getEnterprisePrivacyFeatureProvider(context);
    }

    @Override
    public void updateState(Preference preference) {
        final int certs = mFeatureProvider.getNumberOfOwnerInstalledCaCertsInManagedProfile();
        if (certs == 0) {
            preference.setVisible(false);
            return;
        }
        preference.setTitle(mContext.getResources().getQuantityString(
                R.plurals.enterprise_privacy_ca_certs_work, certs, certs));
        preference.setVisible(true);
    }

    @Override
    public boolean isAvailable() {
        return true;
    }

    @Override
    public String getPreferenceKey() {
        return KEY_CA_CERTS_MANAGED_PROFILE;
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -16,10 +16,13 @@

package com.android.settings.enterprise;

import android.annotation.NonNull;
import android.content.ComponentName;
import android.os.UserHandle;
import android.support.annotation.Nullable;

import java.util.List;

/**
 * This interface replicates a subset of the android.app.admin.DevicePolicyManager (DPM). The
 * interface exists so that we can use a thin wrapper around the DPM in production code and a mock
@@ -97,4 +100,12 @@ public interface DevicePolicyManagerWrapper {
     * @see android.app.admin.DevicePolicyManager#isCurrentInputMethodSetByOwner
     */
    boolean isCurrentInputMethodSetByOwner();


    /**
     * Calls {@code DevicePolicyManager.getOwnerInstalledCaCerts()}.
     *
     * @see android.app.admin.DevicePolicyManager#getOwnerInstalledCaCerts
     */
    List<String> getOwnerInstalledCaCerts(@NonNull UserHandle user);
}
Loading