Merge "Introduce concept of DockUser" into tm-qpr-dev

This commit is contained in:
Adam Bookatz
2022-11-16 00:59:40 +00:00
committed by Android (Google) Code Review
6 changed files with 26 additions and 25 deletions

View File

@@ -10309,11 +10309,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

@@ -2477,8 +2477,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>
@@ -2716,9 +2716,9 @@
will be locked. --> will be locked. -->
<bool name="config_multiuserDelayUserDataLocking">false</bool> <bool name="config_multiuserDelayUserDataLocking">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_multiuserMaximumUsers" /> <java-symbol type="integer" name="config_multiuserMaximumUsers" />
<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_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" />
@@ -2235,7 +2235,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

@@ -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);
@@ -602,7 +601,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) {