Add persistent MTE toggle to development options.

Bug: 245624194
Change-Id: I83283eb74360ec0eccd6b236b42eb987a580ec2c
This commit is contained in:
Florian Mayer
2023-01-27 13:22:54 -08:00
parent 73d7224561
commit 5b93b73df1
16 changed files with 663 additions and 29 deletions

View File

@@ -1,5 +1,6 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,7 +59,11 @@ public class MemtagPreferenceController extends TogglePreferenceController {
refreshSummary(mPreference);
}
if (isChecked != MemtagHelper.isOn()) {
MemtagRebootDialog.show(mContext, mFragment, isChecked);
int msg =
isChecked
? R.string.memtag_reboot_message_on
: R.string.memtag_reboot_message_off;
MemtagRebootDialog.show(mContext, mFragment, msg);
}
return true;
}

View File

@@ -34,16 +34,16 @@ public class MemtagRebootDialog extends InstrumentedDialogFragment
implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener {
public static final String TAG = "MemtagRebootDialog";
private boolean mIsChecked;
private int mMessage;
public MemtagRebootDialog(Context context, boolean isChecked) {
mIsChecked = isChecked;
public MemtagRebootDialog(Context context, int msg) {
mMessage = msg;
}
public static void show(Context context, Fragment host, boolean isChecked) {
public static void show(Context context, Fragment host, int msg) {
final FragmentManager manager = host.getActivity().getSupportFragmentManager();
if (manager.findFragmentByTag(TAG) == null) {
final MemtagRebootDialog dialog = new MemtagRebootDialog(context, isChecked);
final MemtagRebootDialog dialog = new MemtagRebootDialog(context, msg);
dialog.show(manager, TAG);
}
}
@@ -55,11 +55,9 @@ public class MemtagRebootDialog extends InstrumentedDialogFragment
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
int msg =
mIsChecked ? R.string.memtag_reboot_message_on : R.string.memtag_reboot_message_off;
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.memtag_reboot_title)
.setMessage(msg)
.setMessage(mMessage)
.setPositiveButton(R.string.memtag_reboot_yes, this /* onClickListener */)
.setNegativeButton(R.string.memtag_reboot_no, null /* onClickListener */)
.create();