Android 8.1 设置--声音中增加通话音量

Android 8.1 设置--声音中增加通话音量

近来收到项目需求,想要在设置--声音中增加一项通话音量调节,具体修改参照如下:

/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/values/strings.xml

+    <!-- Sound: Title for the option managing call volume. [CHAR LIMIT=30] -->
+    <string name="call_volume_option_title">Call volume</string>

/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/values-zh-rCN/strings.xml

+    <string name="call_volume_option_title">"通话音量"</string>

/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/drawable/ic_volume_voice.xml

<!--
     Copyright (C) 2015 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:height="24.0dp"
    android:viewportHeight="48.0"
    android:viewportWidth="48.0"
    android:width="24.0dp"
    android:tint="?android:attr/colorControlNormal" >

    <path
        android:fillColor="#FFFFFF"
        android:pathData="M13.25,21.59c2.88,5.66 7.51,10.29 13.18,13.17l4.4,-4.41c0.55,-0.55 1.34,-0.71 2.03,-0.49C35.1,30.6 37.51,31.0 40.0,31.0c1.11,0.0 2.0,0.89 2.0,2.0l0.0,7.0c0.0,1.11 -0.89,2.0 -2.0,2.0C21.22,42.0 6.0,26.78 6.0,8.0c0.0,-1.1 0.9,-2.0 2.0,-2.0l7.0,0.0c1.11,0.0 2.0,0.89 2.0,2.0 0.0,2.4 0.4,4.9 1.14,7.1 0.2,0.6 0.06,1.48 -0.49,2.03l-4.4,4.42z" />

</vector>

/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/xml/sound_settings.xml

+        <!-- Call volume -->
+        <com.android.settings.notification.VolumeSeekBarPreference
+                android:key="call_volume"
+                android:icon="@drawable/ic_volume_voice"
+                android:title="@string/call_volume_option_title" />

/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/notification/CallVolumePreferenceController.java

/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.notification;

import android.content.Context;
import android.media.AudioManager;

import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.notification.VolumeSeekBarPreference.Callback;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settings.R;

public class CallVolumePreferenceController extends
    VolumeSeekBarPreferenceController {

    private static final String KEY_CALL_VOLUME = "call_volume";
    private AudioHelper mHelper;

    public CallVolumePreferenceController(Context context, Callback callback,
        Lifecycle lifecycle) {
        this(context, callback, lifecycle, new AudioHelper(context));
    }

    @VisibleForTesting
    CallVolumePreferenceController(Context context, Callback callback, Lifecycle lifecycle,
        AudioHelper helper) {
        super(context, callback, lifecycle);
        mHelper = helper;
    }

    @Override
    public boolean isAvailable() {
        return !mHelper.isSingleVolume();
    }

    @Override
    public String getPreferenceKey() {
        return KEY_CALL_VOLUME;
    }

    @Override
    public int getAudioStream() {
        return AudioManager.STREAM_VOICE_CALL;
    }

    @Override
    public int getMuteIcon() {
        return R.drawable.ic_volume_voice;
    }

}

/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/notification/SoundSettings.java

    private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
            SoundSettings fragment, VolumeSeekBarPreference.Callback callback,
            Lifecycle lifecycle) {
        final List<AbstractPreferenceController> controllers = new ArrayList<>();
        controllers.add(new ZenModePreferenceController(context));
        controllers.add(new EmergencyBroadcastPreferenceController(
                context, KEY_CELL_BROADCAST_SETTINGS));
        controllers.add(new VibrateWhenRingPreferenceController(context));

        // === Volumes ===
        controllers.add(new AlarmVolumePreferenceController(context, callback, lifecycle));
+        controllers.add(new CallVolumePreferenceController(context, callback, lifecycle));

重新编译验证,修改生效,设置--声音中已增加通话音量调节项

相关推荐

  1. Android 8.1 设置--声音增加通话音量

    2024-02-03 05:48:02       30 阅读
  2. Android 设置音量默认值

    2024-02-03 05:48:02       35 阅读
  3. 如何在Android Framework源码增加jni方法

    2024-02-03 05:48:02       32 阅读
  4. Android 10 Android音量调节

    2024-02-03 05:48:02       27 阅读
  5. Android 单一音量控制

    2024-02-03 05:48:02       13 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-02-03 05:48:02       19 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-02-03 05:48:02       20 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-02-03 05:48:02       20 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-02-03 05:48:02       20 阅读

热门阅读

  1. 计算机网络(第六版)复习提纲15

    2024-02-03 05:48:02       26 阅读
  2. ++i(前置自增)和 i++(后置自增)的区别

    2024-02-03 05:48:02       25 阅读
  3. 【前端插件工具】

    2024-02-03 05:48:02       31 阅读
  4. Vue.js 中父组件调用子组件的方法

    2024-02-03 05:48:02       35 阅读
  5. pip安装tf-gpu=2.4的bug解决方案

    2024-02-03 05:48:02       36 阅读
  6. wpf 消息传递

    2024-02-03 05:48:02       29 阅读
  7. Ubuntu 22.04 配置qtchooser默认启用 Qt6

    2024-02-03 05:48:02       32 阅读