From b5129c71a7a74fb7ef98946325dcf23fc66b9b88 Mon Sep 17 00:00:00 2001 From: Alex Johnston Date: Tue, 22 Jun 2021 13:39:03 +0100 Subject: [PATCH] QS: Do not display specific disclosure when the work profile is off * Work-profile related disclosures (e.g. network logging on the work profile) should disappear when the work profile is off. * BYOD device with a work profile * A disclosure isn't shown if there aren't any policies set. * A specific disclosure is shown if a policy is set. If the work profile is off, no disclosure is shown. * COPE device * The disclosure 'This device belongs to your organization' is shown if there aren't any policies set. * A specific disclosure is shown if a policy is set. If the work profile is off, the disclosure 'This device belongs to your organization'is shown. Manual testing scenarios (using TestDPC) - PO no policy -> verify no disclosure - PO with policy -> verify specific disclosure - PO with policy but WP is off -> verify no disclosure - COPE PO no policy -> verify org-owned device disclosure - COPE PO with policy -> verify specific disclosure - COPE PO with policy but WP is off -> verify org-owned device disclosure Bug: 191741537 Test: atest QSSecurityFooterTest atest SecurityControllerTest Manual testing Change-Id: I8036bbf8eba40329ae9fbf502aff1f33cd8d1c4a --- .../android/systemui/qs/QSSecurityFooter.java | 33 +++++++---- .../statusbar/policy/SecurityController.java | 3 +- .../policy/SecurityControllerImpl.java | 6 ++ .../systemui/qs/QSSecurityFooterTest.java | 57 ++++++++++++++++++- .../utils/leaks/FakeSecurityController.java | 5 ++ 5 files changed, 88 insertions(+), 16 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java b/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java index 3a6f1d5a02aee..7f19d0e6c25c8 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java @@ -185,15 +185,22 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen final boolean isProfileOwnerOfOrganizationOwnedDevice = mSecurityController.isProfileOwnerOfOrganizationOwnedDevice(); final boolean isParentalControlsEnabled = mSecurityController.isParentalControlsEnabled(); + final boolean isWorkProfileOn = mSecurityController.isWorkProfileOn(); + final boolean hasDisclosableWorkProfilePolicy = hasCACertsInWorkProfile + || vpnNameWorkProfile != null || (hasWorkProfile && isNetworkLoggingEnabled); // Update visibility of footer - mIsVisible = (isDeviceManaged && !isDemoDevice) || hasCACerts || hasCACertsInWorkProfile - || vpnName != null || vpnNameWorkProfile != null - || isProfileOwnerOfOrganizationOwnedDevice || isParentalControlsEnabled - || (hasWorkProfile && isNetworkLoggingEnabled); + mIsVisible = (isDeviceManaged && !isDemoDevice) + || hasCACerts + || vpnName != null + || isProfileOwnerOfOrganizationOwnedDevice + || isParentalControlsEnabled + || (hasDisclosableWorkProfilePolicy && isWorkProfileOn); // Update the view to be untappable if the device is an organization-owned device with a - // managed profile and there is no policy set which requires a privacy disclosure. - if (mIsVisible && isProfileOwnerOfOrganizationOwnedDevice && !isNetworkLoggingEnabled - && !hasCACertsInWorkProfile && vpnNameWorkProfile == null) { + // managed profile and there is either: + // a) no policy set which requires a privacy disclosure. + // b) a specific work policy set but the work profile is turned off. + if (mIsVisible && isProfileOwnerOfOrganizationOwnedDevice + && (!hasDisclosableWorkProfilePolicy || !isWorkProfileOn)) { mRootView.setClickable(false); mRootView.findViewById(R.id.footer_icon).setVisibility(View.GONE); } else { @@ -204,7 +211,8 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen mFooterTextContent = getFooterText(isDeviceManaged, hasWorkProfile, hasCACerts, hasCACertsInWorkProfile, isNetworkLoggingEnabled, vpnName, vpnNameWorkProfile, organizationName, workProfileOrganizationName, - isProfileOwnerOfOrganizationOwnedDevice, isParentalControlsEnabled); + isProfileOwnerOfOrganizationOwnedDevice, isParentalControlsEnabled, + isWorkProfileOn); // Update the icon int footerIconId = R.drawable.ic_info_outline; if (vpnName != null || vpnNameWorkProfile != null) { @@ -236,7 +244,8 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen boolean hasCACerts, boolean hasCACertsInWorkProfile, boolean isNetworkLoggingEnabled, String vpnName, String vpnNameWorkProfile, CharSequence organizationName, CharSequence workProfileOrganizationName, - boolean isProfileOwnerOfOrganizationOwnedDevice, boolean isParentalControlsEnabled) { + boolean isProfileOwnerOfOrganizationOwnedDevice, boolean isParentalControlsEnabled, + boolean isWorkProfileOn) { if (isParentalControlsEnabled) { return mContext.getString(R.string.quick_settings_disclosure_parental_controls); } @@ -280,7 +289,7 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen organizationName); } } // end if(isDeviceManaged) - if (hasCACertsInWorkProfile) { + if (hasCACertsInWorkProfile && isWorkProfileOn) { if (workProfileOrganizationName == null) { return mContext.getString( R.string.quick_settings_disclosure_managed_profile_monitoring); @@ -295,7 +304,7 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen if (vpnName != null && vpnNameWorkProfile != null) { return mContext.getString(R.string.quick_settings_disclosure_vpns); } - if (vpnNameWorkProfile != null) { + if (vpnNameWorkProfile != null && isWorkProfileOn) { return mContext.getString(R.string.quick_settings_disclosure_managed_profile_named_vpn, vpnNameWorkProfile); } @@ -308,7 +317,7 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen return mContext.getString(R.string.quick_settings_disclosure_named_vpn, vpnName); } - if (hasWorkProfile && isNetworkLoggingEnabled) { + if (hasWorkProfile && isNetworkLoggingEnabled && isWorkProfileOn) { return mContext.getString( R.string.quick_settings_disclosure_managed_profile_network_activity); } 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 e76b8035cd59b..2a93844acd5bf 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java @@ -28,6 +28,8 @@ public interface SecurityController extends CallbackController