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

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

Snap for 9442415 from 2ea4d90c to tm-qpr2-release

Change-Id: I265eaf73365ddc774e00f7a2082d406d02fa5e30
parents 6a3bbdd1 2ea4d90c
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -128,10 +128,10 @@
    <string name="a2dp_sink_mbs_label" msgid="6035366346569127155">"Bluetooth Audio"</string>
    <string name="bluetooth_opp_file_limit_exceeded" msgid="6612109860149473930">"Files bigger than 4GB cannot be transferred"</string>
    <string name="bluetooth_connect_action" msgid="2319449093046720209">"Connect to Bluetooth"</string>
    <string name="bluetooth_enabled_apm_title" msgid="6914461147844949044">"Bluetooth on in airplane mode"</string>
    <string name="bluetooth_enabled_apm_message" msgid="8409900562494838113">"If you keep Bluetooth on, your phone will remember to keep it on the next time you\'re in airplane mode"</string>
    <string name="bluetooth_enabled_apm_title" msgid="6914461147844949044">"Bluetooth on in Airplane mode"</string>
    <string name="bluetooth_enabled_apm_message" msgid="8409900562494838113">"If you keep Bluetooth on, your phone will remember to keep it on the next time you\'re in Airplane mode"</string>
    <string name="bluetooth_stays_on_title" msgid="39720820955212918">"Bluetooth stays on"</string>
    <string name="bluetooth_stays_on_message" msgid="7142453371222249965">"Your phone remembers to keep Bluetooth on in airplane mode. Turn off Bluetooth if you don\'t want it to stay on."</string>
    <string name="bluetooth_stays_on_message" msgid="7142453371222249965">"Your phone remembers to keep Bluetooth on in Airplane mode. Turn off Bluetooth if you don\'t want it to stay on."</string>
    <string name="bluetooth_and_wifi_stays_on_title" msgid="5821932798860821244">"Wi-Fi and Bluetooth stay on"</string>
    <string name="bluetooth_and_wifi_stays_on_message" msgid="2390749828997719812">"Your phone remembers to keep Wi-Fi and Bluetooth on in airplane mode. Turn off Wi-Fi and Bluetooth if you don\'t want them to stay on."</string>
    <string name="bluetooth_and_wifi_stays_on_message" msgid="2390749828997719812">"Your phone remembers to keep Wi-Fi and Bluetooth on in Airplane mode. Turn off Wi-Fi and Bluetooth if you don\'t want them to stay on."</string>
</resources>
+33 −1
Original line number Diff line number Diff line
@@ -18,6 +18,10 @@ package com.android.bluetooth;

import android.annotation.RequiresPermission;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.le.PeriodicAdvertisingCallback;
import android.bluetooth.le.PeriodicAdvertisingManager;
import android.bluetooth.le.ScanResult;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
@@ -27,6 +31,7 @@ import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.Handler;
import android.os.ParcelFileDescriptor;
import android.provider.Telephony;
import android.util.Log;
@@ -180,4 +185,31 @@ public class BluetoothMethodProxy {
    public long telephonyGetOrCreateThreadId(Context context, Set<String> recipients) {
        return Telephony.Threads.getOrCreateThreadId(context, recipients);
    }

    /**
     * Proxies {@link PeriodicAdvertisingManager#registerSync(ScanResult, int, int,
     * PeriodicAdvertisingCallback, Handler)}.
     */
    public void periodicAdvertisingManagerRegisterSync(PeriodicAdvertisingManager manager,
            ScanResult scanResult, int skip, int timeout,
            PeriodicAdvertisingCallback callback, Handler handler) {
        manager.registerSync(scanResult, skip, timeout, callback, handler);
    }

    /**
     * Proxies {@link PeriodicAdvertisingManager#transferSync}.
     */
    public void periodicAdvertisingManagerTransferSync(PeriodicAdvertisingManager manager,
            BluetoothDevice bda, int serviceData, int syncHandle) {
        manager.transferSync(bda, serviceData, syncHandle);
    }

    /**
     * Proxies {@link PeriodicAdvertisingManager#transferSetInfo}.
     */
    public void periodicAdvertisingManagerTransferSetInfo(
            PeriodicAdvertisingManager manager, BluetoothDevice bda, int serviceData,
            int advHandle, PeriodicAdvertisingCallback callback) {
        manager.transferSetInfo(bda, serviceData, advHandle, callback);
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -1309,6 +1309,9 @@ public class A2dpService extends ProfileService {

        @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
        private A2dpService getService(AttributionSource source) {
            if (Utils.isInstrumentationTestMode()) {
                return mService;
            }
            if (!Utils.checkServiceAvailable(mService, TAG)
                    || !Utils.checkCallerIsSystemOrActiveOrManagedUser(mService, TAG)
                    || !Utils.checkConnectPermissionForDataDelivery(mService, source, TAG)) {
+51 −27
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import com.android.bluetooth.Utils;
import com.android.bluetooth.a2dpsink.A2dpSinkService;
import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.btservice.ProfileService;
import com.android.internal.annotations.VisibleForTesting;
import com.android.modules.utils.SynchronousResultReceiver;

import java.util.ArrayList;
@@ -67,7 +68,8 @@ public class AvrcpControllerService extends ProfileService {
    private static final byte JNI_PLAY_STATUS_PLAYING = 0x01;
    private static final byte JNI_PLAY_STATUS_PAUSED = 0x02;
    private static final byte JNI_PLAY_STATUS_FWD_SEEK = 0x03;
    private static final byte JNI_PLAY_STATUS_REV_SEEK = 0x04;
    @VisibleForTesting
    static final byte JNI_PLAY_STATUS_REV_SEEK = 0x04;
    private static final byte JNI_PLAY_STATUS_ERROR = -1;

    /* Folder/Media Item scopes.
@@ -173,6 +175,7 @@ public class AvrcpControllerService extends ProfileService {
        for (AvrcpControllerStateMachine stateMachine : mDeviceStateMap.values()) {
            stateMachine.quitNow();
        }
        mDeviceStateMap.clear();

        sService = null;
        sBrowseTree = null;
@@ -201,7 +204,8 @@ public class AvrcpControllerService extends ProfileService {
    /**
     * Set the current active device, notify devices of activity status
     */
    private boolean setActiveDevice(BluetoothDevice device) {
    @VisibleForTesting
    boolean setActiveDevice(BluetoothDevice device) {
        A2dpSinkService a2dpSinkService = A2dpSinkService.getA2dpSinkService();
        if (a2dpSinkService == null) {
            return false;
@@ -277,7 +281,8 @@ public class AvrcpControllerService extends ProfileService {
        }
    }

    private void refreshContents(BrowseTree.BrowseNode node) {
    @VisibleForTesting
    void refreshContents(BrowseTree.BrowseNode node) {
        BluetoothDevice device = node.getDevice();
        if (device == null) {
            return;
@@ -359,12 +364,16 @@ public class AvrcpControllerService extends ProfileService {
    }

    //Binder object: Must be static class or memory leak may occur
    private static class AvrcpControllerServiceBinder extends IBluetoothAvrcpController.Stub
    @VisibleForTesting
    static class AvrcpControllerServiceBinder extends IBluetoothAvrcpController.Stub
            implements IProfileServiceBinder {
        private AvrcpControllerService mService;

        @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
        private AvrcpControllerService getService(AttributionSource source) {
            if (Utils.isInstrumentationTestMode()) {
                return mService;
            }
            if (!Utils.checkServiceAvailable(mService, TAG)
                    || !Utils.checkCallerIsSystemOrActiveOrManagedUser(mService, TAG)
                    || !Utils.checkConnectPermissionForDataDelivery(mService, source, TAG)) {
@@ -467,14 +476,16 @@ public class AvrcpControllerService extends ProfileService {

    /* JNI API*/
    // Called by JNI when a passthrough key was received.
    private void handlePassthroughRsp(int id, int keyState, byte[] address) {
    @VisibleForTesting
    void handlePassthroughRsp(int id, int keyState, byte[] address) {
        if (DBG) {
            Log.d(TAG, "passthrough response received as: key: " + id
                    + " state: " + keyState + "address:" + Arrays.toString(address));
        }
    }

    private void handleGroupNavigationRsp(int id, int keyState) {
    @VisibleForTesting
    void handleGroupNavigationRsp(int id, int keyState) {
        if (DBG) {
            Log.d(TAG, "group navigation response received as: key: " + id + " state: "
                    + keyState);
@@ -482,17 +493,14 @@ public class AvrcpControllerService extends ProfileService {
    }

    // Called by JNI when a device has connected or disconnected.
    private synchronized void onConnectionStateChanged(boolean remoteControlConnected,
    @VisibleForTesting
    synchronized void onConnectionStateChanged(boolean remoteControlConnected,
            boolean browsingConnected, byte[] address) {
        BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address);
        if (DBG) {
            Log.d(TAG, "onConnectionStateChanged " + remoteControlConnected + " "
                    + browsingConnected + device);
        }
        if (device == null) {
            Log.e(TAG, "onConnectionStateChanged Device is null");
            return;
        }

        StackEvent event =
                StackEvent.connectionStateChanged(remoteControlConnected, browsingConnected);
@@ -512,12 +520,14 @@ public class AvrcpControllerService extends ProfileService {
    }

    // Called by JNI to notify Avrcp of features supported by the Remote device.
    private void getRcFeatures(byte[] address, int features) {
    @VisibleForTesting
    void getRcFeatures(byte[] address, int features) {
        /* Do Nothing. */
    }

    // Called by JNI to notify Avrcp of a remote device's Cover Art PSM
    private void getRcPsm(byte[] address, int psm) {
    @VisibleForTesting
    void getRcPsm(byte[] address, int psm) {
        BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address);
        if (DBG) Log.d(TAG, "getRcPsm(device=" + device + ", psm=" + psm + ")");
        AvrcpControllerStateMachine stateMachine = getOrCreateStateMachine(device);
@@ -528,12 +538,14 @@ public class AvrcpControllerService extends ProfileService {
    }

    // Called by JNI
    private void setPlayerAppSettingRsp(byte[] address, byte accepted) {
    @VisibleForTesting
    void setPlayerAppSettingRsp(byte[] address, byte accepted) {
        /* Do Nothing. */
    }

    // Called by JNI when remote wants to receive absolute volume notifications.
    private synchronized void handleRegisterNotificationAbsVol(byte[] address, byte label) {
    @VisibleForTesting
    synchronized void handleRegisterNotificationAbsVol(byte[] address, byte label) {
        if (DBG) {
            Log.d(TAG, "handleRegisterNotificationAbsVol");
        }
@@ -546,7 +558,8 @@ public class AvrcpControllerService extends ProfileService {
    }

    // Called by JNI when remote wants to set absolute volume.
    private synchronized void handleSetAbsVolume(byte[] address, byte absVol, byte label) {
    @VisibleForTesting
    synchronized void handleSetAbsVolume(byte[] address, byte absVol, byte label) {
        if (DBG) {
            Log.d(TAG, "handleSetAbsVolume ");
        }
@@ -559,7 +572,8 @@ public class AvrcpControllerService extends ProfileService {
    }

    // Called by JNI when a track changes and local AvrcpController is registered for updates.
    private synchronized void onTrackChanged(byte[] address, byte numAttributes, int[] attributes,
    @VisibleForTesting
    synchronized void onTrackChanged(byte[] address, byte numAttributes, int[] attributes,
            String[] attribVals) {
        if (DBG) {
            Log.d(TAG, "onTrackChanged");
@@ -586,7 +600,8 @@ public class AvrcpControllerService extends ProfileService {
    }

    // Called by JNI periodically based upon timer to update play position
    private synchronized void onPlayPositionChanged(byte[] address, int songLen,
    @VisibleForTesting
    synchronized void onPlayPositionChanged(byte[] address, int songLen,
            int currSongPosition) {
        if (DBG) {
            Log.d(TAG, "onPlayPositionChanged pos " + currSongPosition);
@@ -601,7 +616,8 @@ public class AvrcpControllerService extends ProfileService {
    }

    // Called by JNI on changes of play status
    private synchronized void onPlayStatusChanged(byte[] address, byte playStatus) {
    @VisibleForTesting
    synchronized void onPlayStatusChanged(byte[] address, byte playStatus) {
        if (DBG) {
            Log.d(TAG, "onPlayStatusChanged " + playStatus);
        }
@@ -615,7 +631,8 @@ public class AvrcpControllerService extends ProfileService {
    }

    // Called by JNI to report remote Player's capabilities
    private synchronized void handlePlayerAppSetting(byte[] address, byte[] playerAttribRsp,
    @VisibleForTesting
    synchronized void handlePlayerAppSetting(byte[] address, byte[] playerAttribRsp,
            int rspLen) {
        if (DBG) {
            Log.d(TAG, "handlePlayerAppSetting rspLen = " + rspLen);
@@ -631,7 +648,8 @@ public class AvrcpControllerService extends ProfileService {
        }
    }

    private synchronized void onPlayerAppSettingChanged(byte[] address, byte[] playerAttribRsp,
    @VisibleForTesting
    synchronized void onPlayerAppSettingChanged(byte[] address, byte[] playerAttribRsp,
            int rspLen) {
        if (DBG) {
            Log.d(TAG, "onPlayerAppSettingChanged ");
@@ -648,7 +666,8 @@ public class AvrcpControllerService extends ProfileService {
        }
    }

    private void onAvailablePlayerChanged(byte[] address) {
    @VisibleForTesting
    void onAvailablePlayerChanged(byte[] address) {
        if (DBG) {
            Log.d(TAG," onAvailablePlayerChanged");
        }
@@ -766,7 +785,8 @@ public class AvrcpControllerService extends ProfileService {
        return apb.build();
    }

    private void handleChangeFolderRsp(byte[] address, int count) {
    @VisibleForTesting
    void handleChangeFolderRsp(byte[] address, int count) {
        if (DBG) {
            Log.d(TAG, "handleChangeFolderRsp count: " + count);
        }
@@ -778,7 +798,8 @@ public class AvrcpControllerService extends ProfileService {
        }
    }

    private void handleSetBrowsedPlayerRsp(byte[] address, int items, int depth) {
    @VisibleForTesting
    void handleSetBrowsedPlayerRsp(byte[] address, int items, int depth) {
        if (DBG) {
            Log.d(TAG, "handleSetBrowsedPlayerRsp depth: " + depth);
        }
@@ -791,7 +812,8 @@ public class AvrcpControllerService extends ProfileService {
        }
    }

    private void handleSetAddressedPlayerRsp(byte[] address, int status) {
    @VisibleForTesting
    void handleSetAddressedPlayerRsp(byte[] address, int status) {
        if (DBG) {
            Log.d(TAG, "handleSetAddressedPlayerRsp status: " + status);
        }
@@ -804,7 +826,8 @@ public class AvrcpControllerService extends ProfileService {
        }
    }

    private void handleAddressedPlayerChanged(byte[] address, int id) {
    @VisibleForTesting
    void handleAddressedPlayerChanged(byte[] address, int id) {
        if (DBG) {
            Log.d(TAG, "handleAddressedPlayerChanged id: " + id);
        }
@@ -817,7 +840,8 @@ public class AvrcpControllerService extends ProfileService {
        }
    }

    private void handleNowPlayingContentChanged(byte[] address) {
    @VisibleForTesting
    void handleNowPlayingContentChanged(byte[] address) {
        if (DBG) {
            Log.d(TAG, "handleNowPlayingContentChanged");
        }
+3 −0
Original line number Diff line number Diff line
@@ -528,6 +528,9 @@ public class BatteryService extends ProfileService {
        @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
        private BatteryService getService(AttributionSource source) {
            BatteryService service = mServiceRef.get();
            if (Utils.isInstrumentationTestMode()) {
                return service;
            }

            if (!Utils.checkServiceAvailable(service, TAG)
                    || !Utils.checkCallerIsSystemOrActiveOrManagedUser(service, TAG)
Loading