Upate logging to use LogUtil
This CL replaces all calls to Log.* with calls to LogUtil.*.
Bug: 13172967
Change-Id: I649e2c4f74f9d74d046eddc777e192a066882520
diff --git a/src/com/android/telecomm/BinderDeallocator.java b/src/com/android/telecomm/BinderDeallocator.java
index fc57158..22f0758 100644
--- a/src/com/android/telecomm/BinderDeallocator.java
+++ b/src/com/android/telecomm/BinderDeallocator.java
@@ -16,8 +16,6 @@
package com.android.telecomm;
-import android.util.Log;
-
import com.google.common.collect.Sets;
import java.util.Iterator;
@@ -53,8 +51,6 @@
*/
final class BinderDeallocator {
- private static final String TAG = BinderDeallocator.class.getSimpleName();
-
/**
* The number of actions currently permitted to use previously-allocated resources and/or create
* new ones.
@@ -100,7 +96,7 @@
ThreadUtil.checkOnMainThread();
if (mPermitCount < 1) {
- Log.wtf(TAG, "releaseUsePermit should only be invoked upon mPermitCount > 0");
+ Log.wtf(this, "releaseUsePermit should only be invoked upon mPermitCount > 0");
} else if (--mPermitCount == 0) {
deallocateUnusedResources();
}
diff --git a/src/com/android/telecomm/Call.java b/src/com/android/telecomm/Call.java
index e61d5ec..96d8374 100644
--- a/src/com/android/telecomm/Call.java
+++ b/src/com/android/telecomm/Call.java
@@ -19,7 +19,6 @@
import android.telecomm.CallInfo;
import android.telecomm.CallState;
import android.telecomm.ICallServiceSelector;
-import android.util.Log;
import com.google.common.base.Preconditions;
@@ -32,8 +31,6 @@
* connected etc).
*/
final class Call {
- private static final String TAG = Call.class.getSimpleName();
-
/** Unique identifier for the call as a UUID string. */
private final String mId;
@@ -189,9 +186,9 @@
*/
void disconnect() {
if (mCallService == null) {
- Log.w(TAG, "disconnect() request on a call without a call service.");
+ Log.w(this, "disconnect() request on a call without a call service.");
} else {
- Log.i(TAG, "Send disconnect to call service for call with id " + mId);
+ Log.i(this, "Send disconnect to call service for call with id %s", mId);
// The call isn't officially disconnected until the call service confirms that the call
// was actually disconnected. Only then is the association between call and call service
// severed, see {@link CallsManager#markCallAsDisconnected}.
@@ -247,7 +244,7 @@
return true;
}
- Log.i(TAG, "Request to " + actionName + " a non-ringing call " + this);
+ Log.i(this, "Request to %s a non-ringing call %s", actionName, this);
return false;
}
diff --git a/src/com/android/telecomm/CallActivity.java b/src/com/android/telecomm/CallActivity.java
index 9347c2e..2418a0a 100644
--- a/src/com/android/telecomm/CallActivity.java
+++ b/src/com/android/telecomm/CallActivity.java
@@ -22,7 +22,6 @@
import android.os.Bundle;
import android.telecomm.CallServiceDescriptor;
import android.telecomm.TelecommConstants;
-import android.util.Log;
import android.widget.Toast;
/**
@@ -31,11 +30,6 @@
*/
public class CallActivity extends Activity {
- private static final String TAG = CallActivity.class.getSimpleName();
-
- /** Indicates whether or not debug-level entries should be logged. */
- private static boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
-
private CallsManager mCallsManager = CallsManager.getInstance();
/**
@@ -57,11 +51,9 @@
Intent intent = getIntent();
Configuration configuration = getResources().getConfiguration();
- if (DEBUG) {
- Log.d(TAG, "onCreate: this = " + this + ", bundle= " + bundle);
- Log.d(TAG, " - intent = " + intent);
- Log.d(TAG, " - configuration = " + configuration);
- }
+ Log.d(this, "onCreate: this = %s, bundle = %s", this, bundle);
+ Log.d(this, " - intent = %s", intent);
+ Log.d(this, " - configuration = %s", configuration);
// TODO(santoscordon): Figure out if there is something to restore from bundle.
// See OutgoingCallBroadcaster in services/Telephony for more.
@@ -71,9 +63,7 @@
// This activity does not have associated UI, so close.
finish();
- if (DEBUG) {
- Log.d(TAG, "onCreate: end");
- }
+ Log.d(this, "onCreate: end");
}
/**
@@ -122,7 +112,7 @@
CallServiceDescriptor descriptor =
intent.getParcelableExtra(TelecommConstants.EXTRA_CALL_SERVICE_DESCRIPTOR);
if (descriptor == null) {
- Log.w(TAG, "Rejecting incoming call due to null descriptor");
+ Log.w(this, "Rejecting incoming call due to null descriptor");
return;
}
@@ -131,7 +121,7 @@
clientExtras = intent.getBundleExtra(TelecommConstants.EXTRA_INCOMING_CALL_EXTRAS);
}
- Log.d(TAG, "Processing incoming call from call service [" + descriptor + "]");
+ Log.d(this, "Processing incoming call from call service [%s]", descriptor);
mCallsManager.processIncomingCallIntent(descriptor, clientExtras);
}
}
diff --git a/src/com/android/telecomm/CallServiceAdapter.java b/src/com/android/telecomm/CallServiceAdapter.java
index 17063c3..f602d50 100644
--- a/src/com/android/telecomm/CallServiceAdapter.java
+++ b/src/com/android/telecomm/CallServiceAdapter.java
@@ -20,7 +20,6 @@
import android.os.Looper;
import android.telecomm.CallInfo;
import android.telecomm.ICallServiceAdapter;
-import android.util.Log;
import com.google.android.collect.Sets;
import com.google.common.base.Strings;
@@ -38,8 +37,6 @@
* TODO(santoscordon): Do we need Binder.clear/restoreCallingIdentity() in the service methods?
*/
public final class CallServiceAdapter extends ICallServiceAdapter.Stub {
- private static final String TAG = CallServiceAdapter.class.getSimpleName();
-
private final CallsManager mCallsManager;
private final OutgoingCallsManager mOutgoingCallsManager;
@@ -82,7 +79,8 @@
if (mPendingIncomingCallIds.remove(callInfo.getId())) {
mIncomingCallsManager.handleSuccessfulIncomingCall(callInfo);
} else {
- Log.wtf(TAG, "Received details for an unknown incoming call " + callInfo);
+ Log.wtf(CallServiceAdapter.this,
+ "Received details for an unknown incoming call %s", callInfo);
}
}
});
diff --git a/src/com/android/telecomm/CallServiceProviderWrapper.java b/src/com/android/telecomm/CallServiceProviderWrapper.java
index 2002113..7638312 100644
--- a/src/com/android/telecomm/CallServiceProviderWrapper.java
+++ b/src/com/android/telecomm/CallServiceProviderWrapper.java
@@ -21,7 +21,6 @@
import android.os.RemoteException;
import android.telecomm.ICallServiceLookupResponse;
import android.telecomm.ICallServiceProvider;
-import android.util.Log;
/**
* Wrapper for {@link ICallServiceProvider}s, handles binding to {@link ICallServiceProvider} and
@@ -37,8 +36,6 @@
*/
static final String CALL_SERVICE_PROVIDER_ACTION = ICallServiceProvider.class.getName();
- private static final String TAG = CallServiceProviderWrapper.class.getSimpleName();
-
/** The actual service implementation. */
private ICallServiceProvider mServiceInterface;
@@ -60,12 +57,12 @@
public void lookupCallServices(ICallServiceLookupResponse response) {
try {
if (mServiceInterface == null) {
- Log.wtf(TAG, "lookupCallServices() invoked while the service is unbound.");
+ Log.wtf(this, "lookupCallServices() invoked while the service is unbound.");
} else {
mServiceInterface.lookupCallServices(response);
}
} catch (RemoteException e) {
- Log.e(TAG, "Failed to lookupCallServices.", e);
+ Log.e(this, e, "Failed to lookupCallServices.");
}
}
diff --git a/src/com/android/telecomm/CallServiceRepository.java b/src/com/android/telecomm/CallServiceRepository.java
index 93f133f..14a944e 100644
--- a/src/com/android/telecomm/CallServiceRepository.java
+++ b/src/com/android/telecomm/CallServiceRepository.java
@@ -26,7 +26,6 @@
import android.telecomm.CallServiceDescriptor;
import android.telecomm.ICallServiceLookupResponse;
import android.telecomm.ICallServiceProvider;
-import android.util.Log;
import com.android.telecomm.ServiceBinder.BindCallback;
@@ -50,8 +49,6 @@
*/
final class CallServiceRepository {
- private static final String TAG = CallServiceRepository.class.getSimpleName();
-
private final Switchboard mSwitchboard;
private final OutgoingCallsManager mOutgoingCallsManager;
@@ -68,7 +65,7 @@
private final Runnable mLookupTerminator = new Runnable() {
@Override
public void run() {
- Log.d(TAG, "Timed out processing providers");
+ Log.d(CallServiceRepository.this, "Timed out processing providers");
terminateLookup();
}
};
@@ -136,7 +133,7 @@
List<ComponentName> providerNames = getProviderNames();
if (providerNames.isEmpty()) {
- Log.i(TAG, "No ICallServiceProvider implementations found, bailing out.");
+ Log.i(this, "No ICallServiceProvider implementations found, bailing out.");
return;
}
@@ -149,8 +146,8 @@
bindProvider(name);
}
- Log.i(TAG, "Found " + mOutstandingProviders.size() +
- " implementations of ICallServiceProvider.");
+ Log.i(this, "Found %d implementations of ICallServiceProvider.",
+ mOutstandingProviders.size());
// Schedule a lookup terminator to run after Timeouts.getProviderLookupMs() milliseconds.
mHandler.postDelayed(mLookupTerminator, Timeouts.getProviderLookupMs());
@@ -294,7 +291,7 @@
removeOutstandingProvider(providerName);
} else {
- Log.i(TAG, "Unexpected list of call services in lookup " + mLookupId + " from " +
+ Log.i(this, "Unexpected list of call services in lookup %s from %s ", mLookupId,
providerName);
}
}
diff --git a/src/com/android/telecomm/CallServiceSelectorRepository.java b/src/com/android/telecomm/CallServiceSelectorRepository.java
index d384604..98236b2 100644
--- a/src/com/android/telecomm/CallServiceSelectorRepository.java
+++ b/src/com/android/telecomm/CallServiceSelectorRepository.java
@@ -27,7 +27,6 @@
import android.os.IBinder;
import android.os.Looper;
import android.telecomm.ICallServiceSelector;
-import android.util.Log;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
@@ -43,8 +42,6 @@
*/
final class CallServiceSelectorRepository {
- private static final String TAG = CallServiceSelectorRepository.class.getSimpleName();
-
/**
* Used to retrieve all known ICallServiceSelector implementations from the framework.
*/
@@ -58,7 +55,7 @@
private final Runnable mLookupTerminator = new Runnable() {
@Override
public void run() {
- Log.d(TAG, "Timed out processing selectors");
+ Log.d(CallServiceSelectorRepository.this, "Timed out processing selectors");
terminateLookup();
}
};
@@ -123,7 +120,7 @@
List<ComponentName> selectorNames = getSelectorNames();
if (selectorNames.isEmpty()) {
- Log.i(TAG, "No ICallServiceSelector implementations found.");
+ Log.i(this, "No ICallServiceSelector implementations found.");
updateSwitchboard();
return;
}
@@ -144,8 +141,8 @@
int selectorCount = selectorNames.size();
int unregisteredSelectorCount = mUnregisteredSelectors.size();
- Log.i(TAG, "Found " + selectorCount + " implementations of ICallServiceSelector, "
- + unregisteredSelectorCount + " of which are not currently registered.");
+ Log.i(this, "Found %d implementations of ICallServiceSelector, %d of which are not " +
+ "currently registered.", selectorCount , unregisteredSelectorCount);
if (unregisteredSelectorCount == 0) {
// All known (selector) implementations are already registered, pass control
@@ -195,7 +192,7 @@
Intent serviceIntent =
new Intent(CALL_SERVICE_SELECTOR_CLASS_NAME).setComponent(selectorName);
- Log.i(TAG, "Binding to ICallServiceSelector through " + serviceIntent);
+ Log.i(this, "Binding to ICallServiceSelector through %s", serviceIntent);
// Connection object for the service binding.
ServiceConnection connection = new ServiceConnection() {
diff --git a/src/com/android/telecomm/CallServiceWrapper.java b/src/com/android/telecomm/CallServiceWrapper.java
index 067b715..94be7c8 100644
--- a/src/com/android/telecomm/CallServiceWrapper.java
+++ b/src/com/android/telecomm/CallServiceWrapper.java
@@ -24,7 +24,6 @@
import android.telecomm.CallServiceDescriptor;
import android.telecomm.ICallService;
import android.telecomm.ICallServiceAdapter;
-import android.util.Log;
/**
* Wrapper for {@link ICallService}s, handles binding to {@link ICallService} and keeps track of
@@ -41,8 +40,6 @@
*/
static final String CALL_SERVICE_ACTION = ICallService.class.getName();
- private static final String TAG = CallServiceWrapper.class.getSimpleName();
-
/** The descriptor of this call service as supplied by the call-service provider. */
private final CallServiceDescriptor mDescriptor;
@@ -77,7 +74,7 @@
try {
mServiceInterface.setCallServiceAdapter(callServiceAdapter);
} catch (RemoteException e) {
- Log.e(TAG, "Failed to setCallServiceAdapter.", e);
+ Log.e(this, e, "Failed to setCallServiceAdapter.");
}
}
}
@@ -88,7 +85,7 @@
try {
mServiceInterface.isCompatibleWith(callInfo);
} catch (RemoteException e) {
- Log.e(TAG, "Failed checking isCompatibleWith.", e);
+ Log.e(this, e, "Failed checking isCompatibleWith.");
}
}
}
@@ -99,7 +96,7 @@
try {
mServiceInterface.call(callInfo);
} catch (RemoteException e) {
- Log.e(TAG, "Failed to place call " + callInfo.getId() + ".", e);
+ Log.e(this, e, "Failed to place call " + callInfo.getId() + ".");
}
}
}
@@ -111,7 +108,7 @@
try {
mServiceInterface.setIncomingCallId(callId, extras);
} catch (RemoteException e) {
- Log.e(TAG, "Failed to setIncomingCallId for call " + callId, e);
+ Log.e(this, e, "Failed to setIncomingCallId for call %s", callId);
mAdapter.removePendingIncomingCallId(callId);
}
}
@@ -123,7 +120,7 @@
try {
mServiceInterface.disconnect(callId);
} catch (RemoteException e) {
- Log.e(TAG, "Failed to disconnect call " + callId + ".", e);
+ Log.e(this, e, "Failed to disconnect call %s", callId);
}
}
}
@@ -134,7 +131,7 @@
try {
mServiceInterface.answer(callId);
} catch (RemoteException e) {
- Log.e(TAG, "Failed to answer call " + callId, e);
+ Log.e(this, e, "Failed to answer call %s", callId);
}
}
}
@@ -145,7 +142,7 @@
try {
mServiceInterface.reject(callId);
} catch (RemoteException e) {
- Log.e(TAG, "Failed to reject call " + callId, e);
+ Log.e(this, e, "Failed to reject call %s");
}
}
}
@@ -196,7 +193,7 @@
return true;
}
- Log.wtf(TAG, actionName + " invoked while service is unbound");
+ Log.wtf(this, "%s invoked while service is unbound", actionName);
return false;
}
}
diff --git a/src/com/android/telecomm/CallsManager.java b/src/com/android/telecomm/CallsManager.java
index 35d744f..5cb879f 100644
--- a/src/com/android/telecomm/CallsManager.java
+++ b/src/com/android/telecomm/CallsManager.java
@@ -24,7 +24,6 @@
import android.telecomm.CallState;
import android.telecomm.ICallService;
import android.telephony.TelephonyManager;
-import android.util.Log;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
@@ -43,8 +42,6 @@
*/
public final class CallsManager {
- private static final String TAG = CallsManager.class.getSimpleName();
-
private static final CallsManager INSTANCE = new CallsManager();
private final Switchboard mSwitchboard;
@@ -110,7 +107,7 @@
* @param extras The optional extras Bundle passed with the intent used for the incoming call.
*/
void processIncomingCallIntent(CallServiceDescriptor descriptor, Bundle extras) {
- Log.d(TAG, "processIncomingCallIntent");
+ Log.d(this, "processIncomingCallIntent");
// Create a call with no handle. Eventually, switchboard will update the call with
// additional information from the call service, but for now we just need one to pass around
// with a unique call ID.
@@ -126,7 +123,7 @@
* @param call The new incoming call.
*/
void handleSuccessfulIncomingCall(Call call) {
- Log.d(TAG, "handleSuccessfulIncomingCall");
+ Log.d(this, "handleSuccessfulIncomingCall");
Preconditions.checkState(call.getState() == CallState.RINGING);
String handle = call.getHandle();
@@ -134,7 +131,7 @@
for (IncomingCallValidator validator : mIncomingCallValidators) {
if (!validator.isValid(handle, contactInfo)) {
// TODO(gilad): Consider displaying an error message.
- Log.i(TAG, "Dropping restricted incoming call");
+ Log.i(this, "Dropping restricted incoming call");
return;
}
}
@@ -163,7 +160,7 @@
for (OutgoingCallValidator validator : mOutgoingCallValidators) {
if (!validator.isValid(handle, contactInfo)) {
// TODO(gilad): Display an error message.
- Log.i(TAG, "Dropping restricted outgoing call.");
+ Log.i(this, "Dropping restricted outgoing call.");
return;
}
}
@@ -196,7 +193,7 @@
void answerCall(String callId) {
Call call = mCalls.get(callId);
if (call == null) {
- Log.i(TAG, "Request to answer a non-existent call " + callId);
+ Log.i(this, "Request to answer a non-existent call %s", callId);
} else {
stopRinging(call);
@@ -218,7 +215,7 @@
void rejectCall(String callId) {
Call call = mCalls.get(callId);
if (call == null) {
- Log.i(TAG, "Request to reject a non-existent call " + callId);
+ Log.i(this, "Request to reject a non-existent call %s", callId);
} else {
stopRinging(call);
call.reject();
@@ -235,7 +232,7 @@
void disconnectCall(String callId) {
Call call = mCalls.get(callId);
if (call == null) {
- Log.e(TAG, "Unknown call (" + callId + ") asked to disconnect");
+ Log.w(this, "Unknown call (%s) asked to disconnect", callId);
} else {
call.disconnect();
}
@@ -322,8 +319,8 @@
Call call = mCalls.get(callId);
if (call == null) {
- Log.e(TAG, "Call " + callId + " was not found while attempting to update the state " +
- "to " + newState + ".");
+ Log.w(this, "Call %s was not found while attempting to update the state to %s.",
+ callId, newState );
} else {
if (newState != call.getState()) {
// Unfortunately, in the telephony world the radio is king. So if the call notifies
@@ -366,8 +363,8 @@
break;
default:
- Log.e(TAG, "Call is in an unknown state (" + call.getState() +
- "), not broadcasting: " + call.getId());
+ Log.w(this, "Call is in an unknown state (%s), not broadcasting: %s", call.getState(),
+ call.getId());
return;
}
@@ -385,7 +382,7 @@
updateIntent.putExtra(CallService.class.getName(), callService.getComponentName());
}
TelecommApp.getInstance().sendBroadcast(updateIntent, Manifest.permission.READ_PHONE_STATE);
- Log.i(TAG, "Broadcasted state change: " + callState);
+ Log.i(this, "Broadcasted state change: %s", callState);
}
/**
diff --git a/src/com/android/telecomm/InCallAdapter.java b/src/com/android/telecomm/InCallAdapter.java
index 170f66b..9e14a2e 100644
--- a/src/com/android/telecomm/InCallAdapter.java
+++ b/src/com/android/telecomm/InCallAdapter.java
@@ -19,7 +19,6 @@
import android.os.Handler;
import android.os.Looper;
import android.telecomm.IInCallAdapter;
-import android.util.Log;
/**
* Receives call commands and updates from in-call app and passes them through to CallsManager.
@@ -28,8 +27,6 @@
*/
class InCallAdapter extends IInCallAdapter.Stub {
- private static final String TAG = InCallAdapter.class.getSimpleName();
-
private final CallsManager mCallsManager;
private final Handler mHandler = new Handler(Looper.getMainLooper());
@@ -42,7 +39,7 @@
/** {@inheritDoc} */
@Override
public void answerCall(final String callId) {
- Log.d(TAG, "answerCall(" + callId + ")");
+ Log.d(this, "answerCall(%s)", callId);
mHandler.post(new Runnable() {
@Override public void run() {
mCallsManager.answerCall(callId);
@@ -53,7 +50,7 @@
/** {@inheritDoc} */
@Override
public void rejectCall(final String callId) {
- Log.d(TAG, "rejectCall(" + callId + ")");
+ Log.d(this, "rejectCall(%s)", callId);
mHandler.post(new Runnable() {
@Override public void run() {
mCallsManager.rejectCall(callId);
diff --git a/src/com/android/telecomm/InCallController.java b/src/com/android/telecomm/InCallController.java
index b60b5cd..18651e2 100644
--- a/src/com/android/telecomm/InCallController.java
+++ b/src/com/android/telecomm/InCallController.java
@@ -24,7 +24,6 @@
import android.os.RemoteException;
import android.telecomm.CallInfo;
import android.telecomm.IInCallService;
-import android.util.Log;
/**
* Binds to {@link IInCallService} and provides the service to {@link CallsManager} through which it
@@ -52,8 +51,6 @@
}
}
- private static final String TAG = InCallController.class.getSimpleName();
-
/**
* Package name of the in-call app. Although in-call code in kept in its own namespace, it is
* ultimately compiled into the dialer APK, hence the difference in namespaces between this and
@@ -101,11 +98,11 @@
bind();
} else {
// TODO(santoscordon): Protect against logging phone number.
- Log.i(TAG, "Adding call: " + callInfo);
+ Log.i(this, "Adding call: %s", callInfo);
mInCallService.addCall(callInfo);
}
} catch (RemoteException e) {
- Log.e(TAG, "Exception attempting to addCall.", e);
+ Log.e(this, e, "Exception attempting to addCall.");
}
}
@@ -117,11 +114,11 @@
void markCallAsActive(String callId) {
try {
if (mInCallService != null) {
- Log.i(TAG, "Mark call as ACTIVE: " + callId);
+ Log.i(this, "Mark call as ACTIVE: %s", callId);
mInCallService.setActive(callId);
}
} catch (RemoteException e) {
- Log.e(TAG, "Exception attempting to markCallAsActive.", e);
+ Log.e(this, e, "Exception attempting to markCallAsActive.");
}
}
@@ -134,11 +131,11 @@
void markCallAsDisconnected(String callId) {
try {
if (mInCallService != null) {
- Log.i(TAG, "Mark call as DISCONNECTED: " + callId);
+ Log.i(this, "Mark call as DISCONNECTED: %s", callId);
mInCallService.setDisconnected(callId);
}
} catch (RemoteException e) {
- Log.e(TAG, "Exception attempting to markCallAsDisconnected.", e);
+ Log.e(this, e, "Exception attempting to markCallAsDisconnected.");
}
}
@@ -148,7 +145,7 @@
void unbind() {
ThreadUtil.checkOnMainThread();
if (mInCallService != null) {
- Log.i(TAG, "Unbinding from InCallService");
+ Log.i(this, "Unbinding from InCallService");
TelecommApp.getInstance().unbindService(mConnection);
mInCallService = null;
}
@@ -163,14 +160,14 @@
if (mInCallService == null) {
ComponentName component =
new ComponentName(IN_CALL_PACKAGE_NAME, IN_CALL_SERVICE_CLASS_NAME);
- Log.i(TAG, "Attempting to bind to InCallService: " + component);
+ Log.i(this, "Attempting to bind to InCallService: %s", component);
Intent serviceIntent = new Intent(IInCallService.class.getName());
serviceIntent.setComponent(component);
Context context = TelecommApp.getInstance();
if (!context.bindService(serviceIntent, mConnection, Context.BIND_AUTO_CREATE)) {
- Log.e(TAG, "Could not connect to the in-call app (" + component + ")");
+ Log.w(this, "Could not connect to the in-call app (%s)", component);
// TODO(santoscordon): Implement retry or fall-back-to-default logic.
}
@@ -191,7 +188,7 @@
try {
mInCallService.setInCallAdapter(new InCallAdapter(mCallsManager));
} catch (RemoteException e) {
- Log.e(TAG, "Failed to set the in-call adapter.", e);
+ Log.e(this, e, "Failed to set the in-call adapter.");
mInCallService = null;
}
diff --git a/src/com/android/telecomm/IncomingCallsManager.java b/src/com/android/telecomm/IncomingCallsManager.java
index d82a7de..7d33d6b 100644
--- a/src/com/android/telecomm/IncomingCallsManager.java
+++ b/src/com/android/telecomm/IncomingCallsManager.java
@@ -19,7 +19,6 @@
import android.os.Bundle;
import android.telecomm.CallInfo;
import android.telecomm.CallService;
-import android.util.Log;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
@@ -34,8 +33,6 @@
*/
final class IncomingCallsManager {
- private static final String TAG = IncomingCallsManager.class.getSimpleName();
-
private final Switchboard mSwitchboard;
/** Maps call ID to the call. */
@@ -60,7 +57,7 @@
*/
void retrieveIncomingCall(final Call call, Bundle extras) {
ThreadUtil.checkOnMainThread();
- Log.d(TAG, "retrieveIncomingCall");
+ Log.d(this, "retrieveIncomingCall");
final String callId = call.getId();
// Just to be safe, lets make sure we're not already processing this call.
@@ -89,7 +86,7 @@
Call call = mPendingIncomingCalls.remove(callInfo.getId());
if (call != null) {
- Log.d(TAG, "Incoming call " + call.getId() + " found.");
+ Log.d(this, "Incoming call %s found.", call.getId());
call.setHandle(callInfo.getHandle());
call.setState(callInfo.getState());
@@ -106,7 +103,7 @@
ThreadUtil.checkOnMainThread();
if (mPendingIncomingCalls.remove(call.getId()) != null) {
- Log.i(TAG, "Failed to get details for incoming call " + call);
+ Log.i(this, "Failed to get details for incoming call %s", call);
// The call was found still waiting for details. Consider it failed.
mSwitchboard.handleFailedIncomingCall(call);
}
diff --git a/src/com/android/telecomm/Log.java b/src/com/android/telecomm/Log.java
new file mode 100644
index 0000000..73892cd
--- /dev/null
+++ b/src/com/android/telecomm/Log.java
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2014, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.telecomm;
+
+import java.util.IllegalFormatException;
+import java.util.Locale;
+
+/**
+ * Manages logging for the entire module.
+ */
+public class Log {
+
+ // Generic tag for all In Call logging
+ private static final String TAG = "Telecomm";
+
+ public static final boolean FORCE_LOGGING = true; /* STOP SHIP if true */
+ public static final boolean DEBUG = isLoggable(android.util.Log.DEBUG);
+ public static final boolean INFO = isLoggable(android.util.Log.INFO);
+ public static final boolean VERBOSE = isLoggable(android.util.Log.VERBOSE);
+ public static final boolean WARN = isLoggable(android.util.Log.WARN);
+ public static final boolean ERROR = isLoggable(android.util.Log.ERROR);
+
+ private Log() {}
+
+ public static boolean isLoggable(int level) {
+ return FORCE_LOGGING || android.util.Log.isLoggable(TAG, level);
+ }
+
+ public static void d(String prefix, String format, Object... args) {
+ if (DEBUG) {
+ android.util.Log.d(TAG, buildMessage(prefix, format, args));
+ }
+ }
+
+ public static void d(Object objectPrefix, String format, Object... args) {
+ if (DEBUG) {
+ android.util.Log.d(TAG, buildMessage(getPrefixFromObject(objectPrefix), format, args));
+ }
+ }
+
+ public static void i(String prefix, String format, Object... args) {
+ if (INFO) {
+ android.util.Log.i(TAG, buildMessage(prefix, format, args));
+ }
+ }
+
+ public static void i(Object objectPrefix, String format, Object... args) {
+ if (INFO) {
+ android.util.Log.i(TAG, buildMessage(getPrefixFromObject(objectPrefix), format, args));
+ }
+ }
+
+ public static void v(String prefix, String format, Object... args) {
+ if (VERBOSE) {
+ android.util.Log.v(TAG, buildMessage(prefix, format, args));
+ }
+ }
+
+ public static void v(Object objectPrefix, String format, Object... args) {
+ if (VERBOSE) {
+ android.util.Log.v(TAG, buildMessage(getPrefixFromObject(objectPrefix), format, args));
+ }
+ }
+
+ public static void w(String prefix, String format, Object... args) {
+ if (WARN) {
+ android.util.Log.w(TAG, buildMessage(prefix, format, args));
+ }
+ }
+
+ public static void w(Object objectPrefix, String format, Object... args) {
+ if (WARN) {
+ android.util.Log.w(TAG, buildMessage(getPrefixFromObject(objectPrefix), format, args));
+ }
+ }
+
+ public static void e(String prefix, Throwable tr, String format, Object... args) {
+ if (ERROR) {
+ android.util.Log.e(TAG, buildMessage(prefix, format, args), tr);
+ }
+ }
+
+ public static void e(Object objectPrefix, Throwable tr, String format, Object... args) {
+ if (ERROR) {
+ android.util.Log.e(TAG, buildMessage(getPrefixFromObject(objectPrefix), format, args),
+ tr);
+ }
+ }
+
+ public static void wtf(String prefix, Throwable tr, String format, Object... args) {
+ android.util.Log.wtf(TAG, buildMessage(prefix, format, args), tr);
+ }
+
+ public static void wtf(Object objectPrefix, Throwable tr, String format, Object... args) {
+ android.util.Log.wtf(TAG, buildMessage(getPrefixFromObject(objectPrefix), format, args),
+ tr);
+ }
+
+ public static void wtf(String prefix, String format, Object... args) {
+ android.util.Log.wtf(TAG, buildMessage(prefix, format, args));
+ }
+
+ public static void wtf(Object objectPrefix, String format, Object... args) {
+ android.util.Log.wtf(TAG, buildMessage(getPrefixFromObject(objectPrefix), format, args));
+ }
+
+ private static String getPrefixFromObject(Object obj) {
+ return obj == null ? "<null>" : obj.getClass().getSimpleName();
+ }
+
+ private static String buildMessage(String prefix, String format, Object... args) {
+ String msg;
+ try {
+ msg = (args == null || args.length == 0) ? format
+ : String.format(Locale.US, format, args);
+ } catch (IllegalFormatException ife) {
+ wtf("Log", ife, "IllegalFormatException: formatString='%s' numArgs=%d", format,
+ args.length);
+ msg = format + " (An error occurred while formatting the message.)";
+ }
+ return String.format(Locale.US, "%s: %s", prefix, msg);
+ }
+}
diff --git a/src/com/android/telecomm/LogUtil.java b/src/com/android/telecomm/LogUtil.java
deleted file mode 100644
index 9690251..0000000
--- a/src/com/android/telecomm/LogUtil.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2014, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.telecomm;
-
-import android.util.Log;
-
-import java.util.IllegalFormatException;
-import java.util.Locale;
-
-/**
- * Manages logging for the entire module.
- */
-public class LogUtil {
-
- // Generic tag for all In Call logging
- private static final String TAG = "Telecomm";
-
- public static final boolean FORCE_LOGGING = true; /* STOP SHIP if true */
- public static final boolean DEBUG = isLoggable(Log.DEBUG);
- public static final boolean VERBOSE = isLoggable(Log.VERBOSE);
-
- private LogUtil() {}
-
- public static boolean isLoggable(int level) {
- return FORCE_LOGGING || Log.isLoggable(TAG, level);
- }
-
- public static void d(String prefix, String format, Object... args) {
- if (DEBUG) {
- Log.d(TAG, buildMessage(prefix, format, args));
- }
- }
-
- public static void d(Object objectPrefix, String format, Object... args) {
- if (DEBUG) {
- Log.d(TAG, buildMessage(getPrefixFromObject(objectPrefix), format, args));
- }
- }
-
- public static void v(String prefix, String format, Object... args) {
- if (VERBOSE) {
- Log.v(TAG, buildMessage(prefix, format, args));
- }
- }
-
- public static void v(Object objectPrefix, String format, Object... args) {
- if (VERBOSE) {
- Log.v(TAG, buildMessage(getPrefixFromObject(objectPrefix), format, args));
- }
- }
-
- public static void w(String prefix, String format, Object... args) {
- if (isLoggable(Log.WARN)) {
- Log.w(TAG, buildMessage(prefix, format, args));
- }
- }
-
- public static void w(Object objectPrefix, String format, Object... args) {
- if (isLoggable(Log.WARN)) {
- Log.w(TAG, buildMessage(getPrefixFromObject(objectPrefix), format, args));
- }
- }
-
- public static void e(String prefix, Throwable tr, String format, Object... args) {
- if (isLoggable(Log.ERROR)) {
- Log.e(TAG, buildMessage(prefix, format, args), tr);
- }
- }
-
- public static void e(Object objectPrefix, Throwable tr, String format, Object... args) {
- if (isLoggable(Log.ERROR)) {
- Log.e(TAG, buildMessage(getPrefixFromObject(objectPrefix), format, args), tr);
- }
- }
-
- public static void wtf(String prefix, Throwable tr, String format, Object... args) {
- Log.wtf(TAG, buildMessage(prefix, format, args), tr);
- }
-
- public static void wtf(Object objectPrefix, Throwable tr, String format, Object... args) {
- Log.wtf(TAG, buildMessage(getPrefixFromObject(objectPrefix), format, args), tr);
- }
-
- public static void wtf(String prefix, String format, Object... args) {
- Log.wtf(TAG, buildMessage(prefix, format, args));
- }
-
- public static void wtf(Object objectPrefix, String format, Object... args) {
- Log.wtf(TAG, buildMessage(getPrefixFromObject(objectPrefix), format, args));
- }
-
- private static String getPrefixFromObject(Object obj) {
- return obj == null ? "<null>" : obj.getClass().getSimpleName();
- }
-
- private static String buildMessage(String prefix, String format, Object... args) {
- String msg;
- try {
- msg = (args == null || args.length == 0) ? format
- : String.format(Locale.US, format, args);
- } catch (IllegalFormatException ife) {
- wtf("LogUtil", "IllegalFormatException: formatString='%s' numArgs=%d", format,
- args.length);
- msg = format + " (An error occurred while formatting the message.)";
- }
- return String.format(Locale.US, "%s: %s", prefix, msg);
- }
-}
diff --git a/src/com/android/telecomm/OutgoingCallsManager.java b/src/com/android/telecomm/OutgoingCallsManager.java
index 0a41c08..f50f765 100644
--- a/src/com/android/telecomm/OutgoingCallsManager.java
+++ b/src/com/android/telecomm/OutgoingCallsManager.java
@@ -17,7 +17,6 @@
package com.android.telecomm;
import android.telecomm.ICallServiceSelector;
-import android.util.Log;
import com.google.common.collect.Maps;
@@ -33,8 +32,6 @@
* can simply call into this class instead of individual OutgoingCallProcessors.
*/
final class OutgoingCallsManager {
- private static final String TAG = OutgoingCallsManager.class.getSimpleName();
-
private final Switchboard mSwitchboard;
/**
@@ -60,7 +57,7 @@
void placeCall(
Call call, Set<CallServiceWrapper> callServices, List<ICallServiceSelector> selectors) {
- Log.i(TAG, "Placing an outgoing call (" + call.getId() + ")");
+ Log.i(this, "Placing an outgoing call (%s)", call.getId());
// Create the processor for this (outgoing) call and store it in a map such that call
// attempts can be aborted etc.
@@ -84,7 +81,7 @@
if (processor == null) {
// Shouldn't happen, so log a wtf if it does.
- Log.wtf(TAG, "Received an unexpected placed-call notification.");
+ Log.wtf(this, "Received an unexpected placed-call notification.");
} else {
processor.handleSuccessfulCallAttempt();
}
@@ -105,7 +102,7 @@
// TODO(santoscordon): Consider combining the check here and in handleSuccessfulCallAttempt.
if (processor == null) {
// Shouldn't happen, so log a wtf if it does.
- Log.wtf(TAG, "Received an unexpected failed-call notification.");
+ Log.wtf(this, "Received an unexpected failed-call notification.");
} else {
processor.handleFailedCallAttempt(reason);
}
diff --git a/src/com/android/telecomm/ServiceBinder.java b/src/com/android/telecomm/ServiceBinder.java
index 2b9cc5c..98ce4ca 100644
--- a/src/com/android/telecomm/ServiceBinder.java
+++ b/src/com/android/telecomm/ServiceBinder.java
@@ -22,7 +22,6 @@
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.IInterface;
-import android.util.Log;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
@@ -73,8 +72,6 @@
}
}
- private static final String TAG = ServiceBinder.class.getSimpleName();
-
/** The application context. */
private final Context mContext;
@@ -125,7 +122,7 @@
*/
final boolean bind(BindCallback callback) {
ThreadUtil.checkOnMainThread();
- Log.d(TAG, "bind()");
+ Log.d(this, "bind()");
// Reset any abort request if we're asked to bind again.
clearAbort();
@@ -142,13 +139,13 @@
Intent serviceIntent = new Intent(mServiceAction).setComponent(mComponentName);
ServiceConnection connection = new ServiceBinderConnection();
- Log.d(TAG, "Binding to call service with intent: " + serviceIntent);
+ Log.d(this, "Binding to call service with intent: %s", serviceIntent);
if (!mContext.bindService(serviceIntent, connection, Context.BIND_AUTO_CREATE)) {
handleFailedConnection();
return false;
}
} else {
- Log.d(TAG, "Service is already bound.");
+ Log.d(this, "Service is already bound.");
Preconditions.checkNotNull(mBinder);
handleSuccessfulConnection();
}
@@ -164,8 +161,8 @@
if (mAssociatedCallCount > 0) {
mAssociatedCallCount--;
} else {
- Log.wtf(TAG, mComponentName.getClassName() +
- ": ignoring a request to decrement mAssociatedCallCount below zero");
+ Log.wtf(this, "%s: ignoring a request to decrement mAssociatedCallCount below zero",
+ mComponentName.getClassName());
}
}
diff --git a/src/com/android/telecomm/Switchboard.java b/src/com/android/telecomm/Switchboard.java
index 7587419..a612a88 100644
--- a/src/com/android/telecomm/Switchboard.java
+++ b/src/com/android/telecomm/Switchboard.java
@@ -25,7 +25,6 @@
import android.telecomm.CallServiceDescriptor;
import android.telecomm.ICallServiceSelector;
import android.telecomm.TelecommConstants;
-import android.util.Log;
import java.util.Iterator;
import java.util.List;
@@ -38,8 +37,6 @@
*/
final class Switchboard {
- private final static String TAG = Switchboard.class.getSimpleName();
-
private final CallsManager mCallsManager;
/** Used to place outgoing calls. */
@@ -148,7 +145,7 @@
* {@link TelecommConstants#EXTRA_INCOMING_CALL_EXTRAS}
*/
void retrieveIncomingCall(Call call, CallServiceDescriptor descriptor, Bundle extras) {
- Log.d(TAG, "retrieveIncomingCall");
+ Log.d(this, "retrieveIncomingCall");
mBinderDeallocator.acquireUsePermit();
CallServiceWrapper callService = mCallServiceRepository.getCallService(descriptor);
@@ -200,7 +197,7 @@
* see {@link OutgoingCallProcessor}.
*/
void handleSuccessfulOutgoingCall(Call call) {
- Log.d(TAG, "handleSuccessfulOutgoingCall");
+ Log.d(this, "handleSuccessfulOutgoingCall");
mCallsManager.handleSuccessfulOutgoingCall(call);
finalizeOutgoingCall(call);
@@ -211,7 +208,7 @@
* selector/call-service implementations, see {@link OutgoingCallProcessor}.
*/
void handleFailedOutgoingCall(Call call) {
- Log.d(TAG, "handleFailedOutgoingCall");
+ Log.d(this, "handleFailedOutgoingCall");
// TODO(gilad): Notify mCallsManager.
@@ -224,7 +221,7 @@
* point, {@link CallsManager} should bring up the incoming-call UI.
*/
void handleSuccessfulIncomingCall(Call call) {
- Log.d(TAG, "handleSuccessfulIncomingCall");
+ Log.d(this, "handleSuccessfulIncomingCall");
mCallsManager.handleSuccessfulIncomingCall(call);
mBinderDeallocator.releaseUsePermit();
@@ -237,7 +234,7 @@
* @param call The call.
*/
void handleFailedIncomingCall(Call call) {
- Log.d(TAG, "handleFailedIncomingCall");
+ Log.d(this, "handleFailedIncomingCall");
// Since we set the call service before calling into incoming-calls manager, we clear it for
// good measure if an error is reported.
@@ -337,7 +334,7 @@
while (iterator.hasNext()) {
Call call = iterator.next();
if (call.getAgeInMilliseconds() >= newCallTimeoutMs) {
- Log.d(TAG, "Call " + call.getId() + " timed out.");
+ Log.d(this, "Call %s timed out.", call.getId());
mOutgoingCallsManager.abort(call);
calls.remove(call);
diff --git a/src/com/android/telecomm/ThreadUtil.java b/src/com/android/telecomm/ThreadUtil.java
index b826f58..3d5a498 100644
--- a/src/com/android/telecomm/ThreadUtil.java
+++ b/src/com/android/telecomm/ThreadUtil.java
@@ -17,7 +17,6 @@
package com.android.telecomm;
import android.os.Looper;
-import android.util.Log;
/**
* A utility class which helps organize callers' threads. This class cannot be instantiated; callers
@@ -39,7 +38,7 @@
*/
public static void checkOnMainThread() {
if (!isOnMainThread()) {
- Log.wtf(TAG, "Must be on the main thread!", new IllegalStateException());
+ Log.wtf(TAG, new IllegalStateException(), "Must be on the main thread!");
}
}
@@ -49,7 +48,7 @@
*/
public static void checkNotOnMainThread() {
if (isOnMainThread()) {
- Log.wtf(TAG, "Must not be on the main thread!", new IllegalStateException());
+ Log.wtf(TAG, new IllegalStateException(), "Must not be on the main thread!");
}
}
}