summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSantos Cordon <santoscordon@google.com>2013-08-05 02:47:03 -0700
committerSantos Cordon <santoscordon@google.com>2013-08-05 22:04:00 +0000
commitb585c66c5fbf485256ef8fef5b0d06f51d8d9bf5 (patch)
treeeeb32aea02a8e620c54c8b20705304e356eeb2bb
parent7ac6cb331919db2a3a8985e4cb3299b309d9012a (diff)
Adding a central logging class.
Change-Id: I24f68d5ebcfed2740f9645736c35edf17efb4769
-rw-r--r--InCallUI/src/com/android/incallui/AnswerPresenter.java10
-rw-r--r--InCallUI/src/com/android/incallui/CallButtonFragment.java1
-rw-r--r--InCallUI/src/com/android/incallui/CallCardPresenter.java10
-rw-r--r--InCallUI/src/com/android/incallui/CallCommandClient.java13
-rw-r--r--InCallUI/src/com/android/incallui/CallHandlerService.java12
-rw-r--r--InCallUI/src/com/android/incallui/CallList.java18
-rw-r--r--InCallUI/src/com/android/incallui/GlowPadWrapper.java24
-rw-r--r--InCallUI/src/com/android/incallui/InCallActivity.java31
-rw-r--r--InCallUI/src/com/android/incallui/InCallPresenter.java13
-rw-r--r--InCallUI/src/com/android/incallui/Logger.java59
10 files changed, 93 insertions, 98 deletions
diff --git a/InCallUI/src/com/android/incallui/AnswerPresenter.java b/InCallUI/src/com/android/incallui/AnswerPresenter.java
index c491c7e57..5663fd94f 100644
--- a/InCallUI/src/com/android/incallui/AnswerPresenter.java
+++ b/InCallUI/src/com/android/incallui/AnswerPresenter.java
@@ -18,8 +18,6 @@ package com.android.incallui;
import com.google.common.base.Preconditions;
-import android.util.Log;
-
import com.android.incallui.InCallPresenter.InCallState;
import com.android.incallui.InCallPresenter.InCallStateListener;
import com.android.services.telephony.common.Call;
@@ -29,8 +27,6 @@ import com.android.services.telephony.common.Call;
*/
public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi>
implements InCallStateListener {
- private static final String TAG = AnswerPresenter.class.getSimpleName();
- private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private Call mCall;
@@ -45,9 +41,7 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi>
getUi().showAnswerUi(true);
mCall = callList.getIncomingCall();
- if (DEBUG) {
- Log.d(TAG, "Showing incoming with: " + mCall);
- }
+ Logger.d(this, "Showing incoming with: " + mCall);
} else {
getUi().showAnswerUi(false);
mCall = null;
@@ -56,12 +50,14 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi>
public void onAnswer() {
Preconditions.checkNotNull(mCall);
+ Logger.d(this, "onAnswer");
CallCommandClient.getInstance().answerCall(mCall.getCallId());
}
public void onDecline() {
Preconditions.checkNotNull(mCall);
+ Logger.d(this, "onDecline");
CallCommandClient.getInstance().disconnectCall(mCall.getCallId());
}
diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java
index 619720e02..3ccc1d1d1 100644
--- a/InCallUI/src/com/android/incallui/CallButtonFragment.java
+++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java
@@ -19,7 +19,6 @@ package com.android.incallui;
import android.content.Context;
import android.media.AudioManager;
import android.os.Bundle;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java
index d5632a6f0..5f1f3b747 100644
--- a/InCallUI/src/com/android/incallui/CallCardPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java
@@ -16,8 +16,6 @@
package com.android.incallui;
-import android.util.Log;
-
import com.android.incallui.InCallPresenter.InCallState;
import com.android.incallui.InCallPresenter.InCallStateListener;
import com.android.services.telephony.common.Call;
@@ -28,8 +26,6 @@ import com.android.services.telephony.common.Call;
*/
public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
implements InCallStateListener {
- private static final String TAG = CallCardPresenter.class.getSimpleName();
- private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
@Override
public void onUiReady(CallCardUi ui) {
@@ -50,10 +46,8 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
secondary = callList.getBackgroundCall();
}
- if (DEBUG) {
- Log.d(TAG, "Primary call: " + primary);
- Log.d(TAG, "Secondary call: " + secondary);
- }
+ Logger.d(this, "Primary call: " + primary);
+ Logger.d(this, "Secondary call: " + secondary);
// Set primary call data
if (primary != null) {
diff --git a/InCallUI/src/com/android/incallui/CallCommandClient.java b/InCallUI/src/com/android/incallui/CallCommandClient.java
index c63158809..94ec3f525 100644
--- a/InCallUI/src/com/android/incallui/CallCommandClient.java
+++ b/InCallUI/src/com/android/incallui/CallCommandClient.java
@@ -17,7 +17,6 @@
package com.android.incallui;
import android.os.RemoteException;
-import android.util.Log;
import com.android.internal.util.Preconditions;
import com.android.services.telephony.common.ICallCommandService;
@@ -27,8 +26,6 @@ import com.android.services.telephony.common.ICallCommandService;
*/
public class CallCommandClient {
- private static final String TAG = CallCommandClient.class.getSimpleName();
-
private static CallCommandClient sInstance;
public static CallCommandClient getInstance() {
@@ -55,7 +52,7 @@ public class CallCommandClient {
try {
mCommandService.answerCall(callId);
} catch (RemoteException e) {
- Log.e(TAG, "Error answering call.", e);
+ Logger.e(this, "Error answering call.", e);
}
}
@@ -63,7 +60,7 @@ public class CallCommandClient {
try {
mCommandService.disconnectCall(callId);
} catch (RemoteException e) {
- Log.e(TAG, "Error answering call.", e);
+ Logger.e(this, "Error answering call.", e);
}
}
@@ -71,7 +68,7 @@ public class CallCommandClient {
try {
mCommandService.mute(onOff);
} catch (RemoteException e) {
- Log.e(TAG, "Error muting phone.", e);
+ Logger.e(this, "Error muting phone.", e);
}
}
@@ -79,7 +76,7 @@ public class CallCommandClient {
try {
mCommandService.hold(callId, onOff);
} catch (RemoteException e) {
- Log.e(TAG, "Error holding call.", e);
+ Logger.e(this, "Error holding call.", e);
}
}
@@ -87,7 +84,7 @@ public class CallCommandClient {
try {
mCommandService.speaker(onOff);
} catch (RemoteException e) {
- Log.e(TAG, "Error setting speaker.", e);
+ Logger.e(this, "Error setting speaker.", e);
}
}
}
diff --git a/InCallUI/src/com/android/incallui/CallHandlerService.java b/InCallUI/src/com/android/incallui/CallHandlerService.java
index ebb69d732..ad4772976 100644
--- a/InCallUI/src/com/android/incallui/CallHandlerService.java
+++ b/InCallUI/src/com/android/incallui/CallHandlerService.java
@@ -21,7 +21,6 @@ import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
-import android.util.Log;
import com.android.services.telephony.common.Call;
import com.android.services.telephony.common.ICallCommandService;
@@ -34,9 +33,6 @@ import java.util.List;
*/
public class CallHandlerService extends Service {
- private static final String TAG = CallHandlerService.class.getSimpleName();
- private static final boolean DBG = false; // TODO: Have a shared location for this.
-
private static final int ON_UPDATE_CALL = 1;
private static final int ON_UPDATE_MULTI_CALL = 2;
@@ -68,7 +64,7 @@ public class CallHandlerService extends Service {
@Override
public void setCallCommandService(ICallCommandService service) {
- logD("onConnected: " + service.toString());
+ Logger.d(this, "onConnected: " + service.toString());
CallCommandClient.init(service);
}
@@ -84,12 +80,6 @@ public class CallHandlerService extends Service {
}
};
- private void logD(String message) {
- if (DBG) {
- Log.d(TAG, message);
- }
- }
-
/**
* Handles messages from the service so that they get executed on the main thread, where they
* can interact with UI.
diff --git a/InCallUI/src/com/android/incallui/CallList.java b/InCallUI/src/com/android/incallui/CallList.java
index 5852ec723..17e719e7c 100644
--- a/InCallUI/src/com/android/incallui/CallList.java
+++ b/InCallUI/src/com/android/incallui/CallList.java
@@ -23,8 +23,6 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import android.util.Log;
-
import com.android.services.telephony.common.Call;
import java.util.HashMap;
@@ -38,8 +36,6 @@ import java.util.Set;
* Primary lister of changes to this class is InCallPresenter.
*/
public class CallList {
- private static final String TAG = CallList.class.getSimpleName();
- private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private static final Map<Integer, String> STATE_MAP = ImmutableMap.<Integer, String>builder()
.put(Call.State.ACTIVE, "ACTIVE")
.put(Call.State.CALL_WAITING, "CALL_WAITING")
@@ -75,7 +71,7 @@ public class CallList {
* Called when a single call has changed.
*/
public void onUpdate(Call call) {
- logD("onUpdate - " + safeCallString(call));
+ Logger.d(this, "onUpdate - " + safeCallString(call));
updateCallInMap(call);
notifyListenersOfChange();
@@ -85,11 +81,11 @@ public class CallList {
* Called when multiple calls have changed.
*/
public void onUpdate(List<Call> callsToUpdate) {
- logD("onUpdate(...)");
+ Logger.d(this, "onUpdate(...)");
Preconditions.checkNotNull(callsToUpdate);
for (Call call : callsToUpdate) {
- logD("\t" + safeCallString(call));
+ Logger.d(this, "\t" + safeCallString(call));
updateCallInMap(call);
}
@@ -157,7 +153,7 @@ public class CallList {
}
}
- logD("Found " + (retval == null ? "no " : "") + "call with state: " +
+ Logger.d(this, "Found " + (retval == null ? "no " : "") + "call with state: " +
STATE_MAP.get(state));
return retval;
}
@@ -189,12 +185,6 @@ public class CallList {
return Call.State.IDLE == state || Call.State.INVALID == state;
}
- private void logD(String msg) {
- if (DEBUG) {
- Log.d(TAG, msg);
- }
- }
-
/**
* Creates a log-safe string for call objects.
*/
diff --git a/InCallUI/src/com/android/incallui/GlowPadWrapper.java b/InCallUI/src/com/android/incallui/GlowPadWrapper.java
index 4403e6b6d..fbc85ef5d 100644
--- a/InCallUI/src/com/android/incallui/GlowPadWrapper.java
+++ b/InCallUI/src/com/android/incallui/GlowPadWrapper.java
@@ -21,7 +21,6 @@ import android.os.Handler;
import android.os.Message;
import android.os.Parcelable;
import android.util.AttributeSet;
-import android.util.Log;
import android.view.View;
import com.android.incallui.widget.multiwaveview.GlowPadView;
@@ -31,9 +30,6 @@ import com.android.incallui.widget.multiwaveview.GlowPadView;
*/
public class GlowPadWrapper extends GlowPadView implements GlowPadView.OnTriggerListener {
- private static final String TAG = GlowPadWrapper.class.getSimpleName();
- private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
-
// Parameters for the GlowPadView "ping" animation; see triggerPing().
private static final int PING_MESSAGE_WHAT = 101;
private static final boolean ENABLE_PING_AUTO_REPEAT = true;
@@ -63,7 +59,7 @@ public class GlowPadWrapper extends GlowPadView implements GlowPadView.OnTrigger
@Override
protected void onFinishInflate() {
- logD("onFinishInflate()");
+ Logger.d(this, "onFinishInflate()");
super.onFinishInflate();
setOnTriggerListener(this);
startPing();
@@ -71,7 +67,7 @@ public class GlowPadWrapper extends GlowPadView implements GlowPadView.OnTrigger
@Override
protected void onWindowVisibilityChanged(int visibility) {
- logD("Visibility changed " + visibility);
+ Logger.d(this, "Visibility changed " + visibility);
super.onWindowVisibilityChanged(visibility);
switch (visibility) {
case View.VISIBLE:
@@ -86,7 +82,7 @@ public class GlowPadWrapper extends GlowPadView implements GlowPadView.OnTrigger
@Override
protected Parcelable onSaveInstanceState() {
- logD("onSaveInstanceState()");
+ Logger.d(this, "onSaveInstanceState()");
// TODO: evaluate this versus stopping during fragment onPause/onResume
stopPing();
return super.onSaveInstanceState();
@@ -113,19 +109,19 @@ public class GlowPadWrapper extends GlowPadView implements GlowPadView.OnTrigger
@Override
public void onGrabbed(View v, int handle) {
- logD("onGrabbed()");
+ Logger.d(this, "onGrabbed()");
stopPing();
}
@Override
public void onReleased(View v, int handle) {
- logD("onReleased()");
+ Logger.d(this, "onReleased()");
startPing();
}
@Override
public void onTrigger(View v, int target) {
- logD("onTrigger()");
+ Logger.d(this, "onTrigger()");
final int resId = getResourceIdForTarget(target);
switch (resId) {
case R.drawable.ic_lockscreen_answer:
@@ -139,7 +135,7 @@ public class GlowPadWrapper extends GlowPadView implements GlowPadView.OnTrigger
break;
default:
// Code should never reach here.
- Log.e(TAG, "Trigger detected on unhandled resource. Skipping.");
+ Logger.e(this, "Trigger detected on unhandled resource. Skipping.");
}
}
@@ -162,10 +158,4 @@ public class GlowPadWrapper extends GlowPadView implements GlowPadView.OnTrigger
void onDecline();
void onText();
}
-
- private void logD(String msg) {
- if (DEBUG) {
- Log.d(TAG, msg);
- }
- }
}
diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java
index f63b52ef8..89450c534 100644
--- a/InCallUI/src/com/android/incallui/InCallActivity.java
+++ b/InCallUI/src/com/android/incallui/InCallActivity.java
@@ -20,7 +20,6 @@ import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
-import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
@@ -31,17 +30,13 @@ import android.widget.Toast;
* Phone app "in call" screen.
*/
public class InCallActivity extends Activity {
- private static final String TAG = InCallActivity.class.getSimpleName();
- private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
- private static final boolean VERBOSE = Log.isLoggable(TAG, Log.VERBOSE);
-
private CallButtonFragment mCallButtonFragment;
private CallCardFragment mCallCardFragment;
private AnswerFragment mAnswerFragment;
@Override
protected void onCreate(Bundle icicle) {
- logD("onCreate()... this = " + this);
+ Logger.d(this, "onCreate()... this = " + this);
super.onCreate(icicle);
@@ -59,12 +54,12 @@ public class InCallActivity extends Activity {
initializeInCall();
- logD("onCreate(): exit");
+ Logger.d(this, "onCreate(): exit");
}
@Override
protected void onResume() {
- logD("onResume()...");
+ Logger.d(this, "onResume()...");
super.onResume();
}
@@ -72,19 +67,19 @@ public class InCallActivity extends Activity {
// in the background.
@Override
protected void onPause() {
- logD("onPause()...");
+ Logger.d(this, "onPause()...");
super.onPause();
}
@Override
protected void onStop() {
- logD("onStop()...");
+ Logger.d(this, "onStop()...");
super.onStop();
}
@Override
protected void onDestroy() {
- logD("onDestroy()... this = " + this);
+ Logger.d(this, "onDestroy()... this = " + this);
super.onDestroy();
}
@@ -105,7 +100,7 @@ public class InCallActivity extends Activity {
*/
@Override
public void finish() {
- logD("finish()...");
+ Logger.d(this, "finish()...");
super.finish();
// TODO(klp): Actually finish the activity for now. Revisit performance implications of
@@ -115,7 +110,7 @@ public class InCallActivity extends Activity {
@Override
protected void onNewIntent(Intent intent) {
- logD("onNewIntent: intent = " + intent);
+ Logger.d(this, "onNewIntent: intent = " + intent);
// We're being re-launched with a new Intent. Since it's possible for a
// single InCallActivity instance to persist indefinitely (even if we
@@ -174,8 +169,8 @@ public class InCallActivity extends Activity {
// Various testing/debugging features, enabled ONLY when VERBOSE == true.
case KeyEvent.KEYCODE_SLASH:
- if (VERBOSE) {
- Log.v(TAG, "----------- InCallActivity View dump --------------");
+ if (Logger.VERBOSE) {
+ Logger.v(this, "----------- InCallActivity View dump --------------");
// Dump starting from the top-level view of the entire activity:
Window w = this.getWindow();
View decorView = w.getDecorView();
@@ -230,10 +225,4 @@ public class InCallActivity extends Activity {
toast.show();
}
-
- private void logD(String msg) {
- if (DEBUG) {
- Log.d(TAG, msg);
- }
- }
}
diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java
index b73e65a32..118c030c2 100644
--- a/InCallUI/src/com/android/incallui/InCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/InCallPresenter.java
@@ -21,7 +21,6 @@ import com.google.common.base.Preconditions;
import android.content.Context;
import android.content.Intent;
-import android.util.Log;
import java.util.Set;
@@ -34,8 +33,6 @@ import java.util.Set;
* that want to listen in on the in-call state changes.
*/
public class InCallPresenter implements CallList.Listener {
- private static final String TAG = InCallPresenter.class.getSimpleName();
- private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private static InCallPresenter sInCallPresenter;
@@ -52,7 +49,7 @@ public class InCallPresenter implements CallList.Listener {
}
public void init(Context context) {
- Log.i(TAG, "InCallPresenter initialized with context " + context);
+ Logger.i(this, "InCallPresenter initialized with context " + context);
Preconditions.checkState(mContext == null);
mContext = context;
@@ -97,7 +94,7 @@ public class InCallPresenter implements CallList.Listener {
// notify listeners of new state
for (InCallStateListener listener : mListeners) {
- logD("Notify " + listener + " of state " + mInCallState.toString());
+ Logger.d(this, "Notify " + listener + " of state " + mInCallState.toString());
listener.onStateChange(mInCallState, callList);
}
}
@@ -155,12 +152,6 @@ public class InCallPresenter implements CallList.Listener {
CallList.getInstance().addListener(this);
}
- private void logD(String msg) {
- if (DEBUG) {
- Log.d(TAG, msg);
- }
- }
-
/**
* All the main states of InCallActivity.
*/
diff --git a/InCallUI/src/com/android/incallui/Logger.java b/InCallUI/src/com/android/incallui/Logger.java
new file mode 100644
index 000000000..dd4985598
--- /dev/null
+++ b/InCallUI/src/com/android/incallui/Logger.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2006 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.incallui;
+
+import android.util.Log;
+
+/**
+ * Manages logging for the entire class.
+ */
+/*package*/ class Logger {
+
+ // Generic tag for all In Call logging
+ private static final String TAG = "InCall";
+
+ public static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+ public static final boolean VERBOSE = Log.isLoggable(TAG, Log.VERBOSE);
+
+ public static void d(Object obj, String msg) {
+ if (DEBUG) {
+ Log.d(TAG, getPrefix(obj) + msg);
+ }
+ }
+
+ public static void v(Object obj, String msg) {
+ if (VERBOSE) {
+ Log.v(TAG, getPrefix(obj) + msg);
+ }
+ }
+
+ public static void e(Object obj, String msg, Exception e) {
+ Log.e(TAG, getPrefix(obj) + msg, e);
+ }
+
+ public static void e(Object obj, String msg) {
+ Log.e(TAG, getPrefix(obj) + msg);
+ }
+
+ public static void i(Object obj, String msg) {
+ Log.i(TAG, getPrefix(obj) + msg);
+ }
+
+ private static String getPrefix(Object obj) {
+ return (obj == null ? "" : (obj.getClass().getSimpleName() + " - "));
+ }
+}