Merge "Add missing enterprise updatable strings in SysUI" into tm-dev

This commit is contained in:
Kholoud Mohamed
2022-05-12 11:44:21 +00:00
committed by Android (Google) Code Review
4 changed files with 163 additions and 44 deletions

View File

@@ -1498,6 +1498,45 @@ public final class DevicePolicyResources {
* Content description for the work profile lock screen. * Content description for the work profile lock screen.
*/ */
public static final String WORK_LOCK_ACCESSIBILITY = PREFIX + "WORK_LOCK_ACCESSIBILITY"; public static final String WORK_LOCK_ACCESSIBILITY = PREFIX + "WORK_LOCK_ACCESSIBILITY";
/**
* Notification text displayed when screenshots are blocked by an IT admin.
*/
public static final String SCREENSHOT_BLOCKED_BY_ADMIN =
PREFIX + "SCREENSHOT_BLOCKED_BY_ADMIN";
/**
* Message shown when user is almost at the limit of password attempts where the
* profile will be removed. Accepts number of failed attempts and remaining failed
* attempts as params.
*/
public static final String KEYGUARD_DIALOG_FAILED_ATTEMPTS_ALMOST_ERASING_PROFILE =
PREFIX + "KEYGUARD_DIALOG_FAILED_ATTEMPTS_ALMOST_ERASING_PROFILE";
/**
* Message shown in dialog when user has exceeded the maximum attempts and the profile
* will be removed. Accepts number of failed attempts as a param.
*/
public static final String KEYGUARD_DIALOG_FAILED_ATTEMPTS_ERASING_PROFILE =
PREFIX + "KEYGUARD_DIALOG_FAILED_ATTEMPTS_ERASING_PROFILE";
/**
* Monitoring dialog subtitle for the section describing VPN.
*/
public static final String QS_DIALOG_MONITORING_VPN_SUBTITLE =
PREFIX + "QS_DIALOG_MONITORING_VPN_SUBTITLE";
/**
* Monitoring dialog subtitle for the section describing network logging.
*/
public static final String QS_DIALOG_MONITORING_NETWORK_SUBTITLE =
PREFIX + "QS_DIALOG_MONITORING_NETWORK_SUBTITLE";
/**
* Monitoring dialog subtitle for the section describing certificate authorities.
*/
public static final String QS_DIALOG_MONITORING_CA_CERT_SUBTITLE =
PREFIX + "QS_DIALOG_MONITORING_CA_CERT_SUBTITLE";
} }
/** /**

View File

@@ -15,6 +15,8 @@
*/ */
package com.android.keyguard; package com.android.keyguard;
import static android.app.admin.DevicePolicyResources.Strings.SystemUi.KEYGUARD_DIALOG_FAILED_ATTEMPTS_ALMOST_ERASING_PROFILE;
import static android.app.admin.DevicePolicyResources.Strings.SystemUi.KEYGUARD_DIALOG_FAILED_ATTEMPTS_ERASING_PROFILE;
import static android.view.WindowInsets.Type.ime; import static android.view.WindowInsets.Type.ime;
import static android.view.WindowInsets.Type.systemBars; import static android.view.WindowInsets.Type.systemBars;
import static android.view.WindowInsetsAnimation.Callback.DISPATCH_MODE_STOP; import static android.view.WindowInsetsAnimation.Callback.DISPATCH_MODE_STOP;
@@ -32,6 +34,7 @@ import android.animation.ObjectAnimator;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
@@ -676,7 +679,11 @@ public class KeyguardSecurityContainer extends FrameLayout {
attempts, remaining); attempts, remaining);
break; break;
case USER_TYPE_WORK_PROFILE: case USER_TYPE_WORK_PROFILE:
message = mContext.getString(R.string.kg_failed_attempts_almost_at_erase_profile, message = mContext.getSystemService(DevicePolicyManager.class).getResources()
.getString(KEYGUARD_DIALOG_FAILED_ATTEMPTS_ALMOST_ERASING_PROFILE,
() -> mContext.getString(
R.string.kg_failed_attempts_almost_at_erase_profile,
attempts, remaining),
attempts, remaining); attempts, remaining);
break; break;
} }
@@ -695,7 +702,10 @@ public class KeyguardSecurityContainer extends FrameLayout {
attempts); attempts);
break; break;
case USER_TYPE_WORK_PROFILE: case USER_TYPE_WORK_PROFILE:
message = mContext.getString(R.string.kg_failed_attempts_now_erasing_profile, message = mContext.getSystemService(DevicePolicyManager.class).getResources()
.getString(KEYGUARD_DIALOG_FAILED_ATTEMPTS_ERASING_PROFILE,
() -> mContext.getString(
R.string.kg_failed_attempts_now_erasing_profile, attempts),
attempts); attempts);
break; break;
} }

View File

@@ -22,6 +22,9 @@ import static android.app.admin.DevicePolicyResources.Strings.SystemUi.QS_DIALOG
import static android.app.admin.DevicePolicyResources.Strings.SystemUi.QS_DIALOG_MANAGEMENT_NETWORK; import static android.app.admin.DevicePolicyResources.Strings.SystemUi.QS_DIALOG_MANAGEMENT_NETWORK;
import static android.app.admin.DevicePolicyResources.Strings.SystemUi.QS_DIALOG_MANAGEMENT_TITLE; import static android.app.admin.DevicePolicyResources.Strings.SystemUi.QS_DIALOG_MANAGEMENT_TITLE;
import static android.app.admin.DevicePolicyResources.Strings.SystemUi.QS_DIALOG_MANAGEMENT_TWO_NAMED_VPN; import static android.app.admin.DevicePolicyResources.Strings.SystemUi.QS_DIALOG_MANAGEMENT_TWO_NAMED_VPN;
import static android.app.admin.DevicePolicyResources.Strings.SystemUi.QS_DIALOG_MONITORING_CA_CERT_SUBTITLE;
import static android.app.admin.DevicePolicyResources.Strings.SystemUi.QS_DIALOG_MONITORING_NETWORK_SUBTITLE;
import static android.app.admin.DevicePolicyResources.Strings.SystemUi.QS_DIALOG_MONITORING_VPN_SUBTITLE;
import static android.app.admin.DevicePolicyResources.Strings.SystemUi.QS_DIALOG_NAMED_MANAGEMENT; import static android.app.admin.DevicePolicyResources.Strings.SystemUi.QS_DIALOG_NAMED_MANAGEMENT;
import static android.app.admin.DevicePolicyResources.Strings.SystemUi.QS_DIALOG_PERSONAL_PROFILE_NAMED_VPN; import static android.app.admin.DevicePolicyResources.Strings.SystemUi.QS_DIALOG_PERSONAL_PROFILE_NAMED_VPN;
import static android.app.admin.DevicePolicyResources.Strings.SystemUi.QS_DIALOG_VIEW_POLICIES; import static android.app.admin.DevicePolicyResources.Strings.SystemUi.QS_DIALOG_VIEW_POLICIES;
@@ -92,6 +95,7 @@ import com.android.systemui.statusbar.policy.SecurityController;
import com.android.systemui.util.ViewController; import com.android.systemui.util.ViewController;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
@@ -106,7 +110,7 @@ class QSSecurityFooter extends ViewController<View>
private final TextView mFooterText; private final TextView mFooterText;
private final ImageView mPrimaryFooterIcon; private final ImageView mPrimaryFooterIcon;
private final Context mContext; private Context mContext;
private final DevicePolicyManager mDpm; private final DevicePolicyManager mDpm;
private final Callback mCallback = new Callback(); private final Callback mCallback = new Callback();
private final SecurityController mSecurityController; private final SecurityController mSecurityController;
@@ -141,6 +145,63 @@ class QSSecurityFooter extends ViewController<View>
} }
}; };
private Supplier<String> mManagementTitleSupplier = () ->
mContext == null ? null : mContext.getString(R.string.monitoring_title_device_owned);
private Supplier<String> mManagementMessageSupplier = () ->
mContext == null ? null : mContext.getString(
R.string.quick_settings_disclosure_management);
private Supplier<String> mManagementMonitoringStringSupplier = () ->
mContext == null ? null : mContext.getString(
R.string.quick_settings_disclosure_management_monitoring);
private Supplier<String> mManagementMultipleVpnStringSupplier = () ->
mContext == null ? null : mContext.getString(
R.string.quick_settings_disclosure_management_vpns);
private Supplier<String> mWorkProfileMonitoringStringSupplier = () ->
mContext == null ? null : mContext.getString(
R.string.quick_settings_disclosure_managed_profile_monitoring);
private Supplier<String> mWorkProfileNetworkStringSupplier = () ->
mContext == null ? null : mContext.getString(
R.string.quick_settings_disclosure_managed_profile_network_activity);
private Supplier<String> mMonitoringSubtitleCaCertStringSupplier = () ->
mContext == null ? null : mContext.getString(
R.string.monitoring_subtitle_ca_certificate);
private Supplier<String> mMonitoringSubtitleNetworkStringSupplier = () ->
mContext == null ? null : mContext.getString(
R.string.monitoring_subtitle_network_logging);
private Supplier<String> mMonitoringSubtitleVpnStringSupplier = () ->
mContext == null ? null : mContext.getString(R.string.monitoring_subtitle_vpn);
private Supplier<String> mViewPoliciesButtonStringSupplier = () ->
mContext == null ? null : mContext.getString(R.string.monitoring_button_view_policies);
private Supplier<String> mManagementDialogStringSupplier = () ->
mContext == null ? null : mContext.getString(
R.string.monitoring_description_management);
private Supplier<String> mManagementDialogCaCertStringSupplier = () ->
mContext == null ? null : mContext.getString(
R.string.monitoring_description_management_ca_certificate);
private Supplier<String> mWorkProfileDialogCaCertStringSupplier = () ->
mContext == null ? null : mContext.getString(
R.string.monitoring_description_managed_profile_ca_certificate);
private Supplier<String> mManagementDialogNetworkStringSupplier = () ->
mContext == null ? null : mContext.getString(
R.string.monitoring_description_management_network_logging);
private Supplier<String> mWorkProfileDialogNetworkStringSupplier = () ->
mContext == null ? null : mContext.getString(
R.string.monitoring_description_managed_profile_network_logging);
@Inject @Inject
QSSecurityFooter(@Named(QS_SECURITY_FOOTER_VIEW) View rootView, QSSecurityFooter(@Named(QS_SECURITY_FOOTER_VIEW) View rootView,
UserTracker userTracker, @Main Handler mainHandler, UserTracker userTracker, @Main Handler mainHandler,
@@ -337,9 +398,7 @@ class QSSecurityFooter extends ViewController<View>
private String getManagedDeviceMonitoringText(CharSequence organizationName) { private String getManagedDeviceMonitoringText(CharSequence organizationName) {
if (organizationName == null) { if (organizationName == null) {
return mDpm.getResources().getString( return mDpm.getResources().getString(
QS_MSG_MANAGEMENT_MONITORING, QS_MSG_MANAGEMENT_MONITORING, mManagementMonitoringStringSupplier);
() -> mContext.getString(
R.string.quick_settings_disclosure_management_monitoring));
} }
return mDpm.getResources().getString( return mDpm.getResources().getString(
QS_MSG_NAMED_MANAGEMENT_MONITORING, QS_MSG_NAMED_MANAGEMENT_MONITORING,
@@ -354,9 +413,7 @@ class QSSecurityFooter extends ViewController<View>
if (vpnName != null && vpnNameWorkProfile != null) { if (vpnName != null && vpnNameWorkProfile != null) {
if (organizationName == null) { if (organizationName == null) {
return mDpm.getResources().getString( return mDpm.getResources().getString(
QS_MSG_MANAGEMENT_MULTIPLE_VPNS, QS_MSG_MANAGEMENT_MULTIPLE_VPNS, mManagementMultipleVpnStringSupplier);
() -> mContext.getString(
R.string.quick_settings_disclosure_management_vpns));
} }
return mDpm.getResources().getString( return mDpm.getResources().getString(
QS_MSG_NAMED_MANAGEMENT_MULTIPLE_VPNS, QS_MSG_NAMED_MANAGEMENT_MULTIPLE_VPNS,
@@ -386,10 +443,7 @@ class QSSecurityFooter extends ViewController<View>
private String getMangedDeviceGeneralText(CharSequence organizationName) { private String getMangedDeviceGeneralText(CharSequence organizationName) {
if (organizationName == null) { if (organizationName == null) {
return mDpm.getResources().getString( return mDpm.getResources().getString(QS_MSG_MANAGEMENT, mManagementMessageSupplier);
QS_MSG_MANAGEMENT,
() -> mContext.getString(
R.string.quick_settings_disclosure_management));
} }
if (isFinancedDevice()) { if (isFinancedDevice()) {
return mContext.getString( return mContext.getString(
@@ -431,9 +485,7 @@ class QSSecurityFooter extends ViewController<View>
if (hasCACertsInWorkProfile && isWorkProfileOn) { if (hasCACertsInWorkProfile && isWorkProfileOn) {
if (workProfileOrganizationName == null) { if (workProfileOrganizationName == null) {
return mDpm.getResources().getString( return mDpm.getResources().getString(
QS_MSG_WORK_PROFILE_MONITORING, QS_MSG_WORK_PROFILE_MONITORING, mWorkProfileMonitoringStringSupplier);
() -> mContext.getString(
R.string.quick_settings_disclosure_managed_profile_monitoring));
} }
return mDpm.getResources().getString( return mDpm.getResources().getString(
QS_MSG_NAMED_WORK_PROFILE_MONITORING, QS_MSG_NAMED_WORK_PROFILE_MONITORING,
@@ -478,10 +530,9 @@ class QSSecurityFooter extends ViewController<View>
private String getManagedProfileNetworkActivityText() { private String getManagedProfileNetworkActivityText() {
return mDpm.getResources().getString( return mDpm.getResources().getString(
QS_MSG_WORK_PROFILE_NETWORK, QS_MSG_WORK_PROFILE_NETWORK, mWorkProfileNetworkStringSupplier);
() -> mContext.getString(
R.string.quick_settings_disclosure_managed_profile_network_activity));
} }
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_NEGATIVE) { if (which == DialogInterface.BUTTON_NEGATIVE) {
@@ -569,6 +620,12 @@ class QSSecurityFooter extends ViewController<View>
caCertsWarning.setText(caCertsMessage); caCertsWarning.setText(caCertsMessage);
// Make "Open trusted credentials"-link clickable // Make "Open trusted credentials"-link clickable
caCertsWarning.setMovementMethod(new LinkMovementMethod()); caCertsWarning.setMovementMethod(new LinkMovementMethod());
TextView caCertsSubtitle = (TextView) dialogView.findViewById(R.id.ca_certs_subtitle);
String caCertsSubtitleMessage = mDpm.getResources().getString(
QS_DIALOG_MONITORING_CA_CERT_SUBTITLE, mMonitoringSubtitleCaCertStringSupplier);
caCertsSubtitle.setText(caCertsSubtitleMessage);
} }
// network logging section // network logging section
@@ -581,6 +638,13 @@ class QSSecurityFooter extends ViewController<View>
TextView networkLoggingWarning = TextView networkLoggingWarning =
(TextView) dialogView.findViewById(R.id.network_logging_warning); (TextView) dialogView.findViewById(R.id.network_logging_warning);
networkLoggingWarning.setText(networkLoggingMessage); networkLoggingWarning.setText(networkLoggingMessage);
TextView networkLoggingSubtitle = (TextView) dialogView.findViewById(
R.id.network_logging_subtitle);
String networkLoggingSubtitleMessage = mDpm.getResources().getString(
QS_DIALOG_MONITORING_NETWORK_SUBTITLE,
mMonitoringSubtitleNetworkStringSupplier);
networkLoggingSubtitle.setText(networkLoggingSubtitleMessage);
} }
// vpn section // vpn section
@@ -594,6 +658,11 @@ class QSSecurityFooter extends ViewController<View>
vpnWarning.setText(vpnMessage); vpnWarning.setText(vpnMessage);
// Make "Open VPN Settings"-link clickable // Make "Open VPN Settings"-link clickable
vpnWarning.setMovementMethod(new LinkMovementMethod()); vpnWarning.setMovementMethod(new LinkMovementMethod());
TextView vpnSubtitle = (TextView) dialogView.findViewById(R.id.vpn_subtitle);
String vpnSubtitleMessage = mDpm.getResources().getString(
QS_DIALOG_MONITORING_VPN_SUBTITLE, mMonitoringSubtitleVpnStringSupplier);
vpnSubtitle.setText(vpnSubtitleMessage);
} }
// Note: if a new section is added, should update configSubtitleVisibility to include // Note: if a new section is added, should update configSubtitleVisibility to include
@@ -657,8 +726,7 @@ class QSSecurityFooter extends ViewController<View>
@VisibleForTesting @VisibleForTesting
String getSettingsButton() { String getSettingsButton() {
return mDpm.getResources().getString( return mDpm.getResources().getString(
QS_DIALOG_VIEW_POLICIES, QS_DIALOG_VIEW_POLICIES, mViewPoliciesButtonStringSupplier);
() -> mContext.getString(R.string.monitoring_button_view_policies));
} }
private String getPositiveButton() { private String getPositiveButton() {
@@ -692,9 +760,7 @@ class QSSecurityFooter extends ViewController<View>
organizationName); organizationName);
} }
} }
return mDpm.getResources().getString( return mDpm.getResources().getString(QS_DIALOG_MANAGEMENT, mManagementDialogStringSupplier);
QS_DIALOG_MANAGEMENT,
() -> mContext.getString(R.string.monitoring_description_management));
} }
@Nullable @Nullable
@@ -703,15 +769,11 @@ class QSSecurityFooter extends ViewController<View>
if (!(hasCACerts || hasCACertsInWorkProfile)) return null; if (!(hasCACerts || hasCACertsInWorkProfile)) return null;
if (isDeviceManaged) { if (isDeviceManaged) {
return mDpm.getResources().getString( return mDpm.getResources().getString(
QS_DIALOG_MANAGEMENT_CA_CERT, QS_DIALOG_MANAGEMENT_CA_CERT, mManagementDialogCaCertStringSupplier);
() -> mContext.getString(
R.string.monitoring_description_management_ca_certificate));
} }
if (hasCACertsInWorkProfile) { if (hasCACertsInWorkProfile) {
return mDpm.getResources().getString( return mDpm.getResources().getString(
QS_DIALOG_WORK_PROFILE_CA_CERT, QS_DIALOG_WORK_PROFILE_CA_CERT, mWorkProfileDialogCaCertStringSupplier);
() -> mContext.getString(
R.string.monitoring_description_managed_profile_ca_certificate));
} }
return mContext.getString(R.string.monitoring_description_ca_certificate); return mContext.getString(R.string.monitoring_description_ca_certificate);
} }
@@ -722,14 +784,10 @@ class QSSecurityFooter extends ViewController<View>
if (!isNetworkLoggingEnabled) return null; if (!isNetworkLoggingEnabled) return null;
if (isDeviceManaged) { if (isDeviceManaged) {
return mDpm.getResources().getString( return mDpm.getResources().getString(
QS_DIALOG_MANAGEMENT_NETWORK, QS_DIALOG_MANAGEMENT_NETWORK, mManagementDialogNetworkStringSupplier);
() -> mContext.getString(
R.string.monitoring_description_management_network_logging));
} else { } else {
return mDpm.getResources().getString( return mDpm.getResources().getString(
QS_DIALOG_WORK_PROFILE_NETWORK, QS_DIALOG_WORK_PROFILE_NETWORK, mWorkProfileDialogNetworkStringSupplier);
() -> mContext.getString(
R.string.monitoring_description_managed_profile_network_logging));
} }
} }
@@ -799,7 +857,7 @@ class QSSecurityFooter extends ViewController<View>
} else { } else {
return mDpm.getResources().getString( return mDpm.getResources().getString(
QS_DIALOG_MANAGEMENT_TITLE, QS_DIALOG_MANAGEMENT_TITLE,
() -> mContext.getString(R.string.monitoring_title_device_owned)); mManagementTitleSupplier);
} }
} }

View File

@@ -16,6 +16,7 @@
package com.android.systemui.screenshot; package com.android.systemui.screenshot;
import static android.app.admin.DevicePolicyResources.Strings.SystemUi.SCREENSHOT_BLOCKED_BY_ADMIN;
import static android.content.Intent.ACTION_CLOSE_SYSTEM_DIALOGS; import static android.content.Intent.ACTION_CLOSE_SYSTEM_DIALOGS;
import static com.android.internal.util.ScreenshotHelper.SCREENSHOT_MSG_PROCESS_COMPLETE; import static com.android.internal.util.ScreenshotHelper.SCREENSHOT_MSG_PROCESS_COMPLETE;
@@ -54,7 +55,9 @@ import androidx.annotation.NonNull;
import com.android.internal.logging.UiEventLogger; import com.android.internal.logging.UiEventLogger;
import com.android.internal.util.ScreenshotHelper; import com.android.internal.util.ScreenshotHelper;
import com.android.systemui.R; import com.android.systemui.R;
import com.android.systemui.dagger.qualifiers.Background;
import java.util.concurrent.Executor;
import java.util.function.Consumer; import java.util.function.Consumer;
import javax.inject.Inject; import javax.inject.Inject;
@@ -70,6 +73,7 @@ public class TakeScreenshotService extends Service {
private final ScreenshotNotificationsController mNotificationsController; private final ScreenshotNotificationsController mNotificationsController;
private final Handler mHandler; private final Handler mHandler;
private final Context mContext; private final Context mContext;
private final @Background Executor mBgExecutor;
private final BroadcastReceiver mCloseSystemDialogs = new BroadcastReceiver() { private final BroadcastReceiver mCloseSystemDialogs = new BroadcastReceiver() {
@Override @Override
@@ -97,7 +101,8 @@ public class TakeScreenshotService extends Service {
@Inject @Inject
public TakeScreenshotService(ScreenshotController screenshotController, UserManager userManager, public TakeScreenshotService(ScreenshotController screenshotController, UserManager userManager,
DevicePolicyManager devicePolicyManager, UiEventLogger uiEventLogger, DevicePolicyManager devicePolicyManager, UiEventLogger uiEventLogger,
ScreenshotNotificationsController notificationsController, Context context) { ScreenshotNotificationsController notificationsController, Context context,
@Background Executor bgExecutor) {
if (DEBUG_SERVICE) { if (DEBUG_SERVICE) {
Log.d(TAG, "new " + this); Log.d(TAG, "new " + this);
} }
@@ -108,6 +113,7 @@ public class TakeScreenshotService extends Service {
mUiEventLogger = uiEventLogger; mUiEventLogger = uiEventLogger;
mNotificationsController = notificationsController; mNotificationsController = notificationsController;
mContext = context; mContext = context;
mBgExecutor = bgExecutor;
} }
@Override @Override
@@ -189,12 +195,18 @@ public class TakeScreenshotService extends Service {
requestCallback.reportError(); requestCallback.reportError();
return true; return true;
} }
if (mDevicePolicyManager.getScreenCaptureDisabled(null, UserHandle.USER_ALL)) { if (mDevicePolicyManager.getScreenCaptureDisabled(null, UserHandle.USER_ALL)) {
mBgExecutor.execute(() -> {
Log.w(TAG, "Skipping screenshot because an IT admin has disabled " Log.w(TAG, "Skipping screenshot because an IT admin has disabled "
+ "screenshots on the device"); + "screenshots on the device");
Toast.makeText(mContext, R.string.screenshot_blocked_by_admin, String blockedByAdminText = mDevicePolicyManager.getResources().getString(
Toast.LENGTH_SHORT).show(); SCREENSHOT_BLOCKED_BY_ADMIN,
() -> mContext.getString(R.string.screenshot_blocked_by_admin));
mHandler.post(() ->
Toast.makeText(mContext, blockedByAdminText, Toast.LENGTH_SHORT).show());
requestCallback.reportError(); requestCallback.reportError();
});
return true; return true;
} }