[MTE] support force_on for device_control override
driveby: remove period for force_off message. Test: make RunSettingsRoboTests ROBOTEST_FILTER=MemtagHelperTest Bug: 245624194 Change-Id: I1c56af377925fd58c90bb346d9d003249c5e547c
This commit is contained in:
@@ -8037,7 +8037,9 @@
|
|||||||
<!-- [CHAR LIMIT=37] Status label indicating that system needs to be rebooted for Advanced memory protection to be off. -->
|
<!-- [CHAR LIMIT=37] Status label indicating that system needs to be rebooted for Advanced memory protection to be off. -->
|
||||||
<string name="memtag_off_pending" translatable="false">Off after restart</string>
|
<string name="memtag_off_pending" translatable="false">Off after restart</string>
|
||||||
<!-- [CHAR LIMIT=37] Status label indicating that Advanced memory protection was forced off via remote device configuration. -->
|
<!-- [CHAR LIMIT=37] Status label indicating that Advanced memory protection was forced off via remote device configuration. -->
|
||||||
<string name="memtag_force_off" translatable="false">Currently unavailable for your device.</string>
|
<string name="memtag_force_off" translatable="false">Currently unavailable for your device</string>
|
||||||
|
<!-- [CHAR LIMIT=37] Status label indicating that Advanced memory protection was forced on via remote device configuration. -->
|
||||||
|
<string name="memtag_force_on" translatable="false">Always on for your device</string>
|
||||||
<!-- [CHAR LIMIT=NONE] Subtext on page to control Advanced memory protection settings. -->
|
<!-- [CHAR LIMIT=NONE] Subtext on page to control Advanced memory protection settings. -->
|
||||||
<string name="memtag_footer" translatable="false">You\u0027ll have to restart your device to turn Advanced memory protection on or off. When it\u0027s on, you may notice slower device performance.</string>
|
<string name="memtag_footer" translatable="false">You\u0027ll have to restart your device to turn Advanced memory protection on or off. When it\u0027s on, you may notice slower device performance.</string>
|
||||||
<!-- [CHAR LIMIT=31] Header of dialog asking user to reboot device. -->
|
<!-- [CHAR LIMIT=31] Header of dialog asking user to reboot device. -->
|
||||||
|
@@ -32,6 +32,13 @@ public class MemtagHelper {
|
|||||||
"persist.device_config.memory_safety_native.bootloader_override"));
|
"persist.device_config.memory_safety_native.bootloader_override"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isForcedOn() {
|
||||||
|
return "force_on"
|
||||||
|
.equals(
|
||||||
|
SystemProperties.get(
|
||||||
|
"persist.device_config.memory_safety_native.bootloader_override"));
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isChecked() {
|
public static boolean isChecked() {
|
||||||
String modes[] = SystemProperties.get("arm64.memtag.bootctl", "").split(",");
|
String modes[] = SystemProperties.get("arm64.memtag.bootctl", "").split(",");
|
||||||
return Arrays.asList(modes).contains("memtag");
|
return Arrays.asList(modes).contains("memtag");
|
||||||
@@ -43,7 +50,7 @@ public class MemtagHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getAvailabilityStatus() {
|
public static int getAvailabilityStatus() {
|
||||||
if (MemtagHelper.isForcedOff()) {
|
if (MemtagHelper.isForcedOff() || MemtagHelper.isForcedOn()) {
|
||||||
return BasePreferenceController.DISABLED_DEPENDENT_SETTING;
|
return BasePreferenceController.DISABLED_DEPENDENT_SETTING;
|
||||||
}
|
}
|
||||||
return SystemProperties.getBoolean("ro.arm64.memtag.bootctl_settings_toggle", false)
|
return SystemProperties.getBoolean("ro.arm64.memtag.bootctl_settings_toggle", false)
|
||||||
@@ -65,6 +72,9 @@ public class MemtagHelper {
|
|||||||
if (isForcedOff()) {
|
if (isForcedOff()) {
|
||||||
return R.string.memtag_force_off;
|
return R.string.memtag_force_off;
|
||||||
}
|
}
|
||||||
|
if (isForcedOn()) {
|
||||||
|
return R.string.memtag_force_on;
|
||||||
|
}
|
||||||
if (isOn()) {
|
if (isOn()) {
|
||||||
if (isChecked()) {
|
if (isChecked()) {
|
||||||
return R.string.memtag_on;
|
return R.string.memtag_on;
|
||||||
|
@@ -86,6 +86,14 @@ public class MemtagHelperTest {
|
|||||||
.isEqualTo(BasePreferenceController.DISABLED_DEPENDENT_SETTING);
|
.isEqualTo(BasePreferenceController.DISABLED_DEPENDENT_SETTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_isForcedOn_isDISABLED_DEPENDENT_SETTING() {
|
||||||
|
ShadowSystemProperties.override(mDeviceConfigOverride, "force_on");
|
||||||
|
ShadowSystemProperties.override(mMemtagSupportedProperty, "true");
|
||||||
|
assertThat(MemtagHelper.getAvailabilityStatus())
|
||||||
|
.isEqualTo(BasePreferenceController.DISABLED_DEPENDENT_SETTING);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAvailabilityStatus_isUnsupported_isUNSUPPORTED_ON_DEVICE() {
|
public void getAvailabilityStatus_isUnsupported_isUNSUPPORTED_ON_DEVICE() {
|
||||||
ShadowSystemProperties.override(mDeviceConfigOverride, "");
|
ShadowSystemProperties.override(mDeviceConfigOverride, "");
|
||||||
@@ -159,4 +167,13 @@ public class MemtagHelperTest {
|
|||||||
ShadowSystemProperties.override(mMemtagProperty, "memtag");
|
ShadowSystemProperties.override(mMemtagProperty, "memtag");
|
||||||
assertThat(MemtagHelper.getSummary()).isEqualTo(R.string.memtag_force_off);
|
assertThat(MemtagHelper.getSummary()).isEqualTo(R.string.memtag_force_off);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Config(shadows = {ZygoteShadow.class})
|
||||||
|
public void getSummary_forceOffOverride_memtag_force_on() {
|
||||||
|
ZygoteShadow.setSupportsMemoryTagging(false);
|
||||||
|
ShadowSystemProperties.override(mDeviceConfigOverride, "force_on");
|
||||||
|
ShadowSystemProperties.override(mMemtagProperty, "memtag");
|
||||||
|
assertThat(MemtagHelper.getSummary()).isEqualTo(R.string.memtag_force_on);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user