Introduce concept of DockUser

Dreams and docking often refers to "user zero" or "system user".
But more generally, the special user for dreams or switching-to-on-docking
need not be user 0, and in fact won't be in certain modes. So this needs updating.

Test: the files mentioned in the topic
Bug: 257333623
Change-Id: Ic671c91c32e9bf24695b067ff97cf9fa65534b1e
This commit is contained in:
Adam Bookatz
2022-11-07 10:46:53 -08:00
parent 502b19b33a
commit 48d81ecc6d
7 changed files with 27 additions and 26 deletions

View File

@@ -10400,11 +10400,11 @@ public final class Settings {
public static final String QS_AUTO_ADDED_TILES = "qs_auto_tiles"; public static final String QS_AUTO_ADDED_TILES = "qs_auto_tiles";
/** /**
* The duration of timeout, in milliseconds, to switch from a non-primary user to the * The duration of timeout, in milliseconds, to switch from a non-Dock User to the
* primary user when the device is docked. * Dock User when the device is docked.
* @hide * @hide
*/ */
public static final String TIMEOUT_TO_USER_ZERO = "timeout_to_user_zero"; public static final String TIMEOUT_TO_DOCK_USER = "timeout_to_dock_user";
/** /**
* Backup manager behavioral parameters. * Backup manager behavioral parameters.

View File

@@ -2438,8 +2438,8 @@
<integer name="config_dreamsBatteryLevelDrainCutoff">5</integer> <integer name="config_dreamsBatteryLevelDrainCutoff">5</integer>
<!-- Limit of how long the device can remain unlocked due to attention checking. --> <!-- Limit of how long the device can remain unlocked due to attention checking. -->
<integer name="config_attentionMaximumExtension">900000</integer> <!-- 15 minutes. --> <integer name="config_attentionMaximumExtension">900000</integer> <!-- 15 minutes. -->
<!-- Is the system user the only user allowed to dream. --> <!-- Whether there is to be a chosen Dock User who is the only user allowed to dream. -->
<bool name="config_dreamsOnlyEnabledForSystemUser">false</bool> <bool name="config_dreamsOnlyEnabledForDockUser">false</bool>
<!-- Whether dreams are disabled when ambient mode is suppressed. --> <!-- Whether dreams are disabled when ambient mode is suppressed. -->
<bool name="config_dreamsDisabledByAmbientModeSuppressionConfig">false</bool> <bool name="config_dreamsDisabledByAmbientModeSuppressionConfig">false</bool>
@@ -2688,9 +2688,9 @@
Should be false for most devices, except automotive vehicle with passenger displays. --> Should be false for most devices, except automotive vehicle with passenger displays. -->
<bool name="config_multiuserUsersOnSecondaryDisplays">false</bool> <bool name="config_multiuserUsersOnSecondaryDisplays">false</bool>
<!-- Whether to automatically switch a non-primary user back to the primary user after a <!-- Whether to automatically switch to the designated Dock User (the user chosen for
timeout when the device is docked. --> displaying dreams, etc.) after a timeout when the device is docked. -->
<bool name="config_enableTimeoutToUserZeroWhenDocked">false</bool> <bool name="config_enableTimeoutToDockUserWhenDocked">false</bool>
<!-- Whether to only install system packages on a user if they're allowlisted for that user <!-- Whether to only install system packages on a user if they're allowlisted for that user
type. These are flags and can be freely combined. type. These are flags and can be freely combined.

View File

@@ -466,7 +466,7 @@
<java-symbol type="integer" name="config_multiuserMaxRunningUsers" /> <java-symbol type="integer" name="config_multiuserMaxRunningUsers" />
<java-symbol type="bool" name="config_multiuserDelayUserDataLocking" /> <java-symbol type="bool" name="config_multiuserDelayUserDataLocking" />
<java-symbol type="bool" name="config_multiuserUsersOnSecondaryDisplays" /> <java-symbol type="bool" name="config_multiuserUsersOnSecondaryDisplays" />
<java-symbol type="bool" name="config_enableTimeoutToUserZeroWhenDocked" /> <java-symbol type="bool" name="config_enableTimeoutToDockUserWhenDocked" />
<java-symbol type="integer" name="config_userTypePackageWhitelistMode"/> <java-symbol type="integer" name="config_userTypePackageWhitelistMode"/>
<java-symbol type="xml" name="config_user_types" /> <java-symbol type="xml" name="config_user_types" />
<java-symbol type="integer" name="config_safe_media_volume_index" /> <java-symbol type="integer" name="config_safe_media_volume_index" />
@@ -2237,7 +2237,7 @@
<java-symbol type="integer" name="config_dreamsBatteryLevelDrainCutoff" /> <java-symbol type="integer" name="config_dreamsBatteryLevelDrainCutoff" />
<java-symbol type="string" name="config_dreamsDefaultComponent" /> <java-symbol type="string" name="config_dreamsDefaultComponent" />
<java-symbol type="bool" name="config_dreamsDisabledByAmbientModeSuppressionConfig" /> <java-symbol type="bool" name="config_dreamsDisabledByAmbientModeSuppressionConfig" />
<java-symbol type="bool" name="config_dreamsOnlyEnabledForSystemUser" /> <java-symbol type="bool" name="config_dreamsOnlyEnabledForDockUser" />
<java-symbol type="integer" name="config_dreamOpenAnimationDuration" /> <java-symbol type="integer" name="config_dreamOpenAnimationDuration" />
<java-symbol type="integer" name="config_dreamCloseAnimationDuration" /> <java-symbol type="integer" name="config_dreamCloseAnimationDuration" />
<java-symbol type="array" name="config_supportedDreamComplications" /> <java-symbol type="array" name="config_supportedDreamComplications" />

View File

@@ -884,7 +884,7 @@ public class SettingsBackupTest {
Settings.Secure.SHOW_QR_CODE_SCANNER_SETTING, Settings.Secure.SHOW_QR_CODE_SCANNER_SETTING,
Settings.Secure.SKIP_ACCESSIBILITY_SHORTCUT_DIALOG_TIMEOUT_RESTRICTION, Settings.Secure.SKIP_ACCESSIBILITY_SHORTCUT_DIALOG_TIMEOUT_RESTRICTION,
Settings.Secure.SPATIAL_AUDIO_ENABLED, Settings.Secure.SPATIAL_AUDIO_ENABLED,
Settings.Secure.TIMEOUT_TO_USER_ZERO, Settings.Secure.TIMEOUT_TO_DOCK_USER,
Settings.Secure.UI_NIGHT_MODE_LAST_COMPUTED, Settings.Secure.UI_NIGHT_MODE_LAST_COMPUTED,
Settings.Secure.UI_NIGHT_MODE_OVERRIDE_OFF, Settings.Secure.UI_NIGHT_MODE_OVERRIDE_OFF,
Settings.Secure.UI_NIGHT_MODE_OVERRIDE_ON); Settings.Secure.UI_NIGHT_MODE_OVERRIDE_ON);

View File

@@ -44,7 +44,7 @@ import dagger.Provides;
DreamOverlayComponent.class, DreamOverlayComponent.class,
}) })
public interface DreamModule { public interface DreamModule {
String DREAM_ONLY_ENABLED_FOR_SYSTEM_USER = "dream_only_enabled_for_system_user"; String DREAM_ONLY_ENABLED_FOR_DOCK_USER = "dream_only_enabled_for_dock_user";
String DREAM_SUPPORTED = "dream_supported"; String DREAM_SUPPORTED = "dream_supported";
@@ -70,10 +70,10 @@ public interface DreamModule {
/** */ /** */
@Provides @Provides
@Named(DREAM_ONLY_ENABLED_FOR_SYSTEM_USER) @Named(DREAM_ONLY_ENABLED_FOR_DOCK_USER)
static boolean providesDreamOnlyEnabledForSystemUser(@Main Resources resources) { static boolean providesDreamOnlyEnabledForDockUser(@Main Resources resources) {
return resources.getBoolean( return resources.getBoolean(
com.android.internal.R.bool.config_dreamsOnlyEnabledForSystemUser); com.android.internal.R.bool.config_dreamsOnlyEnabledForDockUser);
} }
/** */ /** */

View File

@@ -70,7 +70,7 @@ public class DreamTile extends QSTileImpl<QSTile.BooleanState> {
private final SettingObserver mDreamSettingObserver; private final SettingObserver mDreamSettingObserver;
private final UserTracker mUserTracker; private final UserTracker mUserTracker;
private final boolean mDreamSupported; private final boolean mDreamSupported;
private final boolean mDreamOnlyEnabledForSystemUser; private final boolean mDreamOnlyEnabledForDockUser;
private boolean mIsDocked = false; private boolean mIsDocked = false;
@@ -100,8 +100,8 @@ public class DreamTile extends QSTileImpl<QSTile.BooleanState> {
BroadcastDispatcher broadcastDispatcher, BroadcastDispatcher broadcastDispatcher,
UserTracker userTracker, UserTracker userTracker,
@Named(DreamModule.DREAM_SUPPORTED) boolean dreamSupported, @Named(DreamModule.DREAM_SUPPORTED) boolean dreamSupported,
@Named(DreamModule.DREAM_ONLY_ENABLED_FOR_SYSTEM_USER) @Named(DreamModule.DREAM_ONLY_ENABLED_FOR_DOCK_USER)
boolean dreamOnlyEnabledForSystemUser boolean dreamOnlyEnabledForDockUser
) { ) {
super(host, backgroundLooper, mainHandler, falsingManager, metricsLogger, super(host, backgroundLooper, mainHandler, falsingManager, metricsLogger,
statusBarStateController, activityStarter, qsLogger); statusBarStateController, activityStarter, qsLogger);
@@ -123,7 +123,7 @@ public class DreamTile extends QSTileImpl<QSTile.BooleanState> {
}; };
mUserTracker = userTracker; mUserTracker = userTracker;
mDreamSupported = dreamSupported; mDreamSupported = dreamSupported;
mDreamOnlyEnabledForSystemUser = dreamOnlyEnabledForSystemUser; mDreamOnlyEnabledForDockUser = dreamOnlyEnabledForDockUser;
} }
@Override @Override
@@ -203,7 +203,8 @@ public class DreamTile extends QSTileImpl<QSTile.BooleanState> {
// For now, restrict to debug users. // For now, restrict to debug users.
return Build.isDebuggable() return Build.isDebuggable()
&& mDreamSupported && mDreamSupported
&& (!mDreamOnlyEnabledForSystemUser || mUserTracker.getUserHandle().isSystem()); // TODO(b/257333623): Allow the Dock User to be non-SystemUser user in HSUM.
&& (!mDreamOnlyEnabledForDockUser || mUserTracker.getUserHandle().isSystem());
} }
@VisibleForTesting @VisibleForTesting

View File

@@ -116,7 +116,7 @@ public final class DreamManagerService extends SystemService {
private final DreamUiEventLogger mDreamUiEventLogger; private final DreamUiEventLogger mDreamUiEventLogger;
private final ComponentName mAmbientDisplayComponent; private final ComponentName mAmbientDisplayComponent;
private final boolean mDismissDreamOnActivityStart; private final boolean mDismissDreamOnActivityStart;
private final boolean mDreamsOnlyEnabledForSystemUser; private final boolean mDreamsOnlyEnabledForDockUser;
private final boolean mDreamsEnabledByDefaultConfig; private final boolean mDreamsEnabledByDefaultConfig;
private final boolean mDreamsActivatedOnChargeByDefault; private final boolean mDreamsActivatedOnChargeByDefault;
private final boolean mDreamsActivatedOnDockByDefault; private final boolean mDreamsActivatedOnDockByDefault;
@@ -214,8 +214,8 @@ public final class DreamManagerService extends SystemService {
mContext.getResources().getStringArray(R.array.config_loggable_dream_prefixes)); mContext.getResources().getStringArray(R.array.config_loggable_dream_prefixes));
AmbientDisplayConfiguration adc = new AmbientDisplayConfiguration(mContext); AmbientDisplayConfiguration adc = new AmbientDisplayConfiguration(mContext);
mAmbientDisplayComponent = ComponentName.unflattenFromString(adc.ambientDisplayComponent()); mAmbientDisplayComponent = ComponentName.unflattenFromString(adc.ambientDisplayComponent());
mDreamsOnlyEnabledForSystemUser = mDreamsOnlyEnabledForDockUser =
mContext.getResources().getBoolean(R.bool.config_dreamsOnlyEnabledForSystemUser); mContext.getResources().getBoolean(R.bool.config_dreamsOnlyEnabledForDockUser);
mDismissDreamOnActivityStart = mContext.getResources().getBoolean( mDismissDreamOnActivityStart = mContext.getResources().getBoolean(
R.bool.config_dismissDreamOnActivityStart); R.bool.config_dismissDreamOnActivityStart);
@@ -292,10 +292,9 @@ public final class DreamManagerService extends SystemService {
pw.println(); pw.println();
pw.println("mCurrentDream=" + mCurrentDream); pw.println("mCurrentDream=" + mCurrentDream);
pw.println("mForceAmbientDisplayEnabled=" + mForceAmbientDisplayEnabled); pw.println("mForceAmbientDisplayEnabled=" + mForceAmbientDisplayEnabled);
pw.println("mDreamsOnlyEnabledForSystemUser=" + mDreamsOnlyEnabledForSystemUser); pw.println("mDreamsOnlyEnabledForDockUser=" + mDreamsOnlyEnabledForDockUser);
pw.println("mDreamsEnabledSetting=" + mDreamsEnabledSetting); pw.println("mDreamsEnabledSetting=" + mDreamsEnabledSetting);
pw.println("mForceAmbientDisplayEnabled=" + mForceAmbientDisplayEnabled); pw.println("mForceAmbientDisplayEnabled=" + mForceAmbientDisplayEnabled);
pw.println("mDreamsOnlyEnabledForSystemUser=" + mDreamsOnlyEnabledForSystemUser);
pw.println("mDreamsActivatedOnDockByDefault=" + mDreamsActivatedOnDockByDefault); pw.println("mDreamsActivatedOnDockByDefault=" + mDreamsActivatedOnDockByDefault);
pw.println("mDreamsActivatedOnChargeByDefault=" + mDreamsActivatedOnChargeByDefault); pw.println("mDreamsActivatedOnChargeByDefault=" + mDreamsActivatedOnChargeByDefault);
pw.println("mIsDocked=" + mIsDocked); pw.println("mIsDocked=" + mIsDocked);
@@ -606,7 +605,8 @@ public final class DreamManagerService extends SystemService {
} }
private boolean dreamsEnabledForUser(int userId) { private boolean dreamsEnabledForUser(int userId) {
return !mDreamsOnlyEnabledForSystemUser || (userId == UserHandle.USER_SYSTEM); // TODO(b/257333623): Support non-system Dock Users in HSUM.
return !mDreamsOnlyEnabledForDockUser || (userId == UserHandle.USER_SYSTEM);
} }
private ServiceInfo getServiceInfo(ComponentName name) { private ServiceInfo getServiceInfo(ComponentName name) {