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

Commit 106767a7 authored by Myles Watson's avatar Myles Watson Committed by android-build-merger
Browse files

Merge "btservice: Remove unused reference-counting logic"

am: 19f9e3dc

Change-Id: Ibe1c9c03005a2ab128d5d7c178877d1283b3de6d
parents 622a3583 19f9e3dc
Loading
Loading
Loading
Loading
+0 −25
Original line number Original line Diff line number Diff line
@@ -84,13 +84,9 @@ public class AdapterService extends Service {
    private static final String TAG = "BluetoothAdapterService";
    private static final String TAG = "BluetoothAdapterService";
    private static final boolean DBG = true;
    private static final boolean DBG = true;
    private static final boolean VERBOSE = false;
    private static final boolean VERBOSE = false;
    private static final boolean TRACE_REF = false;
    private static final int MIN_ADVT_INSTANCES_FOR_MA = 5;
    private static final int MIN_ADVT_INSTANCES_FOR_MA = 5;
    private static final int MIN_OFFLOADED_FILTERS = 10;
    private static final int MIN_OFFLOADED_FILTERS = 10;
    private static final int MIN_OFFLOADED_SCAN_STORAGE_BYTES = 1024;
    private static final int MIN_OFFLOADED_SCAN_STORAGE_BYTES = 1024;
    //For Debugging only
    private static int sRefCount = 0;
    private long mBluetoothStartTime = 0;


    private final Object mEnergyInfoLock = new Object();
    private final Object mEnergyInfoLock = new Object();
    private int mStackReportedState;
    private int mStackReportedState;
@@ -185,16 +181,6 @@ public class AdapterService extends Service {
    private ProfileObserver mProfileObserver;
    private ProfileObserver mProfileObserver;
    private PhonePolicy mPhonePolicy;
    private PhonePolicy mPhonePolicy;


    public AdapterService() {
        super();
        if (TRACE_REF) {
            synchronized (AdapterService.class) {
                sRefCount++;
                debugLog("AdapterService() - REFCOUNT: CREATED. INSTANCE_COUNT" + sRefCount);
            }
        }
    }

    public void addProfile(ProfileService profile) {
    public void addProfile(ProfileService profile) {
        synchronized (mProfiles) {
        synchronized (mProfiles) {
            if (!mProfiles.contains(profile)) {
            if (!mProfiles.contains(profile)) {
@@ -1686,7 +1672,6 @@ public class AdapterService extends Service {
        mQuietmode = quietMode;
        mQuietmode = quietMode;
        Message m = mAdapterStateMachine.obtainMessage(AdapterState.BLE_TURN_ON);
        Message m = mAdapterStateMachine.obtainMessage(AdapterState.BLE_TURN_ON);
        mAdapterStateMachine.sendMessage(m);
        mAdapterStateMachine.sendMessage(m);
        mBluetoothStartTime = System.currentTimeMillis();
        return true;
        return true;
    }
    }


@@ -2631,16 +2616,6 @@ public class AdapterService extends Service {


    private native void interopDatabaseAddNative(int feature, byte[] address, int length);
    private native void interopDatabaseAddNative(int feature, byte[] address, int length);


    @Override
    public void finalize() {
        if (TRACE_REF) {
            synchronized (AdapterService.class) {
                sRefCount--;
                debugLog("finalize() - REFCOUNT: FINALIZED. INSTANCE_COUNT= " + sRefCount);
            }
        }
    }

    // Returns if this is a mock object. This is currently used in testing so that we may not call
    // Returns if this is a mock object. This is currently used in testing so that we may not call
    // System.exit() while finalizing the object. Otherwise GC of mock objects unfortunately ends up
    // System.exit() while finalizing the object. Otherwise GC of mock objects unfortunately ends up
    // calling finalize() which in turn calls System.exit() and the process crashes.
    // calling finalize() which in turn calls System.exit() and the process crashes.
+0 −35
Original line number Original line Diff line number Diff line
@@ -26,8 +26,6 @@ import android.util.Log;


import com.android.bluetooth.Utils;
import com.android.bluetooth.Utils;


import java.util.HashMap;

/**
/**
 * Base class for a background service that runs a Bluetooth profile
 * Base class for a background service that runs a Bluetooth profile
 */
 */
@@ -35,9 +33,6 @@ public abstract class ProfileService extends Service {
    private static final boolean DBG = false;
    private static final boolean DBG = false;
    private static final String TAG = "BluetoothProfileService";
    private static final String TAG = "BluetoothProfileService";


    //For Debugging only
    private static final HashMap<String, Integer> sReferenceCount = new HashMap<String, Integer>();

    public static final String BLUETOOTH_ADMIN_PERM = android.Manifest.permission.BLUETOOTH_ADMIN;
    public static final String BLUETOOTH_ADMIN_PERM = android.Manifest.permission.BLUETOOTH_ADMIN;
    public static final String BLUETOOTH_PERM = android.Manifest.permission.BLUETOOTH;
    public static final String BLUETOOTH_PERM = android.Manifest.permission.BLUETOOTH;
    public static final String BLUETOOTH_PRIVILEGED =
    public static final String BLUETOOTH_PRIVILEGED =
@@ -100,36 +95,6 @@ public abstract class ProfileService extends Service {


    protected ProfileService() {
    protected ProfileService() {
        mName = getName();
        mName = getName();
        if (DBG) {
            synchronized (sReferenceCount) {
                Integer refCount = sReferenceCount.get(mName);
                if (refCount == null) {
                    refCount = 1;
                } else {
                    refCount = refCount + 1;
                }
                sReferenceCount.put(mName, refCount);
                if (DBG) {
                    log("REFCOUNT: CREATED. INSTANCE_COUNT=" + refCount);
                }
            }
        }
    }

    @Override
    protected void finalize() {
        if (DBG) {
            synchronized (sReferenceCount) {
                Integer refCount = sReferenceCount.get(mName);
                if (refCount != null) {
                    refCount = refCount - 1;
                } else {
                    refCount = 0;
                }
                sReferenceCount.put(mName, refCount);
                log("REFCOUNT: FINALIZED. INSTANCE_COUNT=" + refCount);
            }
        }
    }
    }


    @Override
    @Override