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

Commit b7f4f56c authored by Jonathan Scott's avatar Jonathan Scott
Browse files

Add missing settings strings.

Also re-enable and fix tests.

Test: manual
Fixes: 226183482
Fixes: 218799125
Fixes: 219375624

Change-Id: I9605f1f4e2e834baf63e015e96639567c5481b5f
parent afe6d302
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
    <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/admin_disabled_other_options_text"
            android:text="@string/admin_disabled_other_options" />
    <TextView android:id="@+id/admin_more_details_link"
            android:layout_width="wrap_content"
+8 −8
Original line number Diff line number Diff line
@@ -7613,15 +7613,15 @@
        <item quantity="other">Trust or remove certificates</item>
    </plurals>
    <!-- Text of message to show to device owner user whose administrator has installed a SSL CA Cert.  [CHAR LIMIT=NONE] -->
    <plurals name="ssl_ca_cert_info_message_device_owner">
        <item quantity="one"><xliff:g id="managing_domain">%s</xliff:g> has installed a certificate authority on your device, which may allow them to monitor your device network activity, including emails, apps, and secure websites.\n\nFor more information about this certificate, contact your admin.</item>
        <item quantity="other"><xliff:g id="managing_domain">%s</xliff:g> has installed certificate authorities on your device, which may allow them to monitor your device network activity, including emails, apps, and secure websites.\n\nFor more information about these certificates, contact your admin.</item>
    </plurals>
    <string name="ssl_ca_cert_info_message_device_owner"> {numberOfCertificates, plural,
        =1 {{orgName} has installed a certificate authority on your device, which may allow them to monitor your device network activity, including emails, apps, and secure websites.\n\nFor more information about this certificate, contact your admin.}
        other {{orgName} has installed certificate authorities on your device, which may allow them to monitor your device network activity, including emails, apps, and secure websites.\n\nFor more information about these certificates, contact your admin.}
        }</string>
    <!-- Text of message to show to work profile users whose administrator has installed a SSL CA Cert.  [CHAR LIMIT=NONE] -->
    <plurals name="ssl_ca_cert_info_message">
        <item quantity="one"><xliff:g id="managing_domain">%s</xliff:g> has installed a certificate authority for your work profile, which may allow them to monitor work network activity, including emails, apps, and secure websites.\n\nFor more information about this certificate, contact your admin.</item>
        <item quantity="other"><xliff:g id="managing_domain">%s</xliff:g> has installed certificate authorities for your work profile, which may allow them to monitor work network activity, including emails, apps, and secure websites.\n\nFor more information about these certificates, contact your admin.</item>
    </plurals>
    <string name="ssl_ca_cert_info_message">{numberOfCertificates, plural,
        =1 {{orgName} has installed a certificate authority for your work profile, which may allow them to monitor work network activity, including emails, apps, and secure websites.\n\nFor more information about this certificate, contact your admin.}
        other {{orgName} has installed certificate authorities for your work profile, which may allow them to monitor work network activity, including emails, apps, and secure websites.\n\nFor more information about these certificates, contact your admin.}
        }</string>
    <!-- Text of warning to show to users that have a SSL CA Cert installed.  [CHAR LIMIT=NONE] -->
    <string name="ssl_ca_cert_warning_message">A third party is capable of monitoring your network activity, including emails, apps, and secure websites.\n\nA trusted credential installed on your device is making this possible.</string>
    <!-- Label on button that will take the user to the Trusted Credentials settings page.  [CHAR LIMIT=NONE]-->
+1 −0
Original line number Diff line number Diff line
@@ -23,5 +23,6 @@

    <com.android.settingslib.widget.FooterPreference
            android:title="@string/enterprise_privacy_apps_count_estimation_info"
            android:key="enterprise_privacy_apps_footer"
            android:selectable="false"/>
</PreferenceScreen>
+31 −5
Original line number Diff line number Diff line
@@ -16,12 +16,16 @@

package com.android.settings;

import static android.app.admin.DevicePolicyResources.Strings.Settings.DEVICE_OWNER_INSTALLED_CERTIFICATE_AUTHORITY_WARNING;
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_INSTALLED_CERTIFICATE_AUTHORITY_WARNING;

import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.icu.text.MessageFormat;
import android.os.Bundle;
import android.os.UserHandle;
import android.provider.Settings;
@@ -30,6 +34,10 @@ import androidx.appcompat.app.AlertDialog;

import com.android.settingslib.RestrictedLockUtils;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

/**
 * Activity that shows a dialog explaining that a CA cert is allowing someone to monitor network
 * traffic. This activity should be launched for the user into which the CA cert is installed
@@ -71,12 +79,30 @@ public class MonitoringCertInfoActivity extends Activity implements OnClickListe
        builder.setOnDismissListener(this);

        if (dpm.getProfileOwnerAsUser(mUserId) != null) {
            builder.setMessage(getResources().getQuantityString(R.plurals.ssl_ca_cert_info_message,
                    numberOfCertificates, dpm.getProfileOwnerNameAsUser(mUserId)));
            MessageFormat msgFormat = new MessageFormat(
                    dpm.getResources().getString(
                            WORK_PROFILE_INSTALLED_CERTIFICATE_AUTHORITY_WARNING,
                            () -> getString(R.string.ssl_ca_cert_info_message)),
                    Locale.getDefault());

            Map<String, Object> arguments = new HashMap<>();
            arguments.put("numberOfCertificates", numberOfCertificates);
            arguments.put("orgName", dpm.getProfileOwnerNameAsUser(mUserId));

            builder.setMessage(msgFormat.format(arguments));
        } else if (dpm.getDeviceOwnerComponentOnCallingUser() != null) {
            builder.setMessage(getResources().getQuantityString(
                    R.plurals.ssl_ca_cert_info_message_device_owner, numberOfCertificates,
                    dpm.getDeviceOwnerNameOnAnyUser()));
            MessageFormat msgFormat = new MessageFormat(
                    dpm.getResources()
                            .getString(DEVICE_OWNER_INSTALLED_CERTIFICATE_AUTHORITY_WARNING,
                                    () -> getResources().getString(
                                            R.string.ssl_ca_cert_info_message_device_owner)),
                    Locale.getDefault());

            Map<String, Object> arguments = new HashMap<>();
            arguments.put("numberOfCertificates", numberOfCertificates);
            arguments.put("orgName", dpm.getDeviceOwnerNameOnAnyUser());

            builder.setMessage(msgFormat.format(arguments));
        } else  {
            // Consumer case.  Show scary warning.
            builder.setIcon(android.R.drawable.stat_notify_error);
+34 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.settings;

import android.app.Activity;
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
@@ -70,6 +71,7 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF

    private static final int ORDER_FIRST = -1;

    protected DevicePolicyManager mDevicePolicyManager;
    private SettingsDialogFragment mDialogFragment;
    // Cache the content resolver for async callbacks
    private ContentResolver mContentResolver;
@@ -135,6 +137,7 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);

        mDevicePolicyManager = getContext().getSystemService(DevicePolicyManager.class);
        if (icicle != null) {
            mPreferenceHighlighted = icicle.getBoolean(SAVE_HIGHLIGHTED_KEY);
        }
@@ -728,4 +731,35 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
        final Activity activity = getActivity();
        return activity == null || activity.isFinishing() || activity.isDestroyed();
    }

    protected void replaceEnterprisePreferenceScreenTitle(String overrideKey, int resource) {
        getActivity().setTitle(mDevicePolicyManager.getResources().getString(
                overrideKey, () -> getString(resource)));
    }

    protected void replaceEnterpriseStringSummary(
            String preferenceKey, String overrideKey, int resource) {
        Preference preference = findPreference(preferenceKey);
        if (preference == null) {
            Log.d(TAG, "Could not find enterprise preference " + preferenceKey);
            return;
        }

        preference.setSummary(
                mDevicePolicyManager.getResources().getString(overrideKey,
                        () -> getString(resource)));
    }

    protected void replaceEnterpriseStringTitle(
            String preferenceKey, String overrideKey, int resource) {
        Preference preference = findPreference(preferenceKey);
        if (preference == null) {
            Log.d(TAG, "Could not find enterprise preference " + preferenceKey);
            return;
        }

        preference.setTitle(
                mDevicePolicyManager.getResources().getString(overrideKey,
                        () -> getString(resource)));
    }
}
Loading