[MTE] allow device policy to control setting
Test: unit tests Test: TestDPC with COPE and DO Test: make RunSettingsRoboTests Bug: 244290023 Change-Id: I0e03d0dbe44ef595d813652f85529c1fe5fd6cec
This commit is contained in:
@@ -16,12 +16,16 @@
|
||||
|
||||
package com.android.settings.security;
|
||||
|
||||
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
|
||||
public class MemtagPagePreferenceController extends BasePreferenceController {
|
||||
static final String KEY_MEMTAG = "memtag_page";
|
||||
@@ -39,6 +43,10 @@ public class MemtagPagePreferenceController extends BasePreferenceController {
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
Preference preference = screen.findPreference(getPreferenceKey());
|
||||
EnforcedAdmin admin = RestrictedLockUtilsInternal.checkIfMteIsDisabled(mContext);
|
||||
if (admin != null) {
|
||||
((RestrictedPreference) preference).setDisabledByAdmin(admin);
|
||||
}
|
||||
refreshSummary(preference);
|
||||
}
|
||||
|
||||
|
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.settings.security;
|
||||
|
||||
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
@@ -24,6 +26,8 @@ import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
import com.android.settingslib.RestrictedSwitchPreference;
|
||||
|
||||
public class MemtagPreferenceController extends TogglePreferenceController {
|
||||
private Preference mPreference;
|
||||
@@ -74,6 +78,12 @@ public class MemtagPreferenceController extends TogglePreferenceController {
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
EnforcedAdmin admin = RestrictedLockUtilsInternal.checkIfMteIsDisabled(mContext);
|
||||
if (admin != null) {
|
||||
// Make sure this is disabled even if the user directly goes to this
|
||||
// page via the android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS intent.
|
||||
((RestrictedSwitchPreference) preference).setDisabledByAdmin(admin);
|
||||
}
|
||||
refreshSummary(preference);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user