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

Commit 8032f68d authored by Vlad Popa's avatar Vlad Popa Committed by Automerger Merge Worker
Browse files

Merge "CSD: Fix initial logic for mSafeMediaVolumeState" into udc-dev am: 661518fc

parents 6873e439 661518fc
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -87,10 +87,11 @@ public class SoundDoseHelper {
    private static final int SAFE_MEDIA_VOLUME_ACTIVE = 3;  // unconfirmed

    private static final int MSG_CONFIGURE_SAFE_MEDIA = SAFE_MEDIA_VOLUME_MSG_START + 1;
    private static final int MSG_PERSIST_SAFE_VOLUME_STATE = SAFE_MEDIA_VOLUME_MSG_START + 2;
    private static final int MSG_PERSIST_MUSIC_ACTIVE_MS = SAFE_MEDIA_VOLUME_MSG_START + 3;
    private static final int MSG_PERSIST_CSD_VALUES = SAFE_MEDIA_VOLUME_MSG_START + 4;
    /*package*/ static final int MSG_CSD_UPDATE_ATTENUATION = SAFE_MEDIA_VOLUME_MSG_START + 5;
    private static final int MSG_CONFIGURE_SAFE_MEDIA_FORCED = SAFE_MEDIA_VOLUME_MSG_START + 2;
    private static final int MSG_PERSIST_SAFE_VOLUME_STATE = SAFE_MEDIA_VOLUME_MSG_START + 3;
    private static final int MSG_PERSIST_MUSIC_ACTIVE_MS = SAFE_MEDIA_VOLUME_MSG_START + 4;
    private static final int MSG_PERSIST_CSD_VALUES = SAFE_MEDIA_VOLUME_MSG_START + 5;
    /*package*/ static final int MSG_CSD_UPDATE_ATTENUATION = SAFE_MEDIA_VOLUME_MSG_START + 6;

    private static final int UNSAFE_VOLUME_MUSIC_ACTIVE_MS_MAX = (20 * 3600 * 1000); // 20 hours

@@ -611,8 +612,7 @@ public class SoundDoseHelper {
    }

    /*package*/ void configureSafeMedia(boolean forced, String caller) {
        int msg = MSG_CONFIGURE_SAFE_MEDIA;

        int msg = forced ? MSG_CONFIGURE_SAFE_MEDIA_FORCED : MSG_CONFIGURE_SAFE_MEDIA;
        mAudioHandler.removeMessages(msg);

        long time = 0;
@@ -622,7 +622,7 @@ public class SoundDoseHelper {
        }

        mAudioHandler.sendMessageAtTime(
                mAudioHandler.obtainMessage(msg, /*arg1=*/forced ? 1 : 0, /*arg2=*/0, caller),
                mAudioHandler.obtainMessage(msg, /*arg1=*/0, /*arg2=*/0, caller),
                time);
    }

@@ -664,8 +664,10 @@ public class SoundDoseHelper {

    /*package*/ void handleMessage(Message msg) {
        switch (msg.what) {
            case MSG_CONFIGURE_SAFE_MEDIA_FORCED:
            case MSG_CONFIGURE_SAFE_MEDIA:
                onConfigureSafeMedia((msg.arg1 == 1), (String) msg.obj);
                onConfigureSafeMedia((msg.what == MSG_CONFIGURE_SAFE_MEDIA_FORCED),
                        (String) msg.obj);
                break;
            case MSG_PERSIST_SAFE_VOLUME_STATE:
                onPersistSafeVolumeState(msg.arg1);