Commit 30bb2ed9 authored by Rohan Parab's avatar Rohan Parab Committed by Commit Bot

Fix getStreamVolumeDB for Android P and above

Bug: 163028167
Test: Locally on android Q device
Change-Id: I463f133981530e5ca936d62d6e1f10cb701e2e2f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2342579Reviewed-by: default avatarLuke Halliwell (slow) <halliwell@chromium.org>
Reviewed-by: default avatarSimeon Anfinrud <sanfin@chromium.org>
Commit-Queue: Rohan Parab <prohan@google.com>
Cr-Commit-Position: refs/heads/master@{#796002}
parent f100b5d7
......@@ -94,6 +94,9 @@ public final class VolumeMap {
// Returns the current volume in dB for the given stream type and volume index.
private static float getStreamVolumeDB(int streamType, int idx) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
return getAudioManager().getStreamVolumeDb(streamType, idx, DEVICE_TYPE);
}
float db = 0;
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.O_MR1
|| Build.VERSION.SDK_INT == Build.VERSION_CODES.N) {
......@@ -106,10 +109,6 @@ public final class VolumeMap {
} catch (Exception e) {
Log.e(TAG, "Can not call AudioManager.getStreamVolumeDb():", e);
}
// TODO(ckuiper): when Android P becomes available add something like this to call the
// AudioManager.getStreamVolumeDb() directly as it is public in P.
// } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
// db = sAudioManager.getStreamVolumeDb();
} else {
Log.e(TAG, "Unsupported Android SDK version:" + Build.VERSION.SDK_INT);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment