Loading packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java +21 −12 Original line number Diff line number Diff line Loading @@ -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 { Loading @@ -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) { Loading Loading @@ -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); } Loading Loading @@ -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); Loading @@ -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); } Loading @@ -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); } Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java +2 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ public interface SecurityController extends CallbackController<SecurityControlle boolean isDeviceManaged(); boolean hasProfileOwner(); boolean hasWorkProfile(); /** Whether the work profile is turned on. */ boolean isWorkProfileOn(); /** Whether this device is organization-owned with a work profile **/ boolean isProfileOwnerOfOrganizationOwnedDevice(); String getDeviceOwnerName(); Loading Loading @@ -57,7 +59,6 @@ public interface SecurityController extends CallbackController<SecurityControlle /** Label for admin */ CharSequence getLabel(DeviceAdminInfo info); public interface SecurityControllerCallback { void onStateChanged(); } Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java +6 −0 Original line number Diff line number Diff line Loading @@ -210,6 +210,12 @@ public class SecurityControllerImpl extends CurrentUserTracker implements Securi return getWorkProfileUserId(mCurrentUserId) != UserHandle.USER_NULL; } @Override public boolean isWorkProfileOn() { final UserHandle userHandle = UserHandle.of(getWorkProfileUserId(mCurrentUserId)); return userHandle != null && !mUserManager.isQuietModeEnabled(userHandle); } @Override public boolean isProfileOwnerOfOrganizationOwnedDevice() { return mDevicePolicyManager.isOrganizationOwnedDeviceWithManagedProfile(); Loading packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java +54 −3 Original line number Diff line number Diff line Loading @@ -204,6 +204,8 @@ public class QSSecurityFooterTest extends SysuiTestCase { public void testTappableView_profileOwnerOfOrgOwnedDevice_networkLoggingEnabled() { when(mSecurityController.isProfileOwnerOfOrganizationOwnedDevice()).thenReturn(true); when(mSecurityController.isNetworkLoggingEnabled()).thenReturn(true); when(mSecurityController.isWorkProfileOn()).thenReturn(true); when(mSecurityController.hasWorkProfile()).thenReturn(true); mFooter.refreshState(); Loading @@ -212,6 +214,19 @@ public class QSSecurityFooterTest extends SysuiTestCase { assertEquals(View.VISIBLE, mRootView.findViewById(R.id.footer_icon).getVisibility()); } @Test public void testUntappableView_profileOwnerOfOrgOwnedDevice_workProfileOff() { when(mSecurityController.isProfileOwnerOfOrganizationOwnedDevice()).thenReturn(true); when(mSecurityController.isNetworkLoggingEnabled()).thenReturn(true); when(mSecurityController.isWorkProfileOn()).thenReturn(false); mFooter.refreshState(); TestableLooper.get(this).processAllMessages(); assertFalse(mRootView.isClickable()); assertEquals(View.GONE, mRootView.findViewById(R.id.footer_icon).getVisibility()); } @Test public void testNetworkLoggingEnabled_deviceOwner() { when(mSecurityController.isDeviceManaged()).thenReturn(true); Loading @@ -237,9 +252,10 @@ public class QSSecurityFooterTest extends SysuiTestCase { } @Test public void testNetworkLoggingEnabled_managedProfileOwner() { public void testNetworkLoggingEnabled_managedProfileOwner_workProfileOn() { when(mSecurityController.hasWorkProfile()).thenReturn(true); when(mSecurityController.isNetworkLoggingEnabled()).thenReturn(true); when(mSecurityController.isWorkProfileOn()).thenReturn(true); mFooter.refreshState(); TestableLooper.get(this).processAllMessages(); Loading @@ -248,6 +264,17 @@ public class QSSecurityFooterTest extends SysuiTestCase { mFooterText.getText()); } @Test public void testNetworkLoggingEnabled_managedProfileOwner_workProfileOff() { when(mSecurityController.hasWorkProfile()).thenReturn(true); when(mSecurityController.isNetworkLoggingEnabled()).thenReturn(true); when(mSecurityController.isWorkProfileOn()).thenReturn(false); mFooter.refreshState(); TestableLooper.get(this).processAllMessages(); assertEquals("", mFooterText.getText()); } @Test public void testManagedCACertsInstalled() { when(mSecurityController.isDeviceManaged()).thenReturn(true); Loading Loading @@ -326,9 +353,10 @@ public class QSSecurityFooterTest extends SysuiTestCase { } @Test public void testWorkProfileCACertsInstalled() { public void testWorkProfileCACertsInstalled_workProfileOn() { when(mSecurityController.isDeviceManaged()).thenReturn(false); when(mSecurityController.hasCACertInWorkProfile()).thenReturn(true); when(mSecurityController.isWorkProfileOn()).thenReturn(true); mFooter.refreshState(); TestableLooper.get(this).processAllMessages(); Loading @@ -349,6 +377,17 @@ public class QSSecurityFooterTest extends SysuiTestCase { mFooterText.getText()); } @Test public void testWorkProfileCACertsInstalled_workProfileOff() { when(mSecurityController.isDeviceManaged()).thenReturn(false); when(mSecurityController.hasCACertInWorkProfile()).thenReturn(true); when(mSecurityController.isWorkProfileOn()).thenReturn(false); mFooter.refreshState(); TestableLooper.get(this).processAllMessages(); assertEquals("", mFooterText.getText()); } @Test public void testCACertsInstalled() { when(mSecurityController.isDeviceManaged()).thenReturn(false); Loading @@ -375,9 +414,10 @@ public class QSSecurityFooterTest extends SysuiTestCase { } @Test public void testWorkProfileVpnEnabled() { public void testWorkProfileVpnEnabled_workProfileOn() { when(mSecurityController.isVpnEnabled()).thenReturn(true); when(mSecurityController.getWorkProfileVpnName()).thenReturn(VPN_PACKAGE_2); when(mSecurityController.isWorkProfileOn()).thenReturn(true); mFooter.refreshState(); TestableLooper.get(this).processAllMessages(); Loading @@ -388,6 +428,17 @@ public class QSSecurityFooterTest extends SysuiTestCase { mFooterText.getText()); } @Test public void testWorkProfileVpnEnabled_workProfileOff() { when(mSecurityController.isVpnEnabled()).thenReturn(true); when(mSecurityController.getWorkProfileVpnName()).thenReturn(VPN_PACKAGE_2); when(mSecurityController.isWorkProfileOn()).thenReturn(false); mFooter.refreshState(); TestableLooper.get(this).processAllMessages(); assertEquals("", mFooterText.getText()); } @Test public void testProfileOwnerOfOrganizationOwnedDeviceNoName() { when(mSecurityController.isProfileOwnerOfOrganizationOwnedDevice()).thenReturn(true); Loading packages/SystemUI/tests/src/com/android/systemui/utils/leaks/FakeSecurityController.java +5 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,11 @@ public class FakeSecurityController extends BaseLeakChecker<SecurityControllerCa return false; } @Override public boolean isWorkProfileOn() { return false; } @Override public boolean isProfileOwnerOfOrganizationOwnedDevice() { return false; Loading Loading
packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java +21 −12 Original line number Diff line number Diff line Loading @@ -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 { Loading @@ -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) { Loading Loading @@ -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); } Loading Loading @@ -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); Loading @@ -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); } Loading @@ -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); } Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java +2 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ public interface SecurityController extends CallbackController<SecurityControlle boolean isDeviceManaged(); boolean hasProfileOwner(); boolean hasWorkProfile(); /** Whether the work profile is turned on. */ boolean isWorkProfileOn(); /** Whether this device is organization-owned with a work profile **/ boolean isProfileOwnerOfOrganizationOwnedDevice(); String getDeviceOwnerName(); Loading Loading @@ -57,7 +59,6 @@ public interface SecurityController extends CallbackController<SecurityControlle /** Label for admin */ CharSequence getLabel(DeviceAdminInfo info); public interface SecurityControllerCallback { void onStateChanged(); } Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java +6 −0 Original line number Diff line number Diff line Loading @@ -210,6 +210,12 @@ public class SecurityControllerImpl extends CurrentUserTracker implements Securi return getWorkProfileUserId(mCurrentUserId) != UserHandle.USER_NULL; } @Override public boolean isWorkProfileOn() { final UserHandle userHandle = UserHandle.of(getWorkProfileUserId(mCurrentUserId)); return userHandle != null && !mUserManager.isQuietModeEnabled(userHandle); } @Override public boolean isProfileOwnerOfOrganizationOwnedDevice() { return mDevicePolicyManager.isOrganizationOwnedDeviceWithManagedProfile(); Loading
packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java +54 −3 Original line number Diff line number Diff line Loading @@ -204,6 +204,8 @@ public class QSSecurityFooterTest extends SysuiTestCase { public void testTappableView_profileOwnerOfOrgOwnedDevice_networkLoggingEnabled() { when(mSecurityController.isProfileOwnerOfOrganizationOwnedDevice()).thenReturn(true); when(mSecurityController.isNetworkLoggingEnabled()).thenReturn(true); when(mSecurityController.isWorkProfileOn()).thenReturn(true); when(mSecurityController.hasWorkProfile()).thenReturn(true); mFooter.refreshState(); Loading @@ -212,6 +214,19 @@ public class QSSecurityFooterTest extends SysuiTestCase { assertEquals(View.VISIBLE, mRootView.findViewById(R.id.footer_icon).getVisibility()); } @Test public void testUntappableView_profileOwnerOfOrgOwnedDevice_workProfileOff() { when(mSecurityController.isProfileOwnerOfOrganizationOwnedDevice()).thenReturn(true); when(mSecurityController.isNetworkLoggingEnabled()).thenReturn(true); when(mSecurityController.isWorkProfileOn()).thenReturn(false); mFooter.refreshState(); TestableLooper.get(this).processAllMessages(); assertFalse(mRootView.isClickable()); assertEquals(View.GONE, mRootView.findViewById(R.id.footer_icon).getVisibility()); } @Test public void testNetworkLoggingEnabled_deviceOwner() { when(mSecurityController.isDeviceManaged()).thenReturn(true); Loading @@ -237,9 +252,10 @@ public class QSSecurityFooterTest extends SysuiTestCase { } @Test public void testNetworkLoggingEnabled_managedProfileOwner() { public void testNetworkLoggingEnabled_managedProfileOwner_workProfileOn() { when(mSecurityController.hasWorkProfile()).thenReturn(true); when(mSecurityController.isNetworkLoggingEnabled()).thenReturn(true); when(mSecurityController.isWorkProfileOn()).thenReturn(true); mFooter.refreshState(); TestableLooper.get(this).processAllMessages(); Loading @@ -248,6 +264,17 @@ public class QSSecurityFooterTest extends SysuiTestCase { mFooterText.getText()); } @Test public void testNetworkLoggingEnabled_managedProfileOwner_workProfileOff() { when(mSecurityController.hasWorkProfile()).thenReturn(true); when(mSecurityController.isNetworkLoggingEnabled()).thenReturn(true); when(mSecurityController.isWorkProfileOn()).thenReturn(false); mFooter.refreshState(); TestableLooper.get(this).processAllMessages(); assertEquals("", mFooterText.getText()); } @Test public void testManagedCACertsInstalled() { when(mSecurityController.isDeviceManaged()).thenReturn(true); Loading Loading @@ -326,9 +353,10 @@ public class QSSecurityFooterTest extends SysuiTestCase { } @Test public void testWorkProfileCACertsInstalled() { public void testWorkProfileCACertsInstalled_workProfileOn() { when(mSecurityController.isDeviceManaged()).thenReturn(false); when(mSecurityController.hasCACertInWorkProfile()).thenReturn(true); when(mSecurityController.isWorkProfileOn()).thenReturn(true); mFooter.refreshState(); TestableLooper.get(this).processAllMessages(); Loading @@ -349,6 +377,17 @@ public class QSSecurityFooterTest extends SysuiTestCase { mFooterText.getText()); } @Test public void testWorkProfileCACertsInstalled_workProfileOff() { when(mSecurityController.isDeviceManaged()).thenReturn(false); when(mSecurityController.hasCACertInWorkProfile()).thenReturn(true); when(mSecurityController.isWorkProfileOn()).thenReturn(false); mFooter.refreshState(); TestableLooper.get(this).processAllMessages(); assertEquals("", mFooterText.getText()); } @Test public void testCACertsInstalled() { when(mSecurityController.isDeviceManaged()).thenReturn(false); Loading @@ -375,9 +414,10 @@ public class QSSecurityFooterTest extends SysuiTestCase { } @Test public void testWorkProfileVpnEnabled() { public void testWorkProfileVpnEnabled_workProfileOn() { when(mSecurityController.isVpnEnabled()).thenReturn(true); when(mSecurityController.getWorkProfileVpnName()).thenReturn(VPN_PACKAGE_2); when(mSecurityController.isWorkProfileOn()).thenReturn(true); mFooter.refreshState(); TestableLooper.get(this).processAllMessages(); Loading @@ -388,6 +428,17 @@ public class QSSecurityFooterTest extends SysuiTestCase { mFooterText.getText()); } @Test public void testWorkProfileVpnEnabled_workProfileOff() { when(mSecurityController.isVpnEnabled()).thenReturn(true); when(mSecurityController.getWorkProfileVpnName()).thenReturn(VPN_PACKAGE_2); when(mSecurityController.isWorkProfileOn()).thenReturn(false); mFooter.refreshState(); TestableLooper.get(this).processAllMessages(); assertEquals("", mFooterText.getText()); } @Test public void testProfileOwnerOfOrganizationOwnedDeviceNoName() { when(mSecurityController.isProfileOwnerOfOrganizationOwnedDevice()).thenReturn(true); Loading
packages/SystemUI/tests/src/com/android/systemui/utils/leaks/FakeSecurityController.java +5 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,11 @@ public class FakeSecurityController extends BaseLeakChecker<SecurityControllerCa return false; } @Override public boolean isWorkProfileOn() { return false; } @Override public boolean isProfileOwnerOfOrganizationOwnedDevice() { return false; Loading