日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

Android:修改默认音量等级

發布時間:2023/12/15 Android 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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:修改默认音量等级的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。