Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0dd3aa27 authored by arangelov's avatar arangelov
Browse files

Add support for PO on corp owned device for QS disclosure dialog

Fixes: 160145930
Test: manual
Test: atest QSSecurityFooterTest
Change-Id: I28fa9a150de16075a2705e5996bcdc2d40dbb555
parent 9e8c7bd6
Loading
Loading
Loading
Loading
+21 −5
Original line number Diff line number Diff line
@@ -265,9 +265,13 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic

    private void createDialog() {
        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();
@@ -284,7 +288,8 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic

        // device management section
        CharSequence managementMessage = getManagementMessage(isDeviceManaged,
                deviceOwnerOrganization);
                deviceOwnerOrganization, isProfileOwnerOfOrganizationOwnedDevice,
                workProfileOrganizationName);
        if (managementMessage == null) {
            dialogView.findViewById(R.id.device_management_disclosures).setVisibility(View.GONE);
        } else {
@@ -292,8 +297,12 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic
            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);
            }
        }

        // ca certificate section
        CharSequence caCertsMessage = getCaCertsMessage(isDeviceManaged, hasCACerts,
@@ -382,11 +391,18 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic
    }

    protected CharSequence getManagementMessage(boolean isDeviceManaged,
            CharSequence organizationName) {
        if (!isDeviceManaged) return null;
        if (organizationName != null)
            CharSequence organizationName, boolean isProfileOwnerOfOrganizationOwnedDevice,
            CharSequence workProfileOrganizationName) {
        if (!isDeviceManaged && !isProfileOwnerOfOrganizationOwnedDevice) {
            return null;
        }
        if (isDeviceManaged && organizationName != null) {
            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);
    }

+37 −4
Original line number Diff line number Diff line
@@ -367,13 +367,46 @@ public class QSSecurityFooterTest extends SysuiTestCase {
    }

    @Test
    public void testGetManagementMessage() {
        assertEquals(null, mFooter.getManagementMessage(false, MANAGING_ORGANIZATION));
    public void testGetManagementMessage_noManagement() {
        assertEquals(null, mFooter.getManagementMessage(
                /* isDeviceManaged= */ false,
                MANAGING_ORGANIZATION,
                /* isProfileOwnerOfOrganizationOwnedDevice= */ false,
                MANAGING_ORGANIZATION));
    }

    @Test
    public void testGetManagementMessage_deviceOwner() {
        assertEquals(mContext.getString(R.string.monitoring_description_named_management,
                                        MANAGING_ORGANIZATION),
                     mFooter.getManagementMessage(
                             /* isDeviceManaged= */ true,
                             MANAGING_ORGANIZATION,
                             /* isProfileOwnerOfOrganizationOwnedDevice= */ false,
                             /* workProfileOrganizationName= */ null));
        assertEquals(mContext.getString(R.string.monitoring_description_management),
                     mFooter.getManagementMessage(
                             /* isDeviceManaged= */ true,
                             /* organizationName= */ null,
                             /* isProfileOwnerOfOrganizationOwnedDevice= */ false,
                             /* workProfileOrganizationName= */ null));
    }

    @Test
    public void testGetManagementMessage_profileOwnerOfOrganizationOwnedDevice() {
        assertEquals(mContext.getString(R.string.monitoring_description_named_management,
                MANAGING_ORGANIZATION),
                     mFooter.getManagementMessage(true, MANAGING_ORGANIZATION));
                mFooter.getManagementMessage(
                        /* isDeviceManaged= */ false,
                        /* organizationName= */ null,
                        /* isProfileOwnerOfOrganizationOwnedDevice= */ true,
                        MANAGING_ORGANIZATION));
        assertEquals(mContext.getString(R.string.monitoring_description_management),
                     mFooter.getManagementMessage(true, null));
                mFooter.getManagementMessage(
                        /* isDeviceManaged= */ false,
                        /* organizationName= */ null,
                        /* isProfileOwnerOfOrganizationOwnedDevice= */ true,
                        /* workProfileOrganizationName= */ null));
    }

    @Test