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

Commit 464e7eb7 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8961426 from 662e5722 to tm-qpr1-release

Change-Id: Ibcaa452224f959730e50a514b0fc7773b305ea4c
parents a6e4eeed 662e5722
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -184,6 +184,11 @@
    <!-- Keywords for bluetooth pairing item [CHAR LIMIT=30] -->
    <string name="keywords_add_bt_device">bluetooth</string>
    <!-- Button to help user to pair right ear of the hearing aid device. It will show when only one of the hearing aid device set is connected. [CHAR LIMIT=20] -->
    <string name="bluetooth_pair_right_ear_button">Pair right ear</string>
    <!-- Button to help user to pair left ear of the hearing aid device. It will show when only one of the hearing aid device set is connected. [CHAR LIMIT=20] -->
    <string name="bluetooth_pair_left_ear_button">Pair left ear</string>
    <!-- Connected devices settings. Title of the dialog to hint user to pair other ear of the hearing aid device. Shows when only one of the hearing aid device set is connected. [CHAR LIMIT=25] -->
    <string name="bluetooth_pair_other_ear_dialog_title">Pair your other ear</string>
    <!-- Connected devices settings. Message of the dialog to hint user to pair right ear of the hearing aid device. Shows when only left side of hearing aid device set is connected. [CHAR LIMIT=NONE] -->
+6 −0
Original line number Diff line number Diff line
@@ -42,6 +42,12 @@
        settings:searchable="false"
        settings:controller="com.android.settings.bluetooth.LeAudioBluetoothDetailsHeaderController"/>

    <com.android.settingslib.widget.ButtonPreference
        android:key="hearing_aid_pair_other_button"
        android:gravity="center" />
    <com.android.settings.applications.SpacePreference
        android:layout_height="8dp" />

    <com.android.settingslib.widget.ActionButtonsPreference
        android:key="action_buttons"
        settings:allowDividerBelow="true"/>
+8 −2
Original line number Diff line number Diff line
@@ -18,10 +18,11 @@ import android.content.Context;
import android.os.Build;
import android.service.notification.NotificationListenerFilter;

import androidx.preference.Preference;

import com.android.settings.core.BasePreferenceController;
import com.android.settings.notification.NotificationBackend;


public class BridgedAppsLinkPreferenceController extends BasePreferenceController {

    private ComponentName mCn;
@@ -61,7 +62,6 @@ public class BridgedAppsLinkPreferenceController extends BasePreferenceControlle
            if (mTargetSdk > Build.VERSION_CODES.S) {
                return AVAILABLE;
            }

            mNlf = mNm.getListenerFilter(mCn, mUserId);
            if (!mNlf.areAllTypesAllowed() || !mNlf.getDisallowedPackages().isEmpty()) {
                return AVAILABLE;
@@ -69,4 +69,10 @@ public class BridgedAppsLinkPreferenceController extends BasePreferenceControlle
        }
        return DISABLED_DEPENDENT_SETTING;
    }

    @Override
    public void updateState(Preference pref) {
        pref.setEnabled(getAvailabilityStatus() == AVAILABLE);
        super.updateState(pref);
    }
}
+2 −10
Original line number Diff line number Diff line
@@ -233,11 +233,7 @@ public class NotificationAccessDetails extends DashboardFragment {
        apc.updateState(screen.findPreference(apc.getPreferenceKey()));
        getPreferenceControllers().forEach(controllers -> {
            controllers.forEach(controller -> {
                if (controller instanceof TypeFilterPreferenceController) {
                    TypeFilterPreferenceController tfpc =
                            (TypeFilterPreferenceController) controller;
                    tfpc.updateState(screen.findPreference(tfpc.getPreferenceKey()));
                }
                controller.updateState(screen.findPreference(controller.getPreferenceKey()));
            });
        });
    }
@@ -249,11 +245,7 @@ public class NotificationAccessDetails extends DashboardFragment {
        apc.updateState(screen.findPreference(apc.getPreferenceKey()));
        getPreferenceControllers().forEach(controllers -> {
            controllers.forEach(controller -> {
                if (controller instanceof TypeFilterPreferenceController) {
                    TypeFilterPreferenceController tfpc =
                            (TypeFilterPreferenceController) controller;
                    tfpc.updateState(screen.findPreference(tfpc.getPreferenceKey()));
                }
                controller.updateState(screen.findPreference(controller.getPreferenceKey()));
            });
        });
    }
+102 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.bluetooth;

import android.content.Context;

import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen;

import com.android.settings.R;
import com.android.settings.core.SubSettingLauncher;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.HearingAidProfile;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.widget.ButtonPreference;

/**
 * This class handles button preference logic to display for hearing aid device.
 */
public class BluetoothDetailsPairOtherController extends BluetoothDetailsController {
    private static final String KEY_PAIR_OTHER = "hearing_aid_pair_other_button";

    private ButtonPreference mPreference;

    public BluetoothDetailsPairOtherController(Context context,
            PreferenceFragmentCompat fragment,
            CachedBluetoothDevice device,
            Lifecycle lifecycle) {
        super(context, fragment, device, lifecycle);
        lifecycle.addObserver(this);
    }

    @Override
    public boolean isAvailable() {
        return getButtonPreferenceVisibility(mCachedDevice);
    }

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

    @Override
    protected void init(PreferenceScreen screen) {
        final int side = mCachedDevice.getDeviceSide();
        final int stringRes = (side == HearingAidProfile.DeviceSide.SIDE_LEFT)
                ? R.string.bluetooth_pair_right_ear_button
                : R.string.bluetooth_pair_left_ear_button;

        mPreference = screen.findPreference(getPreferenceKey());
        mPreference.setTitle(stringRes);
        mPreference.setOnClickListener(v -> launchPairingDetail());
    }

    @Override
    protected void refresh() {
        mPreference.setVisible(getButtonPreferenceVisibility(mCachedDevice));
    }

    private boolean getButtonPreferenceVisibility(CachedBluetoothDevice cachedDevice) {
        return isBinauralMode(cachedDevice) && isOnlyOneSideConnected(cachedDevice);
    }

    private void launchPairingDetail() {
        new SubSettingLauncher(mContext)
                .setDestination(BluetoothPairingDetail.class.getName())
                .setSourceMetricsCategory(
                        ((BluetoothDeviceDetailsFragment) mFragment).getMetricsCategory())
                .launch();
    }

    private boolean isBinauralMode(CachedBluetoothDevice cachedDevice) {
        return cachedDevice.getDeviceMode() == HearingAidProfile.DeviceMode.MODE_BINAURAL;
    }

    private boolean isOnlyOneSideConnected(CachedBluetoothDevice cachedDevice) {
        if (!cachedDevice.isConnectedHearingAidDevice()) {
            return false;
        }

        final CachedBluetoothDevice subDevice = cachedDevice.getSubDevice();
        if (subDevice != null && subDevice.isConnectedHearingAidDevice()) {
            return false;
        }

        return true;
    }
}
Loading