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

Commit 08c43412 authored by Sal Savage's avatar Sal Savage
Browse files

Enable the Pbap Client authenticator

The authentication framework uses the service declaration in the
manifest to allow us create accounts for connected devices. The service
must be enabled for it register in their framework. In our case as well,
it doesn't seem like the service ever actually get's started either.
Just existing in the manifest is enough for us to create the accounts we
need to.

Before this change, it was disabled and PBAP would enable it when it
started. It was found that there's latency between when the service
manifest change is written and when the authentication framework picks
up and acts on the change such that we can create accounts. This causes
a race condition between when they've processed our manifest change such
that we can create an account, and we actually try to make an account.
Making an account without the auth framework knowning of our change
causes crashes.

Given there's no easy way for us to know when the auth framework is
ready for us, the easiest way to handle this is the leave the component
enabled.

Tag: #stability
Bug: 229629444
Test: atest BluetoothInstrumentationTests
Change-Id: If0af12607dbb7a910013f4d9171b70662f0e6319
parent d0a5a350
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -519,9 +519,12 @@
                <action android:name="android.bluetooth.IBluetoothPbapClient"/>
            </intent-filter>
        </service>
        <!--  Note: This service doesn't get started, it just indicates to the Authentication
              framework that we can create accounts of a specific type. As such, its safe to
              have as enabled on all targets and not just the ones that use PBAP Client  -->
        <service android:process="@string/process"
             android:name="com.android.bluetooth.pbapclient.AuthenticationService"
             android:enabled="false"
             android:enabled="true"
             android:exported="true">
            <intent-filter>
                <action android:name="android.accounts.AccountAuthenticator"/>
+0 −9
Original line number Diff line number Diff line
@@ -60,12 +60,6 @@ public class PbapClientService extends ProfileService {
    private static final String TAG = "PbapClientService";
    private static final String SERVICE_NAME = "Phonebook Access PCE";

    /**
     * The component names for the owned authenticator service
     */
    private static final String AUTHENTICATOR_SERVICE =
            AuthenticationService.class.getCanonicalName();

    // MAXIMUM_DEVICES set to 10 to prevent an excessive number of simultaneous devices.
    private static final int MAXIMUM_DEVICES = 10;
    private Map<BluetoothDevice, PbapClientStateMachine> mPbapClientStateMachineMap =
@@ -94,8 +88,6 @@ public class PbapClientService extends ProfileService {
        mDatabaseManager = Objects.requireNonNull(AdapterService.getAdapterService().getDatabase(),
                "DatabaseManager cannot be null when PbapClientService starts");

        setComponentAvailable(AUTHENTICATOR_SERVICE, true);

        IntentFilter filter = new IntentFilter();
        filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
        // delay initial download until after the user is unlocked to add an account.
@@ -128,7 +120,6 @@ public class PbapClientService extends ProfileService {
            pbapClientStateMachine.doQuit();
        }
        removeUncleanAccounts();
        setComponentAvailable(AUTHENTICATOR_SERVICE, false);
        return true;
    }