update volume management to Handle ICS behavior
This commit is contained in:
parent
89093384a4
commit
9b0f8be225
7 changed files with 22 additions and 18 deletions
|
@ -160,8 +160,6 @@
|
|||
<CheckBoxPreference android:key="@string/pref_debug_key"
|
||||
android:title="@string/pref_debug" android:enabled="true"></CheckBoxPreference>
|
||||
|
||||
<CheckBoxPreference android:key="@string/pref_audio_soft_volume_key"
|
||||
android:title="@string/pref_audio_soft_volume_title" />
|
||||
|
||||
<PreferenceScreen android:title="@string/pref_network_title">
|
||||
<CheckBoxPreference android:key="@string/pref_ipv6_key"
|
||||
|
|
|
@ -564,7 +564,7 @@ public class DialerActivity extends Activity implements LinphoneGuiListener {
|
|||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (LinphoneUtils.onKeyVolumeSoftAdjust(keyCode)) return true;
|
||||
if (LinphoneUtils.onKeyVolumeAdjust(keyCode)) return true;
|
||||
boolean isInCall = LinphoneManager.getLc().isIncall();
|
||||
isInCall = isInCall || LinphoneManager.getLc().getCallsNb() > 0;
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && isInCall) {
|
||||
|
|
|
@ -812,7 +812,7 @@ public class IncallActivity extends AbstractCalleesActivity implements
|
|||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (LinphoneUtils.onKeyVolumeSoftAdjust(keyCode)) return true;
|
||||
if (LinphoneUtils.onKeyVolumeAdjust(keyCode)) return true;
|
||||
if (LinphoneUtils.onKeyBackGoHome(this, keyCode, event)) return true;
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
|
|
@ -93,6 +93,7 @@ import android.media.AudioManager;
|
|||
import android.media.MediaPlayer;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
import android.os.PowerManager.WakeLock;
|
||||
import android.os.Vibrator;
|
||||
|
@ -990,7 +991,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
|
||||
if (state == State.Connected) {
|
||||
if (Hacks.needSoftvolume() || sLPref.useSoftvolume()) {
|
||||
adjustSoftwareVolume(0); // Synchronize
|
||||
adjustVolume(0); // Synchronize
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1225,15 +1226,19 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
return r.getString(R.string.unknown_incoming_call_name);
|
||||
}
|
||||
|
||||
public void adjustSoftwareVolume(int i) {
|
||||
int oldVolume = mAudioManager.getStreamVolume(LINPHONE_VOLUME_STREAM);
|
||||
int maxVolume = mAudioManager.getStreamMaxVolume(LINPHONE_VOLUME_STREAM);
|
||||
public void adjustVolume(int i) {
|
||||
if (Build.VERSION.SDK_INT<15) {
|
||||
int oldVolume = mAudioManager.getStreamVolume(LINPHONE_VOLUME_STREAM);
|
||||
int maxVolume = mAudioManager.getStreamMaxVolume(LINPHONE_VOLUME_STREAM);
|
||||
|
||||
int nextVolume = oldVolume +i;
|
||||
if (nextVolume > maxVolume) nextVolume = maxVolume;
|
||||
if (nextVolume < 0) nextVolume = 0;
|
||||
int nextVolume = oldVolume +i;
|
||||
if (nextVolume > maxVolume) nextVolume = maxVolume;
|
||||
if (nextVolume < 0) nextVolume = 0;
|
||||
|
||||
mLc.adjustSoftwareVolume((nextVolume - maxVolume)* dbStep);
|
||||
mLc.adjustSoftwareVolume((nextVolume - maxVolume)* dbStep);
|
||||
} else
|
||||
// starting from ICS, volume must be adjusted by the application, at least for STREAM_VOICE_CALL volume stream
|
||||
mAudioManager.adjustStreamVolume(LINPHONE_VOLUME_STREAM, i<0?AudioManager.ADJUST_LOWER:AudioManager.ADJUST_RAISE, 0);
|
||||
}
|
||||
|
||||
public static Boolean isProximitySensorNearby(final SensorEvent event) {
|
||||
|
|
|
@ -47,6 +47,7 @@ import android.content.Intent;
|
|||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
@ -74,9 +75,9 @@ public final class LinphoneUtils {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static boolean onKeyVolumeSoftAdjust(int keyCode) {
|
||||
public static boolean onKeyVolumeAdjust(int keyCode) {
|
||||
if (!((keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
|
||||
&& Hacks.needSoftvolume())) {
|
||||
&& (Hacks.needSoftvolume())|| Build.VERSION.SDK_INT>=15)) {
|
||||
return false; // continue
|
||||
}
|
||||
|
||||
|
@ -84,9 +85,9 @@ public final class LinphoneUtils {
|
|||
Log.i("Couldn't change softvolume has service is not running");
|
||||
return true;
|
||||
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
|
||||
LinphoneManager.getInstance().adjustSoftwareVolume(1);
|
||||
LinphoneManager.getInstance().adjustVolume(1);
|
||||
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
|
||||
LinphoneManager.getInstance().adjustSoftwareVolume(-1);
|
||||
LinphoneManager.getInstance().adjustVolume(-1);
|
||||
}
|
||||
return preventVolumeBarToDisplay;
|
||||
}
|
||||
|
|
|
@ -374,7 +374,7 @@ public class VideoCallActivity extends Activity implements
|
|||
}
|
||||
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (LinphoneUtils.onKeyVolumeSoftAdjust(keyCode))
|
||||
if (LinphoneUtils.onKeyVolumeAdjust(keyCode))
|
||||
return true;
|
||||
if (Version.isXLargeScreen(this) && LinphoneUtils.onKeyBackGoHome(this, keyCode, event)) {
|
||||
return true;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 9f02a12f4641989a225ee77bf6f403cd1c57d9e6
|
||||
Subproject commit 9496394c88dbdf6e6dd120b5657a2846b603d612
|
Loading…
Reference in a new issue