Merge "Remove device ownership text in quick settings" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c8dffffc26
@@ -190,6 +190,16 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
|
|||||||
|| vpnName != null || vpnNameWorkProfile != null
|
|| vpnName != null || vpnNameWorkProfile != null
|
||||||
|| isProfileOwnerOfOrganizationOwnedDevice || isParentalControlsEnabled
|
|| isProfileOwnerOfOrganizationOwnedDevice || isParentalControlsEnabled
|
||||||
|| (hasWorkProfile && isNetworkLoggingEnabled);
|
|| (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
|
// Update the string
|
||||||
mFooterTextContent = getFooterText(isDeviceManaged, hasWorkProfile,
|
mFooterTextContent = getFooterText(isDeviceManaged, hasWorkProfile,
|
||||||
hasCACerts, hasCACertsInWorkProfile, isNetworkLoggingEnabled, vpnName,
|
hasCACerts, hasCACertsInWorkProfile, isNetworkLoggingEnabled, vpnName,
|
||||||
@@ -345,20 +355,15 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
|
|||||||
|
|
||||||
private View createOrganizationDialogView() {
|
private View createOrganizationDialogView() {
|
||||||
final boolean isDeviceManaged = mSecurityController.isDeviceManaged();
|
final boolean isDeviceManaged = mSecurityController.isDeviceManaged();
|
||||||
boolean isProfileOwnerOfOrganizationOwnedDevice =
|
|
||||||
mSecurityController.isProfileOwnerOfOrganizationOwnedDevice();
|
|
||||||
final boolean hasWorkProfile = mSecurityController.hasWorkProfile();
|
final boolean hasWorkProfile = mSecurityController.hasWorkProfile();
|
||||||
final CharSequence deviceOwnerOrganization =
|
final CharSequence deviceOwnerOrganization =
|
||||||
mSecurityController.getDeviceOwnerOrganizationName();
|
mSecurityController.getDeviceOwnerOrganizationName();
|
||||||
final CharSequence workProfileOrganizationName =
|
|
||||||
mSecurityController.getWorkProfileOrganizationName();
|
|
||||||
final boolean hasCACerts = mSecurityController.hasCACertInCurrentUser();
|
final boolean hasCACerts = mSecurityController.hasCACertInCurrentUser();
|
||||||
final boolean hasCACertsInWorkProfile = mSecurityController.hasCACertInWorkProfile();
|
final boolean hasCACertsInWorkProfile = mSecurityController.hasCACertInWorkProfile();
|
||||||
final boolean isNetworkLoggingEnabled = mSecurityController.isNetworkLoggingEnabled();
|
final boolean isNetworkLoggingEnabled = mSecurityController.isNetworkLoggingEnabled();
|
||||||
final String vpnName = mSecurityController.getPrimaryVpnName();
|
final String vpnName = mSecurityController.getPrimaryVpnName();
|
||||||
final String vpnNameWorkProfile = mSecurityController.getWorkProfileVpnName();
|
final String vpnNameWorkProfile = mSecurityController.getWorkProfileVpnName();
|
||||||
|
|
||||||
|
|
||||||
View dialogView = LayoutInflater.from(mContext)
|
View dialogView = LayoutInflater.from(mContext)
|
||||||
.inflate(R.layout.quick_settings_footer_dialog, null, false);
|
.inflate(R.layout.quick_settings_footer_dialog, null, false);
|
||||||
|
|
||||||
@@ -368,8 +373,7 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
|
|||||||
deviceManagementSubtitle.setText(getManagementTitle(deviceOwnerOrganization));
|
deviceManagementSubtitle.setText(getManagementTitle(deviceOwnerOrganization));
|
||||||
|
|
||||||
CharSequence managementMessage = getManagementMessage(isDeviceManaged,
|
CharSequence managementMessage = getManagementMessage(isDeviceManaged,
|
||||||
deviceOwnerOrganization, isProfileOwnerOfOrganizationOwnedDevice,
|
deviceOwnerOrganization);
|
||||||
workProfileOrganizationName);
|
|
||||||
if (managementMessage == null) {
|
if (managementMessage == null) {
|
||||||
dialogView.findViewById(R.id.device_management_disclosures).setVisibility(View.GONE);
|
dialogView.findViewById(R.id.device_management_disclosures).setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
@@ -377,11 +381,7 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
|
|||||||
TextView deviceManagementWarning =
|
TextView deviceManagementWarning =
|
||||||
(TextView) dialogView.findViewById(R.id.device_management_warning);
|
(TextView) dialogView.findViewById(R.id.device_management_warning);
|
||||||
deviceManagementWarning.setText(managementMessage);
|
deviceManagementWarning.setText(managementMessage);
|
||||||
// Don't show the policies button for profile owner of org owned device, because there
|
mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getSettingsButton(), this);
|
||||||
// is no policies settings screen for it
|
|
||||||
if (!isProfileOwnerOfOrganizationOwnedDevice) {
|
|
||||||
mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getSettingsButton(), this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ca certificate section
|
// ca certificate section
|
||||||
@@ -496,12 +496,11 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected CharSequence getManagementMessage(boolean isDeviceManaged,
|
protected CharSequence getManagementMessage(boolean isDeviceManaged,
|
||||||
CharSequence organizationName, boolean isProfileOwnerOfOrganizationOwnedDevice,
|
CharSequence organizationName) {
|
||||||
CharSequence workProfileOrganizationName) {
|
if (!isDeviceManaged) {
|
||||||
if (!isDeviceManaged && !isProfileOwnerOfOrganizationOwnedDevice) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (isDeviceManaged && organizationName != null) {
|
if (organizationName != null) {
|
||||||
if (isFinancedDevice()) {
|
if (isFinancedDevice()) {
|
||||||
return mContext.getString(R.string.monitoring_financed_description_named_management,
|
return mContext.getString(R.string.monitoring_financed_description_named_management,
|
||||||
organizationName, organizationName);
|
organizationName, organizationName);
|
||||||
@@ -509,9 +508,6 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen
|
|||||||
return mContext.getString(
|
return mContext.getString(
|
||||||
R.string.monitoring_description_named_management, organizationName);
|
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);
|
return mContext.getString(R.string.monitoring_description_management);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import static junit.framework.Assert.assertEquals;
|
|||||||
import static junit.framework.Assert.assertNotNull;
|
import static junit.framework.Assert.assertNotNull;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
@@ -188,6 +189,29 @@ public class QSSecurityFooterTest extends SysuiTestCase {
|
|||||||
assertEquals(View.GONE, mRootView.getVisibility());
|
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
|
@Test
|
||||||
public void testNetworkLoggingEnabled_deviceOwner() {
|
public void testNetworkLoggingEnabled_deviceOwner() {
|
||||||
when(mSecurityController.isDeviceManaged()).thenReturn(true);
|
when(mSecurityController.isDeviceManaged()).thenReturn(true);
|
||||||
@@ -435,10 +459,7 @@ public class QSSecurityFooterTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetManagementMessage_noManagement() {
|
public void testGetManagementMessage_noManagement() {
|
||||||
assertEquals(null, mFooter.getManagementMessage(
|
assertEquals(null, mFooter.getManagementMessage(
|
||||||
/* isDeviceManaged= */ false,
|
/* isDeviceManaged= */ false, MANAGING_ORGANIZATION));
|
||||||
MANAGING_ORGANIZATION,
|
|
||||||
/* isProfileOwnerOfOrganizationOwnedDevice= */ false,
|
|
||||||
MANAGING_ORGANIZATION));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -446,16 +467,11 @@ public class QSSecurityFooterTest extends SysuiTestCase {
|
|||||||
assertEquals(mContext.getString(R.string.monitoring_description_named_management,
|
assertEquals(mContext.getString(R.string.monitoring_description_named_management,
|
||||||
MANAGING_ORGANIZATION),
|
MANAGING_ORGANIZATION),
|
||||||
mFooter.getManagementMessage(
|
mFooter.getManagementMessage(
|
||||||
/* isDeviceManaged= */ true,
|
/* isDeviceManaged= */ true, MANAGING_ORGANIZATION));
|
||||||
MANAGING_ORGANIZATION,
|
|
||||||
/* isProfileOwnerOfOrganizationOwnedDevice= */ false,
|
|
||||||
/* workProfileOrganizationName= */ null));
|
|
||||||
assertEquals(mContext.getString(R.string.monitoring_description_management),
|
assertEquals(mContext.getString(R.string.monitoring_description_management),
|
||||||
mFooter.getManagementMessage(
|
mFooter.getManagementMessage(
|
||||||
/* isDeviceManaged= */ true,
|
/* isDeviceManaged= */ true,
|
||||||
/* organizationName= */ null,
|
/* organizationName= */ null));
|
||||||
/* isProfileOwnerOfOrganizationOwnedDevice= */ false,
|
|
||||||
/* workProfileOrganizationName= */ null));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -467,27 +483,7 @@ public class QSSecurityFooterTest extends SysuiTestCase {
|
|||||||
assertEquals(mContext.getString(R.string.monitoring_financed_description_named_management,
|
assertEquals(mContext.getString(R.string.monitoring_financed_description_named_management,
|
||||||
MANAGING_ORGANIZATION, MANAGING_ORGANIZATION),
|
MANAGING_ORGANIZATION, MANAGING_ORGANIZATION),
|
||||||
mFooter.getManagementMessage(
|
mFooter.getManagementMessage(
|
||||||
/* isDeviceManaged= */ true,
|
/* isDeviceManaged= */ true, MANAGING_ORGANIZATION));
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user