[MTE] disable dev option if security setting is on
Test: make RunSettingsRoboTests check dev settings manually Bug: 245624194 Change-Id: I3d9c9b89cd5483eee9800077943b1c30738e4c16
This commit is contained in:
@@ -10475,6 +10475,8 @@
|
||||
<!-- Title for the button to reboot with MTE enabled. [CHAR LIMIT=NONE] -->
|
||||
<string name="reboot_with_mte_title">Reboot with MTE</string>
|
||||
<string name="reboot_with_mte_message">System will reboot and allow to experiment with Memory Tagging Extension (MTE). MTE may negatively impact system performance and stability. Will be reset on next subsequent reboot.</string>
|
||||
<string name="reboot_with_mte_summary">Try MTE for a single boot for app development.</string>
|
||||
<string name="reboot_with_mte_already_enabled">MTE is enabled through Advanced memory protection.</string>
|
||||
<!-- Toast that is shown when the user initiates capturing a heap dump for the system server. [CHAR LIMIT=NONE] -->
|
||||
<string name="capturing_system_heap_dump_message">Capturing system heap dump</string>
|
||||
<!-- Toast that is shown if there's an error capturing the user initiated heap dump. [CHAR LIMIT=NONE] -->
|
||||
|
@@ -21,8 +21,10 @@ import android.text.TextUtils;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.security.MemtagHelper;
|
||||
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
|
||||
|
||||
public class RebootWithMtePreferenceController extends DeveloperOptionsPreferenceController
|
||||
@@ -43,6 +45,20 @@ public class RebootWithMtePreferenceController extends DeveloperOptionsPreferenc
|
||||
return android.os.SystemProperties.getBoolean("ro.arm64.memtag.bootctl_supported", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
if (MemtagHelper.isChecked()) {
|
||||
return mContext.getResources().getString(R.string.reboot_with_mte_already_enabled);
|
||||
}
|
||||
return mContext.getResources().getString(R.string.reboot_with_mte_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
preference.setEnabled(!MemtagHelper.isChecked());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_REBOOT_WITH_MTE;
|
||||
|
@@ -22,6 +22,7 @@ import static junit.framework.Assert.assertTrue;
|
||||
import android.content.Context;
|
||||
import android.os.SystemProperties;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -61,4 +62,19 @@ public class RebootWithMtePreferenceControllerTest {
|
||||
SystemProperties.set("ro.arm64.memtag.bootctl_supported", "1");
|
||||
assertTrue(mController.isAvailable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_enabledByDefault() {
|
||||
Preference preference = new Preference(mContext);
|
||||
mController.updateState(preference);
|
||||
assertTrue(preference.isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_disabledIfAlreadyOn() {
|
||||
SystemProperties.set("arm64.memtag.bootctl", "memtag");
|
||||
Preference preference = new Preference(mContext);
|
||||
mController.updateState(preference);
|
||||
assertFalse(preference.isEnabled());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user