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

Commit 43aa7c3c authored by William Escande's avatar William Escande
Browse files

OppService: merge "start" into constructor

Test: atest BluetoothInstrumentationTests
Flag: Exempt refactor no-op
Bug: 311772251
Change-Id: Idb0728ed6214d4464d1a6af8249e12bd6bce9006
parent f7903793
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -51,7 +51,6 @@ import android.util.Log;
import com.android.bluetooth.BluetoothMethodProxy;
import com.android.bluetooth.R;
import com.android.bluetooth.Utils;
import com.android.bluetooth.flags.Flags;

import com.google.common.annotations.VisibleForTesting;

@@ -234,7 +233,7 @@ class BluetoothOppNotification {
                        case NOTIFY:
                            synchronized (BluetoothOppNotification.this) {
                                if (mPendingUpdate > 0 && mUpdateNotificationThread == null) {
                                    Log.v(TAG, "new notify threadi!");
                                    Log.v(TAG, "new notify thread!");
                                    mUpdateNotificationThread = new NotificationUpdateThread();
                                    mUpdateNotificationThread.start();
                                    Log.v(TAG, "send delay message");
+12 −28
Original line number Diff line number Diff line
@@ -51,7 +51,6 @@ import android.database.Cursor;
import android.media.MediaScannerConnection;
import android.media.MediaScannerConnection.MediaScannerConnectionClient;
import android.net.Uri;
import android.os.Binder;
import android.os.Handler;
import android.os.Message;
import android.os.Process;
@@ -135,7 +134,7 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
    private BluetoothShareContentObserver mObserver;

    /** Class to handle Notification Manager updates */
    @VisibleForTesting BluetoothOppNotification mNotifier;
    @VisibleForTesting final BluetoothOppNotification mNotifier;

    private boolean mPendingUpdate;

@@ -236,28 +235,6 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
                    BluetoothStatsLog.BLUETOOTH_CONTENT_PROFILE_ERROR_REPORTED__TYPE__LOG_WARN,
                    0);
        }
    }

    public static boolean isEnabled() {
        return BluetoothProperties.isProfileOppEnabled().orElse(false);
    }

    @Override
    protected IProfileServiceBinder initBinder() {
        return new OppBinder();
    }

    private static class OppBinder extends Binder implements IProfileServiceBinder {

        OppBinder() {}

        @Override
        public void cleanup() {}
    }

    @Override
    public void start() {
        Log.v(TAG, "start()");

        setComponentAvailable(OPP_PROVIDER, true);
        setComponentAvailable(INCOMING_FILE_CONFIRM_ACTIVITY, true);
@@ -282,6 +259,15 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
        setBluetoothOppService(this);
    }

    public static boolean isEnabled() {
        return BluetoothProperties.isProfileOppEnabled().orElse(false);
    }

    @Override
    protected IProfileServiceBinder initBinder() {
        return null;
    }

    @Override
    public void stop() {
        if (sBluetoothOppService == null) {
@@ -457,7 +443,7 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
                                                BluetoothStatsLog
                                                        .BLUETOOTH_CONTENT_PROFILE_ERROR_REPORTED__TYPE__EXCEPTION,
                                                7);
                                        Log.e(TAG, "close tranport error");
                                        Log.e(TAG, "close transport error");
                                    }
                                } else {
                                    Log.i(TAG, "OPP busy! Retry after 1 second");
@@ -623,10 +609,8 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti
            }
        }

        if (mNotifier != null) {
        mNotifier.cancelOppNotifications();
    }
    }

    /* suppose we auto accept an incoming OPUSH connection */
    private void createServerSession(ObexTransport transport) {
+0 −1
Original line number Diff line number Diff line
@@ -61,7 +61,6 @@ public class BluetoothOppServiceCleanupTest {
        BluetoothOppService service = null;
        try {
            service = new BluetoothOppService(adapterService);
            service.start();
            service.setAvailable(true);

            // Call stop while UpdateThread is running.
+0 −1
Original line number Diff line number Diff line
@@ -81,7 +81,6 @@ public class BluetoothOppServiceTest {

        AdapterService adapterService = new AdapterService(mTargetContext);
        mService = new BluetoothOppService(adapterService);
        mService.start();
        mService.setAvailable(true);
        mIsBluetoothOppServiceStarted = true;