Android:修改默认音量等级
生活随笔
收集整理的這篇文章主要介紹了
Android:修改默认音量等级
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
修改辦法如下:
frameworks/base/services/core/java/com/android/server/audio/AudioService.java
/** @hide */public AudioService(Context context) {mContext = context;mContentResolver = context.getContentResolver();mAppOps = (AppOpsManager)context.getSystemService(Context.APP_OPS_SERVICE);mPlatformType = AudioSystem.getPlatformType(context);mIsSingleVolume = AudioSystem.isSingleVolume(context);mUserManagerInternal = LocalServices.getService(UserManagerInternal.class);mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class);PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);mAudioEventWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "handleAudioEvent");mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);mHasVibrator = mVibrator == null ? false : mVibrator.hasVibrator();// Initialize volumeint maxCallVolume = SystemProperties.getInt("ro.config.vc_call_vol_steps", -1);if (maxCallVolume != -1) {MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL] = maxCallVolume;AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL] =(maxCallVolume * 3) / 4;}int maxMusicVolume = SystemProperties.getInt("ro.config.media_vol_steps", -1);if (maxMusicVolume != -1) {MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] = maxMusicVolume;}int defaultMusicVolume = SystemProperties.getInt("ro.config.media_vol_default", -1);if (defaultMusicVolume != -1 &&defaultMusicVolume <= MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC]) {AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] = defaultMusicVolume;} else {if (isPlatformTelevision()) {AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] =MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] / 4;} else {AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] =MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] / 3;}}/* modify by leezs for set default music volume start*/AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] = 10;/* modify by leezs for set default music volume end*/int maxAlarmVolume = SystemProperties.getInt("ro.config.alarm_vol_steps", -1);if (maxAlarmVolume != -1) {MAX_STREAM_VOLUME[AudioSystem.STREAM_ALARM] = maxAlarmVolume;}int defaultAlarmVolume = SystemProperties.getInt("ro.config.alarm_vol_default", -1);if (defaultAlarmVolume != -1 &&defaultAlarmVolume <= MAX_STREAM_VOLUME[AudioSystem.STREAM_ALARM]) {AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_ALARM] = defaultAlarmVolume;} else {// Default is 6 out of 7 (default maximum), so scale accordingly.AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_ALARM] =6 * MAX_STREAM_VOLUME[AudioSystem.STREAM_ALARM] / 7;}/* modify by leezs for set default alarm volume start*/AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_ALARM] = 3;/* modify by leezs for set default alarm volume end*/int maxSystemVolume = SystemProperties.getInt("ro.config.system_vol_steps", -1);if (maxSystemVolume != -1) {MAX_STREAM_VOLUME[AudioSystem.STREAM_SYSTEM] = maxSystemVolume;}int defaultSystemVolume = SystemProperties.getInt("ro.config.system_vol_default", -1);if (defaultSystemVolume != -1 &&defaultSystemVolume <= MAX_STREAM_VOLUME[AudioSystem.STREAM_SYSTEM]) {AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_SYSTEM] = defaultSystemVolume;} else {// Default is to use maximum.AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_SYSTEM] =MAX_STREAM_VOLUME[AudioSystem.STREAM_SYSTEM];}int defaultRingVolume = SystemProperties.getInt("ro.config.ring_vol_default", -1);if (defaultRingVolume != -1 &&defaultRingVolume <= MAX_STREAM_VOLUME[AudioSystem.STREAM_RING]) {AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_RING] = defaultRingVolume;}/* modify by leezs for set default ring volume start*/AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_RING] = 3;/* modify by leezs for set default ring volume end*/int defaultNotificationVolume = SystemProperties.getInt("ro.config.notification_vol_default", -1);if (defaultNotificationVolume != -1 &&defaultNotificationVolume <= MAX_STREAM_VOLUME[AudioSystem.STREAM_NOTIFICATION]) {AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_NOTIFICATION] = defaultNotificationVolume;}/* modify by leezs for set default notification volume start*/AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_NOTIFICATION] = 3;/* modify by leezs for set default notification volume end*/sSoundEffectVolumeDb = context.getResources().getInteger(com.android.internal.R.integer.config_soundEffectVolumeDb);... ... ...}總結
以上是生活随笔為你收集整理的Android:修改默认音量等级的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 新版CorelDRAW Technica
- 下一篇: android输入法把底部顶起来,And