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

Commit 31860023 authored by William Escande's avatar William Escande
Browse files

OppTransfer: use final variable from constructor

Provide Adapter constructor (it is the context too).

Bug: 331948250
Test: atest BluetoothInstrumentationTests | No behavior changes
Flag: Exempt, no behavior changes
Change-Id: I9018aa6e59a94dab8db144625e33d735d1d0b12f
parent 5ef6c686
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -894,11 +894,12 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
                    Log.v(TAG,
                            "Service create new Batch " + newBatch.mId + " for OUTBOUND info "
                                    + info.mId);
                    mTransfer = new BluetoothOppTransfer(this, newBatch);
                    mTransfer = new BluetoothOppTransfer(mAdapterService, newBatch);
                } else if (info.mDirection == BluetoothShare.DIRECTION_INBOUND) {
                    Log.v(TAG, "Service create new Batch " + newBatch.mId + " for INBOUND info "
                            + info.mId);
                    mServerTransfer = new BluetoothOppTransfer(this, newBatch, mServerSession);
                    mServerTransfer =
                            new BluetoothOppTransfer(mAdapterService, newBatch, mServerSession);
                }

                if (info.mDirection == BluetoothShare.DIRECTION_OUTBOUND && mTransfer != null) {
@@ -1131,7 +1132,7 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
                    // just finish a transfer, start pending outbound transfer
                    if (nextBatch.mDirection == BluetoothShare.DIRECTION_OUTBOUND) {
                        Log.v(TAG, "Start pending outbound batch " + nextBatch.mId);
                        mTransfer = new BluetoothOppTransfer(this, nextBatch);
                        mTransfer = new BluetoothOppTransfer(mAdapterService, nextBatch);
                        mTransfer.start();
                        return;
                    } else if (nextBatch.mDirection == BluetoothShare.DIRECTION_INBOUND
@@ -1139,7 +1140,9 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
                        // have to support pending inbound transfer
                        // if an outbound transfer and incoming socket happens together
                        Log.v(TAG, "Start pending inbound batch " + nextBatch.mId);
                        mServerTransfer = new BluetoothOppTransfer(this, nextBatch, mServerSession);
                        mServerTransfer =
                                new BluetoothOppTransfer(
                                        mAdapterService, nextBatch, mServerSession);
                        mServerTransfer.start();
                        if (nextBatch.getPendingShare() != null
                                && nextBatch.getPendingShare().mConfirm
+8 −6
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@

package com.android.bluetooth.opp;

import static java.util.Objects.requireNonNull;

import android.app.NotificationManager;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
@@ -84,14 +86,14 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch

    private static final Object INSTANCE_LOCK = new Object();

    private Context mContext;
    private final Context mContext;

    private BluetoothAdapter mAdapter;

    @VisibleForTesting
    BluetoothDevice mDevice;

    private BluetoothOppBatch mBatch;
    private final BluetoothOppBatch mBatch;

    private BluetoothOppObexSession mSession;

@@ -124,7 +126,7 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch
                                    .BLUETOOTH_CONTENT_PROFILE_ERROR_REPORTED__TYPE__LOG_ERROR,
                            0);
                    return;
                } else if (mBatch == null || mCurrentShare == null) {
                } else if (mCurrentShare == null) {
                    Log.e(
                            TAG,
                            "device : "
@@ -228,11 +230,11 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch

    private OppConnectionReceiver mBluetoothReceiver;

    public BluetoothOppTransfer(Context context, BluetoothOppBatch batch,
            BluetoothOppObexSession session) {
    public BluetoothOppTransfer(
            Context context, BluetoothOppBatch batch, BluetoothOppObexSession session) {

        mContext = context;
        mBatch = batch;
        mBatch = requireNonNull(batch);
        mSession = session;

        mBatch.registerListener(this);