Allow Device Management Role Holder to update Settings strings.
Test: manual Bug: 188414370 Change-Id: I6e1a06619799a9e99382d791e72e2e4518f93cac
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
// TODO (b/35202196): move this class out of the root of the package.
|
||||
package com.android.settings.password;
|
||||
|
||||
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_LOCK_ATTEMPTS_FAILED;
|
||||
|
||||
import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
@@ -243,13 +245,16 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFr
|
||||
// Last try
|
||||
final String title = getActivity().getString(
|
||||
R.string.lock_last_attempt_before_wipe_warning_title);
|
||||
final int messageId = getLastTryErrorMessage(userType);
|
||||
LastTryDialog.show(fragmentManager, title, messageId,
|
||||
final String overrideMessageId = getLastTryOverrideErrorMessageId(userType);
|
||||
final int defaultMessageId = getLastTryDefaultErrorMessage(userType);
|
||||
final String message = mDevicePolicyManager.getString(
|
||||
overrideMessageId, () -> getString(defaultMessageId));
|
||||
LastTryDialog.show(fragmentManager, title, message,
|
||||
android.R.string.ok, false /* dismiss */);
|
||||
} else {
|
||||
// Device, profile, or secondary user is wiped
|
||||
final int messageId = getWipeMessage(userType);
|
||||
LastTryDialog.show(fragmentManager, null /* title */, messageId,
|
||||
final String message = getWipeMessage(userType);
|
||||
LastTryDialog.show(fragmentManager, null /* title */, message,
|
||||
R.string.lock_failed_attempts_now_wiping_dialog_dismiss, true /* dismiss */);
|
||||
}
|
||||
}
|
||||
@@ -266,16 +271,18 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFr
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract int getLastTryErrorMessage(int userType);
|
||||
protected abstract String getLastTryOverrideErrorMessageId(int userType);
|
||||
protected abstract int getLastTryDefaultErrorMessage(int userType);
|
||||
|
||||
private int getWipeMessage(int userType) {
|
||||
private String getWipeMessage(int userType) {
|
||||
switch (userType) {
|
||||
case USER_TYPE_PRIMARY:
|
||||
return R.string.lock_failed_attempts_now_wiping_device;
|
||||
return getString(R.string.lock_failed_attempts_now_wiping_device);
|
||||
case USER_TYPE_MANAGED_PROFILE:
|
||||
return R.string.lock_failed_attempts_now_wiping_profile;
|
||||
return mDevicePolicyManager.getString(WORK_PROFILE_LOCK_ATTEMPTS_FAILED,
|
||||
() -> getString(R.string.lock_failed_attempts_now_wiping_profile));
|
||||
case USER_TYPE_SECONDARY:
|
||||
return R.string.lock_failed_attempts_now_wiping_user;
|
||||
return getString(R.string.lock_failed_attempts_now_wiping_user);
|
||||
default:
|
||||
throw new IllegalArgumentException("Unrecognized user type:" + userType);
|
||||
}
|
||||
@@ -311,7 +318,7 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFr
|
||||
private static final String ARG_BUTTON = "button";
|
||||
private static final String ARG_DISMISS = "dismiss";
|
||||
|
||||
static boolean show(FragmentManager from, String title, int message, int button,
|
||||
static boolean show(FragmentManager from, String title, String message, int button,
|
||||
boolean dismiss) {
|
||||
LastTryDialog existent = (LastTryDialog) from.findFragmentByTag(TAG);
|
||||
if (existent != null && !existent.isRemoving()) {
|
||||
@@ -319,7 +326,7 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFr
|
||||
}
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_TITLE, title);
|
||||
args.putInt(ARG_MESSAGE, message);
|
||||
args.putString(ARG_MESSAGE, message);
|
||||
args.putInt(ARG_BUTTON, button);
|
||||
args.putBoolean(ARG_DISMISS, dismiss);
|
||||
|
||||
@@ -349,7 +356,7 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFr
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
Dialog dialog = new AlertDialog.Builder(getActivity())
|
||||
.setTitle(getArguments().getString(ARG_TITLE))
|
||||
.setMessage(getArguments().getInt(ARG_MESSAGE))
|
||||
.setMessage(getArguments().getString(ARG_MESSAGE))
|
||||
.setPositiveButton(getArguments().getInt(ARG_BUTTON), null)
|
||||
.create();
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
|
Reference in New Issue
Block a user