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

Commit eeef865a authored by Rahul Sabnis's avatar Rahul Sabnis
Browse files

Refactor AudioPlaybackConfiguration to reduce usages of hidden APIs

Bug: 141947725
Test: Manual
Change-Id: Ia95776cda3408c321d94494cb25b9cd85cb8662a
parent de032f2e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3732,6 +3732,7 @@ package android.media {
    method public android.media.PlayerProxy getPlayerProxy();
    method public int getPlayerState();
    method public int getPlayerType();
    method public boolean isActive();
    field public static final int PLAYER_STATE_IDLE = 1; // 0x1
    field public static final int PLAYER_STATE_PAUSED = 3; // 0x3
    field public static final int PLAYER_STATE_RELEASED = 0; // 0x0
+11 −12
Original line number Diff line number Diff line
@@ -400,6 +400,7 @@ public final class AudioPlaybackConfiguration implements Parcelable {
     * configurations
     * @return true if active
     */
    @SystemApi
    public boolean isActive() {
        switch (mPlayerState) {
            case PLAYER_STATE_STARTED:
@@ -420,18 +421,7 @@ public final class AudioPlaybackConfiguration implements Parcelable {
     * @param pw
     */
    public void dump(PrintWriter pw) {
        pw.println("  " + toLogFriendlyString(this));
    }

    /**
     * @hide
     */
    public static String toLogFriendlyString(AudioPlaybackConfiguration apc) {
        return new String("ID:" + apc.mPlayerIId
                + " -- type:" + toLogFriendlyPlayerType(apc.mPlayerType)
                + " -- u/pid:" + apc.mClientUid +"/" + apc.mClientPid
                + " -- state:" + toLogFriendlyPlayerState(apc.mPlayerState)
                + " -- attr:" + apc.mPlayerAttr);
        pw.println("  " + this);
    }

    public static final @android.annotation.NonNull Parcelable.Creator<AudioPlaybackConfiguration> CREATOR
@@ -498,6 +488,15 @@ public final class AudioPlaybackConfiguration implements Parcelable {
                && (mClientPid == that.mClientPid));
    }

    @Override
    public String toString() {
        return "AudioPlaybackConfiguration piid:" + mPlayerIId
                + " type:" + toLogFriendlyPlayerType(mPlayerType)
                + " u/pid:" + mClientUid + "/" + mClientPid
                + " state:" + toLogFriendlyPlayerState(mPlayerState)
                + " attr:" + mPlayerAttr;
    }

    //=====================================================================
    // Inner class for corresponding IPlayer and its death monitoring
    static final class IPlayerShell implements IBinder.DeathRecipient {
+1 −2
Original line number Diff line number Diff line
@@ -240,8 +240,7 @@ class AudioPlayerStateMonitor {
                    if (!mPrevActiveAudioPlaybackConfigs.containsKey(
                            config.getPlayerInterfaceId())) {
                        if (DEBUG) {
                            Log.d(TAG, "Found a new active media playback. "
                                    + AudioPlaybackConfiguration.toLogFriendlyString(config));
                            Log.d(TAG, "Found a new active media playback. " + config);
                        }
                        // New active audio playback.
                        int index = mSortedAudioPlaybackClientUids.indexOf(uid);