Adding the resource-deallocation utility.
Change-Id: I73ee3b648d7b224017bb2445597f199f979be5de
diff --git a/src/com/android/telecomm/ServiceBinder.java b/src/com/android/telecomm/ServiceBinder.java
index 3c84967..2b9cc5c 100644
--- a/src/com/android/telecomm/ServiceBinder.java
+++ b/src/com/android/telecomm/ServiceBinder.java
@@ -93,6 +93,9 @@
/** The binder provided by {@link ServiceConnection#onServiceConnected} */
private IBinder mBinder;
+ /** The number of calls currently associated with this service. */
+ private int mAssociatedCallCount = 0;
+
/**
* Indicates that an unbind request was made when the service was not yet bound. If the service
* successfully connects when this is true, it should be unbound immediately.
@@ -153,6 +156,23 @@
return true;
}
+ final void incrementAssociatedCallCount() {
+ mAssociatedCallCount++;
+ }
+
+ final void decrementAssociatedCallCount() {
+ if (mAssociatedCallCount > 0) {
+ mAssociatedCallCount--;
+ } else {
+ Log.wtf(TAG, mComponentName.getClassName() +
+ ": ignoring a request to decrement mAssociatedCallCount below zero");
+ }
+ }
+
+ final int getAssociatedCallCount() {
+ return mAssociatedCallCount;
+ }
+
/**
* Unbinds from the service if already bound, no-op otherwise.
*/