AudioService: check calls to AudioSystem.initStreamVolume

AudioSystem.initStreamVolume initializes the min and max stream
volume indices. The return value was never checked to ensure
success of the call. An unchecked failure could leave min/max
values at -1 in native AudioPolicyManager, which could lead
to no valid volume to be set, and thus no audio would be heard
as a result.
The fix consists in ensuring we retry initializing the stream
volumes whenever an error is detected when calling
the initialization method, or after checking whether the
min/max values are valid after initialization.

Bug: 161950968
Test: adb shell dumpsys audio, check lifecycle section
Change-Id: I3714c0db2a9657a88488635f7d6c78e682f326aa
Merged-In: I3714c0db2a9657a88488635f7d6c78e682f326aa
2 files changed