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

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

Snap for 9410359 from a4efbba0 to tm-qpr2-release

Change-Id: I26c4acb8a07f34a6a8724ceeefe5b6cfd3a2f3ba
parents aa794b93 a4efbba0
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -129,12 +129,9 @@
    <string name="bluetooth_opp_file_limit_exceeded" msgid="6612109860149473930">"ከ4 ጊባ በላይ የሆኑ ፋይሎች ሊዛወሩ አይችሉም"</string>
    <string name="bluetooth_connect_action" msgid="2319449093046720209">"ከብሉቱዝ ጋር ተገናኝ"</string>
    <string name="bluetooth_enabled_apm_title" msgid="6914461147844949044">"ብሉቱዝ በአውሮፕላን ሁነታ ላይ በርቷል"</string>
    <!-- no translation found for bluetooth_enabled_apm_message (8409900562494838113) -->
    <skip />
    <string name="bluetooth_enabled_apm_message" msgid="8409900562494838113">"ብሉቱዝን አብርተው ካቆዩ በቀጣይ ጊዜ በአውሮፕላን ሁነታ ውስጥ ሲሆኑ ስልክዎ እሱን አብርቶ ማቆየቱን ያስታውሳል"</string>
    <string name="bluetooth_stays_on_title" msgid="39720820955212918">"ብሉቱዝ በርቶ ይቆያል"</string>
    <!-- no translation found for bluetooth_stays_on_message (7142453371222249965) -->
    <skip />
    <string name="bluetooth_stays_on_message" msgid="7142453371222249965">"ስልክዎ ብሉቱዝን በአውሮፕላን ሁነታ ውስጥ አብርቶ ማቆየትን ያስታውሳል። በርቶ እንዲቆይ ካልፈለጉ ብሉቱዝን ያጥፉት።"</string>
    <string name="bluetooth_and_wifi_stays_on_title" msgid="5821932798860821244">"Wi-Fi እና ብሉቱዝ በርተው ይቆያሉ"</string>
    <!-- no translation found for bluetooth_and_wifi_stays_on_message (2390749828997719812) -->
    <skip />
    <string name="bluetooth_and_wifi_stays_on_message" msgid="2390749828997719812">"ስልክዎ Wi-Fiን እና ብሉቱዝን በአውሮፕላን ሁነታ ውስጥ አብርቶ ማቆየትን ያስታውሳል። በርተው እንዲቆዩ ካልፈለጉ Wi-Fi እና ብሉቱዝን ያጥፏቸው።"</string>
</resources>
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@
    <string name="bt_enable_line1" msgid="8429910585843481489">"బ్లూటూత్ సేవలను ఉపయోగించడానికి, మీరు తప్పనిసరిగా ముందుగా బ్లూటూత్‌ను ప్రారంభించాలి."</string>
    <string name="bt_enable_line2" msgid="1466367120348920892">"ఇప్పుడే బ్లూటూత్‌ను ప్రారంభించాలా?"</string>
    <string name="bt_enable_cancel" msgid="6770180540581977614">"రద్దు చేయి"</string>
    <string name="bt_enable_ok" msgid="4224374055813566166">"ప్రారంభించ"</string>
    <string name="bt_enable_ok" msgid="4224374055813566166">"ప్రారంభించండి"</string>
    <string name="incoming_file_confirm_title" msgid="938251186275547290">"ఫైల్ బదిలీ"</string>
    <string name="incoming_file_confirm_content" msgid="6573502088511901157">"ఇన్‌కమింగ్ ఫైల్‌ను ఆమోదించాలా?"</string>
    <string name="incoming_file_confirm_cancel" msgid="9205906062663982692">"తిరస్కరిస్తున్నాను"</string>
+24 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission;

import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadset;
import android.bluetooth.BluetoothProfile;
@@ -2184,10 +2185,32 @@ public class HeadsetService extends ProfileService {
    public BluetoothDevice getFallbackDevice() {
        DatabaseManager dbManager = mAdapterService.getDatabase();
        return dbManager != null ? dbManager
            .getMostRecentlyConnectedDevicesInList(getConnectedDevices())
            .getMostRecentlyConnectedDevicesInList(getFallbackCandidates(dbManager))
            : null;
    }

    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    List<BluetoothDevice> getFallbackCandidates(DatabaseManager dbManager) {
        List<BluetoothDevice> fallbackCandidates = getConnectedDevices();
        List<BluetoothDevice> uninterestedCandidates = new ArrayList<>();
        for (BluetoothDevice device : fallbackCandidates) {
            byte[] deviceType = dbManager.getCustomMeta(device,
                    BluetoothDevice.METADATA_DEVICE_TYPE);
            BluetoothClass deviceClass = device.getBluetoothClass();
            if ((deviceClass != null
                    && deviceClass.getMajorDeviceClass()
                    == BluetoothClass.Device.WEARABLE_WRIST_WATCH)
                    || (deviceType != null
                    && BluetoothDevice.DEVICE_TYPE_WATCH.equals(new String(deviceType)))) {
                uninterestedCandidates.add(device);
            }
        }
        for (BluetoothDevice device : uninterestedCandidates) {
            fallbackCandidates.remove(device);
        }
        return fallbackCandidates;
    }

    @Override
    public void dump(StringBuilder sb) {
        boolean isScoOn = mSystemInterface.getAudioManager().isBluetoothScoOn();
+64 −0
Original line number Diff line number Diff line
@@ -938,6 +938,70 @@ public class HeadsetServiceTest {
        Assert.assertEquals(null, mHeadsetService.getActiveDevice());
    }

    @Test
    public void testGetFallbackCandidates() {
        BluetoothDevice deviceA = TestUtils.getTestDevice(mAdapter, 0);
        BluetoothDevice deviceB = TestUtils.getTestDevice(mAdapter, 1);
        when(mDatabaseManager.getCustomMeta(any(BluetoothDevice.class),
                any(Integer.class))).thenReturn(null);

        // No connected device
        Assert.assertTrue(mHeadsetService.getFallbackCandidates(mDatabaseManager).isEmpty());

        // One connected device
        addConnectedDeviceHelper(deviceA);
        Assert.assertTrue(mHeadsetService.getFallbackCandidates(mDatabaseManager)
                .contains(deviceA));

        // Two connected devices
        addConnectedDeviceHelper(deviceB);
        Assert.assertTrue(mHeadsetService.getFallbackCandidates(mDatabaseManager)
                .contains(deviceA));
        Assert.assertTrue(mHeadsetService.getFallbackCandidates(mDatabaseManager)
                .contains(deviceB));
    }

    @Test
    public void testGetFallbackCandidates_HasWatchDevice() {
        BluetoothDevice deviceWatch = TestUtils.getTestDevice(mAdapter, 0);
        BluetoothDevice deviceRegular = TestUtils.getTestDevice(mAdapter, 1);

        // Make deviceWatch a watch
        when(mDatabaseManager.getCustomMeta(deviceWatch, BluetoothDevice.METADATA_DEVICE_TYPE))
                .thenReturn(BluetoothDevice.DEVICE_TYPE_WATCH.getBytes());
        when(mDatabaseManager.getCustomMeta(deviceRegular, BluetoothDevice.METADATA_DEVICE_TYPE))
                .thenReturn(null);

        // Has a connected watch device
        addConnectedDeviceHelper(deviceWatch);
        Assert.assertTrue(mHeadsetService.getFallbackCandidates(mDatabaseManager).isEmpty());

        // Two connected devices with one watch
        addConnectedDeviceHelper(deviceRegular);
        Assert.assertFalse(mHeadsetService.getFallbackCandidates(mDatabaseManager)
                .contains(deviceWatch));
        Assert.assertTrue(mHeadsetService.getFallbackCandidates(mDatabaseManager)
                .contains(deviceRegular));
    }

    private void addConnectedDeviceHelper(BluetoothDevice device) {
        mCurrentDevice = device;
        when(mDatabaseManager.getProfileConnectionPolicy(any(BluetoothDevice.class),
                eq(BluetoothProfile.HEADSET)))
                .thenReturn(BluetoothProfile.CONNECTION_POLICY_UNKNOWN);
        Assert.assertTrue(mHeadsetService.connect(device));
        when(mStateMachines.get(device).getDevice()).thenReturn(device);
        when(mStateMachines.get(device).getConnectionState()).thenReturn(
                BluetoothProfile.STATE_CONNECTING);
        Assert.assertEquals(BluetoothProfile.STATE_CONNECTING,
                mHeadsetService.getConnectionState(device));
        when(mStateMachines.get(mCurrentDevice).getConnectionState()).thenReturn(
                BluetoothProfile.STATE_CONNECTED);
        Assert.assertEquals(BluetoothProfile.STATE_CONNECTED,
                mHeadsetService.getConnectionState(device));
        Assert.assertTrue(mHeadsetService.getConnectedDevices().contains(device));
    }

    /*
     *  Helper function to test okToAcceptConnection() method
     *