AudioDeviceInventory: fix devices role cache purge.

Purging the devices role cache when a device is disconnected should be
handled differently whether the role request comes from an API or whether
it has been created internally. Requests coming from an API must not be
cancelled when the device is disconnected, whereas internal requests
must.
Created separate caches for internal and API requests.
Also fix a problem in AudioDeviceInventory.purgeRoles() where we cannot
rely on the connected device list (mConnectedDevices) because it does not
contain attached devices like a speaker.

Bug: 284468571
Test: repro steps in bug
Test: atest NonDefaultDeviceForStrategyTest
Test: atest AudioManagerTest#testPreferredDevicesForStrategy
Test: atest AudioManagerTest#testPreferredDeviceForCapturePreset

Change-Id: I04d620b7c494ce3275baa001fa6f6ed04857e889
2 files changed