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

Commit c068900c authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Refactor PBAP Server logging to be unguarded" into main am: c3e4bc53 am: e039aacd

parents f435a6d8 e039aacd
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ public class BluetoothPbapActivity extends AlertActivity
        implements Preference.OnPreferenceChangeListener, TextWatcher {
    private static final String TAG = "BluetoothPbapActivity";

    private static final boolean V = BluetoothPbapService.VERBOSE;

    private static final int BLUETOOTH_OBEX_AUTHKEY_MAX_LENGTH = 16;

@@ -223,9 +222,7 @@ public class BluetoothPbapActivity extends AlertActivity
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        mTimeout = savedInstanceState.getBoolean(KEY_USER_TIMEOUT);
        if (V) {
        Log.v(TAG, "onRestoreInstanceState() mTimeout: " + mTimeout);
        }
        if (mTimeout) {
            onTimeout();
        }
@@ -268,9 +265,7 @@ public class BluetoothPbapActivity extends AlertActivity
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case DISMISS_TIMEOUT_DIALOG:
                    if (V) {
                    Log.v(TAG, "Received DISMISS_TIMEOUT_DIALOG msg.");
                    }
                    finish();
                    break;
                default:
+64 −157
Original line number Diff line number Diff line
@@ -53,9 +53,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {

    private static final String TAG = "BluetoothPbapObexServer";

    private static final boolean D = BluetoothPbapService.DEBUG;

    private static final boolean V = BluetoothPbapService.VERBOSE;

    private static final int UUID_LENGTH = 16;

@@ -268,18 +266,14 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {

    @Override
    public int onConnect(final HeaderSet request, HeaderSet reply) {
        if (V) {
        logHeader(request);
        }
        notifyUpdateWakeLock();
        try {
            byte[] uuid = (byte[]) mPbapMethodProxy.getHeader(request, HeaderSet.TARGET);
            if (uuid == null) {
                return ResponseCodes.OBEX_HTTP_NOT_ACCEPTABLE;
            }
            if (D) {
            Log.d(TAG, "onConnect(): uuid=" + Arrays.toString(uuid));
            }

            if (uuid.length != UUID_LENGTH) {
                Log.w(TAG, "Wrong UUID length");
@@ -316,9 +310,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
        try {
            byte[] remote = (byte[]) mPbapMethodProxy.getHeader(request, HeaderSet.WHO);
            if (remote != null) {
                if (D) {
                Log.d(TAG, "onConnect(): remote=" + Arrays.toString(remote));
                }
                reply.setHeader(HeaderSet.TARGET, remote);
            }
        } catch (IOException e) {
@@ -348,30 +340,22 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
            return ResponseCodes.OBEX_HTTP_INTERNAL_ERROR;
        }

        if (V) {
        Log.v(TAG, "onConnect(): uuid is ok, will send out " + "MSG_SESSION_ESTABLISHED msg.");
        }

        return ResponseCodes.OBEX_HTTP_OK;
    }

    @Override
    public void onDisconnect(final HeaderSet req, final HeaderSet resp) {
        if (D) {
        Log.d(TAG, "onDisconnect(): enter");
        }
        if (V) {
        logHeader(req);
        }
        notifyUpdateWakeLock();
        resp.responseCode = ResponseCodes.OBEX_HTTP_OK;
    }

    @Override
    public int onAbort(HeaderSet request, HeaderSet reply) {
        if (D) {
        Log.d(TAG, "onAbort(): enter.");
        }
        notifyUpdateWakeLock();
        sIsAborted = true;
        return ResponseCodes.OBEX_HTTP_OK;
@@ -379,18 +363,14 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {

    @Override
    public int onPut(final Operation op) {
        if (D) {
        Log.d(TAG, "onPut(): not support PUT request.");
        }
        notifyUpdateWakeLock();
        return ResponseCodes.OBEX_HTTP_BAD_REQUEST;
    }

    @Override
    public int onDelete(final HeaderSet request, final HeaderSet reply) {
        if (D) {
        Log.d(TAG, "onDelete(): not support PUT request.");
        }
        notifyUpdateWakeLock();
        return ResponseCodes.OBEX_HTTP_BAD_REQUEST;
    }
@@ -398,12 +378,8 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
    @Override
    public int onSetPath(final HeaderSet request, final HeaderSet reply, final boolean backup,
            final boolean create) {
        if (V) {
        logHeader(request);
        }
        if (D) {
        Log.d(TAG, "before setPath, mCurrentPath ==  " + mCurrentPath);
        }
        notifyUpdateWakeLock();
        String currentPathTmp = mCurrentPath;
        String tmpPath = null;
@@ -418,9 +394,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
            Log.e(TAG, "Get name header fail");
            return ResponseCodes.OBEX_HTTP_INTERNAL_ERROR;
        }
        if (D) {
        Log.d(TAG, "backup=" + backup + " create=" + create + " name=" + tmpPath);
        }

        if (backup) {
            if (currentPathTmp.length() != 0) {
@@ -458,9 +432,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
            }
        }
        mCurrentPath = currentPathTmp;
        if (V) {
        Log.v(TAG, "after setPath, mCurrentPath ==  " + mCurrentPath);
        }

        return ResponseCodes.OBEX_HTTP_OK;
    }
@@ -498,12 +470,8 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {

        /* TODO: block Get request if contacts are not completely loaded locally */

        if (V) {
        logHeader(request);
        }
        if (D) {
        Log.d(TAG, "OnGet type is " + type + "; name is " + name);
        }

        if (type == null) {
            return ResponseCodes.OBEX_HTTP_NOT_ACCEPTABLE;
@@ -535,11 +503,9 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
        boolean isSimEnabled = BluetoothPbapService.isSimEnabled();

        if (!validName || (validName && type.equals(TYPE_VCARD))) {
            if (D) {
            Log.d(
                    TAG,
                    "Guess what carkit actually want from current path (" + mCurrentPath + ")");
            }

            if (mCurrentPath.equals(PB_PATH)) {
                appParamValue.needTag = ContentType.PHONEBOOK;
@@ -582,9 +548,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
                        11);
                return ResponseCodes.OBEX_HTTP_NOT_ACCEPTABLE;
            }
            if (D) {
            Log.v(TAG, "onGet(): appParamValue.needTag=" + appParamValue.needTag);
            }
        } else {
            // we have weak name checking here to provide better
            // compatibility with other devices,although unique name such as
@@ -592,7 +556,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
            if (mVcardSimManager.isSimPhoneBook(name, type, PB, SIM1,
                TYPE_PB, TYPE_LISTING, mCurrentPath)) {
                appParamValue.needTag = ContentType.SIM_PHONEBOOK;
                if (D) Log.d(TAG, "download SIM phonebook request");
                Log.d(TAG, "download SIM phonebook request");
                if (!isSimEnabled) {
                    // Not support SIM card currently
                    Log.w(TAG, "Not support access SIM card info!");
@@ -606,47 +570,35 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
                }
            } else if (isNameMatchTarget(name, PB)) {
                appParamValue.needTag = ContentType.PHONEBOOK;
                if (D) {
                Log.v(TAG, "download phonebook request");
                }
            } else if (isNameMatchTarget(name, FAV)) {
                appParamValue.needTag = ContentType.FAVORITES;
                if (D) {
                Log.v(TAG, "download favorites request");
                }
            } else if (isNameMatchTarget(name, ICH)) {
                appParamValue.needTag = ContentType.INCOMING_CALL_HISTORY;
                appParamValue.callHistoryVersionCounter =
                        mVcardManager.getCallHistoryPrimaryFolderVersion(
                                ContentType.INCOMING_CALL_HISTORY);
                if (D) {
                Log.v(TAG, "download incoming calls request");
                }
            } else if (isNameMatchTarget(name, OCH)) {
                appParamValue.needTag = ContentType.OUTGOING_CALL_HISTORY;
                appParamValue.callHistoryVersionCounter =
                        mVcardManager.getCallHistoryPrimaryFolderVersion(
                                ContentType.OUTGOING_CALL_HISTORY);
                if (D) {
                Log.v(TAG, "download outgoing calls request");
                }
            } else if (isNameMatchTarget(name, MCH)) {
                appParamValue.needTag = ContentType.MISSED_CALL_HISTORY;
                appParamValue.callHistoryVersionCounter =
                        mVcardManager.getCallHistoryPrimaryFolderVersion(
                                ContentType.MISSED_CALL_HISTORY);
                mNeedNewMissedCallsNum = true;
                if (D) {
                Log.v(TAG, "download missed calls request");
                }
            } else if (isNameMatchTarget(name, CCH)) {
                appParamValue.needTag = ContentType.COMBINED_CALL_HISTORY;
                appParamValue.callHistoryVersionCounter =
                        mVcardManager.getCallHistoryPrimaryFolderVersion(
                                ContentType.COMBINED_CALL_HISTORY);
                if (D) {
                Log.v(TAG, "download combined calls request");
                }
            } else {
                Log.w(TAG, "Input name doesn't contain valid info!!!");
                ContentProfileErrorReportUtils.report(
@@ -769,11 +721,13 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
            supportedFeature = new byte[]{0x00, 0x00, 0x00, 0x00};
        }

        public void dump() {
            Log.i(TAG, "maxListCount=" + maxListCount + " listStartOffset=" + listStartOffset
                    + " searchValue=" + searchValue + " searchAttr=" + searchAttr + " needTag="
                    + needTag + " vcard21=" + vcard21 + " order=" + order + "vcardselector="
                    + Arrays.toString(vCardSelector) + "vcardselop=" + vCardSelectorOperator);
        @Override
        public String toString() {
            return "AppParamValue<maxListCount=" + maxListCount + " listStartOffset="
                    + listStartOffset + " searchValue=" + searchValue + " searchAttr=" + searchAttr
                    + " needTag=" + needTag + " vcard21=" + vcard21 + " order=" + order
                    + "vcardselector=" + Arrays.toString(vCardSelector) + "vcardselop="
                    + vCardSelectorOperator + ">";
        }
    }

@@ -891,10 +845,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
            }
        }

        if (D) {
            appParamValue.dump();
        }

        Log.d(TAG, "ParseApplicationParameter: params=" + appParamValue);
        return parseOk;
    }

@@ -941,10 +892,8 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
            if (endPoint > nameList.size()) {
                endPoint = nameList.size();
            }
            if (D) {
            Log.d(TAG, "call log list, size=" + requestSize + " offset="
                    + appParamValue.listStartOffset);
            }

            for (int j = startPoint; j < endPoint; j++) {
                writeVCardEntry(j + 1, nameList.get(j), result);
@@ -952,9 +901,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
        }
        result.append("</vCard-listing>");

        if (D) {
        Log.d(TAG, "itemsFound =" + itemsFound);
        }

        return pushBytes(op, result.toString());
    }
@@ -986,10 +933,8 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
        final int listSize = nameList.size();
        String compareValue = "", currentValue;

        if (D) {
        Log.d(TAG, "search by " + type + ", requestSize=" + requestSize + " offset="
                + appParamValue.listStartOffset + " searchValue=" + appParamValue.searchValue);
        }

        if (type.equals("number")) {
            ArrayList<Integer> savedPosList = new ArrayList<>();
@@ -1004,12 +949,10 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
            if (mOrderBy == ORDER_BY_ALPHABETICAL) Collections.sort(names);
            for (int i = 0; i < names.size(); i++) {
                compareValue = names.get(i).trim();
                if (D) Log.d(TAG, "compareValue=" + compareValue);
                Log.d(TAG, "compareValue=" + compareValue);
                for (int pos = 0; pos < listSize; pos++) {
                    currentValue = nameList.get(pos);
                    if (V) {
                        Log.d(TAG, "currentValue=" + currentValue);
                    }
                    Log.v(TAG, "currentValue=" + currentValue);
                    if (currentValue.equals(compareValue)) {
                        if (currentValue.contains(",")) {
                            currentValue = currentValue.substring(0, currentValue.lastIndexOf(','));
@@ -1067,12 +1010,8 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
    static int pushHeader(final Operation op, final HeaderSet reply) {
        OutputStream outputStream = null;

        if (D) {
        Log.d(TAG, "Push Header");
        }
        if (D) {
        Log.d(TAG, reply.toString());
        }

        int pushResult = ResponseCodes.OBEX_HTTP_OK;
        try {
@@ -1107,9 +1046,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
        try {
            outputStream = op.openOutputStream();
            outputStream.write(vcardString.getBytes());
            if (V) {
            Log.v(TAG, "Send Data complete!");
            }
        } catch (IOException e) {
            ContentProfileErrorReportUtils.report(
                    BluetoothProfile.PBAP,
@@ -1146,9 +1083,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
        // In such case, PCE only want the number of index.
        // So response not contain any Body header.
        if (mNeedPhonebookSize) {
            if (D) {
            Log.d(TAG, "Need Phonebook size in response header.");
            }
            mNeedPhonebookSize = false;

            byte[] pbsize = new byte[2];
@@ -1178,11 +1113,9 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
                misnum[0] = (byte) nmnum;
                ap.addTriplet(ApplicationParameter.TRIPLET_TAGID.NEWMISSEDCALLS_TAGID,
                        ApplicationParameter.TRIPLET_LENGTH.NEWMISSEDCALLS_LENGTH, misnum);
                if (D) {
                Log.d(TAG, "handleAppParaForResponse(): mNeedNewMissedCallsNum=true,  num= "
                        + nmnum);
            }
            }

            if (checkPbapFeatureSupport(mDatabaseIdentifierBitMask)) {
                setDbCounters(ap);
@@ -1195,9 +1128,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
            }
            reply.setHeader(HeaderSet.APPLICATION_PARAMETER, ap.getHeader());

            if (D) {
            Log.d(TAG, "Send back Phonebook size only, without body info! Size= " + size);
            }

            return pushHeader(op, reply);
        }
@@ -1206,9 +1137,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
        // NewMissedCalls is used only in the response, together with Body
        // header.
        if (mNeedNewMissedCallsNum) {
            if (D) {
            Log.d(TAG, "Need new missed call num in response header.");
            }
            mNeedNewMissedCallsNum = false;
            int nmnum = 0;
            ContentResolver contentResolver;
@@ -1226,18 +1155,14 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {

            nmnum = nmnum > 0 ? nmnum : 0;
            misnum[0] = (byte) nmnum;
            if (D) {
            Log.d(TAG,
                    "handleAppParaForResponse(): mNeedNewMissedCallsNum=true,  num= " + nmnum);
            }

            ap.addTriplet(ApplicationParameter.TRIPLET_TAGID.NEWMISSEDCALLS_TAGID,
                    ApplicationParameter.TRIPLET_LENGTH.NEWMISSEDCALLS_LENGTH, misnum);
            reply.setHeader(HeaderSet.APPLICATION_PARAMETER, ap.getHeader());
            if (D) {
            Log.d(TAG,
                    "handleAppParaForResponse(): mNeedNewMissedCallsNum=true,  num= " + nmnum);
            }

            // Only Specifies the headers, not write for now, will write to PCE
            // together with Body
@@ -1312,9 +1237,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
        if (searchAttr == null || searchAttr.length() == 0) {
            // If searchAttr is not set by PCE, set default value per spec.
            appParamValue.searchAttr = "0";
            if (D) {
            Log.d(TAG, "searchAttr is not set by PCE, assume search by name by default");
            }
        } else if (!searchAttr.equals("0") && !searchAttr.equals("1")) {
            Log.w(TAG, "search attr not supported");
            if (searchAttr.equals("2")) {
@@ -1340,9 +1263,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
        }

        if (size == 0) {
            if (D) {
            Log.d(TAG, "PhonebookSize is 0, return.");
            }
            return ResponseCodes.OBEX_HTTP_OK;
        }

@@ -1350,14 +1271,10 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
        if (TextUtils.isEmpty(orderPara)) {
            // If order parameter is not set by PCE, set default value per spec.
            orderPara = "0";
            if (D) {
            Log.d(TAG, "Order parameter is not set by PCE. "
                    + "Assume order by 'Indexed' by default");
            }
        } else if (!orderPara.equals("0") && !orderPara.equals("1")) {
            if (D) {
            Log.d(TAG, "Order parameter is not supported: " + appParamValue.order);
            }
            if (orderPara.equals("2")) {
                // Order by sound is not supported currently
                Log.w(TAG, "Do not support order by sound");
@@ -1385,9 +1302,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
    private int pullVcardEntry(
            AppParamValue appParamValue, Operation op, HeaderSet reply, final String name) {
        if (name == null || name.length() < VCARD_NAME_SUFFIX_LENGTH) {
            if (D) {
            Log.d(TAG, "Name is Null, or the length of name < 5 !");
            }
            return ResponseCodes.OBEX_HTTP_NOT_ACCEPTABLE;
        }
        String strIndex = name.substring(0, name.length() - VCARD_NAME_SUFFIX_LENGTH + 1);
@@ -1409,9 +1324,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
        int size = mVcardManager.getPhonebookSize(appParamValue.needTag, mVcardSimManager);
        int needSendBody = handleAppParaForResponse(appParamValue, size, reply, op, name);
        if (size == 0) {
            if (D) {
            Log.d(TAG, "PhonebookSize is 0, return.");
            }
            return ResponseCodes.OBEX_HTTP_NOT_FOUND;
        }

@@ -1517,9 +1430,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
        }

        if (pbSize == 0) {
            if (D) {
            Log.d(TAG, "PhonebookSize is 0, return.");
            }
            return ResponseCodes.OBEX_HTTP_OK;
        }

@@ -1563,10 +1474,8 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
            }
        }

        if (D) {
        Log.d(TAG, "pullPhonebook(): requestSize=" + requestSize + " startPoint=" + startPoint
                + " endPoint=" + endPoint);
        }

        boolean vcard21 = appParamValue.vcard21;
        boolean favorites =
@@ -1667,9 +1576,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
            default:
                break;
        }
        if (V) {
        Log.v(TAG, "Call log selection: " + selection);
        }
        return selection;
    }

+22 −63
Original line number Diff line number Diff line
@@ -81,9 +81,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
     * DEBUG log: "setprop log.tag.BluetoothPbapService VERBOSE"
     */

    public static final boolean DEBUG = true;

    public static final boolean VERBOSE = Log.isLoggable(TAG, Log.VERBOSE);

    /**
     * The component name of the owned BluetoothPbapActivity
@@ -223,9 +221,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect

    private void parseIntent(final Intent intent) {
        String action = intent.getAction();
        if (DEBUG) {
        Log.d(TAG, "action: " + action);
        }
        if (BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY.equals(action)) {
            int requestType = intent.getIntExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE,
                    BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS);
@@ -255,18 +251,14 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
                if (access == BluetoothDevice.CONNECTION_ACCESS_YES) {
                    if (savePreference) {
                        device.setPhonebookAccessPermission(BluetoothDevice.ACCESS_ALLOWED);
                        if (VERBOSE) {
                        Log.v(TAG, "setPhonebookAccessPermission(ACCESS_ALLOWED)");
                    }
                    }
                    sm.sendMessage(PbapStateMachine.AUTHORIZED);
                } else {
                    if (savePreference) {
                        device.setPhonebookAccessPermission(BluetoothDevice.ACCESS_REJECTED);
                        if (VERBOSE) {
                        Log.v(TAG, "setPhonebookAccessPermission(ACCESS_REJECTED)");
                    }
                    }
                    sm.sendMessage(PbapStateMachine.REJECTED);
                }
            }
@@ -347,9 +339,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
    };

    private void closeService() {
        if (VERBOSE) {
        Log.v(TAG, "Pbap Service closeService");
        }

        BluetoothPbapUtils.savePbapParams(this);

@@ -405,10 +395,8 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
                                pbapSupportedRepositories,
                                SDP_PBAP_SUPPORTED_FEATURES);

        if (DEBUG) {
        Log.d(TAG, "created Sdp record, mSdpHandle=" + mSdpHandle);
    }
    }

    private void cleanUpSdpRecord() {
        if (mSdpHandle < 0) {
@@ -418,9 +406,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
        int sdpHandle = mSdpHandle;
        mSdpHandle = -1;
        SdpManagerNativeInterface nativeInterface = SdpManagerNativeInterface.getInstance();
        if (DEBUG) {
        Log.d(TAG, "cleanUpSdpRecord, mSdpHandle=" + sdpHandle);
        }
        if (!nativeInterface.isAvailable()) {
            Log.e(TAG, "SdpManagerNativeInterface is not available");
            ContentProfileErrorReportUtils.report(
@@ -440,7 +426,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect

    /*Creates Notification for PBAP version upgrade */
    protected static void createNotification(BluetoothPbapService context) {
        if (VERBOSE) Log.v(TAG, "Create PBAP Notification for Upgrade");
        Log.v(TAG, "Create PBAP Notification for Upgrade");
        // create Notification channel.
        sNotificationManager = context.getSystemService(NotificationManager.class);
        if (sNotificationManager != null) {
@@ -501,9 +487,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect

        @Override
        public void handleMessage(Message msg) {
            if (VERBOSE) {
            Log.v(TAG, "Handler(): got msg=" + msg.what);
            }

            switch (msg.what) {
                case START_LISTENER:
@@ -660,9 +644,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
    public boolean setConnectionPolicy(BluetoothDevice device, int connectionPolicy) {
        enforceCallingOrSelfPermission(
                BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission");
        if (DEBUG) {
        Log.d(TAG, "Saved connectionPolicy " + device + " = " + connectionPolicy);
        }

        if (!mDatabaseManager.setProfileConnectionPolicy(device, BluetoothProfile.PBAP,
                  connectionPolicy)) {
@@ -726,9 +708,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect

    @Override
    public void start() {
        if (VERBOSE) {
        Log.v(TAG, "start()");
        }
        mDatabaseManager = Objects.requireNonNull(AdapterService.getAdapterService().getDatabase(),
            "DatabaseManager cannot be null when PbapService starts");

@@ -792,9 +772,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect

    @Override
    public void stop() {
        if (VERBOSE) {
        Log.v(TAG, "stop()");
        }
        setBluetoothPbapService(null);
        if (mSessionStatusHandler != null) {
            mSessionStatusHandler.obtainMessage(SHUTDOWN).sendToTarget();
@@ -836,9 +814,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
    }

    private static synchronized void setBluetoothPbapService(BluetoothPbapService instance) {
        if (DEBUG) {
        Log.d(TAG, "setBluetoothPbapService(): set to: " + instance);
        }
        sBluetoothPbapService = instance;
    }

@@ -860,9 +836,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
        }

        PbapBinder(BluetoothPbapService service) {
            if (VERBOSE) {
            Log.v(TAG, "PbapBinder()");
            }
            mService = service;
        }

@@ -873,9 +847,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect

        @Override
        public List<BluetoothDevice> getConnectedDevices(AttributionSource source) {
            if (DEBUG) {
            Log.d(TAG, "getConnectedDevices");
            }
            BluetoothPbapService service = getService(source);
            if (service == null) {
                return Collections.emptyList();
@@ -886,9 +858,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
        @Override
        public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states,
                AttributionSource source) {
            if (DEBUG) {
            Log.d(TAG, "getDevicesMatchingConnectionStates");
            }
            BluetoothPbapService service = getService(source);
            if (service == null) {
                return Collections.emptyList();
@@ -898,9 +868,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect

        @Override
        public int getConnectionState(BluetoothDevice device, AttributionSource source) {
            if (DEBUG) {
            Log.d(TAG, "getConnectionState: " + device);
            }
            BluetoothPbapService service = getService(source);
            if (service == null) {
                return BluetoothAdapter.STATE_DISCONNECTED;
@@ -911,10 +879,8 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
        @Override
        public boolean setConnectionPolicy(BluetoothDevice device, int connectionPolicy,
                AttributionSource source) {
            if (DEBUG) {
            Log.d(TAG, "setConnectionPolicy for device: " + device + ", policy:"
                    + connectionPolicy);
            }
            BluetoothPbapService service = getService(source);
            if (service == null) {
                return false;
@@ -924,9 +890,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect

        @Override
        public void disconnect(BluetoothDevice device, AttributionSource source) {
            if (DEBUG) {
            Log.d(TAG, "disconnect");
            }
            BluetoothPbapService service = getService(source);
            if (service == null) {
                return;
@@ -972,9 +936,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
    public void checkOrGetPhonebookPermission(PbapStateMachine stateMachine) {
        BluetoothDevice device = stateMachine.getRemoteDevice();
        int permission = device.getPhonebookAccessPermission();
        if (DEBUG) {
        Log.d(TAG, "getPhonebookAccessPermission() = " + permission);
        }

        if (permission == BluetoothDevice.ACCESS_ALLOWED) {
            setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
@@ -993,9 +955,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
                    Utils.getTempAllowlistBroadcastOptions(), null/* resultReceiver */,
                    null/* scheduler */, Activity.RESULT_OK/* initialCode */, null/* initialData */,
                    null/* initialExtras */);
            if (VERBOSE) {
            Log.v(TAG, "waiting for authorization for connection from: " + device);
            }
            /* In case car kit time out and try to use HFP for phonebook
             * access, while UI still there waiting for user to confirm */
            Message msg = mSessionStatusHandler.obtainMessage(BluetoothPbapService.USER_TIMEOUT,
@@ -1075,7 +1035,6 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect
            sLocalPhoneNum = tm.getLine1Number();
            sLocalPhoneName = this.getString(R.string.localPhoneName);
        }
        if (VERBOSE)
        Log.v(TAG, "Local Phone Details- Number:" + sLocalPhoneNum
                    + ", Name:" + sLocalPhoneName);
    }
+8 −9

File changed.

Preview size limit exceeded, changes collapsed.

+8 −23

File changed.

Preview size limit exceeded, changes collapsed.

Loading