From a9ad16f112ff4c5265a5bb10498b7171f8e8ddce Mon Sep 17 00:00:00 2001 From: Salud Lemus Date: Fri, 26 Feb 2021 22:43:47 +0000 Subject: [PATCH] Update Quick Settings footer and dialog text for a financed device Bug: 173826319 Bug: 158157476 Test: Used a test device that is registered via ZT Test: atest SystemUITests:com.android.systemui.qs.QSSecurityFooterTest Change-Id: Iff3630c3d4cb640115d04a6b8775a58db8d7ca6a --- .../layout/quick_settings_footer_dialog.xml | 1 - packages/SystemUI/res/values/strings.xml | 9 ++ .../android/systemui/qs/QSSecurityFooter.java | 45 +++++++-- .../statusbar/policy/SecurityController.java | 5 + .../policy/SecurityControllerImpl.java | 14 +++ .../systemui/qs/QSSecurityFooterTest.java | 95 +++++++++++++++++++ .../policy/SecurityControllerTest.java | 21 ++++ .../utils/leaks/FakeSecurityController.java | 11 +++ 8 files changed, 191 insertions(+), 10 deletions(-) diff --git a/packages/SystemUI/res/layout/quick_settings_footer_dialog.xml b/packages/SystemUI/res/layout/quick_settings_footer_dialog.xml index b969a1527c09d..4798b437298aa 100644 --- a/packages/SystemUI/res/layout/quick_settings_footer_dialog.xml +++ b/packages/SystemUI/res/layout/quick_settings_footer_dialog.xml @@ -38,7 +38,6 @@ android:id="@+id/device_management_subtitle" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/monitoring_title_device_owned" style="@style/DeviceManagementDialogTitle" android:paddingBottom="@dimen/qs_footer_dialog_subtitle_padding" /> diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 783f80c2ee028..3954b2aa4b9de 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -1259,6 +1259,9 @@ %1$s owns this device and may monitor network traffic + + This device is provided by %s + This device belongs to your organization and is connected to %1$s @@ -1298,6 +1301,9 @@ This device is connected to %1$s + + This device is provided by %s + Device management @@ -1332,6 +1338,9 @@ This device belongs to %1$s.\n\nYour IT admin can monitor and manage settings, corporate access, apps, data associated with your device, and your device\'s location information.\n\nFor more information, contact your IT admin. + + %1$s may be able to access data associated with this device and change this device\’s settings.\n\nIf you have questions, contact %2$s. + This device belongs to your organization.\n\nYour IT admin can monitor and manage settings, corporate access, apps, data associated with your device, and your device\'s location information.\n\nFor more information, contact your IT admin. diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java b/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java index 1411fa1ea21f7..5e13fd345b814 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java @@ -15,6 +15,8 @@ */ package com.android.systemui.qs; +import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_FINANCED; + import static com.android.systemui.qs.dagger.QSFragmentModule.QS_SECURITY_FOOTER_VIEW; import android.app.AlertDialog; @@ -244,8 +246,14 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen if (organizationName == null) { return mContext.getString(R.string.quick_settings_disclosure_management); } - return mContext.getString(R.string.quick_settings_disclosure_named_management, - organizationName); + if (isFinancedDevice()) { + return mContext.getString( + R.string.quick_settings_financed_disclosure_named_management, + organizationName); + } else { + return mContext.getString(R.string.quick_settings_disclosure_named_management, + organizationName); + } } // end if(isDeviceManaged) if (hasCACertsInWorkProfile) { if (workProfileOrganizationName == null) { @@ -355,6 +363,10 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen .inflate(R.layout.quick_settings_footer_dialog, null, false); // device management section + TextView deviceManagementSubtitle = + dialogView.findViewById(R.id.device_management_subtitle); + deviceManagementSubtitle.setText(getManagementTitle(deviceOwnerOrganization)); + CharSequence managementMessage = getManagementMessage(isDeviceManaged, deviceOwnerOrganization, isProfileOwnerOfOrganizationOwnedDevice, workProfileOrganizationName); @@ -468,7 +480,8 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen } } - private String getSettingsButton() { + @VisibleForTesting + String getSettingsButton() { return mContext.getString(R.string.monitoring_button_view_policies); } @@ -490,8 +503,13 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen return null; } if (isDeviceManaged && organizationName != null) { - return mContext.getString( - R.string.monitoring_description_named_management, organizationName); + if (isFinancedDevice()) { + return mContext.getString(R.string.monitoring_financed_description_named_management, + organizationName, organizationName); + } else { + return mContext.getString( + R.string.monitoring_description_named_management, organizationName); + } } else if (isProfileOwnerOfOrganizationOwnedDevice && workProfileOrganizationName != null) { return mContext.getString( R.string.monitoring_description_named_management, workProfileOrganizationName); @@ -557,14 +575,23 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen return message; } - private int getTitle(String deviceOwner) { - if (deviceOwner != null) { - return R.string.monitoring_title_device_owned; + @VisibleForTesting + CharSequence getManagementTitle(CharSequence deviceOwnerOrganization) { + if (deviceOwnerOrganization != null && isFinancedDevice()) { + return mContext.getString(R.string.monitoring_title_financed_device, + deviceOwnerOrganization); } else { - return R.string.monitoring_title; + return mContext.getString(R.string.monitoring_title_device_owned); } } + private boolean isFinancedDevice() { + return mSecurityController.isDeviceManaged() + && mSecurityController.getDeviceOwnerType( + mSecurityController.getDeviceOwnerComponentOnAnyUser()) + == DEVICE_OWNER_TYPE_FINANCED; + } + private final Runnable mUpdateIcon = new Runnable() { @Override public void run() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java index e8331a176134f..e76b8035cd59b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.policy; import android.app.admin.DeviceAdminInfo; +import android.content.ComponentName; import android.graphics.drawable.Drawable; import com.android.systemui.Dumpable; @@ -33,6 +34,10 @@ public interface SecurityController extends CallbackController