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

Commit 52565ad5 authored by Salud Lemus's avatar Salud Lemus
Browse files

Remove default admin support message for an Enterprise device

Bug: 182195172
Test: m RunSettingsRoboTests ROBOTEST_FILTER=ActionDisabledByAdminDialogHelperTest

Change-Id: Ie844eee14ff0cc6a1c2f9dd0485c865f4e5e3e72
parent 50527b1f
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -10487,8 +10487,6 @@
    <string name="disabled_by_policy_title_suspend_packages">Can’t open this app</string>
    <!-- Dialog title. This dialog lets a user know that a specific setting is blocked by their credit provider. Since the user purchased the device from the credit provider, the credit provider controls what they can access. [CHAR LIMIT=50] -->
    <string name="disabled_by_policy_title_financed_device">Blocked by your credit provider</string>
    <!-- Shown when the user tries to change a settings locked by an admin [CHAR LIMIT=200] -->
    <string name="default_admin_support_msg">If you have questions, contact your IT admin</string>
    <!-- Shown in dialog to allow user to see more information about the device admin [CHAR LIMIT=30] -->
    <string name="admin_support_more_info">More details</string>
    <!-- Shown in admin details page to warn user about policies the admin can set in a work profile. [CHAR LIMIT=NONE] -->
+0 −2
Original line number Diff line number Diff line
@@ -233,8 +233,6 @@ public class ActionDisabledByAdminDialogHelper {
        final TextView textView = root.findViewById(R.id.admin_support_msg);
        if (supportMessage != null) {
            textView.setText(supportMessage);
        } else if (!isFinancedDevice()) {
            textView.setText(R.string.default_admin_support_msg);
        }
    }

+13 −13
Original line number Diff line number Diff line
@@ -195,7 +195,7 @@ public class ActionDisabledByAdminDialogHelperTest {
    }

    @Test
    public void testSetAdminSupportDetailsNotAdmin() {
    public void testSetAdminSupportDetails_shortSupportMessageIsNull() {
        final ShadowDevicePolicyManager dpmShadow = ShadowDevicePolicyManager.getShadow();
        final UserManager userManager = RuntimeEnvironment.application.getSystemService(
                UserManager.class);
@@ -205,19 +205,18 @@ public class ActionDisabledByAdminDialogHelperTest {
                "some.package.name.SomeClass");
        final EnforcedAdmin admin = new EnforcedAdmin(component, UserHandle.of(123));
        final TextView textView = createAdminSupportTextView(view, mActivity);
        dpmShadow.setShortSupportMessageForUser(component, 123, "some message");
        dpmShadow.setIsAdminActiveAsUser(false);
        userManagerShadow.addProfile(new UserInfo(123, null, 0));
        dpmShadow.setShortSupportMessageForUser(component, 123, null);
        dpmShadow.setIsAdminActiveAsUser(true);
        createShadowWorkProfile(userManagerShadow);

        mHelper.setAdminSupportDetails(mActivity, textView, admin);
        mHelper.setAdminSupportDetails(mActivity, view, admin);

        assertNull(admin.component);
        assertEquals(mActivity.getString(R.string.default_admin_support_msg),
                Shadows.shadowOf(textView).innerText());
        assertNotNull(admin.component);
        assertEquals("", Shadows.shadowOf(textView).innerText());
    }

    @Test
    public void testSetAdminSupportDetailsForFinancedDevice_shortSupportMessageIsNull() {
    public void testSetAdminSupportDetailsNotAdmin() {
        final ShadowDevicePolicyManager dpmShadow = ShadowDevicePolicyManager.getShadow();
        final UserManager userManager = RuntimeEnvironment.application.getSystemService(
                UserManager.class);
@@ -227,12 +226,13 @@ public class ActionDisabledByAdminDialogHelperTest {
                "some.package.name.SomeClass");
        final EnforcedAdmin admin = new EnforcedAdmin(component, UserHandle.of(123));
        final TextView textView = createAdminSupportTextView(view, mActivity);
        setupFinancedDevice(dpmShadow);
        createShadowWorkProfile(userManagerShadow);
        dpmShadow.setShortSupportMessageForUser(component, 123, "some message");
        dpmShadow.setIsAdminActiveAsUser(false);
        userManagerShadow.addProfile(new UserInfo(123, null, 0));

        mHelper.setAdminSupportDetails(mActivity, view, admin);
        mHelper.setAdminSupportDetails(mActivity, textView, admin);

        assertNotNull(admin.component);
        assertNull(admin.component);
        assertEquals("", Shadows.shadowOf(textView).innerText());
    }