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

Commit 052cd987 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6050516 from f985e3f3 to rvc-release

Change-Id: I28bbb70595eac0963c4205dd9580e23df5059100
parents 13884f96 f985e3f3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@
    <string name="bt_enable_line2" msgid="4341936569415937994">"Vols activar el Bluetooth ara?"</string>
    <string name="bt_enable_cancel" msgid="1988832367505151727">"Cancel·la"</string>
    <string name="bt_enable_ok" msgid="3432462749994538265">"Activa"</string>
    <string name="incoming_file_confirm_title" msgid="8139874248612182627">"Transferència del fitxer"</string>
    <string name="incoming_file_confirm_title" msgid="8139874248612182627">"Transferència de fitxers"</string>
    <string name="incoming_file_confirm_content" msgid="2752605552743148036">"Acceptes el fitxer entrant?"</string>
    <string name="incoming_file_confirm_cancel" msgid="2973321832477704805">"Rebutja"</string>
    <string name="incoming_file_confirm_ok" msgid="281462442932231475">"Accepta"</string>
+13 −0
Original line number Diff line number Diff line
@@ -33,6 +33,9 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -529,4 +532,14 @@ public final class Utils {
        return DateTimeFormatter.ofPattern("MM-dd HH:mm:ss.SSS")
                .withZone(ZoneId.systemDefault()).format(Instant.now());
    }

    public static void skipCurrentTag(XmlPullParser parser)
            throws XmlPullParserException, IOException {
        int outerDepth = parser.getDepth();
        int type;
        while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
                && (type != XmlPullParser.END_TAG
                || parser.getDepth() > outerDepth)) {
        }
    }
}
+44 −19
Original line number Diff line number Diff line
@@ -229,8 +229,8 @@ public class A2dpService extends ProfileService {
            Log.d(TAG, "connect(): " + device);
        }

        if (getPriority(device) == BluetoothProfile.PRIORITY_OFF) {
            Log.e(TAG, "Cannot connect to " + device + " : PRIORITY_OFF");
        if (getConnectionPolicy(device) == BluetoothProfile.CONNECTION_POLICY_FORBIDDEN) {
            Log.e(TAG, "Cannot connect to " + device + " : CONNECTION_POLICY_FORBIDDEN");
            return false;
        }
        if (!BluetoothUuid.isUuidPresent(mAdapterService.getRemoteUuids(device),
@@ -356,19 +356,18 @@ public class A2dpService extends ProfileService {
                    + " : too many connected devices");
            return false;
        }
        // Check priority and accept or reject the connection.
        int priority = getPriority(device);
        // Check connectionPolicy and accept or reject the connection.
        int connectionPolicy = getConnectionPolicy(device);
        int bondState = mAdapterService.getBondState(device);
        // Allow this connection only if the device is bonded. Any attempt to connect while
        // bonding would potentially lead to an unauthorized connection.
        if (bondState != BluetoothDevice.BOND_BONDED) {
            Log.w(TAG, "okToConnect: return false, bondState=" + bondState);
            return false;
        } else if (priority != BluetoothProfile.PRIORITY_UNDEFINED
                && priority != BluetoothProfile.PRIORITY_ON
                && priority != BluetoothProfile.PRIORITY_AUTO_CONNECT) {
            // Otherwise, reject the connection if priority is not valid.
            Log.w(TAG, "okToConnect: return false, priority=" + priority);
        } else if (connectionPolicy != BluetoothProfile.CONNECTION_POLICY_UNKNOWN
                && connectionPolicy != BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
            // Otherwise, reject the connection if connectionPolicy is not valid.
            Log.w(TAG, "okToConnect: return false, connectionPolicy=" + connectionPolicy);
            return false;
        }
        return true;
@@ -592,20 +591,46 @@ public class A2dpService extends ProfileService {
        }
    }

    public boolean setPriority(BluetoothDevice device, int priority) {
    /**
     * Set connection policy of the profile
     *
     * <p> The device should already be paired.
     * Connection policy can be one of:
     * {@link BluetoothProfile#CONNECTION_POLICY_ALLOWED},
     * {@link BluetoothProfile#CONNECTION_POLICY_FORBIDDEN},
     * {@link BluetoothProfile#CONNECTION_POLICY_UNKNOWN}
     *
     * @param device Paired bluetooth device
     * @param connectionPolicy is the connection policy to set to for this profile
     * @return true if connectionPolicy is set, false on error
     * @hide
     */
    public boolean setConnectionPolicy(BluetoothDevice device, int connectionPolicy) {
        enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission");
        if (DBG) {
            Log.d(TAG, "Saved priority " + device + " = " + priority);
            Log.d(TAG, "Saved connectionPolicy " + device + " = " + connectionPolicy);
        }
        mAdapterService.getDatabase()
                .setProfilePriority(device, BluetoothProfile.A2DP, priority);
                .setProfileConnectionPolicy(device, BluetoothProfile.A2DP, connectionPolicy);
        return true;
    }

    public int getPriority(BluetoothDevice device) {
    /**
     * Get the connection policy of the profile.
     *
     * <p> The connection policy can be any of:
     * {@link BluetoothProfile#CONNECTION_POLICY_ALLOWED},
     * {@link BluetoothProfile#CONNECTION_POLICY_FORBIDDEN},
     * {@link BluetoothProfile#CONNECTION_POLICY_UNKNOWN}
     *
     * @param device Bluetooth device
     * @return connection policy of the device
     * @hide
     */
    public int getConnectionPolicy(BluetoothDevice device) {
        enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission");
        return mAdapterService.getDatabase()
                .getProfilePriority(device, BluetoothProfile.A2DP);
                .getProfileConnectionPolicy(device, BluetoothProfile.A2DP);
    }

    public boolean isAvrcpAbsoluteVolumeSupported() {
@@ -1189,21 +1214,21 @@ public class A2dpService extends ProfileService {
        }

        @Override
        public boolean setPriority(BluetoothDevice device, int priority) {
        public boolean setConnectionPolicy(BluetoothDevice device, int connectionPolicy) {
            A2dpService service = getService();
            if (service == null) {
                return false;
            }
            return service.setPriority(device, priority);
            return service.setConnectionPolicy(device, connectionPolicy);
        }

        @Override
        public int getPriority(BluetoothDevice device) {
        public int getConnectionPolicy(BluetoothDevice device) {
            A2dpService service = getService();
            if (service == null) {
                return BluetoothProfile.PRIORITY_UNDEFINED;
                return BluetoothProfile.CONNECTION_POLICY_UNKNOWN;
            }
            return service.getPriority(device);
            return service.getConnectionPolicy(device);
        }

        @Override
+17 −16
Original line number Diff line number Diff line
@@ -171,21 +171,21 @@ public class A2dpSinkService extends ProfileService {
        }

        @Override
        public boolean setPriority(BluetoothDevice device, int priority) {
        public boolean setConnectionPolicy(BluetoothDevice device, int connectionPolicy) {
            A2dpSinkService service = getService();
            if (service == null) {
                return false;
            }
            return service.setPriority(device, priority);
            return service.setConnectionPolicy(device, connectionPolicy);
        }

        @Override
        public int getPriority(BluetoothDevice device) {
        public int getConnectionPolicy(BluetoothDevice device) {
            A2dpSinkService service = getService();
            if (service == null) {
                return BluetoothProfile.PRIORITY_UNDEFINED;
                return BluetoothProfile.CONNECTION_POLICY_UNKNOWN;
            }
            return service.getPriority(device);
            return service.getConnectionPolicy(device);
        }

        @Override
@@ -224,8 +224,9 @@ public class A2dpSinkService extends ProfileService {
            Log.d(TAG, " connect device: " + device
                    + ", InstanceMap start state: " + sb.toString());
        }
        if (getPriority(device) == BluetoothProfile.PRIORITY_OFF) {
            Log.w(TAG, "Connection not allowed: <" + device.getAddress() + "> is PRIORITY_OFF");
        if (getConnectionPolicy(device) == BluetoothProfile.CONNECTION_POLICY_FORBIDDEN) {
            Log.w(TAG, "Connection not allowed: <" + device.getAddress()
                    + "> is CONNECTION_POLICY_FORBIDDEN");
            return false;
        }
        A2dpSinkStateMachine stateMachine = getOrCreateStateMachine(device);
@@ -312,32 +313,32 @@ public class A2dpSinkService extends ProfileService {
    }

    /**
     * Set the priority of the  profile.
     * Set the connectionPolicy of the  profile.
     *
     * @param device   the remote device
     * @param priority the priority of the profile
     * @param connectionPolicy the connectionPolicy of the profile
     * @return true on success, otherwise false
     */
    public boolean setPriority(BluetoothDevice device, int priority) {
    public boolean setConnectionPolicy(BluetoothDevice device, int connectionPolicy) {
        enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission");
        if (DBG) {
            Log.d(TAG, "Saved priority " + device + " = " + priority);
            Log.d(TAG, "Saved connectionPolicy " + device + " = " + connectionPolicy);
        }
        AdapterService.getAdapterService().getDatabase()
                .setProfilePriority(device, BluetoothProfile.A2DP_SINK, priority);
                .setProfileConnectionPolicy(device, BluetoothProfile.A2DP_SINK, connectionPolicy);
        return true;
    }

    /**
     * Get the priority of the profile.
     * Get the connection policy of the profile.
     *
     * @param device the remote device
     * @return priority of the specified device
     * @return connection policy of the specified device
     */
    public int getPriority(BluetoothDevice device) {
    public int getConnectionPolicy(BluetoothDevice device) {
        enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission");
        return AdapterService.getAdapterService().getDatabase()
                .getProfilePriority(device, BluetoothProfile.A2DP_SINK);
                .getProfileConnectionPolicy(device, BluetoothProfile.A2DP_SINK);
    }


+2 −3
Original line number Diff line number Diff line
@@ -15,8 +15,6 @@
 */
package com.android.bluetooth.a2dpsink;

import static android.bluetooth.BluetoothProfile.PRIORITY_OFF;

import android.bluetooth.BluetoothA2dpSink;
import android.bluetooth.BluetoothAudioConfig;
import android.bluetooth.BluetoothDevice;
@@ -171,7 +169,8 @@ public class A2dpSinkStateMachine extends StateMachine {
                case StackEvent.EVENT_TYPE_CONNECTION_STATE_CHANGED:
                    switch (event.mState) {
                        case StackEvent.CONNECTION_STATE_CONNECTING:
                            if (mService.getPriority(mDevice) == PRIORITY_OFF) {
                            if (mService.getConnectionPolicy(mDevice)
                                    == BluetoothProfile.CONNECTION_POLICY_FORBIDDEN) {
                                Log.w(TAG, "Ignore incoming connection, profile is"
                                        + " turned off for " + mDevice);
                                mService.disconnectA2dpNative(mDeviceAddress);
Loading