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

Commit 774b6d56 authored by Vlad Popa's avatar Vlad Popa
Browse files

CSD: Persist csd and recover after boot or audioserver crash

Using the Settings.Global to persist any new CSD entry on the
AudioService side. Reason for global is because the standard is defined
for a PMP and not user. When the system boots we recover the previously
persisted CSD. After a crash in audioserver we apply the AudioService
cached values to the restarted audioserver. This will include the
recovery of the csd value and records which lead to that value.
New settings should not be backed up since they are determinedi for each
device independently.

Test: logs and dumpsys after audioserver kill and reboot
Bug: 264254900
Change-Id: Ie0c7b400d466981d198145d0ca0fc9c9e29eca63
parent fd19f960
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -15497,6 +15497,25 @@ public final class Settings {
        @Readable
        public static final String AUDIO_SAFE_VOLUME_STATE = "audio_safe_volume_state";
        /**
         * Persisted safe hearding current CSD value. Values are stored as float percentages where
         * 1.f represents 100% sound dose has been reached.
         * @hide
         */
        public static final String AUDIO_SAFE_CSD_CURRENT_VALUE = "audio_safe_csd_current_value";
        /**
         * Persisted safe hearding next CSD warning value. Values are stored as float percentages.
         * @hide
         */
        public static final String AUDIO_SAFE_CSD_NEXT_WARNING = "audio_safe_csd_next_warning";
        /**
         * Persisted safe hearding dose records (see {@link android.media.SoundDoseRecord})
         * @hide
         */
        public static final String AUDIO_SAFE_CSD_DOSE_RECORDS = "audio_safe_csd_dose_records";
        /**
         * URL for tzinfo (time zone) updates
         * @hide
+4 −1
Original line number Diff line number Diff line
@@ -88,6 +88,9 @@ message GlobalSettingsProto {

    optional SettingProto assisted_gps_enabled = 14 [ (android.privacy).dest = DEST_AUTOMATIC ];
    optional SettingProto audio_safe_volume_state = 15 [ (android.privacy).dest = DEST_AUTOMATIC ];
    optional SettingProto audio_safe_csd_current_value = 157 [ (android.privacy).dest = DEST_AUTOMATIC ];
    optional SettingProto audio_safe_csd_next_warning = 158 [ (android.privacy).dest = DEST_AUTOMATIC ];
    optional SettingProto audio_safe_csd_dose_records = 159 [ (android.privacy).dest = DEST_AUTOMATIC ];

    reserved 17; // Used to be autofill_compat_mode_allowed_packages

@@ -1087,5 +1090,5 @@ message GlobalSettingsProto {

    // Please insert fields in alphabetical order and group them into messages
    // if possible (to avoid reaching the method limit).
    // Next tag = 157;
    // Next tag = 160;
}
+9 −0
Original line number Diff line number Diff line
@@ -238,6 +238,15 @@ class SettingsProtoDumpUtil {
        dumpSetting(s, p,
                Settings.Global.AUDIO_SAFE_VOLUME_STATE,
                GlobalSettingsProto.AUDIO_SAFE_VOLUME_STATE);
        dumpSetting(s, p,
                Settings.Global.AUDIO_SAFE_CSD_CURRENT_VALUE,
                GlobalSettingsProto.AUDIO_SAFE_CSD_CURRENT_VALUE);
        dumpSetting(s, p,
                Settings.Global.AUDIO_SAFE_CSD_NEXT_WARNING,
                GlobalSettingsProto.AUDIO_SAFE_CSD_NEXT_WARNING);
        dumpSetting(s, p,
                Settings.Global.AUDIO_SAFE_CSD_DOSE_RECORDS,
                GlobalSettingsProto.AUDIO_SAFE_CSD_DOSE_RECORDS);

        final long autofillToken = p.start(GlobalSettingsProto.AUTOFILL);
        dumpSetting(s, p,
+3 −0
Original line number Diff line number Diff line
@@ -131,6 +131,9 @@ public class SettingsBackupTest {
                    Settings.Global.ART_VERIFIER_VERIFY_DEBUGGABLE,
                    Settings.Global.ASSISTED_GPS_ENABLED,
                    Settings.Global.AUDIO_SAFE_VOLUME_STATE,
                    Settings.Global.AUDIO_SAFE_CSD_CURRENT_VALUE,
                    Settings.Global.AUDIO_SAFE_CSD_NEXT_WARNING,
                    Settings.Global.AUDIO_SAFE_CSD_DOSE_RECORDS,
                    Settings.Global.AUTOFILL_LOGGING_LEVEL,
                    Settings.Global.AUTOFILL_MAX_PARTITIONS_SIZE,
                    Settings.Global.AUTOFILL_MAX_VISIBLE_DATASETS,
+2 −2
Original line number Diff line number Diff line
@@ -1462,7 +1462,7 @@ public class AudioService extends IAudioService.Stub
        mNm = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
        mSoundDoseHelper.configureSafeMediaVolume(/*forced=*/true, TAG);
        mSoundDoseHelper.configureSafeMedia(/*forced=*/true, TAG);
        initA11yMonitoring();
@@ -10224,7 +10224,7 @@ public class AudioService extends IAudioService.Stub
            // reading new configuration "safely" (i.e. under try catch) in case anything
            // goes wrong.
            Configuration config = context.getResources().getConfiguration();
            mSoundDoseHelper.configureSafeMediaVolume(/*forced*/false, TAG);
            mSoundDoseHelper.configureSafeMedia(/*forced*/false, TAG);
            boolean cameraSoundForced = readCameraSoundForced();
            synchronized (mSettingsLock) {
Loading