Remove Learn more button in Admin-Support Dialog
Google accessibility require us to remove the 'learn more' as it's not accessible(initial entry point is a disabled state). This currently directs to a generic work profile help article, which is pretty out of context and not super useful. We also don't change dialog title by restriction anymore. Bug: 252967902 Test: manual Change-Id: I6ff34c541a22dec50efc8564325923deabfeaafa
This commit is contained in:
@@ -18,12 +18,9 @@ package com.android.settingslib.enterprise;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
@@ -69,50 +66,11 @@ final class ManagedDeviceActionDisabledByAdminController
|
||||
mResolveActivityChecker = requireNonNull(resolveActivityChecker);
|
||||
}
|
||||
|
||||
/**
|
||||
* We don't show Learn More button in Admin-Support Dialog anymore.
|
||||
*/
|
||||
@Override
|
||||
public void setupLearnMoreButton(Context context) {
|
||||
assertInitialized();
|
||||
|
||||
String url = mStringProvider.getLearnMoreHelpPageUrl();
|
||||
|
||||
if (!TextUtils.isEmpty(url)
|
||||
&& canLaunchHelpPageInPreferredOrCurrentUser(context, url, mPreferredUserHandle)) {
|
||||
setupLearnMoreButtonToLaunchHelpPage(context, url, mPreferredUserHandle);
|
||||
} else {
|
||||
mLauncher.setupLearnMoreButtonToShowAdminPolicies(context, mEnforcementAdminUserId,
|
||||
mEnforcedAdmin);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canLaunchHelpPageInPreferredOrCurrentUser(
|
||||
Context context, String url, UserHandle preferredUserHandle) {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
if (mLauncher.canLaunchHelpPage(
|
||||
packageManager, url, preferredUserHandle, mResolveActivityChecker)
|
||||
&& mForegroundUserChecker.isUserForeground(context, preferredUserHandle)) {
|
||||
return true;
|
||||
}
|
||||
return mLauncher.canLaunchHelpPage(
|
||||
packageManager, url, context.getUser(), mResolveActivityChecker);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the "Learn more" button to launch the web help page in the {@code
|
||||
* preferredUserHandle} user. If not possible to launch it there, it sets up the button to
|
||||
* launch it in the current user instead.
|
||||
*/
|
||||
private void setupLearnMoreButtonToLaunchHelpPage(
|
||||
Context context, String url, UserHandle preferredUserHandle) {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
if (mLauncher.canLaunchHelpPage(
|
||||
packageManager, url, preferredUserHandle, mResolveActivityChecker)
|
||||
&& mForegroundUserChecker.isUserForeground(context, preferredUserHandle)) {
|
||||
mLauncher.setupLearnMoreButtonToLaunchHelpPage(context, url, preferredUserHandle);
|
||||
}
|
||||
if (mLauncher.canLaunchHelpPage(
|
||||
packageManager, url, context.getUser(), mResolveActivityChecker)) {
|
||||
mLauncher.setupLearnMoreButtonToLaunchHelpPage(context, url, context.getUser());
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isUserForeground(Context context, UserHandle userHandle) {
|
||||
@@ -122,25 +80,7 @@ final class ManagedDeviceActionDisabledByAdminController
|
||||
|
||||
@Override
|
||||
public String getAdminSupportTitle(@Nullable String restriction) {
|
||||
if (restriction == null) {
|
||||
return mStringProvider.getDefaultDisabledByPolicyTitle();
|
||||
}
|
||||
switch (restriction) {
|
||||
case UserManager.DISALLOW_ADJUST_VOLUME:
|
||||
return mStringProvider.getDisallowAdjustVolumeTitle();
|
||||
case UserManager.DISALLOW_OUTGOING_CALLS:
|
||||
return mStringProvider.getDisallowOutgoingCallsTitle();
|
||||
case UserManager.DISALLOW_SMS:
|
||||
return mStringProvider.getDisallowSmsTitle();
|
||||
case DevicePolicyManager.POLICY_DISABLE_CAMERA:
|
||||
return mStringProvider.getDisableCameraTitle();
|
||||
case DevicePolicyManager.POLICY_DISABLE_SCREEN_CAPTURE:
|
||||
return mStringProvider.getDisableScreenCaptureTitle();
|
||||
case DevicePolicyManager.POLICY_SUSPEND_PACKAGES:
|
||||
return mStringProvider.getSuspendPackagesTitle();
|
||||
default:
|
||||
return mStringProvider.getDefaultDisabledByPolicyTitle();
|
||||
}
|
||||
return mStringProvider.getDefaultDisabledByPolicyTitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,10 +18,7 @@ package com.android.settingslib.enterprise;
|
||||
|
||||
import static com.android.settingslib.enterprise.ActionDisabledByAdminControllerTestUtils.ENFORCED_ADMIN;
|
||||
import static com.android.settingslib.enterprise.ActionDisabledByAdminControllerTestUtils.ENFORCEMENT_ADMIN_USER_ID;
|
||||
import static com.android.settingslib.enterprise.ActionDisabledByAdminControllerTestUtils.LEARN_MORE_ACTION_LAUNCH_HELP_PAGE;
|
||||
import static com.android.settingslib.enterprise.ActionDisabledByAdminControllerTestUtils.LEARN_MORE_ACTION_SHOW_ADMIN_POLICIES;
|
||||
import static com.android.settingslib.enterprise.ActionDisabledByAdminControllerTestUtils.SUPPORT_MESSAGE;
|
||||
import static com.android.settingslib.enterprise.ActionDisabledByAdminControllerTestUtils.URL;
|
||||
import static com.android.settingslib.enterprise.FakeDeviceAdminStringProvider.DEFAULT_DISABLED_BY_POLICY_CONTENT;
|
||||
import static com.android.settingslib.enterprise.FakeDeviceAdminStringProvider.DEFAULT_DISABLED_BY_POLICY_TITLE;
|
||||
import static com.android.settingslib.enterprise.FakeDeviceAdminStringProvider.DISALLOW_ADJUST_VOLUME_TITLE;
|
||||
@@ -63,67 +60,6 @@ public class ManagedDeviceActionDisabledByAdminControllerTest {
|
||||
mActivity.setTheme(R.style.Theme_AppCompat_DayNight);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setupLearnMoreButton_noUrl_negativeButtonSet() {
|
||||
ManagedDeviceActionDisabledByAdminController controller = createController(EMPTY_URL);
|
||||
|
||||
controller.setupLearnMoreButton(mContext);
|
||||
|
||||
mTestUtils.assertLearnMoreAction(LEARN_MORE_ACTION_SHOW_ADMIN_POLICIES);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setupLearnMoreButton_validUrl_foregroundUser_launchesHelpPage() {
|
||||
ManagedDeviceActionDisabledByAdminController controller = createController(
|
||||
URL,
|
||||
/* isUserForeground= */ true,
|
||||
/* preferredUserHandle= */ MANAGED_USER,
|
||||
/* userContainingBrowser= */ MANAGED_USER);
|
||||
|
||||
controller.setupLearnMoreButton(mContext);
|
||||
|
||||
mTestUtils.assertLearnMoreAction(LEARN_MORE_ACTION_LAUNCH_HELP_PAGE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setupLearnMoreButton_validUrl_browserInPreferredUser_notForeground_showsAdminPolicies() {
|
||||
ManagedDeviceActionDisabledByAdminController controller = createController(
|
||||
URL,
|
||||
/* isUserForeground= */ false,
|
||||
/* preferredUserHandle= */ MANAGED_USER,
|
||||
/* userContainingBrowser= */ MANAGED_USER);
|
||||
|
||||
controller.setupLearnMoreButton(mContext);
|
||||
|
||||
mTestUtils.assertLearnMoreAction(LEARN_MORE_ACTION_SHOW_ADMIN_POLICIES);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setupLearnMoreButton_validUrl_browserInCurrentUser_launchesHelpPage() {
|
||||
ManagedDeviceActionDisabledByAdminController controller = createController(
|
||||
URL,
|
||||
/* isUserForeground= */ false,
|
||||
/* preferredUserHandle= */ MANAGED_USER,
|
||||
/* userContainingBrowser= */ mContext.getUser());
|
||||
|
||||
controller.setupLearnMoreButton(mContext);
|
||||
|
||||
mTestUtils.assertLearnMoreAction(LEARN_MORE_ACTION_LAUNCH_HELP_PAGE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setupLearnMoreButton_validUrl_browserNotOnAnyUser_showsAdminPolicies() {
|
||||
ManagedDeviceActionDisabledByAdminController controller = createController(
|
||||
URL,
|
||||
/* isUserForeground= */ false,
|
||||
/* preferredUserHandle= */ MANAGED_USER,
|
||||
/* userContainingBrowser= */ null);
|
||||
|
||||
controller.setupLearnMoreButton(mContext);
|
||||
|
||||
mTestUtils.assertLearnMoreAction(LEARN_MORE_ACTION_SHOW_ADMIN_POLICIES);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAdminSupportTitleResource_noRestriction_works() {
|
||||
ManagedDeviceActionDisabledByAdminController controller = createController();
|
||||
@@ -137,7 +73,7 @@ public class ManagedDeviceActionDisabledByAdminControllerTest {
|
||||
ManagedDeviceActionDisabledByAdminController controller = createController();
|
||||
|
||||
assertThat(controller.getAdminSupportTitle(RESTRICTION))
|
||||
.isEqualTo(SUPPORT_TITLE_FOR_RESTRICTION);
|
||||
.isEqualTo(DEFAULT_DISABLED_BY_POLICY_TITLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user