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

Commit a88208c3 authored by Marie Janssen's avatar Marie Janssen Committed by Gerrit Code Review
Browse files

Merge "Use resources for pairing ui package"

parents 55665c40 7c75c1de
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -86,4 +86,14 @@
    <integer name="a2dp_source_codec_priority_aptx_hd">4001</integer>
    <integer name="a2dp_source_codec_priority_ldac">5001</integer>

    <!-- Package that is responsible for user interaction on pairing request,
         success or cancel.
         Receives:
          - BluetootDevice.ACTION_PAIRING_CANCEL on bond failure
          - BluetoothDevice.ACTION_PAIRING_REUQEST on pin request
          - BluetootDevice.ACTION_BOND_STATE_CHANGED on pairing request and success
          - BluetoothDevice.ACTION_CONNECTION_ACCESS_REQUEST on access requests
          - BluetoothDevice.ACTION_CONNECTION_ACCESS_CANCEL to cancel access requests -->
    <string name="pairing_ui_package">com.android.settings</string>

</resources>
+3 −4
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.os.Message;
import android.os.UserHandle;
import android.util.Log;

import com.android.bluetooth.R;
import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.RemoteDevices.DeviceProperties;
import com.android.internal.util.State;
@@ -72,8 +73,6 @@ final class BondStateMachine extends StateMachine {

    public static final String OOBDATA = "oobdata";

    private static final String PAIRING_REQUEST_PACKAGE = "com.android.settings";

    private BondStateMachine(AdapterService service,
            AdapterProperties prop, RemoteDevices remoteDevices) {
        super("BondStateMachine:");
@@ -326,7 +325,7 @@ final class BondStateMachine extends StateMachine {
        }
        intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, variant);
        intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND);
        intent.setPackage(PAIRING_REQUEST_PACKAGE);
        intent.setPackage(mAdapterService.getString(R.string.pairing_ui_package));
        mAdapterService.sendOrderedBroadcast(intent, mAdapterService.BLUETOOTH_ADMIN_PERM);
    }

@@ -345,7 +344,7 @@ final class BondStateMachine extends StateMachine {
        intent.putExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE, oldState);
        if (newState == BluetoothDevice.BOND_NONE)
            intent.putExtra(BluetoothDevice.EXTRA_REASON, reason);
        intent.setPackage(PAIRING_REQUEST_PACKAGE);
        intent.setPackage(mAdapterService.getString(R.string.pairing_ui_package));
        mAdapterService.sendBroadcastAsUser(intent, UserHandle.ALL,
                AdapterService.BLUETOOTH_PERM);
        infoLog("Bond State Change Intent:" + device + " OldState: " + oldState
+2 −3
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.os.Handler;
import android.os.Message;
import android.os.ParcelUuid;
import android.util.Log;
import com.android.bluetooth.R;
import com.android.bluetooth.Utils;
import java.util.ArrayList;
import java.util.HashMap;
@@ -45,8 +46,6 @@ final class RemoteDevices {
    private static final int UUID_INTENT_DELAY = 6000;
    private static final int MESSAGE_UUID_INTENT = 1;

    private static final String PAIRING_REQUEST_PACKAGE = "com.android.settings";

    private HashMap<String, DeviceProperties> mDevices;
    private Queue<String> mDeviceQueue;

@@ -408,7 +407,7 @@ final class RemoteDevices {
                // Send PAIRING_CANCEL intent to dismiss any dialog requesting bonding.
                intent = new Intent(BluetoothDevice.ACTION_PAIRING_CANCEL);
                intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
                intent.setPackage(PAIRING_REQUEST_PACKAGE);
                intent.setPackage(mAdapterService.getString(R.string.pairing_ui_package));
                mAdapterService.sendBroadcast(intent, mAdapterService.BLUETOOTH_PERM);
            }
            if (state == BluetoothAdapter.STATE_ON || state == BluetoothAdapter.STATE_TURNING_OFF) {
+4 −4
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.provider.ContactsContract.PhoneLookup;
import android.telephony.PhoneNumberUtils;
import android.util.Log;

import com.android.bluetooth.R;
import com.android.bluetooth.Utils;
import com.android.bluetooth.util.DevicePolicyUtils;

@@ -86,9 +87,7 @@ public class AtPhonebook {
    private boolean mCheckingAccessPermission;

    // package and class name to which we send intent to check phone book access permission
    private static final String ACCESS_AUTHORITY_PACKAGE = "com.android.settings";
    private static final String ACCESS_AUTHORITY_CLASS =
        "com.android.settings.bluetooth.BluetoothPermissionRequest";
    private final String mPairingPackage;
    private static final String BLUETOOTH_ADMIN_PERM = android.Manifest.permission.BLUETOOTH_ADMIN;

    private final HashMap<String, PhonebookResult> mPhonebooks =
@@ -101,6 +100,7 @@ public class AtPhonebook {

    public AtPhonebook(Context context, HeadsetStateMachine headsetState) {
        mContext = context;
        mPairingPackage = context.getString(R.string.pairing_ui_package);
        mContentResolver = context.getContentResolver();
        mStateMachine = headsetState;
        mPhonebooks.put("DC", new PhonebookResult());  // dialled calls
@@ -604,7 +604,7 @@ public class AtPhonebook {
        if (permission == BluetoothDevice.ACCESS_UNKNOWN) {
            log("checkAccessPermission - ACTION_CONNECTION_ACCESS_REQUEST");
            Intent intent = new Intent(BluetoothDevice.ACTION_CONNECTION_ACCESS_REQUEST);
            intent.setClassName(ACCESS_AUTHORITY_PACKAGE, ACCESS_AUTHORITY_CLASS);
            intent.setPackage(mPairingPackage);
            intent.putExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE,
            BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS);
            intent.putExtra(BluetoothDevice.EXTRA_DEVICE, remoteDevice);
+3 −7
Original line number Diff line number Diff line
@@ -41,11 +41,11 @@ import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray;

import com.android.bluetooth.R;
import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.btservice.ProfileService;
import com.android.bluetooth.btservice.ProfileService.IProfileServiceBinder;
import com.android.bluetooth.R;

import java.io.IOException;
import java.util.ArrayList;
@@ -153,9 +153,6 @@ public class BluetoothMapService extends ProfileService {

    private boolean mSmsCapable = true;

    // package and class name to which we send intent to check phone book access permission
    private static final String ACCESS_AUTHORITY_PACKAGE = "com.android.settings";

    private static final ParcelUuid[] MAP_UUIDS = {
        BluetoothUuid.MAP,
        BluetoothUuid.MNS,
@@ -163,7 +160,6 @@ public class BluetoothMapService extends ProfileService {

    public BluetoothMapService() {
        mState = BluetoothMap.STATE_DISCONNECTED;

    }


@@ -361,7 +357,7 @@ public class BluetoothMapService extends ProfileService {
                case USER_TIMEOUT:
                    if (mIsWaitingAuthorization) {
                        Intent intent = new Intent(BluetoothDevice.ACTION_CONNECTION_ACCESS_CANCEL);
                        intent.setPackage(ACCESS_AUTHORITY_PACKAGE);
                        intent.setPackage(getString(R.string.pairing_ui_package));
                        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mRemoteDevice);
                        intent.putExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE,
                                BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS);
@@ -871,7 +867,7 @@ public class BluetoothMapService extends ProfileService {
        if (sendIntent) {
            // This will trigger Settings app's dialog.
            Intent intent = new Intent(BluetoothDevice.ACTION_CONNECTION_ACCESS_REQUEST);
            intent.setPackage(ACCESS_AUTHORITY_PACKAGE);
            intent.setPackage(getString(R.string.pairing_ui_package));
            intent.putExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE,
                            BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS);
            intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mRemoteDevice);
Loading