Merge "Update display text in cert notification" into nyc-dev
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index db5b07a..788a20c 100755
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -296,7 +296,8 @@
* 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 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";
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index dd60778..fa799c9 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -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 />
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 98661cf..e37f8d5 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1095,7 +1095,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" />
@@ -1115,6 +1114,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_sms_enabled_locking_shift_tables" />
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index d229633..72e8bd3 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -211,7 +211,7 @@
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";
@@ -2696,23 +2696,25 @@
// 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);
@@ -2726,7 +2728,8 @@
}
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)