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

Commit a90920ae authored by Sal Savage's avatar Sal Savage
Browse files

Control PBAP Client logging with setprop

This change makes the individual components of our PBAP Client
implementation have runtime controllable logging by using adb setprop
and toggling the Bluetooth adapter.

PBAP Client was the last profile used on Automotive form factors that
didn't use this pattern. Many profiles outside of the profiles used on
Auotmotive form factors also follow this pattern.

Tag: #refactor
Bug: 283300028
Test: atest BluetoothInstrumentationTests
Change-Id: Id3cb5a048bcc88b4a06f72d3c50338fc7ea28e77
parent fec3d3ff
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -25,8 +25,8 @@ import android.os.Bundle;
import android.util.Log;
import android.util.Log;


public class Authenticator extends AbstractAccountAuthenticator {
public class Authenticator extends AbstractAccountAuthenticator {
    private static final String TAG = "PbapAuthenticator";
    private static final String TAG = "PbapClientAuthenticator";
    private static final boolean DBG = Utils.DBG;
    private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG);


    public Authenticator(Context context) {
    public Authenticator(Context context) {
        super(context);
        super(context);
+7 −6
Original line number Original line Diff line number Diff line
@@ -31,8 +31,9 @@ import java.util.Arrays;
 */
 */
class BluetoothPbapObexAuthenticator implements Authenticator {
class BluetoothPbapObexAuthenticator implements Authenticator {


    private static final String TAG = "BtPbapObexAuthenticator";
    private static final String TAG = "PbapClientObexAuth";
    private static final boolean DBG = Utils.DBG;
    private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG);
    private static final boolean VDBG = Log.isLoggable(TAG, Log.VERBOSE);


    //Default session key for legacy devices is 0000
    //Default session key for legacy devices is 0000
    @VisibleForTesting
    @VisibleForTesting
@@ -48,14 +49,14 @@ class BluetoothPbapObexAuthenticator implements Authenticator {
    public PasswordAuthentication onAuthenticationChallenge(String description,
    public PasswordAuthentication onAuthenticationChallenge(String description,
            boolean isUserIdRequired, boolean isFullAccess) {
            boolean isUserIdRequired, boolean isFullAccess) {
        PasswordAuthentication pa = null;
        PasswordAuthentication pa = null;
        if (DBG) Log.v(TAG, "onAuthenticationChallenge: starting");
        if (DBG) Log.d(TAG, "onAuthenticationChallenge: starting");


        if (mSessionKey != null && mSessionKey.length() != 0) {
        if (mSessionKey != null && mSessionKey.length() != 0) {
            if (DBG) Log.v(TAG, "onAuthenticationChallenge: mSessionKey=" + mSessionKey);
            if (DBG) Log.d(TAG, "onAuthenticationChallenge: mSessionKey=" + mSessionKey);
            pa = new PasswordAuthentication(null, mSessionKey.getBytes());
            pa = new PasswordAuthentication(null, mSessionKey.getBytes());
        } else {
        } else {
            if (DBG) {
            if (DBG) {
                Log.v(TAG,
                Log.d(TAG,
                        "onAuthenticationChallenge: mSessionKey is empty, timeout/cancel occured");
                        "onAuthenticationChallenge: mSessionKey is empty, timeout/cancel occured");
            }
            }
        }
        }
@@ -65,7 +66,7 @@ class BluetoothPbapObexAuthenticator implements Authenticator {


    @Override
    @Override
    public byte[] onAuthenticationResponse(byte[] userName) {
    public byte[] onAuthenticationResponse(byte[] userName) {
        if (DBG) Log.v(TAG, "onAuthenticationResponse: " + Arrays.toString(userName));
        if (VDBG) Log.v(TAG, "onAuthenticationResponse: " + Arrays.toString(userName));
        /* required only in case PCE challenges PSE which we don't do now */
        /* required only in case PCE challenges PSE which we don't do now */
        return null;
        return null;
    }
    }
+2 −2
Original line number Original line Diff line number Diff line
@@ -28,8 +28,8 @@ import java.io.InputStream;


abstract class BluetoothPbapRequest {
abstract class BluetoothPbapRequest {


    private static final String TAG = "BluetoothPbapRequest";
    static final String TAG = "PbapClient.BaseRequest";
    private static final boolean DBG = Utils.DBG;
    private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG);


    protected static final byte OAP_TAGID_ORDER = 0x01;
    protected static final byte OAP_TAGID_ORDER = 0x01;
    protected static final byte OAP_TAGID_SEARCH_VALUE = 0x02;
    protected static final byte OAP_TAGID_SEARCH_VALUE = 0x02;
+2 −4
Original line number Original line Diff line number Diff line
@@ -28,10 +28,8 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.ArrayList;


final class BluetoothPbapRequestPullPhoneBook extends BluetoothPbapRequest {
final class BluetoothPbapRequestPullPhoneBook extends BluetoothPbapRequest {

    private static final String TAG = "PbapClient.PullPb";
    private static final boolean VDBG = Utils.VDBG;
    private static final boolean VDBG = Log.isLoggable(TAG, Log.VERBOSE);

    private static final String TAG = "BtPbapReqPullPhoneBook";


    private static final String TYPE = "x-bt/phonebook";
    private static final String TYPE = "x-bt/phonebook";


+2 −4
Original line number Original line Diff line number Diff line
@@ -22,10 +22,8 @@ import com.android.bluetooth.ObexAppParameters;
import com.android.obex.HeaderSet;
import com.android.obex.HeaderSet;


final class BluetoothPbapRequestPullPhoneBookSize extends BluetoothPbapRequest {
final class BluetoothPbapRequestPullPhoneBookSize extends BluetoothPbapRequest {

    private static final String TAG = "PbapClient.PullPbSize";
    private static final boolean VDBG = Utils.VDBG;
    private static final boolean VDBG = Log.isLoggable(TAG, Log.VERBOSE);

    private static final String TAG = "BtPbapReqPullPhoneBookSize";


    private static final String TYPE = "x-bt/phonebook";
    private static final String TYPE = "x-bt/phonebook";


Loading