Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6bc03f95 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add developer menu to select max number of connected audio devices"

parents a63075f0 b2730b7b
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -309,6 +309,24 @@
        <item>Never time out</item>
    </string-array>

    <!-- Bluetooth developer settings: Titles for maximum number of connected audio devices -->
    <string-array name="bluetooth_max_connected_audio_devices">
        <item>1 (Default)</item>
        <item>2</item>
        <item>3</item>
        <item>4</item>
        <item>5</item>
    </string-array>

    <!-- Bluetooth developer settings: Values for maximum number of connected audio devices -->
    <string-array name="bluetooth_max_connected_audio_devices_values">
        <item>1</item>
        <item>2</item>
        <item>3</item>
        <item>4</item>
        <item>5</item>
    </string-array>

    <!-- Match this with drawable.wifi_signal. --> <skip />
    <!-- Wi-Fi settings. The signal strength a Wi-Fi network has. -->
    <string-array name="wifi_signal">
+5 −0
Original line number Diff line number Diff line
@@ -1629,6 +1629,11 @@
    <!-- Bluetooth settings.  Dock Setting Dialog - Remember setting and don't ask user again -->
    <string name="bluetooth_dock_settings_remember">Remember settings</string>
    <!-- Bluetooth developer settings: Maximum number of connected audio devices -->
    <string name="bluetooth_max_connected_audio_devices_string">Maximum number of connected Bluetooth audio devices</string>
    <!-- Bluetooth developer settings: Maximum number of connected audio devices -->
    <string name="bluetooth_max_connected_audio_devices_dialog_title">Select maximum number of connected Bluetooth audio devices</string>
    <!-- Wifi Display settings. The title of the screen. [CHAR LIMIT=40] -->
    <string name="wifi_display_settings_title">Cast</string>
    <!-- Wifi Display settings. The title of a menu item to enable wireless display [CHAR LIMIT=40] -->
+7 −0
Original line number Diff line number Diff line
@@ -286,6 +286,13 @@
            android:entries="@array/bluetooth_a2dp_codec_ldac_playback_quality_titles"
            android:entryValues="@array/bluetooth_a2dp_codec_ldac_playback_quality_values" />

        <ListPreference
                android:key="bluetooth_max_connected_audio_devices"
                android:title="@string/bluetooth_max_connected_audio_devices_string"
                android:dialogTitle="@string/bluetooth_max_connected_audio_devices_dialog_title"
                android:entries="@array/bluetooth_max_connected_audio_devices"
                android:entryValues="@array/bluetooth_max_connected_audio_devices_values" />

    </PreferenceCategory>

    <PreferenceCategory android:key="debug_input_category"
+102 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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.development;

import android.content.Context;
import android.os.SystemProperties;
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;

import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;

public class BluetoothMaxConnectedAudioDevicesPreferenceController extends
        DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
        PreferenceControllerMixin {

    private static final String BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_KEY =
            "bluetooth_max_connected_audio_devices";

    @VisibleForTesting
    static final String BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY =
            "persist.bluetooth.maxconnectedaudiodevices";

    private final String[] mListValues;
    private final String[] mListSummaries;
    private ListPreference mPreference;

    public BluetoothMaxConnectedAudioDevicesPreferenceController(Context context) {
        super(context);

        mListValues = context.getResources()
                .getStringArray(R.array.bluetooth_max_connected_audio_devices_values);
        mListSummaries = context.getResources()
                .getStringArray(R.array.bluetooth_max_connected_audio_devices);
    }

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

    @Override
    public void displayPreference(PreferenceScreen screen) {
        super.displayPreference(screen);

        mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
    }

    @Override
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        SystemProperties.set(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, newValue.toString());
        return true;
    }

    @Override
    public void updateState(Preference preference) {
        final String currentValue = SystemProperties.get(
                BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY);
        int index = 0; // Defaults to 1 device
        for (int i = 0; i < mListValues.length; i++) {
            if (TextUtils.equals(currentValue, mListValues[i])) {
                index = i;
                break;
            }
        }
        mPreference.setValue(mListValues[index]);
        mPreference.setSummary(mListSummaries[index]);
    }

    @Override
    protected void onDeveloperOptionsSwitchEnabled() {
        mPreference.setEnabled(true);
        mPreference.setValue(mListValues[0]);
        mPreference.setSummary(mListSummaries[0]);
    }

    @Override
    protected void onDeveloperOptionsSwitchDisabled() {
        mPreference.setEnabled(false);
        mPreference.setValue(mListValues[0]);
        mPreference.setSummary(mListSummaries[0]);
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -417,6 +417,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
                bluetoothA2dpConfigStore));
        controllers.add(new BluetoothAudioQualityPreferenceController(context, lifecycle,
                bluetoothA2dpConfigStore));
        controllers.add(new BluetoothMaxConnectedAudioDevicesPreferenceController(context));
        controllers.add(new ShowTapsPreferenceController(context));
        controllers.add(new PointerLocationPreferenceController(context));
        controllers.add(new ShowSurfaceUpdatesPreferenceController(context));
Loading