性能优化

This commit is contained in:
ZhanGSKen 2025-02-26 05:08:56 +08:00
parent e7633e53ed
commit bdb9bc7637
3 changed files with 12 additions and 20 deletions

View File

@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Wed Feb 26 04:37:17 HKT 2025 #Tue Feb 25 21:06:27 GMT 2025
stageCount=3 stageCount=3
libraryProject= libraryProject=
baseVersion=1.0 baseVersion=1.0
publishVersion=1.0.2 publishVersion=1.0.2
buildCount=0 buildCount=2
baseBetaVersion=1.0.3 baseBetaVersion=1.0.3

View File

@ -61,7 +61,7 @@ public class PhoneCallService extends InCallService {
// 记录原始铃声音量 // 记录原始铃声音量
// //
AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE); AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
int ringerVolume = audioManager.getStreamVolume(AudioManager.STREAM_RING);
// 恢复铃声音量预防其他意外条件导致的音量变化问题 // 恢复铃声音量预防其他意外条件导致的音量变化问题
// //
@ -75,8 +75,10 @@ public class PhoneCallService extends InCallService {
// 如果当前音量和应用保存的不一致就恢复为应用设定值 // 如果当前音量和应用保存的不一致就恢复为应用设定值
// 恢复铃声音量 // 恢复铃声音量
try { try {
audioManager.setStreamVolume(AudioManager.STREAM_RING, bean.getStreamVolume(), 0); if (ringerVolume != bean.getStreamVolume()) {
//audioManager.setMode(AudioManager.RINGER_MODE_NORMAL); audioManager.setStreamVolume(AudioManager.STREAM_RING, bean.getStreamVolume(), 0);
//audioManager.setMode(AudioManager.RINGER_MODE_NORMAL);
}
} catch (java.lang.SecurityException e) { } catch (java.lang.SecurityException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace()); LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
} }
@ -114,18 +116,6 @@ public class PhoneCallService extends InCallService {
} }
} }
void resumeStreamVolume(AudioManager audioManager, int originalRingVolume) {
// 如果当前音量和应用保存的不一致就恢复为应用设定值
RingTongBean bean = RingTongBean.loadBean(this, RingTongBean.class);
if (bean == null) {
bean = new RingTongBean();
}
if (originalRingVolume != bean.getStreamVolume()) {
// 恢复铃声音量
audioManager.setStreamVolume(AudioManager.STREAM_RING, bean.getStreamVolume(), 0);
}
}
@Override @Override
public void onCallRemoved(Call call) { public void onCallRemoved(Call call) {
super.onCallRemoved(call); super.onCallRemoved(call);

View File

@ -81,7 +81,7 @@ public class MainService extends Service {
@Override @Override
public void run() { public void run() {
AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE); AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
int ringerVolume = audioManager.getStreamVolume(AudioManager.STREAM_RING);
// 恢复铃声音量预防其他意外条件导致的音量变化问题 // 恢复铃声音量预防其他意外条件导致的音量变化问题
// //
@ -95,8 +95,10 @@ public class MainService extends Service {
// 如果当前音量和应用保存的不一致就恢复为应用设定值 // 如果当前音量和应用保存的不一致就恢复为应用设定值
// 恢复铃声音量 // 恢复铃声音量
try { try {
audioManager.setStreamVolume(AudioManager.STREAM_RING, bean.getStreamVolume(), 0); if (ringerVolume != bean.getStreamVolume()) {
//audioManager.setMode(AudioManager.RINGER_MODE_NORMAL); audioManager.setStreamVolume(AudioManager.STREAM_RING, bean.getStreamVolume(), 0);
//audioManager.setMode(AudioManager.RINGER_MODE_NORMAL);
}
} catch (java.lang.SecurityException e) { } catch (java.lang.SecurityException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace()); LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
} }