Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6d25f8b3 authored by Tetiana Meronyk's avatar Tetiana Meronyk
Browse files

Add config overlay for alarms improvement features in multiuser

By default the features are enabled but can be disabled by overriding their values in corresponding overlay file.

Bug: 385341949
Test: atest UserManagerServiceTest && atest VibratorManagerServiceTest && atest AlarmManagerServiceTest // with config values both on and off
Flag: android.multiuser.multiple_alarm_notifications_support
Change-Id: Ibfdd4d30920bdbef4a3ff1ec177ce8042f403d5d
parent 6988e7a4
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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();
+10 −0
Original line number Diff line number Diff line
@@ -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>
+2 −0
Original line number Diff line number Diff line
@@ -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"/>
+13 −1
Original line number Diff line number Diff line
@@ -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);
        }
    }
@@ -8479,6 +8480,17 @@ public class UserManagerService extends IUserManager.Stub {
                .getBoolean(R.bool.config_canSwitchToHeadlessSystemUser);
    }

    /**
     * @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}.
     */
+3 −2
Original line number Diff line number Diff line
@@ -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);
Loading