Android: Slightly rework logging to logcat by offloading duplicated code to a new helper class.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30161 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Martitz 2011-07-18 21:26:03 +00:00
parent 33de9cdaef
commit 02b2b285d6
5 changed files with 6 additions and 35 deletions

View file

@ -29,7 +29,6 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.media.AudioManager; import android.media.AudioManager;
import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
public class MediaButtonReceiver public class MediaButtonReceiver
@ -144,7 +143,7 @@ public class MediaButtonReceiver
public void onAudioFocusChange(int focusChange) public void onAudioFocusChange(int focusChange)
{ {
Log.d("Rockbox", "Audio focus" + ((focusChange>0)?"gained":"lost")+ Logger.d("Audio focus" + ((focusChange>0)?"gained":"lost")+
": "+ focusChange); ": "+ focusChange);
if (running) if (running)
{ /* Play nice and stop for the the other app */ { /* Play nice and stop for the the other app */

View file

@ -40,16 +40,6 @@ public class RunForegroundManager
initForegroundCompat(); initForegroundCompat();
} }
private void LOG(CharSequence text)
{
Log.d("Rockbox", (String)text);
}
private void LOG(CharSequence text, Throwable tr)
{
Log.d("Rockbox", (String)text, tr);
}
public void startForeground() public void startForeground()
{ {
startForegroundCompat(R.string.notification, mNotification); startForegroundCompat(R.string.notification, mNotification);

View file

@ -28,7 +28,6 @@ import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.ResultReceiver; import android.os.ResultReceiver;
import android.util.Log;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.Toast; import android.widget.Toast;
@ -129,9 +128,4 @@ public class RockboxActivity extends Activity
super.onDestroy(); super.onDestroy();
setServiceActivity(false); setServiceActivity(false);
} }
private void LOG(CharSequence text)
{
Log.d("Rockbox", (String) text);
}
} }

View file

@ -28,7 +28,6 @@ import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Rect; import android.graphics.Rect;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.SurfaceHolder; import android.view.SurfaceHolder;
@ -96,11 +95,6 @@ public class RockboxFramebuffer extends SurfaceView
holder.unlockCanvasAndPost(c); holder.unlockCanvasAndPost(c);
} }
private void LOG(CharSequence text)
{
Log.d("Rockbox", (String) text);
}
public boolean onTouchEvent(MotionEvent me) public boolean onTouchEvent(MotionEvent me)
{ {
int x = (int) me.getX(); int x = (int) me.getX();

View file

@ -22,6 +22,7 @@
package org.rockbox; package org.rockbox;
import java.util.Arrays; import java.util.Arrays;
import org.rockbox.Helper.Logger;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -32,7 +33,6 @@ import android.media.AudioTrack;
import android.os.Handler; import android.os.Handler;
import android.os.HandlerThread; import android.os.HandlerThread;
import android.os.Process; import android.os.Process;
import android.util.Log;
public class RockboxPCM extends AudioTrack public class RockboxPCM extends AudioTrack
{ {
@ -58,11 +58,6 @@ public class RockboxPCM extends AudioTrack
private float curpcmvolume = 0; private float curpcmvolume = 0;
private float pcmrange; private float pcmrange;
private void LOG(CharSequence text)
{
Log.d("Rockbox", (String) text);
}
public RockboxPCM() public RockboxPCM()
{ {
super(streamtype, samplerate, channels, encoding, super(streamtype, samplerate, channels, encoding,
@ -99,7 +94,7 @@ public class RockboxPCM extends AudioTrack
{ {
int rbvolume = ((maxstreamvolume - volume) * -99) / int rbvolume = ((maxstreamvolume - volume) * -99) /
maxstreamvolume; maxstreamvolume;
LOG("java:postVolumeChangedEvent, avol "+volume+" rbvol "+rbvolume); Logger.d("java:postVolumeChangedEvent, avol "+volume+" rbvol "+rbvolume);
postVolumeChangedEvent(rbvolume); postVolumeChangedEvent(rbvolume);
} }
@ -138,7 +133,6 @@ public class RockboxPCM extends AudioTrack
new IntentFilter("android.media.VOLUME_CHANGED_ACTION")); new IntentFilter("android.media.VOLUME_CHANGED_ACTION"));
} }
@SuppressWarnings("unused")
private int bytes2frames(int bytes) private int bytes2frames(int bytes)
{ {
/* 1 sample is 2 bytes, 2 samples are 1 frame */ /* 1 sample is 2 bytes, 2 samples are 1 frame */
@ -213,7 +207,7 @@ public class RockboxPCM extends AudioTrack
@SuppressWarnings("unused") @SuppressWarnings("unused")
private void set_volume(int volume) private void set_volume(int volume)
{ {
LOG("java:set_volume("+volume+")"); Logger.d("java:set_volume("+volume+")");
/* Rockbox 'volume' is 0..-990 deci-dB attenuation. /* Rockbox 'volume' is 0..-990 deci-dB attenuation.
Android streams have rather low resolution volume control, Android streams have rather low resolution volume control,
typically 8 or 15 steps. typically 8 or 15 steps.
@ -233,7 +227,7 @@ public class RockboxPCM extends AudioTrack
int oldstreamvolume = audiomanager.getStreamVolume(streamtype); int oldstreamvolume = audiomanager.getStreamVolume(streamtype);
if (streamvolume != oldstreamvolume) { if (streamvolume != oldstreamvolume) {
LOG("java:setStreamVolume("+streamvolume+")"); Logger.d("java:setStreamVolume("+streamvolume+")");
setstreamvolume = streamvolume; setstreamvolume = streamvolume;
audiomanager.setStreamVolume(streamtype, streamvolume, 0); audiomanager.setStreamVolume(streamtype, streamvolume, 0);
} }
@ -264,7 +258,7 @@ public class RockboxPCM extends AudioTrack
setNotificationMarkerPosition(pcm.refillmark); setNotificationMarkerPosition(pcm.refillmark);
break; break;
case PLAYSTATE_STOPPED: case PLAYSTATE_STOPPED:
LOG("Stopped"); Logger.d("Stopped");
break; break;
} }
} }