Merge "Remove device ownership text in quick settings" into sc-dev

This commit is contained in:
Alex Johnston
2021-05-11 10:32:23 +00:00
committed by Android (Google) Code Review
2 changed files with 43 additions and 51 deletions

View File

@@ -190,6 +190,16 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
|| vpnName != null || vpnNameWorkProfile != null
|| isProfileOwnerOfOrganizationOwnedDevice || isParentalControlsEnabled
|| (hasWorkProfile && isNetworkLoggingEnabled);
// 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) {
mRootView.setClickable(false);
mRootView.findViewById(R.id.footer_icon).setVisibility(View.GONE);
} else {
mRootView.setClickable(true);
mRootView.findViewById(R.id.footer_icon).setVisibility(View.VISIBLE);
}
// Update the string
mFooterTextContent = getFooterText(isDeviceManaged, hasWorkProfile,
hasCACerts, hasCACertsInWorkProfile, isNetworkLoggingEnabled, vpnName,
@@ -345,20 +355,15 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
private View createOrganizationDialogView() {
final boolean isDeviceManaged = mSecurityController.isDeviceManaged();
boolean isProfileOwnerOfOrganizationOwnedDevice =
mSecurityController.isProfileOwnerOfOrganizationOwnedDevice();
final boolean hasWorkProfile = mSecurityController.hasWorkProfile();
final CharSequence deviceOwnerOrganization =
mSecurityController.getDeviceOwnerOrganizationName();
final CharSequence workProfileOrganizationName =
mSecurityController.getWorkProfileOrganizationName();
final boolean hasCACerts = mSecurityController.hasCACertInCurrentUser();
final boolean hasCACertsInWorkProfile = mSecurityController.hasCACertInWorkProfile();
final boolean isNetworkLoggingEnabled = mSecurityController.isNetworkLoggingEnabled();
final String vpnName = mSecurityController.getPrimaryVpnName();
final String vpnNameWorkProfile = mSecurityController.getWorkProfileVpnName();
View dialogView = LayoutInflater.from(mContext)
.inflate(R.layout.quick_settings_footer_dialog, null, false);
@@ -368,8 +373,7 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
deviceManagementSubtitle.setText(getManagementTitle(deviceOwnerOrganization));
CharSequence managementMessage = getManagementMessage(isDeviceManaged,
deviceOwnerOrganization, isProfileOwnerOfOrganizationOwnedDevice,
workProfileOrganizationName);
deviceOwnerOrganization);
if (managementMessage == null) {
dialogView.findViewById(R.id.device_management_disclosures).setVisibility(View.GONE);
} else {
@@ -377,11 +381,7 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
TextView deviceManagementWarning =
(TextView) dialogView.findViewById(R.id.device_management_warning);
deviceManagementWarning.setText(managementMessage);
// Don't show the policies button for profile owner of org owned device, because there
// is no policies settings screen for it
if (!isProfileOwnerOfOrganizationOwnedDevice) {
mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getSettingsButton(), this);
}
mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getSettingsButton(), this);
}
// ca certificate section
@@ -496,12 +496,11 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
}
protected CharSequence getManagementMessage(boolean isDeviceManaged,
CharSequence organizationName, boolean isProfileOwnerOfOrganizationOwnedDevice,
CharSequence workProfileOrganizationName) {
if (!isDeviceManaged && !isProfileOwnerOfOrganizationOwnedDevice) {
CharSequence organizationName) {
if (!isDeviceManaged) {
return null;
}
if (isDeviceManaged && organizationName != null) {
if (organizationName != null) {
if (isFinancedDevice()) {
return mContext.getString(R.string.monitoring_financed_description_named_management,
organizationName, organizationName);
@@ -509,9 +508,6 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
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);
}
return mContext.getString(R.string.monitoring_description_management);
}

View File

@@ -21,6 +21,7 @@ import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -188,6 +189,29 @@ public class QSSecurityFooterTest extends SysuiTestCase {
assertEquals(View.GONE, mRootView.getVisibility());
}
@Test
public void testUntappableView_profileOwnerOfOrgOwnedDevice() {
when(mSecurityController.isProfileOwnerOfOrganizationOwnedDevice()).thenReturn(true);
mFooter.refreshState();
TestableLooper.get(this).processAllMessages();
assertFalse(mRootView.isClickable());
assertEquals(View.GONE, mRootView.findViewById(R.id.footer_icon).getVisibility());
}
@Test
public void testTappableView_profileOwnerOfOrgOwnedDevice_networkLoggingEnabled() {
when(mSecurityController.isProfileOwnerOfOrganizationOwnedDevice()).thenReturn(true);
when(mSecurityController.isNetworkLoggingEnabled()).thenReturn(true);
mFooter.refreshState();
TestableLooper.get(this).processAllMessages();
assertTrue(mRootView.isClickable());
assertEquals(View.VISIBLE, mRootView.findViewById(R.id.footer_icon).getVisibility());
}
@Test
public void testNetworkLoggingEnabled_deviceOwner() {
when(mSecurityController.isDeviceManaged()).thenReturn(true);
@@ -435,10 +459,7 @@ public class QSSecurityFooterTest extends SysuiTestCase {
@Test
public void testGetManagementMessage_noManagement() {
assertEquals(null, mFooter.getManagementMessage(
/* isDeviceManaged= */ false,
MANAGING_ORGANIZATION,
/* isProfileOwnerOfOrganizationOwnedDevice= */ false,
MANAGING_ORGANIZATION));
/* isDeviceManaged= */ false, MANAGING_ORGANIZATION));
}
@Test
@@ -446,16 +467,11 @@ public class QSSecurityFooterTest extends SysuiTestCase {
assertEquals(mContext.getString(R.string.monitoring_description_named_management,
MANAGING_ORGANIZATION),
mFooter.getManagementMessage(
/* isDeviceManaged= */ true,
MANAGING_ORGANIZATION,
/* isProfileOwnerOfOrganizationOwnedDevice= */ false,
/* workProfileOrganizationName= */ null));
/* isDeviceManaged= */ true, MANAGING_ORGANIZATION));
assertEquals(mContext.getString(R.string.monitoring_description_management),
mFooter.getManagementMessage(
/* isDeviceManaged= */ true,
/* organizationName= */ null,
/* isProfileOwnerOfOrganizationOwnedDevice= */ false,
/* workProfileOrganizationName= */ null));
/* organizationName= */ null));
}
@Test
@@ -467,27 +483,7 @@ public class QSSecurityFooterTest extends SysuiTestCase {
assertEquals(mContext.getString(R.string.monitoring_financed_description_named_management,
MANAGING_ORGANIZATION, MANAGING_ORGANIZATION),
mFooter.getManagementMessage(
/* isDeviceManaged= */ true,
MANAGING_ORGANIZATION,
/* isProfileOwnerOfOrganizationOwnedDevice= */ false,
/* workProfileOrganizationName= */ null));
}
@Test
public void testGetManagementMessage_profileOwnerOfOrganizationOwnedDevice() {
assertEquals(mContext.getString(R.string.monitoring_description_named_management,
MANAGING_ORGANIZATION),
mFooter.getManagementMessage(
/* isDeviceManaged= */ false,
/* organizationName= */ null,
/* isProfileOwnerOfOrganizationOwnedDevice= */ true,
MANAGING_ORGANIZATION));
assertEquals(mContext.getString(R.string.monitoring_description_management),
mFooter.getManagementMessage(
/* isDeviceManaged= */ false,
/* organizationName= */ null,
/* isProfileOwnerOfOrganizationOwnedDevice= */ true,
/* workProfileOrganizationName= */ null));
/* isDeviceManaged= */ true, MANAGING_ORGANIZATION));
}
@Test