Loading services/core/java/com/android/server/pm/UserManagerInternal.java +12 −0 Original line number Diff line number Diff line Loading @@ -23,7 +23,9 @@ import android.content.Context; import android.content.pm.LauncherUserInfo; import android.content.pm.UserInfo; import android.content.pm.UserProperties; import android.content.res.Resources; import android.graphics.Bitmap; import android.multiuser.Flags; import android.os.Bundle; import android.os.UserManager; import android.util.DebugUtils; Loading Loading @@ -617,4 +619,14 @@ public abstract class UserManagerInternal { * if there is no such user. */ public abstract @UserIdInt int getCommunalProfileId(); /** * Checks whether to show a notification for sounds (e.g., alarms, timers, etc.) from * background users. */ public static boolean shouldShowNotificationForBackgroundUserSounds() { return Flags.addUiForSoundsFromBackgroundUsers() && Resources.getSystem().getBoolean( com.android.internal.R.bool.config_showNotificationForBackgroundUserAlarms) && UserManager.supportsMultipleUsers(); } } services/core/java/com/android/server/pm/UserManagerService.java +1 −13 Original line number Diff line number Diff line Loading @@ -33,7 +33,6 @@ import static android.os.UserManager.SYSTEM_USER_MODE_EMULATION_PROPERTY; import static android.os.UserManager.USER_OPERATION_ERROR_UNKNOWN; import static android.os.UserManager.USER_OPERATION_ERROR_USER_RESTRICTED; import static android.os.UserManager.USER_TYPE_PROFILE_PRIVATE; import static android.os.UserManager.supportsMultipleUsers; import static android.provider.Settings.Secure.HIDE_PRIVATESPACE_ENTRY_POINT; import static com.android.internal.app.SetScreenLockDialogActivity.EXTRA_ORIGIN_USER_ID; Loading @@ -60,7 +59,6 @@ import android.annotation.RequiresPermission; import android.annotation.SpecialUsers.CanBeALL; import android.annotation.SpecialUsers.CanBeCURRENT; import android.annotation.SpecialUsers.CanBeNULL; import android.annotation.SpecialUsers.CannotBeSpecialUser; import android.annotation.StringRes; import android.annotation.UserIdInt; import android.app.ActivityManager; Loading Loading @@ -1161,7 +1159,7 @@ public class UserManagerService extends IUserManager.Stub { showHsumNotificationIfNeeded(); if (shouldShowNotificationForBackgroundUserSounds()) { if (UserManagerInternal.shouldShowNotificationForBackgroundUserSounds()) { new BackgroundUserSoundNotifier(mContext); } } Loading Loading @@ -8498,16 +8496,6 @@ public class UserManagerService extends IUserManager.Stub { .getBoolean(R.bool.config_canSwitchToHeadlessSystemUser); } /** * Checks whether to show a notification for sounds (e.g., alarms, timers, etc.) from * background users. */ public static boolean shouldShowNotificationForBackgroundUserSounds() { return Flags.addUiForSoundsFromBackgroundUsers() && Resources.getSystem().getBoolean( com.android.internal.R.bool.config_showNotificationForBackgroundUserAlarms) && supportsMultipleUsers(); } /** * Returns instance of {@link com.android.server.pm.UserJourneyLogger}. */ Loading services/core/java/com/android/server/vibrator/VibratorManagerService.java +3 −3 Original line number Diff line number Diff line Loading @@ -79,7 +79,7 @@ import com.android.internal.app.IBatteryStats; import com.android.internal.util.DumpUtils; import com.android.server.SystemService; import com.android.server.pm.BackgroundUserSoundNotifier; import com.android.server.pm.UserManagerService; import com.android.server.pm.UserManagerInternal; import com.android.server.vibrator.VibrationSession.CallerInfo; import com.android.server.vibrator.VibrationSession.DebugInfo; import com.android.server.vibrator.VibrationSession.Status; Loading Loading @@ -201,7 +201,7 @@ public class VibratorManagerService extends IVibratorManagerService.Stub { VibratorManagerService.this::shouldCancelOnScreenOffLocked, Status.CANCELLED_BY_SCREEN_OFF); } } else if (UserManagerService.shouldShowNotificationForBackgroundUserSounds() } else if (UserManagerInternal.shouldShowNotificationForBackgroundUserSounds() && intent.getAction().equals(BackgroundUserSoundNotifier.ACTION_MUTE_SOUND)) { synchronized (mLock) { maybeClearCurrentAndNextSessionsLocked( Loading Loading @@ -325,7 +325,7 @@ public class VibratorManagerService extends IVibratorManagerService.Stub { IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_SCREEN_OFF); if (UserManagerService.shouldShowNotificationForBackgroundUserSounds()) { if (UserManagerInternal.shouldShowNotificationForBackgroundUserSounds()) { filter.addAction(BackgroundUserSoundNotifier.ACTION_MUTE_SOUND); } context.registerReceiver(mIntentReceiver, filter, Context.RECEIVER_NOT_EXPORTED); Loading services/tests/mockingservicestests/src/com/android/server/pm/UserManagerServiceTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,7 @@ public final class UserManagerServiceTest { .spyStatic(ActivityManager.class) .mockStatic(Settings.Global.class) .mockStatic(Settings.Secure.class) .mockStatic(Resources.class) .build(); @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule( Loading Loading @@ -202,6 +203,7 @@ public final class UserManagerServiceTest { doReturn(0) .when(mSpyResources) .getInteger(com.android.internal.R.integer.config_hsumBootStrategy); doReturn(mSpyResources).when(() -> Resources.getSystem()); // Must construct UserManagerService in the UiThread mTestDir = new File(mRealContext.getDataDir(), "umstest"); Loading services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -109,7 +109,7 @@ import com.android.internal.util.test.FakeSettingsProviderRule; import com.android.server.LocalServices; import com.android.server.companion.virtual.VirtualDeviceManagerInternal; import com.android.server.pm.BackgroundUserSoundNotifier; import com.android.server.pm.UserManagerService; import com.android.server.pm.UserManagerInternal; import com.android.server.vibrator.VibrationSession.Status; import org.junit.After; Loading Loading @@ -898,7 +898,7 @@ public class VibratorManagerServiceTest { @Test public void vibrate_thenFgUserRequestsMute_getsCancelled() throws Throwable { assumeTrue(UserManagerService.shouldShowNotificationForBackgroundUserSounds()); assumeTrue(UserManagerInternal.shouldShowNotificationForBackgroundUserSounds()); mockVibrators(1); VibratorManagerService service = createSystemReadyService(); Loading Loading @@ -2760,7 +2760,7 @@ public class VibratorManagerServiceTest { @Test public void onExternalVibration_thenFgUserRequestsMute_doNotCancelVibration() throws Throwable { assumeTrue(UserManagerService.shouldShowNotificationForBackgroundUserSounds()); assumeTrue(UserManagerInternal.shouldShowNotificationForBackgroundUserSounds()); mockVibrators(1); mVibratorProviders.get(1).setCapabilities(IVibrator.CAP_EXTERNAL_CONTROL); VibratorManagerService service = createSystemReadyService(); Loading Loading
services/core/java/com/android/server/pm/UserManagerInternal.java +12 −0 Original line number Diff line number Diff line Loading @@ -23,7 +23,9 @@ import android.content.Context; import android.content.pm.LauncherUserInfo; import android.content.pm.UserInfo; import android.content.pm.UserProperties; import android.content.res.Resources; import android.graphics.Bitmap; import android.multiuser.Flags; import android.os.Bundle; import android.os.UserManager; import android.util.DebugUtils; Loading Loading @@ -617,4 +619,14 @@ public abstract class UserManagerInternal { * if there is no such user. */ public abstract @UserIdInt int getCommunalProfileId(); /** * Checks whether to show a notification for sounds (e.g., alarms, timers, etc.) from * background users. */ public static boolean shouldShowNotificationForBackgroundUserSounds() { return Flags.addUiForSoundsFromBackgroundUsers() && Resources.getSystem().getBoolean( com.android.internal.R.bool.config_showNotificationForBackgroundUserAlarms) && UserManager.supportsMultipleUsers(); } }
services/core/java/com/android/server/pm/UserManagerService.java +1 −13 Original line number Diff line number Diff line Loading @@ -33,7 +33,6 @@ import static android.os.UserManager.SYSTEM_USER_MODE_EMULATION_PROPERTY; import static android.os.UserManager.USER_OPERATION_ERROR_UNKNOWN; import static android.os.UserManager.USER_OPERATION_ERROR_USER_RESTRICTED; import static android.os.UserManager.USER_TYPE_PROFILE_PRIVATE; import static android.os.UserManager.supportsMultipleUsers; import static android.provider.Settings.Secure.HIDE_PRIVATESPACE_ENTRY_POINT; import static com.android.internal.app.SetScreenLockDialogActivity.EXTRA_ORIGIN_USER_ID; Loading @@ -60,7 +59,6 @@ import android.annotation.RequiresPermission; import android.annotation.SpecialUsers.CanBeALL; import android.annotation.SpecialUsers.CanBeCURRENT; import android.annotation.SpecialUsers.CanBeNULL; import android.annotation.SpecialUsers.CannotBeSpecialUser; import android.annotation.StringRes; import android.annotation.UserIdInt; import android.app.ActivityManager; Loading Loading @@ -1161,7 +1159,7 @@ public class UserManagerService extends IUserManager.Stub { showHsumNotificationIfNeeded(); if (shouldShowNotificationForBackgroundUserSounds()) { if (UserManagerInternal.shouldShowNotificationForBackgroundUserSounds()) { new BackgroundUserSoundNotifier(mContext); } } Loading Loading @@ -8498,16 +8496,6 @@ public class UserManagerService extends IUserManager.Stub { .getBoolean(R.bool.config_canSwitchToHeadlessSystemUser); } /** * Checks whether to show a notification for sounds (e.g., alarms, timers, etc.) from * background users. */ public static boolean shouldShowNotificationForBackgroundUserSounds() { return Flags.addUiForSoundsFromBackgroundUsers() && Resources.getSystem().getBoolean( com.android.internal.R.bool.config_showNotificationForBackgroundUserAlarms) && supportsMultipleUsers(); } /** * Returns instance of {@link com.android.server.pm.UserJourneyLogger}. */ Loading
services/core/java/com/android/server/vibrator/VibratorManagerService.java +3 −3 Original line number Diff line number Diff line Loading @@ -79,7 +79,7 @@ import com.android.internal.app.IBatteryStats; import com.android.internal.util.DumpUtils; import com.android.server.SystemService; import com.android.server.pm.BackgroundUserSoundNotifier; import com.android.server.pm.UserManagerService; import com.android.server.pm.UserManagerInternal; import com.android.server.vibrator.VibrationSession.CallerInfo; import com.android.server.vibrator.VibrationSession.DebugInfo; import com.android.server.vibrator.VibrationSession.Status; Loading Loading @@ -201,7 +201,7 @@ public class VibratorManagerService extends IVibratorManagerService.Stub { VibratorManagerService.this::shouldCancelOnScreenOffLocked, Status.CANCELLED_BY_SCREEN_OFF); } } else if (UserManagerService.shouldShowNotificationForBackgroundUserSounds() } else if (UserManagerInternal.shouldShowNotificationForBackgroundUserSounds() && intent.getAction().equals(BackgroundUserSoundNotifier.ACTION_MUTE_SOUND)) { synchronized (mLock) { maybeClearCurrentAndNextSessionsLocked( Loading Loading @@ -325,7 +325,7 @@ public class VibratorManagerService extends IVibratorManagerService.Stub { IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_SCREEN_OFF); if (UserManagerService.shouldShowNotificationForBackgroundUserSounds()) { if (UserManagerInternal.shouldShowNotificationForBackgroundUserSounds()) { filter.addAction(BackgroundUserSoundNotifier.ACTION_MUTE_SOUND); } context.registerReceiver(mIntentReceiver, filter, Context.RECEIVER_NOT_EXPORTED); Loading
services/tests/mockingservicestests/src/com/android/server/pm/UserManagerServiceTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,7 @@ public final class UserManagerServiceTest { .spyStatic(ActivityManager.class) .mockStatic(Settings.Global.class) .mockStatic(Settings.Secure.class) .mockStatic(Resources.class) .build(); @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule( Loading Loading @@ -202,6 +203,7 @@ public final class UserManagerServiceTest { doReturn(0) .when(mSpyResources) .getInteger(com.android.internal.R.integer.config_hsumBootStrategy); doReturn(mSpyResources).when(() -> Resources.getSystem()); // Must construct UserManagerService in the UiThread mTestDir = new File(mRealContext.getDataDir(), "umstest"); Loading
services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -109,7 +109,7 @@ import com.android.internal.util.test.FakeSettingsProviderRule; import com.android.server.LocalServices; import com.android.server.companion.virtual.VirtualDeviceManagerInternal; import com.android.server.pm.BackgroundUserSoundNotifier; import com.android.server.pm.UserManagerService; import com.android.server.pm.UserManagerInternal; import com.android.server.vibrator.VibrationSession.Status; import org.junit.After; Loading Loading @@ -898,7 +898,7 @@ public class VibratorManagerServiceTest { @Test public void vibrate_thenFgUserRequestsMute_getsCancelled() throws Throwable { assumeTrue(UserManagerService.shouldShowNotificationForBackgroundUserSounds()); assumeTrue(UserManagerInternal.shouldShowNotificationForBackgroundUserSounds()); mockVibrators(1); VibratorManagerService service = createSystemReadyService(); Loading Loading @@ -2760,7 +2760,7 @@ public class VibratorManagerServiceTest { @Test public void onExternalVibration_thenFgUserRequestsMute_doNotCancelVibration() throws Throwable { assumeTrue(UserManagerService.shouldShowNotificationForBackgroundUserSounds()); assumeTrue(UserManagerInternal.shouldShowNotificationForBackgroundUserSounds()); mockVibrators(1); mVibratorProviders.get(1).setCapabilities(IVibrator.CAP_EXTERNAL_CONTROL); VibratorManagerService service = createSystemReadyService(); Loading