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

Commit 2b97edec authored by Hyundo Moon's avatar Hyundo Moon
Browse files

Metrics: Log error metrics for PBAP

Bug: 317002318
Bug: 294797589
Test: m -j;
Change-Id: I7bea5d19232c8e763034ff3aab75627075244dc7
parent 49bd10b6
Loading
Loading
Loading
Loading
+26 −31
Original line number Diff line number Diff line
/*
 * Copyright (c) 2008-2009, Motorola, Inc.
 * Copyright (C) 2024 The Android Open Source Project
 *
 * All rights reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * - Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 *
 * - Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * - Neither the name of the Motorola, Inc. nor the names of its contributors
 * may be used to endorse or promote products derived from this software
 * without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.bluetooth.pbap;
@@ -36,6 +20,8 @@ import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTE

import android.bluetooth.AlertActivity;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothProtoEnums;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
@@ -54,14 +40,16 @@ import android.widget.EditText;
import android.widget.TextView;

import com.android.bluetooth.BluetoothMethodProxy;
import com.android.bluetooth.BluetoothStatsLog;
import com.android.bluetooth.R;
import com.android.bluetooth.content_profiles.ContentProfileErrorReportUtils;
import com.android.internal.annotations.VisibleForTesting;

/**
 * PbapActivity shows two dialogues: One for accepting incoming pbap request and
 * the other prompts the user to enter a session key for authentication with a
 * remote Bluetooth device.
 * PbapActivity shows two dialogues: One for accepting incoming pbap request and the other prompts
 * the user to enter a session key for authentication with a remote Bluetooth device.
 */
// Next tag value for ContentProfileErrorReportUtils.report(): 1
public class BluetoothPbapActivity extends AlertActivity
        implements Preference.OnPreferenceChangeListener, TextWatcher {
    private static final String TAG = "BluetoothPbapActivity";
@@ -117,8 +105,15 @@ public class BluetoothPbapActivity extends AlertActivity
            showPbapDialog(DIALOG_YES_NO_AUTH);
            mCurrentDialog = DIALOG_YES_NO_AUTH;
        } else {
            Log.e(TAG, "Error: this activity may be started only with intent "
            Log.e(
                    TAG,
                    "Error: this activity may be started only with intent "
                            + "PBAP_ACCESS_REQUEST or PBAP_AUTH_CHALL ");
            ContentProfileErrorReportUtils.report(
                    BluetoothProfile.PBAP,
                    BluetoothProtoEnums.BLUETOOTH_PBAP_ACTIVITY,
                    BluetoothStatsLog.BLUETOOTH_CONTENT_PROFILE_ERROR_REPORTED__TYPE__LOG_ERROR,
                    0);
            finish();
        }
        IntentFilter filter = new IntentFilter(BluetoothPbapService.USER_CONFIRM_TIMEOUT_ACTION);
+22 −28
Original line number Diff line number Diff line
/*
 * Copyright (c) 2008-2009, Motorola, Inc.
 * Copyright (C) 2024 The Android Open Source Project
 *
 * All rights reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * - Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 *
 * - Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * - Neither the name of the Motorola, Inc. nor the names of its contributors
 * may be used to endorse or promote products derived from this software
 * without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.bluetooth.pbap;

import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothProtoEnums;
import android.util.Log;

import com.android.bluetooth.BluetoothStatsLog;
import com.android.bluetooth.content_profiles.ContentProfileErrorReportUtils;
import com.android.internal.annotations.VisibleForTesting;
import com.android.obex.Authenticator;
import com.android.obex.PasswordAuthentication;

/**
 * BluetoothPbapAuthenticator is a used by BluetoothObexServer for obex
 * authentication procedure.
 * BluetoothPbapAuthenticator is a used by BluetoothObexServer for obex authentication procedure.
 */
// Next tag value for ContentProfileErrorReportUtils.report(): 1
public class BluetoothPbapAuthenticator implements Authenticator {
    private static final String TAG = "PbapAuthenticator";

@@ -80,6 +68,12 @@ public class BluetoothPbapAuthenticator implements Authenticator {
                try {
                    wait();
                } catch (InterruptedException e) {
                    ContentProfileErrorReportUtils.report(
                            BluetoothProfile.PBAP,
                            BluetoothProtoEnums.BLUETOOTH_PBAP_AUTHENTICATOR,
                            BluetoothStatsLog
                                    .BLUETOOTH_CONTENT_PROFILE_ERROR_REPORTED__TYPE__EXCEPTION,
                            0);
                    Log.e(TAG, "Interrupted while waiting on isChallenged or AuthCancelled");
                }
            }
+26 −4
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package com.android.bluetooth.pbap;

import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothProtoEnums;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteException;
@@ -25,7 +27,9 @@ import android.text.TextUtils;
import android.util.Log;

import com.android.bluetooth.BluetoothMethodProxy;
import com.android.bluetooth.BluetoothStatsLog;
import com.android.bluetooth.R;
import com.android.bluetooth.content_profiles.ContentProfileErrorReportUtils;
import com.android.internal.annotations.VisibleForTesting;
import com.android.vcard.VCardBuilder;
import com.android.vcard.VCardConfig;
@@ -36,9 +40,8 @@ import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;

/**
 * VCard composer especially for Call Log used in Bluetooth.
 */
/** VCard composer especially for Call Log used in Bluetooth. */
// Next tag value for ContentProfileErrorReportUtils.report(): 3
public class BluetoothPbapCallLogComposer {
    private static final String TAG = "PbapCallLogComposer";

@@ -121,6 +124,11 @@ public class BluetoothPbapCallLogComposer {
            try {
                mCursor.close();
            } catch (SQLiteException e) {
                ContentProfileErrorReportUtils.report(
                        BluetoothProfile.PBAP,
                        BluetoothProtoEnums.BLUETOOTH_PBAP_CALL_LOG_COMPOSER,
                        BluetoothStatsLog.BLUETOOTH_CONTENT_PROFILE_ERROR_REPORTED__TYPE__EXCEPTION,
                        0);
                Log.e(TAG, "SQLiteException on Cursor#close(): " + e.getMessage());
            } finally {
                mErrorReason = FAILURE_REASON_NO_ENTRY;
@@ -243,12 +251,20 @@ public class BluetoothPbapCallLogComposer {
            }
            default: {
                Log.w(TAG, "Call log type not correct.");
                ContentProfileErrorReportUtils.report(
                        BluetoothProfile.PBAP,
                        BluetoothProtoEnums.BLUETOOTH_PBAP_CALL_LOG_COMPOSER,
                        BluetoothStatsLog
                                .BLUETOOTH_CONTENT_PROFILE_ERROR_REPORTED__TYPE__LOG_WARN,
                        1);
                return;
            }
        }

        final long dateAsLong = mCursor.getLong(DATE_COLUMN_INDEX);
        builder.appendLine(VCARD_PROPERTY_X_TIMESTAMP, Arrays.asList(callLogTypeStr),
        builder.appendLine(
                VCARD_PROPERTY_X_TIMESTAMP,
                Arrays.asList(callLogTypeStr),
                toRfc2455Format(dateAsLong));
    }

@@ -257,6 +273,12 @@ public class BluetoothPbapCallLogComposer {
            try {
                mCursor.close();
            } catch (SQLiteException e) {
                ContentProfileErrorReportUtils.report(
                        BluetoothProfile.PBAP,
                        BluetoothProtoEnums.BLUETOOTH_PBAP_CALL_LOG_COMPOSER,
                        BluetoothStatsLog.BLUETOOTH_CONTENT_PROFILE_ERROR_REPORTED__TYPE__EXCEPTION,
                        2);

                Log.e(TAG, "SQLiteException on Cursor#close(): " + e.getMessage());
            }
            mCursor = null;
+28 −14
Original line number Diff line number Diff line
/************************************************************************************
 *
 *  Copyright (C) 2009-2012 Broadcom Corporation
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -13,17 +12,21 @@
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ************************************************************************************/
 */
package com.android.bluetooth.pbap;

import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothProtoEnums;
import android.content.Context;
import android.content.res.Resources;
import android.util.Log;

import com.android.bluetooth.BluetoothStatsLog;
import com.android.bluetooth.R;
import com.android.bluetooth.content_profiles.ContentProfileErrorReportUtils;
import com.android.internal.annotations.VisibleForTesting;

// Next tag value for ContentProfileErrorReportUtils.report(): 2
public class BluetoothPbapConfig {
    private static boolean sUseProfileForOwnerVcard = true;
    private static boolean sIncludePhotosInVcard = false;
@@ -34,11 +37,22 @@ public class BluetoothPbapConfig {
            try {
                sUseProfileForOwnerVcard = r.getBoolean(R.bool.pbap_use_profile_for_owner_vcard);
            } catch (Exception e) {
                ContentProfileErrorReportUtils.report(
                        BluetoothProfile.PBAP,
                        BluetoothProtoEnums.BLUETOOTH_PBAP_CONFIG,
                        BluetoothStatsLog.BLUETOOTH_CONTENT_PROFILE_ERROR_REPORTED__TYPE__EXCEPTION,
                        0);

                Log.e("BluetoothPbapConfig", "", e);
            }
            try {
                sIncludePhotosInVcard = r.getBoolean(R.bool.pbap_include_photos_in_vcard);
            } catch (Exception e) {
                ContentProfileErrorReportUtils.report(
                        BluetoothProfile.PBAP,
                        BluetoothProtoEnums.BLUETOOTH_PBAP_CONFIG,
                        BluetoothStatsLog.BLUETOOTH_CONTENT_PROFILE_ERROR_REPORTED__TYPE__EXCEPTION,
                        1);
                Log.e("BluetoothPbapConfig", "", e);
            }
        }
+205 −35

File changed.

Preview size limit exceeded, changes collapsed.

Loading