forked from davidepianca98/STE_patches
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTelephony.patch
More file actions
77 lines (71 loc) · 3.05 KB
/
Telephony.patch
File metadata and controls
77 lines (71 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
commit e493cd583069652483ad63e7c86234dedfc9d6f7
Author: h3llrais3r <pooh_beer_1@hotmail.com>
Date: Wed Mar 19 21:53:08 2014 +0100
Ported my low-incall volume fix from CM-10.2 to CM-11.0
diff --git a/src/com/android/phone/AudioRouter.java b/src/com/android/phone/AudioRouter.java
index 3c8e9d3..de13889 100644
--- a/src/com/android/phone/AudioRouter.java
+++ b/src/com/android/phone/AudioRouter.java
@@ -179,7 +179,12 @@ import java.util.List;
public void onMuteChange(boolean muted) {
logD("onMuteChange: " + muted);
+
notifyListeners();
+
+ // Fix for low in-call volume bug
+ // Reset the audio volume stream after mute change
+ PhoneUtils.resetAudioStreamVolume();
}
/**
@@ -350,6 +355,10 @@ import java.util.List;
if (doNotify) {
notifyListeners();
}
+
+ // Fix for low in-call volume bug
+ // Reset the audio volume stream after switching audio mode
+ PhoneUtils.resetAudioStreamVolume();
}
/**
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index 2d44977..7df15e9 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -2027,6 +2027,38 @@ public class PhoneUtils {
}
}
}
+
+ /**
+ * Reset the audio stream volume to fix the low in-call volume bug.
+ *
+ * Due to a bug in the OMX system, the audio stream volume is set to 0 after it was set to it's default volume.
+ * Calling PhoneUtils.resetAudioStreamVolume() triggers the system to reset the volume.
+ *
+ * This should be called on every place where is switched between audio modes.
+ *
+ * REMARK: I think it only appears on the voice call stream, but to be sure I also do it on the bluetooth stream.
+ */
+ static void resetAudioStreamVolume() {
+ PhoneGlobals app = PhoneGlobals.getInstance();
+ BluetoothManager btManager = app.getBluetoothManager();
+ AudioManager audioManager = (AudioManager) app.getSystemService(Context.AUDIO_SERVICE);
+ // determine actual streamType
+ int streamType = AudioManager.STREAM_VOICE_CALL;
+ if (btManager.isBluetoothHeadsetAudioOn()) {
+ streamType = AudioManager.STREAM_BLUETOOTH_SCO;
+ }
+ // determine volume and 1 level lower volume (lowest level can be 0)
+ int volume = audioManager.getStreamVolume(streamType);
+ int lowerVolume = volume - 1;
+ if (lowerVolume < 0) {
+ lowerVolume = 0;
+ }
+ log("resetAudioStreamVolume (streamType=" + streamType + ", streamVolume=" + volume + ")...");
+ // It's important to change it to another volume before restoring the original volume,
+ // otherwise the volume change will NOT be triggered!!
+ audioManager.setStreamVolume(streamType, lowerVolume, 0);
+ audioManager.setStreamVolume(streamType, volume, 0);
+ }
static boolean isInEmergencyCall(CallManager cm) {
for (Connection cn : cm.getActiveFgCall().getConnections()) {