Fix work profile screen timeout policy

am: 36cce83

* commit '36cce830b9319985b138432b89ea1022acf68785':
  Fix work profile screen timeout policy

Change-Id: If444464cd47efd2ced9c7b3d4f99465ab48360ea
This commit is contained in:
Ricky Wai
2016-04-07 16:30:20 +00:00
committed by android-build-merger
3 changed files with 6 additions and 3 deletions

View File

@@ -566,7 +566,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
return;
}
if (mDpm.getMaximumTimeToLock(null) > 0) {
if (mDpm.getMaximumTimeToLockForUserAndProfiles(UserHandle.myUserId()) > 0) {
// A DeviceAdmin has specified a maximum time until the device
// will lock... in this case we can't allow the user to turn
// on "stay awake when plugged in" because that would defeat the

View File

@@ -30,6 +30,7 @@ import android.hardware.SensorManager;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.support.v14.preference.SwitchPreference;
@@ -302,7 +303,8 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
if (dpm != null) {
final EnforcedAdmin admin = RestrictedLockUtils.checkIfMaximumTimeToLockIsSet(
getActivity());
final long maxTimeout = dpm.getMaximumTimeToLock(null);
final long maxTimeout = dpm
.getMaximumTimeToLockForUserAndProfiles(UserHandle.myUserId());
mScreenTimeoutPreference.removeUnusableTimeouts(maxTimeout, admin);
}
updateTimeoutPreferenceDescription(currentTimeout);

View File

@@ -1116,7 +1116,8 @@ public class SecuritySettings extends SettingsPreferenceFragment
if (mDPM != null) {
final EnforcedAdmin admin = RestrictedLockUtils.checkIfMaximumTimeToLockIsSet(
getActivity());
final long adminTimeout = mDPM.getMaximumTimeToLock(null);
final long adminTimeout = mDPM
.getMaximumTimeToLockForUserAndProfiles(UserHandle.myUserId());
final long displayTimeout = Math.max(0,
Settings.System.getInt(getContentResolver(), SCREEN_OFF_TIMEOUT, 0));
// This setting is a slave to display timeout when a device policy is enforced.