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

Commit 3d9d52f3 authored by Vlad Popa's avatar Vlad Popa
Browse files

Remove rolled out flag port_to_piid_simplification

This flag has been rolled out in 24Q3 and can be removed.

Test: make
Bug: 335747248
Flag: EXEMPT removing com.android.media.port_to_piid_simplification
Change-Id: I8baf4294fd9cbca73404ccf69ebd99e4fed0fccf
parent 73a3e6ed
Loading
Loading
Loading
Loading
+22 −70
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.server.audio;

import static android.media.AudioPlaybackConfiguration.EXTRA_PLAYER_EVENT_MUTE;
import static android.media.AudioPlaybackConfiguration.MUTED_BY_OP_PLAY_AUDIO;
import static android.media.AudioPlaybackConfiguration.MUTED_BY_CLIENT_VOLUME;
import static android.media.AudioPlaybackConfiguration.MUTED_BY_MASTER;
@@ -28,8 +27,6 @@ import static android.media.AudioPlaybackConfiguration.MUTED_BY_OP_CONTROL_AUDIO
import static android.media.AudioPlaybackConfiguration.PLAYER_PIID_INVALID;
import static android.media.AudioPlaybackConfiguration.PLAYER_UPDATE_MUTED;

import static com.android.media.audio.Flags.portToPiidSimplification;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
@@ -158,8 +155,6 @@ public final class PlaybackActivityMonitor

    @GuardedBy("mPlayerLock")
    private final SparseIntArray mPiidToPortId = new SparseIntArray();
    @GuardedBy("mPlayerLock")
    private final SparseIntArray mPortIdToPiid = new SparseIntArray();

    private final Context mContext;
    private int mSavedAlarmVolume = -1;
@@ -387,11 +382,7 @@ public final class PlaybackActivityMonitor
            sEventLogger.enqueue(new PlayerEvent(piid, event, eventValues));

            if (event == AudioPlaybackConfiguration.PLAYER_UPDATE_PORT_ID) {
                if (portToPiidSimplification()) {
                mPiidToPortId.put(piid, eventValues[0]);
                } else {
                    mPortIdToPiid.put(eventValues[0], piid);
                }
                return;
            } else if (event == AudioPlaybackConfiguration.PLAYER_STATE_STARTED) {
                for (Integer uidInteger: mBannedUids) {
@@ -446,20 +437,12 @@ public final class PlaybackActivityMonitor

        synchronized (mPlayerLock) {
            int piid;
            if (portToPiidSimplification()) {
            int idxOfPiid = mPiidToPortId.indexOfValue(portId);
            if (idxOfPiid < 0) {
                Log.w(TAG, "No piid assigned for invalid/internal port id " + portId);
                return;
            }
            piid = mPiidToPortId.keyAt(idxOfPiid);
            } else {
                piid = mPortIdToPiid.get(portId, PLAYER_PIID_INVALID);
                if (piid == PLAYER_PIID_INVALID) {
                    Log.w(TAG, "No piid assigned for invalid/internal port id " + portId);
                    return;
                }
            }
            final AudioPlaybackConfiguration apc = mPlayers.get(piid);
            if (apc == null) {
                Log.w(TAG, "No AudioPlaybackConfiguration assigned for piid " + piid);
@@ -496,20 +479,13 @@ public final class PlaybackActivityMonitor

        synchronized (mPlayerLock) {
            int piid;
            if (portToPiidSimplification()) {
            int idxOfPiid = mPiidToPortId.indexOfValue(portId);
            if (idxOfPiid < 0) {
                Log.w(TAG, "No piid assigned for invalid/internal port id " + portId);
                return;
            }
            piid = mPiidToPortId.keyAt(idxOfPiid);
            } else {
                piid = mPortIdToPiid.get(portId, PLAYER_PIID_INVALID);
                if (piid == PLAYER_PIID_INVALID) {
                    Log.w(TAG, "No piid assigned for invalid/internal port id " + portId);
                    return;
                }
            }

            final AudioPlaybackConfiguration apc = mPlayers.get(piid);
            if (apc == null) {
                Log.w(TAG, "No AudioPlaybackConfiguration assigned for piid " + piid);
@@ -559,15 +535,7 @@ public final class PlaybackActivityMonitor
                change = apc.handleStateEvent(AudioPlaybackConfiguration.PLAYER_STATE_RELEASED,
                        AudioPlaybackConfiguration.PLAYER_DEVICEIDS_INVALID);

                if (portToPiidSimplification()) {
                mPiidToPortId.delete(piid);
                } else {
                    // remove all port ids mapped to the released player
                    int portIdx;
                    while ((portIdx = mPortIdToPiid.indexOfValue(piid)) >= 0) {
                        mPortIdToPiid.removeAt(portIdx);
                    }
                }

                if (change && mDoNotLogPiidList.contains(piid)) {
                    // do not dispatch a change for a "do not log" player
@@ -585,17 +553,10 @@ public final class PlaybackActivityMonitor
                new EventLogger.StringEvent(
                        "clear port id to piid map"));
        synchronized (mPlayerLock) {
            if (portToPiidSimplification()) {
            if (DEBUG) {
                Log.v(TAG, "clear piid to portId map:\n" + mPiidToPortId);
            }
            mPiidToPortId.clear();
            } else {
                if (DEBUG) {
                    Log.v(TAG, "clear port id to piid map:\n" + mPortIdToPiid);
                }
                mPortIdToPiid.clear();
            }
        }
    }

@@ -754,7 +715,6 @@ public final class PlaybackActivityMonitor
                pw.print(" " + piid);
            }
            pw.println("\n");
            if (portToPiidSimplification()) {
            // portId to piid mappings:
            pw.println("\n  current piid to portId map:");
            for (int i = 0; i < mPiidToPortId.size(); ++i) {
@@ -762,14 +722,6 @@ public final class PlaybackActivityMonitor
                        "  piid: " + mPiidToPortId.keyAt(i) + " portId: "
                                + mPiidToPortId.valueAt(i));
            }
            } else {
                // portId to piid mappings:
                pw.println("\n  current portId to piid map:");
                for (int i = 0; i < mPortIdToPiid.size(); ++i) {
                    pw.println("  portId: " + mPortIdToPiid.keyAt(i) + " piid: "
                            + mPortIdToPiid.valueAt(i));
                }
            }
            pw.println("\n");
            // log
            sEventLogger.dump(pw);