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

Commit 3ca44187 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Refactor OPP logging to be unguarded" into main

parents e433300a e60845e0
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -60,7 +60,6 @@ import java.util.ArrayList;

public class BluetoothOppBatch {
    private static final String TAG = "BtOppBatch";
    private static final boolean V = Constants.VERBOSE;

    public int mId;
    public int mStatus;
@@ -111,10 +110,8 @@ public class BluetoothOppBatch {
        mStatus = Constants.BATCH_STATUS_PENDING;
        mShares.add(info);

        if (V) {
        Log.v(TAG, "New Batch created for info " + info.mId);
    }
    }

    /**
     * Add one share into the batch.
@@ -137,9 +134,7 @@ public class BluetoothOppBatch {
     * 3) update ContentProvider for these canceled transfer
     */
    public void cancelBatch() {
        if (V) {
        Log.v(TAG, "batch " + this.mId + " is canceled");
        }

        if (mListener != null) {
            mListener.onBatchCanceled();
@@ -154,9 +149,7 @@ public class BluetoothOppBatch {
                            mContext.getContentResolver(), info.mUri, null, null
                    );
                }
                if (V) {
                Log.v(TAG, "Cancel batch for info " + info.mId);
                }

                Constants.updateShareStatus(mContext, info.mId, BluetoothShare.STATUS_CANCELED);
            }
+3 −11
Original line number Diff line number Diff line
@@ -58,9 +58,7 @@ import com.android.internal.annotations.VisibleForTesting;
public class BluetoothOppBtEnablingActivity extends AlertActivity {
    private static final String TAG = "BluetoothOppEnablingActivity";

    private static final boolean D = Constants.DEBUG;

    private static final boolean V = Constants.VERBOSE;

    private static final int BT_ENABLING_TIMEOUT = 0;

@@ -106,9 +104,7 @@ public class BluetoothOppBtEnablingActivity extends AlertActivity {
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            if (D) {
            Log.d(TAG, "onKeyDown() called; Key: back key");
            }
            mTimeoutHandler.removeMessages(BT_ENABLING_TIMEOUT);
            cancelSendingProgress();
        }
@@ -129,9 +125,7 @@ public class BluetoothOppBtEnablingActivity extends AlertActivity {
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case BT_ENABLING_TIMEOUT:
                    if (V) {
                    Log.v(TAG, "Received BT_ENABLING_TIMEOUT msg.");
                    }
                    cancelSendingProgress();
                    break;
                default:
@@ -145,9 +139,7 @@ public class BluetoothOppBtEnablingActivity extends AlertActivity {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (V) {
            Log.v(TAG, "Received intent: " + action);
            }
            if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
                switch (intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR)) {
                    case BluetoothAdapter.STATE_ON:
+6 −17
Original line number Diff line number Diff line
@@ -31,21 +31,18 @@ import java.util.ArrayList;

public class BluetoothOppHandoverReceiver extends BroadcastReceiver {
    public static final String TAG = "BluetoothOppHandoverReceiver";
    private static final boolean D = Constants.DEBUG;

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (D) Log.d(TAG, "Action :" + action);
        Log.d(TAG, "Action :" + action);
        if (action == null) return;
        if (action.equals(Constants.ACTION_HANDOVER_SEND) || action.equals(
                Constants.ACTION_HANDOVER_SEND_MULTIPLE)) {
            final BluetoothDevice device =
                    (BluetoothDevice) intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
            if (device == null) {
                if (D) {
                Log.d(TAG, "No device attached to handover intent.");
                }
                return;
            }

@@ -74,9 +71,7 @@ public class BluetoothOppHandoverReceiver extends BroadcastReceiver {
                });
                t.start();
            } else {
                if (D) {
                Log.d(TAG, "No mimeType or stream attached to handover request");
                }
                return;
            }
        } else if (action.equals(Constants.ACTION_ACCEPTLIST_DEVICE)) {
@@ -89,26 +84,20 @@ public class BluetoothOppHandoverReceiver extends BroadcastReceiver {
                    Flags.identityAddressNullIfUnknown()
                            ? Utils.getBrEdrAddress(device)
                            : device.getIdentityAddress();
            if (D) {
            Log.d(TAG, "Adding " + brEdrAddress + " to acceptlist");
            }
            BluetoothOppManager.getInstance(context).addToAcceptlist(brEdrAddress);
        } else if (action.equals(Constants.ACTION_STOP_HANDOVER)) {
            int id = intent.getIntExtra(Constants.EXTRA_BT_OPP_TRANSFER_ID, -1);
            if (id != -1) {
                Uri contentUri = Uri.parse(BluetoothShare.CONTENT_URI + "/" + id);

                if (D) {
                Log.d(TAG, "Stopping handover transfer with Uri " + contentUri);
                }
                BluetoothMethodProxy.getInstance().contentResolverDelete(
                        context.getContentResolver(), contentUri, null, null);
            }
        } else {
            if (D) {
            Log.d(TAG, "Unknown action: " + action);
        }
    }
    }

}
+8 −26
Original line number Diff line number Diff line
@@ -64,8 +64,6 @@ import com.android.internal.annotations.VisibleForTesting;
// Next tag value for ContentProfileErrorReportUtils.report(): 1
public class BluetoothOppIncomingFileConfirmActivity extends AlertActivity {
    private static final String TAG = "BluetoothIncomingFileConfirmActivity";
    private static final boolean D = Constants.DEBUG;
    private static final boolean V = Constants.VERBOSE;

    @VisibleForTesting
    static final int DISMISS_TIMEOUT_DIALOG = 0;
@@ -88,9 +86,7 @@ public class BluetoothOppIncomingFileConfirmActivity extends AlertActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setTheme(R.style.Theme_Material_Settings_Floating);
        if (V) {
            Log.d(TAG, "onCreate(): action = " + getIntent().getAction());
        }
        Log.v(TAG, "onCreate(): action = " + getIntent().getAction());
        super.onCreate(savedInstanceState);

        getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
@@ -99,9 +95,7 @@ public class BluetoothOppIncomingFileConfirmActivity extends AlertActivity {
        mTransInfo = new BluetoothOppTransferInfo();
        mTransInfo = BluetoothOppUtility.queryRecord(this, mUri);
        if (mTransInfo == null) {
            if (V) {
                Log.e(TAG, "Error: Can not get data from db");
            }
            Log.w(TAG, "Error: Can not get data from db");
            ContentProfileErrorReportUtils.report(
                    BluetoothProfile.OPP,
                    BluetoothProtoEnums.BLUETOOTH_OPP_INCOMING_FILE_CONFIRM_ACTIVITY,
@@ -119,16 +113,12 @@ public class BluetoothOppIncomingFileConfirmActivity extends AlertActivity {
                (dialog, which) -> onIncomingFileConfirmCancel());

        setupAlert();
        if (V) {
        Log.v(TAG, "mTimeout: " + mTimeout);
        }
        if (mTimeout) {
            onTimeout();
        }

        if (V) {
        Log.v(TAG, "BluetoothIncomingFileConfirmActivity: Got uri:" + mUri);
        }

        mReceiver = new BroadcastReceiver() {
            @Override
@@ -187,9 +177,7 @@ public class BluetoothOppIncomingFileConfirmActivity extends AlertActivity {
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            if (D) {
            Log.d(TAG, "onKeyDown() called; Key: back key");
            }
            finish();
            return true;
        }
@@ -208,9 +196,7 @@ public class BluetoothOppIncomingFileConfirmActivity extends AlertActivity {
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        mTimeout = savedInstanceState.getBoolean(PREFERENCE_USER_TIMEOUT);
        if (V) {
        Log.v(TAG, "onRestoreInstanceState() mTimeout: " + mTimeout);
        }
        if (mTimeout) {
            onTimeout();
        }
@@ -219,9 +205,7 @@ public class BluetoothOppIncomingFileConfirmActivity extends AlertActivity {
    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        if (V) {
        Log.v(TAG, "onSaveInstanceState() mTimeout: " + mTimeout);
        }
        outState.putBoolean(PREFERENCE_USER_TIMEOUT, mTimeout);
    }

@@ -245,9 +229,7 @@ public class BluetoothOppIncomingFileConfirmActivity 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:
+12 −30
Original line number Diff line number Diff line
@@ -71,8 +71,6 @@ import java.util.regex.Pattern;
// Next tag value for ContentProfileErrorReportUtils.report(): 11
public class BluetoothOppLauncherActivity extends Activity {
    private static final String TAG = "BluetoothOppLauncherActivity";
    private static final boolean D = Constants.DEBUG;
    private static final boolean V = Constants.VERBOSE;

    // Regex that matches characters that have special meaning in HTML. '<', '>', '&' and
    // multiple continuous spaces.
@@ -124,10 +122,8 @@ public class BluetoothOppLauncherActivity extends Activity {
                // EXTRA_TEXT, we will try send this TEXT out; Currently in
                // Browser, share one link goes to this case;
                if (stream != null && type != null) {
                    if (V) {
                    Log.v(TAG,
                            "Get ACTION_SEND intent: Uri = " + stream + "; mimetype = " + type);
                    }
                    // Save type/stream, will be used when adding transfer
                    // session to DB.
                    Thread t = new Thread(new Runnable() {
@@ -140,11 +136,9 @@ public class BluetoothOppLauncherActivity extends Activity {
                    t.start();
                    return;
                } else if (extraText != null && type != null) {
                    if (V) {
                    Log.v(TAG,
                            "Get ACTION_SEND intent with Extra_text = " + extraText.toString()
                                    + "; mimetype = " + type);
                    }
                    final Uri fileUri = createFileForSharedContent(
                            this.createCredentialProtectedStorageContext(), extraText);
                    if (fileUri != null) {
@@ -183,10 +177,8 @@ public class BluetoothOppLauncherActivity extends Activity {
                final String mimeType = intent.getType();
                final ArrayList<Uri> uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
                if (mimeType != null && uris != null) {
                    if (V) {
                    Log.v(TAG, "Get ACTION_SHARE_MULTIPLE intent: uris " + uris + "\n Type= "
                            + mimeType);
                    }
                    Thread t =
                            new Thread(
                                    new Runnable() {
@@ -233,9 +225,7 @@ public class BluetoothOppLauncherActivity extends Activity {
            }
        } else if (action.equals(Constants.ACTION_OPEN)) {
            Uri uri = getIntent().getData();
            if (V) {
            Log.v(TAG, "Get ACTION_OPEN intent: Uri = " + uri);
            }
            Intent intent1 = new Intent(Constants.ACTION_OPEN);
            intent1.setClassName(this, BluetoothOppReceiver.class.getName());
            intent1.setDataAndNormalize(uri);
@@ -265,16 +255,12 @@ public class BluetoothOppLauncherActivity extends Activity {
        // directly,
        // and let DevicePickerActivity to handle Bluetooth Enable.
        if (!BluetoothOppManager.getInstance(this).isEnabled()) {
            if (V) {
            Log.v(TAG, "Prepare Enable BT!! ");
            }
            Intent in = new Intent(this, BluetoothOppBtEnableActivity.class);
            in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(in);
        } else {
            if (V) {
            Log.v(TAG, "BT already enabled!! ");
            }
            Intent in1 = new Intent(BluetoothDevicePicker.ACTION_LAUNCH);
            in1.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
            in1.putExtra(BluetoothDevicePicker.EXTRA_NEED_AUTH, false);
@@ -283,9 +269,7 @@ public class BluetoothOppLauncherActivity extends Activity {
            in1.putExtra(BluetoothDevicePicker.EXTRA_LAUNCH_PACKAGE, getPackageName());
            in1.putExtra(BluetoothDevicePicker.EXTRA_LAUNCH_CLASS,
                    BluetoothOppReceiver.class.getName());
            if (V) {
                Log.d(TAG, "Launching " + BluetoothDevicePicker.ACTION_LAUNCH);
            }
            Log.v(TAG, "Launching " + BluetoothDevicePicker.ACTION_LAUNCH);
            startActivity(in1);
        }
    }
@@ -394,11 +378,9 @@ public class BluetoothOppLauncherActivity extends Activity {
                outStream.write(byteBuff, 0, byteBuff.length);
                fileUri = Uri.fromFile(new File(context.getFilesDir(), fileName));
                if (fileUri != null) {
                    if (D) {
                    Log.d(TAG, "Created one file for shared content: " + fileUri.toString());
                }
            }
            }
        } catch (FileNotFoundException e) {
            ContentProfileErrorReportUtils.report(
                    BluetoothProfile.OPP,
Loading