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

Commit 355d4769 authored by Victor Chang's avatar Victor Chang
Browse files

Update display text in cert notification

- Show DPC app name for PO
- Check user id for DO
- Update notification title for all cases
- update symbols for private resource ssl_ca_cert_warning changed from string to plural
- Pass number of certificate to MonitoringCertInfoActivity

Bug: 25772443
Bug: 18224038
Change-Id: I68db06f55a24879c1d5f532e38b97e2932bf990e
parent 36712853
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -296,7 +296,8 @@ public final class Settings {
     * monitoring of encrypted network traffic.
     * <p>
     * In some cases, a matching Activity may not exist, so ensure you
     * safeguard against this.
     * safeguard against this. Add {@link #EXTRA_NUMBER_OF_CERTIFICATES} extra to indicate the
     * number of certificates.
     * <p>
     * Input: Nothing.
     * <p>
@@ -1369,6 +1370,16 @@ public final class Settings {
    public static final String EXTRA_DO_NOT_DISTURB_MODE_MINUTES =
            "android.settings.extra.do_not_disturb_mode_minutes";

    /**
     * Activity Extra: Number of certificates
     * <p>
     * This can be passed as an extra field to the {@link #ACTION_MONITORING_CERT_INFO}
     * intent to indicate the number of certificates
     * @hide
     */
    public static final String EXTRA_NUMBER_OF_CERTIFICATES =
            "android.settings.extra.number_of_certificates";

    private static final String JID_RESOURCE_PREFIX = "android";

    public static final String AUTHORITY = "settings";
+10 −10
Original line number Diff line number Diff line
@@ -349,18 +349,18 @@
    <!-- SSL CA cert notification --> <skip />
    <!-- Shows up when there is a user SSL CA Cert installed on the
         device.  Indicates to the user that SSL traffic can be intercepted.  [CHAR LIMIT=NONE] -->
    <string name="ssl_ca_cert_warning">Network may be monitored</string>
    <!-- Content text for a notification. The Title of the notification is "ssl_ca_cert_warning",
         i.e. "Network may be monitored". This says that an unknown party is doing the monitoring.
         [CHAR LIMIT=100]-->
    <plurals name="ssl_ca_cert_warning">
        <item quantity="one">Certificate authority installed</item>
        <item quantity="other">Certificate authorities installed</item>
    </plurals>
    <!-- Content text for a notification. The Title of the notification is "ssl_ca_cert_warning".
         This says that an unknown party is doing the monitoring. [CHAR LIMIT=100]-->
    <string name="ssl_ca_cert_noti_by_unknown">By an unknown third party</string>
    <!-- Content text for a notification. The Title of the notification is "ssl_ca_cert_warning",
        i.e. "Network may be monitored". This indicates that an unspecified administrator is doing
        the monitoring. [CHAR LIMIT=100]-->
    <!-- Content text for a notification. The Title of the notification is "ssl_ca_cert_warning".
         This indicates that an unspecified administrator is doing the monitoring. [CHAR LIMIT=100]-->
    <string name="ssl_ca_cert_noti_by_administrator">By your work profile administrator</string>
    <!-- Content text for a notification. The Title of the notification is "ssl_ca_cert_warning",
         i.e. "Network may be monitored". This indicates who is doing the monitoring.
         [CHAR LIMIT=100]-->
    <!-- Content text for a notification. The Title of the notification is "ssl_ca_cert_warning".
         This indicates who is doing the monitoring. [CHAR LIMIT=100]-->
    <string name="ssl_ca_cert_noti_managed">By <xliff:g id="managing_domain">%s</xliff:g></string>

    <!-- Work profile deleted notification--> <skip />
+1 −1
Original line number Diff line number Diff line
@@ -1108,7 +1108,6 @@
  <java-symbol type="string" name="ssl_ca_cert_noti_by_unknown" />
  <java-symbol type="string" name="ssl_ca_cert_noti_by_administrator" />
  <java-symbol type="string" name="ssl_ca_cert_noti_managed" />
  <java-symbol type="string" name="ssl_ca_cert_warning" />
  <java-symbol type="string" name="work_profile_deleted" />
  <java-symbol type="string" name="work_profile_deleted_description" />
  <java-symbol type="string" name="work_profile_deleted_details" />
@@ -1128,6 +1127,7 @@
  <java-symbol type="plurals" name="matches_found" />
  <java-symbol type="plurals" name="restr_pin_countdown" />
  <java-symbol type="plurals" name="pinpuk_attempts" />
  <java-symbol type="plurals" name="ssl_ca_cert_warning" />

  <java-symbol type="array" name="carrier_properties" />
  <java-symbol type="array" name="config_data_usage_network_types" />
+11 −8
Original line number Diff line number Diff line
@@ -215,7 +215,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
    private static final String ACTION_EXPIRED_PASSWORD_NOTIFICATION
            = "com.android.server.ACTION_EXPIRED_PASSWORD_NOTIFICATION";

    private static final int MONITORING_CERT_NOTIFICATION_ID = R.string.ssl_ca_cert_warning;
    private static final int MONITORING_CERT_NOTIFICATION_ID = R.plurals.ssl_ca_cert_warning;
    private static final int PROFILE_WIPED_NOTIFICATION_ID = 1001;

    private static final String ATTR_PERMISSION_PROVIDER = "permission-provider";
@@ -2703,23 +2703,25 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
            // Build and show a warning notification
            int smallIconId;
            String contentText;
            // TODO Why does it use the DO name?  The cert APIs are all for PO. b/25772443
            final String ownerName = getDeviceOwnerName();
            if (isManagedProfile(userHandle.getIdentifier())) {
                contentText = mContext.getString(R.string.ssl_ca_cert_noti_by_administrator);
            if (getProfileOwner(userHandle.getIdentifier()) != null) {
                contentText = mContext.getString(R.string.ssl_ca_cert_noti_managed,
                        getProfileOwnerName(userHandle.getIdentifier()));
                smallIconId = R.drawable.stat_sys_certificate_info;
            } else if (ownerName != null) {
                contentText = mContext.getString(R.string.ssl_ca_cert_noti_managed, ownerName);
            } else if (getDeviceOwnerUserId() == userHandle.getIdentifier()) {
                contentText = mContext.getString(R.string.ssl_ca_cert_noti_managed,
                        getDeviceOwnerName());
                smallIconId = R.drawable.stat_sys_certificate_info;
            } else {
                contentText = mContext.getString(R.string.ssl_ca_cert_noti_by_unknown);
                smallIconId = android.R.drawable.stat_sys_warning;
            }

            final int numberOfCertificates = pendingCertificates.size();
            Intent dialogIntent = new Intent(Settings.ACTION_MONITORING_CERT_INFO);
            dialogIntent.setFlags(
                    Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
            dialogIntent.setPackage("com.android.settings");
            dialogIntent.putExtra(Settings.EXTRA_NUMBER_OF_CERTIFICATES, numberOfCertificates);
            PendingIntent notifyIntent = PendingIntent.getActivityAsUser(mContext, 0,
                    dialogIntent, PendingIntent.FLAG_UPDATE_CURRENT, null, userHandle);

@@ -2733,7 +2735,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
            }
            final Notification noti = new Notification.Builder(userContext)
                .setSmallIcon(smallIconId)
                .setContentTitle(mContext.getString(R.string.ssl_ca_cert_warning))
                .setContentTitle(mContext.getResources().getQuantityText(
                        R.plurals.ssl_ca_cert_warning, numberOfCertificates))
                .setContentText(contentText)
                .setContentIntent(notifyIntent)
                .setPriority(Notification.PRIORITY_HIGH)