diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index f4d63acdb4e88..bc6fb04eb43f4 100755 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -296,7 +296,8 @@ public final class Settings { * monitoring of encrypted network traffic. *

* 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. *

* Input: Nothing. *

@@ -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 + *

+ * 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 b4f95dcbd8f68..65bc41dd40654 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -349,18 +349,18 @@ - Network may be monitored - + + Certificate authority installed + Certificate authorities installed + + By an unknown third party - + By your work profile administrator - + By %s diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 1e10f863f0fbe..182dac64dc05b 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1108,7 +1108,6 @@ - @@ -1128,6 +1127,7 @@ + diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 0d4887d65cfed..c564124be2889 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -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)