summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java4
-rw-r--r--core/res/res/values/config.xml10
-rw-r--r--core/res/res/values/symbols.xml2
-rw-r--r--services/core/java/com/android/server/pm/UserManagerService.java14
-rw-r--r--services/core/java/com/android/server/vibrator/VibratorManagerService.java5
-rw-r--r--services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java5
6 files changed, 34 insertions, 6 deletions
diff --git a/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java b/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java
index 60ba3b896a28..829442aed6ac 100644
--- a/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java
+++ b/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java
@@ -96,6 +96,7 @@ import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.PackageManagerInternal;
import android.content.pm.UserPackage;
+import android.content.res.Resources;
import android.net.Uri;
import android.os.BatteryManager;
import android.os.BatteryStatsInternal;
@@ -1784,7 +1785,8 @@ public class AlarmManagerService extends SystemService {
mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class);
mStartUserBeforeScheduledAlarms = Flags.startUserBeforeScheduledAlarms()
- && UserManager.supportsMultipleUsers();
+ && UserManager.supportsMultipleUsers() && Resources.getSystem().getBoolean(
+ com.android.internal.R.bool.config_allowAlarmsOnStoppedUsers);
if (mStartUserBeforeScheduledAlarms) {
mUserWakeupStore = new UserWakeupStore();
mUserWakeupStore.init();
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 45a5d85a097d..b7dd4a86c6a7 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -3141,6 +3141,16 @@
with admin privileges and admin privileges can be granted/revoked from existing users. -->
<bool name="config_enableMultipleAdmins">false</bool>
+ <!-- Whether to start stopped users before their scheduled alarms. If set to true, users will be
+ started in background before the alarm time so that it can go off. If false, alarms of
+ stopped users will not go off and users will remain stopped. -->
+ <bool name="config_allowAlarmsOnStoppedUsers">true</bool>
+
+ <!-- Whether notification is shown to foreground user when alarm/timer goes off on background
+ user. If set to true, foreground user will receive a notification with ability to mute
+ sound or switch user. If false, system notification will not be shown. -->
+ <bool name="config_showNotificationForBackgroundUserAlarms">true</bool>
+
<!-- Whether there is a communal profile which should always be running.
Only relevant for Headless System User Mode (HSUM) devices. -->
<bool name="config_omnipresentCommunalUser">false</bool>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index a18f923d625b..17efc839c7b8 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -366,6 +366,8 @@
<java-symbol type="bool" name="config_canSwitchToHeadlessSystemUser"/>
<java-symbol type="bool" name="config_enableMultiUserUI"/>
<java-symbol type="bool" name="config_enableMultipleAdmins"/>
+ <java-symbol type="bool" name="config_allowAlarmsOnStoppedUsers"/>
+ <java-symbol type="bool" name="config_showNotificationForBackgroundUserAlarms"/>
<java-symbol type="bool" name="config_bootToHeadlessSystemUser"/>
<java-symbol type="bool" name="config_omnipresentCommunalUser"/>
<java-symbol type="bool" name="config_enableNewAutoSelectNetworkUI"/>
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index 8249d65868cd..aac8ecc69059 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -33,6 +33,7 @@ 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;
@@ -1156,7 +1157,7 @@ public class UserManagerService extends IUserManager.Stub {
showHsumNotificationIfNeeded();
- if (Flags.addUiForSoundsFromBackgroundUsers()) {
+ if (shouldShowNotificationForBackgroundUserSounds()) {
new BackgroundUserSoundNotifier(mContext);
}
}
@@ -8480,6 +8481,17 @@ public class UserManagerService extends IUserManager.Stub {
}
/**
+ * @hide
+ * 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}.
*/
public UserJourneyLogger getUserJourneyLogger() {
diff --git a/services/core/java/com/android/server/vibrator/VibratorManagerService.java b/services/core/java/com/android/server/vibrator/VibratorManagerService.java
index ae726c15ed79..a5805043ac42 100644
--- a/services/core/java/com/android/server/vibrator/VibratorManagerService.java
+++ b/services/core/java/com/android/server/vibrator/VibratorManagerService.java
@@ -79,6 +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.vibrator.VibrationSession.CallerInfo;
import com.android.server.vibrator.VibrationSession.DebugInfo;
import com.android.server.vibrator.VibrationSession.Status;
@@ -200,7 +201,7 @@ public class VibratorManagerService extends IVibratorManagerService.Stub {
VibratorManagerService.this::shouldCancelOnScreenOffLocked,
Status.CANCELLED_BY_SCREEN_OFF);
}
- } else if (android.multiuser.Flags.addUiForSoundsFromBackgroundUsers()
+ } else if (UserManagerService.shouldShowNotificationForBackgroundUserSounds()
&& intent.getAction().equals(BackgroundUserSoundNotifier.ACTION_MUTE_SOUND)) {
synchronized (mLock) {
maybeClearCurrentAndNextSessionsLocked(
@@ -324,7 +325,7 @@ public class VibratorManagerService extends IVibratorManagerService.Stub {
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_SCREEN_OFF);
- if (android.multiuser.Flags.addUiForSoundsFromBackgroundUsers()) {
+ if (UserManagerService.shouldShowNotificationForBackgroundUserSounds()) {
filter.addAction(BackgroundUserSoundNotifier.ACTION_MUTE_SOUND);
}
context.registerReceiver(mIntentReceiver, filter, Context.RECEIVER_NOT_EXPORTED);
diff --git a/services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java b/services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java
index 194d48a80a65..767c02bd268f 100644
--- a/services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java
+++ b/services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java
@@ -109,6 +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.vibrator.VibrationSession.Status;
import org.junit.After;
@@ -896,8 +897,8 @@ public class VibratorManagerServiceTest {
}
@Test
- @EnableFlags(android.multiuser.Flags.FLAG_ADD_UI_FOR_SOUNDS_FROM_BACKGROUND_USERS)
public void vibrate_thenFgUserRequestsMute_getsCancelled() throws Throwable {
+ assumeTrue(UserManagerService.shouldShowNotificationForBackgroundUserSounds());
mockVibrators(1);
VibratorManagerService service = createSystemReadyService();
@@ -2758,8 +2759,8 @@ public class VibratorManagerServiceTest {
}
@Test
- @EnableFlags(android.multiuser.Flags.FLAG_ADD_UI_FOR_SOUNDS_FROM_BACKGROUND_USERS)
public void onExternalVibration_thenFgUserRequestsMute_doNotCancelVibration() throws Throwable {
+ assumeTrue(UserManagerService.shouldShowNotificationForBackgroundUserSounds());
mockVibrators(1);
mVibratorProviders.get(1).setCapabilities(IVibrator.CAP_EXTERNAL_CONTROL);
VibratorManagerService service = createSystemReadyService();