summaryrefslogtreecommitdiffstats
path: root/android/src
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-08-08 16:44:06 +0000
committerThomas Martitz <kugel@rockbox.org>2010-08-08 16:44:06 +0000
commit4a3e6dbe8ff680c8ac43d35606564e9d4d3774c0 (patch)
tree22bd125646448527a94056c1adb1fb2ad45bea9d /android/src
parent4aa3d010660dd5e785e02050ab9a87522f297f7a (diff)
downloadrockbox-4a3e6dbe8ff680c8ac43d35606564e9d4d3774c0.tar.gz
rockbox-4a3e6dbe8ff680c8ac43d35606564e9d4d3774c0.zip
A bit of cleanup.
Replace // with /* */ style comments Cleanup copy&paste from the doc examples. Don't pretend to handle exception we don't handle actually. cleanup imports git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27754 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'android/src')
-rw-r--r--android/src/org/rockbox/RockboxActivity.java2
-rw-r--r--android/src/org/rockbox/RockboxFramebuffer.java5
-rw-r--r--android/src/org/rockbox/RockboxPCM.java5
-rw-r--r--android/src/org/rockbox/RockboxService.java91
-rw-r--r--android/src/org/rockbox/RockboxTimer.java5
5 files changed, 52 insertions, 56 deletions
diff --git a/android/src/org/rockbox/RockboxActivity.java b/android/src/org/rockbox/RockboxActivity.java
index 3be9e3ed47..8d3beb99a0 100644
--- a/android/src/org/rockbox/RockboxActivity.java
+++ b/android/src/org/rockbox/RockboxActivity.java
@@ -86,8 +86,6 @@ public class RockboxActivity extends Activity {
ViewGroup g = (ViewGroup)RockboxService.fb.getParent();
g.removeView(RockboxService.fb);
setContentView(RockboxService.fb);
- } catch (Exception e) {
- LOG(e.toString());
}
RockboxService.fb.resume();
}
diff --git a/android/src/org/rockbox/RockboxFramebuffer.java b/android/src/org/rockbox/RockboxFramebuffer.java
index ca11de090c..32fbfef111 100644
--- a/android/src/org/rockbox/RockboxFramebuffer.java
+++ b/android/src/org/rockbox/RockboxFramebuffer.java
@@ -25,7 +25,6 @@ import java.nio.ByteBuffer;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
-import android.os.Handler;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
@@ -68,14 +67,14 @@ public class RockboxFramebuffer extends View
postInvalidate(x, y, x+w, y+h);
}
+ @SuppressWarnings("unused")
private void LOG(CharSequence text)
{
- Log.d("RockboxBootloader", (String) text);
+ Log.d("Rockbox", (String) text);
}
public boolean onTouchEvent(MotionEvent me)
{
- LOG("onTouchEvent");
switch (me.getAction())
{
case MotionEvent.ACTION_CANCEL:
diff --git a/android/src/org/rockbox/RockboxPCM.java b/android/src/org/rockbox/RockboxPCM.java
index eef56f501d..003ca7c74c 100644
--- a/android/src/org/rockbox/RockboxPCM.java
+++ b/android/src/org/rockbox/RockboxPCM.java
@@ -138,7 +138,7 @@ public class RockboxPCM extends AudioTrack
}
@Override
public void onMarkerReached(AudioTrack track) {
- // push new data to the hardware
+ /* push new data to the hardware */
RockboxPCM pcm = (RockboxPCM)track;
int result = -1;
pcm.pcmSamplesToByteArray(buf);
@@ -169,8 +169,7 @@ public class RockboxPCM extends AudioTrack
@Override
public void onPeriodicNotification(AudioTrack track) {
- // TODO Auto-generated method stub
-
+ // TODO Auto-generated method stub
}
}
}
diff --git a/android/src/org/rockbox/RockboxService.java b/android/src/org/rockbox/RockboxService.java
index a73f614782..8ef6b5a302 100644
--- a/android/src/org/rockbox/RockboxService.java
+++ b/android/src/org/rockbox/RockboxService.java
@@ -3,7 +3,9 @@ package org.rockbox;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Enumeration;
@@ -15,7 +17,6 @@ import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
-import android.os.Binder;
import android.os.IBinder;
import android.util.Log;
@@ -25,9 +26,9 @@ public class RockboxService extends Service
public static RockboxFramebuffer fb = null;
private static RockboxService instance;
private Notification notification;
- private static final Class[] mStartForegroundSignature = new Class[] {
+ private static final Class<?>[] mStartForegroundSignature = new Class[] {
int.class, Notification.class};
- private static final Class[] mStopForegroundSignature = new Class[] {
+ private static final Class<?>[] mStopForegroundSignature = new Class[] {
boolean.class};
private NotificationManager mNM;
@@ -45,7 +46,7 @@ public class RockboxService extends Service
mStopForeground = getClass().getMethod("stopForeground",
mStopForegroundSignature);
} catch (NoSuchMethodException e) {
- // Running on an older platform.
+ /* Running on an older platform: fall back to old API */
mStartForeground = mStopForeground = null;
}
startservice();
@@ -63,6 +64,11 @@ public class RockboxService extends Service
{
Log.d("Rockbox", (String) text);
}
+
+ private void LOG(CharSequence text, Throwable tr)
+ {
+ Log.d("Rockbox", (String) text, tr);
+ }
public void onStart(Intent intent, int startId) {
do_start(intent);
@@ -71,7 +77,7 @@ public class RockboxService extends Service
public int onStartCommand(Intent intent, int flags, int startId)
{
do_start(intent);
- return 1; /* START_STICKY */
+ return 1; /* old API compatibility: 1 == START_STICKY */
}
private void startservice()
@@ -83,8 +89,8 @@ public class RockboxService extends Service
* because there's no other way to ship files and have access
* to them from native code
*/
- try
- {
+ try
+ {
BufferedOutputStream dest = null;
BufferedInputStream is = null;
ZipEntry entry;
@@ -127,8 +133,12 @@ public class RockboxService extends Service
is.close();
}
}
- } catch(Exception e) {
- e.printStackTrace();
+ } catch(FileNotFoundException e) {
+ LOG("FileNotFoundException when unzipping", e);
+ e.printStackTrace();
+ } catch(IOException e) {
+ LOG("IOException when unzipping", e);
+ e.printStackTrace();
}
System.loadLibrary("rockbox");
@@ -149,36 +159,25 @@ public class RockboxService extends Service
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
- } /**
- * Class for clients to access. Because we know this service always
- * runs in the same process as its clients, we don't need to deal with
- * IPC.
- */
- public class LocalBinder extends Binder {
- RockboxService getService() {
- return RockboxService.this;
- }
- }
+ }
- /* heavily based on the example found on
+ /* all below is heavily based on the examples found on
* http://developer.android.com/reference/android/app/Service.html
*/
private void create_notification()
{
- // In this sample, we'll use the same text for the ticker and the expanded notification
+ /* For now we'll use the same text for the ticker and the expanded notification */
CharSequence text = getText(R.string.notification);
-
- // Set the icon, scrolling text and timestamp
+ /* Set the icon, scrolling text and timestamp */
notification = new Notification(R.drawable.icon, text,
System.currentTimeMillis());
- // The PendingIntent to launch our activity if the user selects this notification
+ /* The PendingIntent to launch our activity if the user selects this notification */
Intent intent = new Intent(this, RockboxActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, 0);
-
- // Set the info for the views that show in the notification panel.
+ /* Set the info for the views that show in the notification panel. */
notification.setLatestEventInfo(this, getText(R.string.notification), text, contentIntent);
}
@@ -186,10 +185,11 @@ public class RockboxService extends Service
{
if (instance != null)
{
- // Send the notification.
- // We use a layout id because it is a unique number. We use it later to cancel.
+ /*
+ * Send the notification.
+ * We use a layout id because it is a unique number. We use it later to cancel.
+ */
instance.mNM.notify(R.string.notification, instance.notification);
-
/*
* this call makes the service run as foreground, which
* provides enough cpu time to do music decoding in the
@@ -212,24 +212,24 @@ public class RockboxService extends Service
* This is a wrapper around the new startForeground method, using the older
* APIs if it is not available.
*/
- void startForegroundCompat(int id, Notification notification) {
- // If we have the new startForeground API, then use it.
+ void startForegroundCompat(int id, Notification notification)
+ {
if (mStartForeground != null) {
mStartForegroundArgs[0] = Integer.valueOf(id);
mStartForegroundArgs[1] = notification;
try {
mStartForeground.invoke(this, mStartForegroundArgs);
} catch (InvocationTargetException e) {
- // Should not happen.
- Log.w("ApiDemos", "Unable to invoke startForeground", e);
+ /* Should not happen. */
+ LOG("Unable to invoke startForeground", e);
} catch (IllegalAccessException e) {
- // Should not happen.
- Log.w("ApiDemos", "Unable to invoke startForeground", e);
+ /* Should not happen. */
+ LOG("Unable to invoke startForeground", e);
}
return;
}
- // Fall back on the old API.
+ /* Fall back on the old API.*/
setForeground(true);
mNM.notify(id, notification);
}
@@ -238,31 +238,32 @@ public class RockboxService extends Service
* This is a wrapper around the new stopForeground method, using the older
* APIs if it is not available.
*/
- void stopForegroundCompat(int id) {
- // If we have the new stopForeground API, then use it.
+ void stopForegroundCompat(int id)
+ {
if (mStopForeground != null) {
mStopForegroundArgs[0] = Boolean.TRUE;
try {
mStopForeground.invoke(this, mStopForegroundArgs);
} catch (InvocationTargetException e) {
- // Should not happen.
- Log.w("ApiDemos", "Unable to invoke stopForeground", e);
+ /* Should not happen. */
+ LOG("Unable to invoke stopForeground", e);
} catch (IllegalAccessException e) {
- // Should not happen.
- Log.w("ApiDemos", "Unable to invoke stopForeground", e);
+ /* Should not happen. */
+ LOG("Unable to invoke stopForeground", e);
}
return;
}
- // Fall back on the old API. Note to cancel BEFORE changing the
- // foreground state, since we could be killed at that point.
+ /* Fall back on the old API. Note to cancel BEFORE changing the
+ * foreground state, since we could be killed at that point. */
mNM.cancel(id);
setForeground(false);
}
@Override
public void onDestroy() {
- // Make sure our notification is gone.
+ super.onDestroy();
+ /* Make sure our notification is gone. */
stopForegroundCompat(R.string.notification);
}
}
diff --git a/android/src/org/rockbox/RockboxTimer.java b/android/src/org/rockbox/RockboxTimer.java
index 68a0e866fb..a38e6c12d6 100644
--- a/android/src/org/rockbox/RockboxTimer.java
+++ b/android/src/org/rockbox/RockboxTimer.java
@@ -75,6 +75,7 @@ public class RockboxTimer extends Timer
interval = period_inverval_in_ms;
}
+ @SuppressWarnings("unused")
private void LOG(CharSequence text)
{
Log.d("Rockbox", (String) text);
@@ -88,9 +89,7 @@ public class RockboxTimer extends Timer
try {
this.wait();
} catch (InterruptedException e) {
- /* wakeup and return */
- } catch (Exception e) {
- LOG(e.toString());
+ /* Not an error: wakeup and return */
}
}
}