Merge changes from topic "presubmit-am-6f72bdc3cc444506871d5647fce4bbd2" into tm-mainline-prod

* changes:
  [automerge] Add the ability to restrict dreams to the system user. 2p: 789f052027
  Add the ability to restrict dreams to the system user.
This commit is contained in:
William Leshner
2022-04-07 21:22:08 +00:00
committed by Android (Google) Code Review
3 changed files with 16 additions and 0 deletions

View File

@@ -2403,6 +2403,8 @@
<integer name="config_dreamsBatteryLevelDrainCutoff">5</integer>
<!-- Limit of how long the device can remain unlocked due to attention checking. -->
<integer name="config_attentionMaximumExtension">900000</integer> <!-- 15 minutes. -->
<!-- Is the system user the only user allowed to dream. -->
<bool name="config_dreamsOnlyEnabledForSystemUser">false</bool>
<!-- The prefix of dream component names that are loggable. If empty, logs "other" for all. -->
<string name ="config_loggable_dream_prefix" translatable="false"></string>

View File

@@ -2216,6 +2216,7 @@
<java-symbol type="integer" name="config_dreamsBatteryLevelMinimumWhenNotPowered" />
<java-symbol type="integer" name="config_dreamsBatteryLevelDrainCutoff" />
<java-symbol type="string" name="config_dreamsDefaultComponent" />
<java-symbol type="bool" name="config_dreamsOnlyEnabledForSystemUser" />
<java-symbol type="array" name="config_supportedDreamComplications" />
<java-symbol type="array" name="config_dreamComplicationsEnabledByDefault" />
<java-symbol type="array" name="config_disabledDreamComponents" />

View File

@@ -92,6 +92,7 @@ public final class DreamManagerService extends SystemService {
private boolean mCurrentDreamIsDozing;
private boolean mCurrentDreamIsWaking;
private boolean mForceAmbientDisplayEnabled;
private boolean mDreamsOnlyEnabledForSystemUser;
private int mCurrentDreamDozeScreenState = Display.STATE_UNKNOWN;
private int mCurrentDreamDozeScreenBrightness = PowerManager.BRIGHTNESS_DEFAULT;
@@ -115,6 +116,8 @@ public final class DreamManagerService extends SystemService {
mContext.getResources().getString(R.string.config_loggable_dream_prefix));
AmbientDisplayConfiguration adc = new AmbientDisplayConfiguration(mContext);
mAmbientDisplayComponent = ComponentName.unflattenFromString(adc.ambientDisplayComponent());
mDreamsOnlyEnabledForSystemUser =
mContext.getResources().getBoolean(R.bool.config_dreamsOnlyEnabledForSystemUser);
}
@Override
@@ -156,6 +159,7 @@ public final class DreamManagerService extends SystemService {
pw.println("mCurrentDreamIsDozing=" + mCurrentDreamIsDozing);
pw.println("mCurrentDreamIsWaking=" + mCurrentDreamIsWaking);
pw.println("mForceAmbientDisplayEnabled=" + mForceAmbientDisplayEnabled);
pw.println("mDreamsOnlyEnabledForSystemUser=" + mDreamsOnlyEnabledForSystemUser);
pw.println("mCurrentDreamDozeScreenState="
+ Display.stateToString(mCurrentDreamDozeScreenState));
pw.println("mCurrentDreamDozeScreenBrightness=" + mCurrentDreamDozeScreenBrightness);
@@ -314,6 +318,11 @@ public final class DreamManagerService extends SystemService {
}
private ComponentName[] getDreamComponentsForUser(int userId) {
if (!dreamsEnabledForUser(userId)) {
// Don't return any dream components if the user is not allowed to dream.
return null;
}
String names = Settings.Secure.getStringForUser(mContext.getContentResolver(),
Settings.Secure.SCREENSAVER_COMPONENTS,
userId);
@@ -367,6 +376,10 @@ public final class DreamManagerService extends SystemService {
}
private boolean dreamsEnabledForUser(int userId) {
return !mDreamsOnlyEnabledForSystemUser || (userId == UserHandle.USER_SYSTEM);
}
private ServiceInfo getServiceInfo(ComponentName name) {
try {
return name != null ? mContext.getPackageManager().getServiceInfo(name,