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

Commit 4e984e55 authored by hjin81.lee's avatar hjin81.lee Committed by Jean-Michel Trivi
Browse files

Add Multi Audio focus

Allows the multiple audio focus that requested with AUDIOFOCUS_GAIN.

Test: atest SettingsProviderTest
Test: Manual - play music on A app
Test: play music on B app    // play music on A app and B app
Test: receive a call         // stop music
Test: end a call             // play music on A app and B app
Test: receive a notification // ducking all music

Bug: b/135749683
Change-Id: I4bdd2cdc5e543674f331fc000bd24fd30499bdc3
parent c0a89245
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -4729,6 +4729,14 @@ public final class Settings {
         */
         */
        public static final String SHOW_BATTERY_PERCENT = "status_bar_show_battery_percent";
        public static final String SHOW_BATTERY_PERCENT = "status_bar_show_battery_percent";
        /**
         * Whether or not to enable multiple audio focus.
         * When enabled, requires more management by user over application playback activity,
         * for instance pausing media apps when another starts.
         * @hide
         */
        public static final String MULTI_AUDIO_FOCUS_ENABLED = "multi_audio_focus_enabled";
        /**
        /**
         * IMPORTANT: If you add a new public settings you also have to add it to
         * IMPORTANT: If you add a new public settings you also have to add it to
         * PUBLIC_SETTINGS below. If the new setting is hidden you have to add
         * PUBLIC_SETTINGS below. If the new setting is hidden you have to add
+11 −0
Original line number Original line Diff line number Diff line
@@ -6001,6 +6001,17 @@ public class AudioManager {
        }
        }
    }
    }


    /** @hide
     * TODO: make this a @SystemApi */
    @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING)
    public void setMultiAudioFocusEnabled(boolean enabled) {
        try {
            getService().setMultiAudioFocusEnabled(enabled);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    //---------------------------------------------------------
    //---------------------------------------------------------
    // Inner classes
    // Inner classes
    //--------------------
    //--------------------
+2 −0
Original line number Original line Diff line number Diff line
@@ -296,4 +296,6 @@ interface IAudioService {


    // WARNING: read warning at top of file, new methods that need to be used by native
    // WARNING: read warning at top of file, new methods that need to be used by native
    // code via IAudioManager.h need to be added to the top section.
    // code via IAudioManager.h need to be added to the top section.

    oneway void setMultiAudioFocusEnabled(in boolean enabled);
}
}
+2 −1
Original line number Original line Diff line number Diff line
@@ -101,7 +101,8 @@ public class SettingsBackupTest {
                    Settings.System.MIN_REFRESH_RATE, // depends on hardware capabilities
                    Settings.System.MIN_REFRESH_RATE, // depends on hardware capabilities
                    Settings.System.PEAK_REFRESH_RATE, // depends on hardware capabilities
                    Settings.System.PEAK_REFRESH_RATE, // depends on hardware capabilities
                    Settings.System.SCREEN_BRIGHTNESS_FLOAT,
                    Settings.System.SCREEN_BRIGHTNESS_FLOAT,
                    Settings.System.SCREEN_BRIGHTNESS_FOR_VR_FLOAT
                    Settings.System.SCREEN_BRIGHTNESS_FOR_VR_FLOAT,
                    Settings.System.MULTI_AUDIO_FOCUS_ENABLED // form-factor/OEM specific
                    );
                    );


    private static final Set<String> BACKUP_BLACKLISTED_GLOBAL_SETTINGS =
    private static final Set<String> BACKUP_BLACKLISTED_GLOBAL_SETTINGS =
+17 −0
Original line number Original line Diff line number Diff line
@@ -8285,6 +8285,23 @@ public class AudioService extends IAudioService.Stub
        AudioSystem.setAudioHalPids(pidsArray);
        AudioSystem.setAudioHalPids(pidsArray);
    }
    }


    //======================
    // Multi Audio Focus
    //======================
    public void setMultiAudioFocusEnabled(boolean enabled) {
        enforceModifyAudioRoutingPermission();
        if (mMediaFocusControl != null) {
            boolean mafEnabled = mMediaFocusControl.getMultiAudioFocusEnabled();
            if (mafEnabled != enabled) {
                mMediaFocusControl.updateMultiAudioFocus(enabled);
                if (!enabled) {
                    mDeviceBroker.postBroadcastBecomingNoisy();
                }
            }
        }
    }


    //======================
    //======================
    // misc
    // misc
    //======================
    //======================
Loading