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

Commit f9f115d9 authored by Nadav Bar's avatar Nadav Bar
Browse files

Add STREAM_VOICE_CALL to MUTE_STREAMS_AFFECTED on upgrade

Update the system setting MUTE_STREAMS_AFFECTED to indicate that
STREAM_VOICE_CALL is affected by mute, as starting from P, phone apps can
mute the voice call stream as well.

Test: Tested manually that after upgrade stream can be muted.
Bug: 110398177
Change-Id: Ia20aa87525296bbf33e3f5234681427a47caaabe
parent 054ca07f
Loading
Loading
Loading
Loading
+32 −1
Original line number Diff line number Diff line
@@ -2935,7 +2935,7 @@ public class SettingsProvider extends ContentProvider {
        }

        private final class UpgradeController {
            private static final int SETTINGS_VERSION = 169;
            private static final int SETTINGS_VERSION = 170;

            private final int mUserId;

@@ -3810,6 +3810,37 @@ public class SettingsProvider extends ContentProvider {
                    currentVersion = 169;
                }

                if (currentVersion == 169) {
                    // Version 169: by default, add STREAM_VOICE_CALL to list of streams that can
                    // be muted.
                    final SettingsState systemSettings = getSystemSettingsLocked(userId);
                    final Setting currentSetting = systemSettings.getSettingLocked(
                              Settings.System.MUTE_STREAMS_AFFECTED);
                    if (!currentSetting.isNull()) {
                        try {
                            int currentSettingIntegerValue = Integer.parseInt(
                                    currentSetting.getValue());
                            if ((currentSettingIntegerValue
                                 & (1 << AudioManager.STREAM_VOICE_CALL)) == 0) {
                                systemSettings.insertSettingLocked(
                                    Settings.System.MUTE_STREAMS_AFFECTED,
                                    Integer.toString(
                                        currentSettingIntegerValue
                                        | (1 << AudioManager.STREAM_VOICE_CALL)),
                                    null, true, SettingsState.SYSTEM_PACKAGE_NAME);
                            }
                        } catch (NumberFormatException e) {
                            // remove the setting in case it is not a valid integer
                            Slog.w("Failed to parse integer value of MUTE_STREAMS_AFFECTED"
                                   + "setting, removing setting", e);
                            systemSettings.deleteSettingLocked(
                                Settings.System.MUTE_STREAMS_AFFECTED);
                        }

                    }
                    currentVersion = 170;
                }

                // vXXX: Add new settings above this point.

                if (currentVersion != newVersion) {