AudioFlinger: Remove unnecessary friends

Remove obsolete TODOs, replace as needed with specific bug numbers.

Test: compiles
Bug: 288339104
Merged-In: Ied525f2f100203800f746239685e77b8e033618e
Change-Id: Ied525f2f100203800f746239685e77b8e033618e
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 203af2f..276314c 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -3692,7 +3692,7 @@
          // clang-tidy suggests const ref
         sp<IAfEffectChain> ec = chains[i];  // NOLINT(performance-unnecessary-copy-initialization)
         int sessionid = ec->sessionId();
-        const auto t = sp<IAfThreadBase>::cast(ec->thread().promote()); // TODO(b/288339104)
+        const auto t = ec->thread().promote();
         if (t == 0) {
             continue;
         }
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 9bc0ff9..046fc90 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -151,8 +151,6 @@
 
 static const nsecs_t kDefaultStandbyTimeInNsecs = seconds(3);
 
-#define INCLUDING_FROM_AUDIOFLINGER_H
-
 using android::content::AttributionSourceState;
 
 struct stream_type_t {
@@ -163,6 +161,7 @@
 class AudioFlinger : public AudioFlingerServerAdapter::Delegate
 {
     friend class sp<AudioFlinger>;
+    // TODO(b/291319167) Create interface and remove friends.
     friend class Client; // removeClient_l();
     friend class DeviceEffectManager;
     friend class DeviceEffectManagerCallback;
@@ -513,7 +512,7 @@
     // Internal dump utilities.
     static const int kDumpLockTimeoutNs = 1 * NANOS_PER_SECOND;
 public:
-    // TODO(b/288339104) extract to afutils
+    // TODO(b/291319167) extract to afutils
     static bool dumpTryLock(Mutex& mutex);
 private:
     void dumpPermissionDenial(int fd, const Vector<String16>& args);
@@ -657,7 +656,7 @@
             IAfPlaybackThread* srcThread, IAfPlaybackThread* dstThread);
 
 public:
-    // TODO(b/288339104) cluster together
+    // TODO(b/291319167) cluster together
               status_t moveAuxEffectToIo(int EffectId,
             const sp<IAfPlaybackThread>& dstThread, sp<IAfPlaybackThread>* srcThread);
 private:
@@ -682,7 +681,7 @@
                 void        removeClient_l(pid_t pid);
                 void        removeNotificationClient(pid_t pid);
 public:
-    // TODO(b/288339104) cluster together
+    // TODO(b/291319167) cluster together
                 bool isNonOffloadableGlobalEffectEnabled_l();
 private:
                 void onNonOffloadableGlobalEffectEnable();
@@ -704,7 +703,7 @@
                 // and removed from mOrphanEffectChains if it does not contain any effect.
                 // Return true if the effect was found in mOrphanEffectChains, false otherwise.
 public:
-// TODO(b/288339104) suggest better grouping
+// TODO(b/291319167) suggest better grouping
                 bool updateOrphanEffectChains(const sp<IAfEffectModule>& effect);
 private:
                 std::vector< sp<IAfEffectModule> > purgeStaleEffects_l();
@@ -726,13 +725,13 @@
     };
 
 public:
-    // TODO(b/288339104) access by getter,
+    // TODO(b/291319167) access by getter,
     mutable     Mutex                               mLock;
                 // protects mClients and mNotificationClients.
                 // must be locked after mLock and ThreadBase::mLock if both must be locked
                 // avoids acquiring AudioFlinger::mLock from inside thread loop.
 
-    // TODO(b/288339104) access by getter,
+    // TODO(b/291319167) access by getter,
     mutable     Mutex                               mClientLock;
 private:
                 // protected by mClientLock
@@ -861,7 +860,7 @@
     const sp<IAfPatchPanel> mPatchPanel = IAfPatchPanel::create(this);
 
 public:
-    // TODO(b/288339104) access by getter.
+    // TODO(b/291319167) access by getter.
     sp<EffectsFactoryHalInterface> mEffectsFactoryHal;
 private:
 
@@ -897,8 +896,6 @@
     std::atomic_bool mBluetoothLatencyModesEnabled;
 };
 
-#undef INCLUDING_FROM_AUDIOFLINGER_H
-
 std::string formatToString(audio_format_t format);
 std::string inputFlagsToString(audio_input_flags_t flags);
 std::string outputFlagsToString(audio_output_flags_t flags);
diff --git a/services/audioflinger/Client.h b/services/audioflinger/Client.h
index cb507fe..142d384 100644
--- a/services/audioflinger/Client.h
+++ b/services/audioflinger/Client.h
@@ -16,7 +16,7 @@
 
 #pragma once
 
-// TODO(b/288339104) Move to nested namespace
+// TODO(b/291318727) Move to nested namespace
 namespace android {
 
 class AudioFlinger;
diff --git a/services/audioflinger/Effects.cpp b/services/audioflinger/Effects.cpp
index 563a3e3..4c1ed4f 100644
--- a/services/audioflinger/Effects.cpp
+++ b/services/audioflinger/Effects.cpp
@@ -2115,7 +2115,6 @@
         const wp<IAfThreadBase>& wThread,
         audio_session_t sessionId)
 {
-    // TODO(b/288339104) no weak pointer cast.
     return sp<EffectChain>::make(wThread, sessionId);
 }
 
diff --git a/services/audioflinger/IAfEffect.h b/services/audioflinger/IAfEffect.h
index 6937fd9..1236bc7 100644
--- a/services/audioflinger/IAfEffect.h
+++ b/services/audioflinger/IAfEffect.h
@@ -350,7 +350,7 @@
             const IAfPatchPanel::Patch& patch) = 0;
     virtual void onReleasePatch(audio_patch_handle_t patchHandle) = 0;
 
-    virtual void dump2(int fd, int spaces) const = 0; // TODO(b/288339104) naming?
+    virtual void dump2(int fd, int spaces) const = 0; // TODO(b/291319101) naming?
 
 private:
     // used by DeviceEffectProxy
diff --git a/services/audioflinger/IAfThread.h b/services/audioflinger/IAfThread.h
index 8b87ed7..ce4d62d 100644
--- a/services/audioflinger/IAfThread.h
+++ b/services/audioflinger/IAfThread.h
@@ -486,10 +486,10 @@
     virtual status_t getExternalPosition(uint64_t* position, int64_t* timeNanos) const = 0;
     virtual status_t reportData(const void* buffer, size_t frameCount) = 0;
 
-    // TODO(b/288339104)  move to IAfThreadBase?
+    // TODO(b/291317898)  move to IAfThreadBase?
     virtual void invalidateTracks(std::set<audio_port_handle_t>& portIds) = 0;
 
-    // Sets the UID records silence - TODO(b/288339104)  move to IAfMmapCaptureThread
+    // Sets the UID records silence - TODO(b/291317898)  move to IAfMmapCaptureThread
     virtual void setRecordSilenced(audio_port_handle_t portId, bool silenced) = 0;
 
     virtual sp<IAfMmapPlaybackThread> asIAfMmapPlaybackThread() { return nullptr; }
diff --git a/services/audioflinger/IAfTrack.h b/services/audioflinger/IAfTrack.h
index 35338fa..44d8a09 100644
--- a/services/audioflinger/IAfTrack.h
+++ b/services/audioflinger/IAfTrack.h
@@ -209,12 +209,12 @@
 
     /**
      * For RecordTrack
-     * TODO(b/288339104) either use this or add asRecordTrack or asTrack etc.
+     * TODO(b/291317964) either use this or add asRecordTrack or asTrack etc.
      */
     virtual void handleSyncStartEvent(const sp<audioflinger::SyncEvent>& event __unused){};
 
     // For Thread use, fast tracks and offloaded tracks only
-    // TODO(b/288339104) rearrange to IAfTrack.
+    // TODO(b/291317964) rearrange to IAfTrack.
     virtual bool isStopped() const = 0;
     virtual bool isStopping() const = 0;
     virtual bool isStopping_1() const = 0;
@@ -388,7 +388,7 @@
     virtual ExtendedAudioBufferProvider* asExtendedAudioBufferProvider() = 0;
     virtual VolumeProvider* asVolumeProvider() = 0;
 
-    // TODO(b/288339104) split into getter/setter
+    // TODO(b/291317964) split into getter/setter
     virtual FillingStatus& fillingStatus() = 0;
     virtual int8_t& retryCount() = 0;
     virtual FastTrackUnderruns& fastTrackUnderruns() = 0;
@@ -397,7 +397,6 @@
 // playback track, used by DuplicatingThread
 class IAfOutputTrack : public virtual IAfTrack {
 public:
-    // TODO(b/288339104) void*
     static sp<IAfOutputTrack> create(
             IAfPlaybackThread* playbackThread,
             IAfDuplicatingThread* sourceThread, uint32_t sampleRate,
@@ -416,7 +415,6 @@
 
 class IAfMmapTrack : public virtual IAfTrackBase {
 public:
-    // TODO(b/288339104) void*
     static sp<IAfMmapTrack> create(IAfThreadBase* thread,
             const audio_attributes_t& attr,
             uint32_t sampleRate,
@@ -454,7 +452,6 @@
     // Only one AIDL IAudioRecord interface adapter should be created per RecordTrack.
     static sp<media::IAudioRecord> createIAudioRecordAdapter(const sp<IAfRecordTrack>& recordTrack);
 
-    // TODO(b/288339104) void*
     static sp<IAfRecordTrack> create(IAfRecordThread* thread,
             const sp<Client>& client,
             const audio_attributes_t& attr,
@@ -477,7 +474,7 @@
     // set the buffer overflow flag and return previous value
     virtual bool setOverflow() = 0;
 
-    // TODO(b/288339104) handleSyncStartEvent in IAfTrackBase should move here.
+    // TODO(b/291317964) handleSyncStartEvent in IAfTrackBase should move here.
     virtual void clearSyncStartEvent() = 0;
     virtual void updateTrackFrameInfo(
             int64_t trackFramesReleased, int64_t sourceFramesRead, uint32_t halSampleRate,
diff --git a/services/audioflinger/MmapTracks.h b/services/audioflinger/MmapTracks.h
index 16c141f..c695098 100644
--- a/services/audioflinger/MmapTracks.h
+++ b/services/audioflinger/MmapTracks.h
@@ -62,8 +62,6 @@
                             mute_state_t muteState)
                             /* REQUIRES(MmapPlaybackThread::mLock) */ final;
 private:
-    friend class MmapThread;
-
     DISALLOW_COPY_AND_ASSIGN(MmapTrack);
 
     // AudioBufferProvider interface
diff --git a/services/audioflinger/PlaybackTracks.h b/services/audioflinger/PlaybackTracks.h
index de6fc32..ee91d50 100644
--- a/services/audioflinger/PlaybackTracks.h
+++ b/services/audioflinger/PlaybackTracks.h
@@ -214,11 +214,6 @@
     void processMuteEvent_l(const sp<IAudioManager>& audioManager, mute_state_t muteState) final;
 
 protected:
-    // for numerous
-    friend class PlaybackThread;
-    friend class MixerThread;
-    friend class DirectOutputThread;
-    friend class OffloadThread;
 
     DISALLOW_COPY_AND_ASSIGN(Track);
 
diff --git a/services/audioflinger/RecordTracks.h b/services/audioflinger/RecordTracks.h
index 5cf09c5..89e2f66 100644
--- a/services/audioflinger/RecordTracks.h
+++ b/services/audioflinger/RecordTracks.h
@@ -95,8 +95,6 @@
     }
 
 private:
-    friend class AudioFlinger;  // for mState
-
     DISALLOW_COPY_AND_ASSIGN(RecordTrack);
 
 protected:
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index a3bd53d..ce4396d 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -7537,7 +7537,6 @@
     if (numTracks > 0) {
         ss << ":";
         for (const auto &track : mOutputTracks) {
-            // TODO(b/288339104) type
             const auto thread = track->thread().promote();
             ss << " (" << track->id() << " : ";
             if (thread.get() != nullptr) {
@@ -7622,7 +7621,6 @@
 {
     mWaitTimeMs = UINT_MAX;
     for (size_t i = 0; i < mOutputTracks.size(); i++) {
-        // TODO(b/288339104) type
         const auto strong = mOutputTracks[i]->thread().promote();
         if (strong != 0) {
             uint32_t waitTimeMs = (strong->frameCount() * 2 * 1000) / strong->sampleRate();
@@ -8936,7 +8934,7 @@
         sp<IAfTrackBase> ptr =
                 std::any_cast<const wp<IAfTrackBase>>(strongEvent->cookie()).promote();
         if (ptr != nullptr) {
-            // TODO(b/288339104) handleSyncStartEvent is in IAfTrackBase not IAfRecordTrack.
+            // TODO(b/291317898) handleSyncStartEvent is in IAfTrackBase not IAfRecordTrack.
             ptr->handleSyncStartEvent(strongEvent);
         }
     }
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index 8d80382..77776a0 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -22,10 +22,6 @@
 class AsyncCallbackThread;
 
 class ThreadBase : public virtual IAfThreadBase, public Thread {
-    // TODO(b/288339104) remove friends
-    friend class RecordTrack;
-    friend class Track;
-    friend class TrackBase;
 public:
     static const char *threadTypeToString(type_t type);
 
@@ -421,7 +417,7 @@
     void disconnectEffectHandle(IAfEffectHandle* handle, bool unpinIfLast) final;
                 // detach all tracks connected to an auxiliary effect
     void detachAuxEffect_l(int /* effectId */) override {}
-    // TODO(b/288339104) - remove hasAudioSession_l below.
+    // TODO(b/291317898) - remove hasAudioSession_l below.
     uint32_t hasAudioSession_l(audio_session_t sessionId) const override = 0;
     uint32_t hasAudioSession(audio_session_t sessionId) const final {
                     Mutex::Autolock _l(mLock);
@@ -571,7 +567,7 @@
                                 return INVALID_OPERATION;
                             }
 public:
-// TODO(b/288339104) organize with publics
+// TODO(b/291317898) organize with publics
                 product_strategy_t getStrategyForStream(audio_stream_type_t stream) const;
 protected:
 
@@ -581,9 +577,6 @@
                             { }
     virtual     void        dumpTracks_l(int fd __unused, const Vector<String16>& args __unused) { }
 
-
-    friend class AudioFlinger;      // for mEffectChains and mAudioManager
-
                 const type_t            mType;
 
                 // Used by parameters, config events, addTrack_l, exit
@@ -793,9 +786,6 @@
 class PlaybackThread : public ThreadBase, public virtual IAfPlaybackThread,
                        public StreamOutHalInterfaceCallback,
                        public virtual VolumeInterface, public StreamOutHalInterfaceEventCallback {
-    // TODO(b/288339104) remove friends
-    friend class OutputTrack;
-    friend class Track;
 public:
     sp<IAfPlaybackThread> asIAfPlaybackThread() final {
         return sp<IAfPlaybackThread>::fromExisting(this);
@@ -1236,8 +1226,6 @@
                                 ThreadBase::invalidateTracksForAudioSession_l(sessionId, mTracks);
                             }
 
-    friend class AudioFlinger;      // for numerous
-
     DISALLOW_COPY_AND_ASSIGN(PlaybackThread);
 
     status_t addTrack_l(const sp<IAfTrack>& track) final;
@@ -1806,9 +1794,6 @@
 // record thread
 class RecordThread : public IAfRecordThread, public ThreadBase
 {
-    // TODO(b/288339104) remove friends
-    friend class PassthruPatchRecord;
-    friend class RecordTrack;
     friend class ResamplerBufferProvider;
 public:
     sp<IAfRecordThread> asIAfRecordThread() final {
@@ -1866,7 +1851,7 @@
     AudioStreamIn* getInput() const final { return mInput; }
     AudioStreamIn* clearInput() final;
 
-            // TODO(b/288339104) Unify with IAfThreadBase
+            // TODO(b/291317898) Unify with IAfThreadBase
             virtual sp<StreamHalInterface> stream() const;
 
 
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index bd4804c..84cceb6 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -388,7 +388,6 @@
     : BnAudioTrack(),
       mTrack(track)
 {
-    // TODO(b/288339104) binder thread priority change not needed.
     setMinSchedulerPolicy(SCHED_NORMAL, ANDROID_PRIORITY_AUDIO);
 }
 
@@ -2614,7 +2613,6 @@
     : BnAudioRecord(),
     mRecordTrack(recordTrack)
 {
-    // TODO(b/288339104) binder thread priority change not needed.
     setMinSchedulerPolicy(SCHED_NORMAL, ANDROID_PRIORITY_AUDIO);
 }
 
@@ -2669,7 +2667,7 @@
 #define LOG_TAG "AF::RecordTrack"
 
 
-/* static */ // TODO(b/288339104)
+/* static */
 sp<IAfRecordTrack> IAfRecordTrack::create(IAfRecordThread* thread,
         const sp<Client>& client,
         const audio_attributes_t& attr,