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

Commit f7a1534d authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add config overlay for alarms improvement features in multiuser" into main

parents 150daf9d 6d25f8b3
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -96,6 +96,7 @@ import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.content.pm.PackageManagerInternal;
import android.content.pm.PackageManagerInternal;
import android.content.pm.UserPackage;
import android.content.pm.UserPackage;
import android.content.res.Resources;
import android.net.Uri;
import android.net.Uri;
import android.os.BatteryManager;
import android.os.BatteryManager;
import android.os.BatteryStatsInternal;
import android.os.BatteryStatsInternal;
@@ -1784,7 +1785,8 @@ public class AlarmManagerService extends SystemService {
        mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class);
        mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class);


        mStartUserBeforeScheduledAlarms = Flags.startUserBeforeScheduledAlarms()
        mStartUserBeforeScheduledAlarms = Flags.startUserBeforeScheduledAlarms()
                && UserManager.supportsMultipleUsers();
                && UserManager.supportsMultipleUsers() && Resources.getSystem().getBoolean(
                com.android.internal.R.bool.config_allowAlarmsOnStoppedUsers);
        if (mStartUserBeforeScheduledAlarms) {
        if (mStartUserBeforeScheduledAlarms) {
            mUserWakeupStore = new UserWakeupStore();
            mUserWakeupStore = new UserWakeupStore();
            mUserWakeupStore.init();
            mUserWakeupStore.init();
+10 −0
Original line number Original line Diff line number Diff line
@@ -3156,6 +3156,16 @@
         with admin privileges and admin privileges can be granted/revoked from existing users. -->
         with admin privileges and admin privileges can be granted/revoked from existing users. -->
    <bool name="config_enableMultipleAdmins">false</bool>
    <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.
    <!-- Whether there is a communal profile which should always be running.
         Only relevant for Headless System User Mode (HSUM) devices. -->
         Only relevant for Headless System User Mode (HSUM) devices. -->
    <bool name="config_omnipresentCommunalUser">false</bool>
    <bool name="config_omnipresentCommunalUser">false</bool>
+2 −0
Original line number Original line Diff line number Diff line
@@ -366,6 +366,8 @@
  <java-symbol type="bool" name="config_canSwitchToHeadlessSystemUser"/>
  <java-symbol type="bool" name="config_canSwitchToHeadlessSystemUser"/>
  <java-symbol type="bool" name="config_enableMultiUserUI"/>
  <java-symbol type="bool" name="config_enableMultiUserUI"/>
  <java-symbol type="bool" name="config_enableMultipleAdmins"/>
  <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_bootToHeadlessSystemUser"/>
  <java-symbol type="bool" name="config_omnipresentCommunalUser"/>
  <java-symbol type="bool" name="config_omnipresentCommunalUser"/>
  <java-symbol type="bool" name="config_enableNewAutoSelectNetworkUI"/>
  <java-symbol type="bool" name="config_enableNewAutoSelectNetworkUI"/>
+13 −1
Original line number Original line 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_UNKNOWN;
import static android.os.UserManager.USER_OPERATION_ERROR_USER_RESTRICTED;
import static android.os.UserManager.USER_OPERATION_ERROR_USER_RESTRICTED;
import static android.os.UserManager.USER_TYPE_PROFILE_PRIVATE;
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 android.provider.Settings.Secure.HIDE_PRIVATESPACE_ENTRY_POINT;


import static com.android.internal.app.SetScreenLockDialogActivity.EXTRA_ORIGIN_USER_ID;
import static com.android.internal.app.SetScreenLockDialogActivity.EXTRA_ORIGIN_USER_ID;
@@ -1156,7 +1157,7 @@ public class UserManagerService extends IUserManager.Stub {


        showHsumNotificationIfNeeded();
        showHsumNotificationIfNeeded();


        if (Flags.addUiForSoundsFromBackgroundUsers()) {
        if (shouldShowNotificationForBackgroundUserSounds()) {
            new BackgroundUserSoundNotifier(mContext);
            new BackgroundUserSoundNotifier(mContext);
        }
        }
    }
    }
@@ -8485,6 +8486,17 @@ public class UserManagerService extends IUserManager.Stub {
                .getBoolean(R.bool.config_canSwitchToHeadlessSystemUser);
                .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}.
     * Returns instance of {@link com.android.server.pm.UserJourneyLogger}.
     */
     */
+3 −2
Original line number Original line Diff line number Diff line
@@ -79,6 +79,7 @@ import com.android.internal.app.IBatteryStats;
import com.android.internal.util.DumpUtils;
import com.android.internal.util.DumpUtils;
import com.android.server.SystemService;
import com.android.server.SystemService;
import com.android.server.pm.BackgroundUserSoundNotifier;
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.CallerInfo;
import com.android.server.vibrator.VibrationSession.DebugInfo;
import com.android.server.vibrator.VibrationSession.DebugInfo;
import com.android.server.vibrator.VibrationSession.Status;
import com.android.server.vibrator.VibrationSession.Status;
@@ -200,7 +201,7 @@ public class VibratorManagerService extends IVibratorManagerService.Stub {
                            VibratorManagerService.this::shouldCancelOnScreenOffLocked,
                            VibratorManagerService.this::shouldCancelOnScreenOffLocked,
                            Status.CANCELLED_BY_SCREEN_OFF);
                            Status.CANCELLED_BY_SCREEN_OFF);
                }
                }
            } else if (android.multiuser.Flags.addUiForSoundsFromBackgroundUsers()
            } else if (UserManagerService.shouldShowNotificationForBackgroundUserSounds()
                    && intent.getAction().equals(BackgroundUserSoundNotifier.ACTION_MUTE_SOUND)) {
                    && intent.getAction().equals(BackgroundUserSoundNotifier.ACTION_MUTE_SOUND)) {
                synchronized (mLock) {
                synchronized (mLock) {
                    maybeClearCurrentAndNextSessionsLocked(
                    maybeClearCurrentAndNextSessionsLocked(
@@ -324,7 +325,7 @@ public class VibratorManagerService extends IVibratorManagerService.Stub {


        IntentFilter filter = new IntentFilter();
        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_SCREEN_OFF);
        filter.addAction(Intent.ACTION_SCREEN_OFF);
        if (android.multiuser.Flags.addUiForSoundsFromBackgroundUsers()) {
        if (UserManagerService.shouldShowNotificationForBackgroundUserSounds()) {
            filter.addAction(BackgroundUserSoundNotifier.ACTION_MUTE_SOUND);
            filter.addAction(BackgroundUserSoundNotifier.ACTION_MUTE_SOUND);
        }
        }
        context.registerReceiver(mIntentReceiver, filter, Context.RECEIVER_NOT_EXPORTED);
        context.registerReceiver(mIntentReceiver, filter, Context.RECEIVER_NOT_EXPORTED);
Loading