Loading core/java/android/bluetooth/BluetoothHeadset.java +12 −0 Original line number Original line Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.os.IBinder; import android.os.Looper; import android.os.Looper; import android.os.Message; import android.os.Message; import android.os.RemoteException; import android.os.RemoteException; import android.util.CloseGuard; import android.util.Log; import android.util.Log; import java.util.ArrayList; import java.util.ArrayList; Loading Loading @@ -338,6 +339,8 @@ public final class BluetoothHeadset implements BluetoothProfile { private static final int MESSAGE_HEADSET_SERVICE_CONNECTED = 100; private static final int MESSAGE_HEADSET_SERVICE_CONNECTED = 100; private static final int MESSAGE_HEADSET_SERVICE_DISCONNECTED = 101; private static final int MESSAGE_HEADSET_SERVICE_DISCONNECTED = 101; private final CloseGuard mCloseGuard = new CloseGuard(); private Context mContext; private Context mContext; private ServiceListener mServiceListener; private ServiceListener mServiceListener; private volatile IBluetoothHeadset mService; private volatile IBluetoothHeadset mService; Loading Loading @@ -385,6 +388,7 @@ public final class BluetoothHeadset implements BluetoothProfile { } } doBind(); doBind(); mCloseGuard.open("close"); } } private boolean doBind() { private boolean doBind() { Loading Loading @@ -438,6 +442,14 @@ public final class BluetoothHeadset implements BluetoothProfile { } } mServiceListener = null; mServiceListener = null; doUnbind(); doUnbind(); mCloseGuard.close(); } /** {@hide} */ @Override protected void finalize() throws Throwable { mCloseGuard.warnIfOpen(); close(); } } /** /** Loading core/java/android/bluetooth/BluetoothProfileConnector.java +11 −0 Original line number Original line Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.os.Build; import android.os.IBinder; import android.os.IBinder; import android.os.RemoteException; import android.os.RemoteException; import android.os.UserHandle; import android.os.UserHandle; import android.util.CloseGuard; import android.util.Log; import android.util.Log; /** /** Loading @@ -36,6 +37,7 @@ import android.util.Log; */ */ @SuppressLint("AndroidFrameworkBluetoothPermission") @SuppressLint("AndroidFrameworkBluetoothPermission") public abstract class BluetoothProfileConnector<T> { public abstract class BluetoothProfileConnector<T> { private final CloseGuard mCloseGuard = new CloseGuard(); private final int mProfileId; private final int mProfileId; private BluetoothProfile.ServiceListener mServiceListener; private BluetoothProfile.ServiceListener mServiceListener; private final BluetoothProfile mProfileProxy; private final BluetoothProfile mProfileProxy; Loading Loading @@ -82,11 +84,19 @@ public abstract class BluetoothProfileConnector<T> { mServiceName = serviceName; mServiceName = serviceName; } } /** {@hide} */ @Override public void finalize() { mCloseGuard.warnIfOpen(); doUnbind(); } @SuppressLint("AndroidFrameworkRequiresPermission") @SuppressLint("AndroidFrameworkRequiresPermission") private boolean doBind() { private boolean doBind() { synchronized (mConnection) { synchronized (mConnection) { if (mService == null) { if (mService == null) { logDebug("Binding service..."); logDebug("Binding service..."); mCloseGuard.open("doUnbind"); try { try { Intent intent = new Intent(mServiceName); Intent intent = new Intent(mServiceName); ComponentName comp = intent.resolveSystemService( ComponentName comp = intent.resolveSystemService( Loading @@ -110,6 +120,7 @@ public abstract class BluetoothProfileConnector<T> { synchronized (mConnection) { synchronized (mConnection) { if (mService != null) { if (mService != null) { logDebug("Unbinding service..."); logDebug("Unbinding service..."); mCloseGuard.close(); try { try { mContext.unbindService(mConnection); mContext.unbindService(mConnection); } catch (IllegalArgumentException ie) { } catch (IllegalArgumentException ie) { Loading Loading
core/java/android/bluetooth/BluetoothHeadset.java +12 −0 Original line number Original line Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.os.IBinder; import android.os.Looper; import android.os.Looper; import android.os.Message; import android.os.Message; import android.os.RemoteException; import android.os.RemoteException; import android.util.CloseGuard; import android.util.Log; import android.util.Log; import java.util.ArrayList; import java.util.ArrayList; Loading Loading @@ -338,6 +339,8 @@ public final class BluetoothHeadset implements BluetoothProfile { private static final int MESSAGE_HEADSET_SERVICE_CONNECTED = 100; private static final int MESSAGE_HEADSET_SERVICE_CONNECTED = 100; private static final int MESSAGE_HEADSET_SERVICE_DISCONNECTED = 101; private static final int MESSAGE_HEADSET_SERVICE_DISCONNECTED = 101; private final CloseGuard mCloseGuard = new CloseGuard(); private Context mContext; private Context mContext; private ServiceListener mServiceListener; private ServiceListener mServiceListener; private volatile IBluetoothHeadset mService; private volatile IBluetoothHeadset mService; Loading Loading @@ -385,6 +388,7 @@ public final class BluetoothHeadset implements BluetoothProfile { } } doBind(); doBind(); mCloseGuard.open("close"); } } private boolean doBind() { private boolean doBind() { Loading Loading @@ -438,6 +442,14 @@ public final class BluetoothHeadset implements BluetoothProfile { } } mServiceListener = null; mServiceListener = null; doUnbind(); doUnbind(); mCloseGuard.close(); } /** {@hide} */ @Override protected void finalize() throws Throwable { mCloseGuard.warnIfOpen(); close(); } } /** /** Loading
core/java/android/bluetooth/BluetoothProfileConnector.java +11 −0 Original line number Original line Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.os.Build; import android.os.IBinder; import android.os.IBinder; import android.os.RemoteException; import android.os.RemoteException; import android.os.UserHandle; import android.os.UserHandle; import android.util.CloseGuard; import android.util.Log; import android.util.Log; /** /** Loading @@ -36,6 +37,7 @@ import android.util.Log; */ */ @SuppressLint("AndroidFrameworkBluetoothPermission") @SuppressLint("AndroidFrameworkBluetoothPermission") public abstract class BluetoothProfileConnector<T> { public abstract class BluetoothProfileConnector<T> { private final CloseGuard mCloseGuard = new CloseGuard(); private final int mProfileId; private final int mProfileId; private BluetoothProfile.ServiceListener mServiceListener; private BluetoothProfile.ServiceListener mServiceListener; private final BluetoothProfile mProfileProxy; private final BluetoothProfile mProfileProxy; Loading Loading @@ -82,11 +84,19 @@ public abstract class BluetoothProfileConnector<T> { mServiceName = serviceName; mServiceName = serviceName; } } /** {@hide} */ @Override public void finalize() { mCloseGuard.warnIfOpen(); doUnbind(); } @SuppressLint("AndroidFrameworkRequiresPermission") @SuppressLint("AndroidFrameworkRequiresPermission") private boolean doBind() { private boolean doBind() { synchronized (mConnection) { synchronized (mConnection) { if (mService == null) { if (mService == null) { logDebug("Binding service..."); logDebug("Binding service..."); mCloseGuard.open("doUnbind"); try { try { Intent intent = new Intent(mServiceName); Intent intent = new Intent(mServiceName); ComponentName comp = intent.resolveSystemService( ComponentName comp = intent.resolveSystemService( Loading @@ -110,6 +120,7 @@ public abstract class BluetoothProfileConnector<T> { synchronized (mConnection) { synchronized (mConnection) { if (mService != null) { if (mService != null) { logDebug("Unbinding service..."); logDebug("Unbinding service..."); mCloseGuard.close(); try { try { mContext.unbindService(mConnection); mContext.unbindService(mConnection); } catch (IllegalArgumentException ie) { } catch (IllegalArgumentException ie) { Loading