Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a858e630 authored by Chaohui Wang's avatar Chaohui Wang Committed by Android Build Coastguard Worker
Browse files

Enforce BaseUserRestriction for DISALLOW_CONFIG_SCREEN_TIMEOUT

Fix: 329202191
Test: pm set-user-restriction --user 0 no_config_screen_timeout 1
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:dd0f6752be54612db53e7d9b083c7dc12b6a2bb6)
Merged-In: Icd35365f446296fb53b1068d278d4cf5fd25939e
Change-Id: Icd35365f446296fb53b1068d278d4cf5fd25939e
parent 73014fe2
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static com.android.settings.display.ScreenTimeoutSettings.FALLBACK_SCREEN

import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.os.Process;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
@@ -67,9 +68,13 @@ public class ScreenTimeoutPreferenceController extends BasePreferenceController
                    .getString(DISABLED_BY_IT_ADMIN_TITLE,
                            () -> mContext.getString(R.string.disabled_by_policy_title)));
            ((RestrictedPreference) preference).setDisabledByAdmin(admin);
        } else {
            preference.setSummary(getTimeoutSummary(maxTimeout));
            return;
        }
        if (UserManager.get(mContext).hasBaseUserRestriction(
                UserManager.DISALLOW_CONFIG_SCREEN_TIMEOUT, Process.myUserHandle())) {
            preference.setEnabled(false);
        }
        preference.setSummary(getTimeoutSummary(maxTimeout));
    }

    private CharSequence getTimeoutSummary(long maxTimeout) {