forked from len0rd/rockbox
Code style changes in the java part (whitespaces and braces) to match Rockbox coding style.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28065 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
54c838d2ae
commit
282adacb54
5 changed files with 549 additions and 528 deletions
|
|
@ -29,7 +29,8 @@ import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
public class RockboxActivity extends Activity {
|
public class RockboxActivity extends Activity
|
||||||
|
{
|
||||||
/** Called when the activity is first created. */
|
/** Called when the activity is first created. */
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState)
|
public void onCreate(Bundle savedInstanceState)
|
||||||
|
|
@ -52,7 +53,8 @@ public class RockboxActivity extends Activity {
|
||||||
* This thread waits for the fb to become ready */
|
* This thread waits for the fb to become ready */
|
||||||
new Thread(new Runnable()
|
new Thread(new Runnable()
|
||||||
{
|
{
|
||||||
public void run() {
|
public void run()
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
while (RockboxService.fb == null)
|
while (RockboxService.fb == null)
|
||||||
Thread.sleep(250);
|
Thread.sleep(250);
|
||||||
|
|
@ -95,19 +97,22 @@ public class RockboxActivity extends Activity {
|
||||||
* which is nice
|
* which is nice
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause()
|
||||||
|
{
|
||||||
super.onPause();
|
super.onPause();
|
||||||
RockboxService.fb.suspend();
|
RockboxService.fb.suspend();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop()
|
||||||
|
{
|
||||||
super.onStop();
|
super.onStop();
|
||||||
RockboxService.fb.suspend();
|
RockboxService.fb.suspend();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy()
|
||||||
|
{
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
RockboxService.fb.suspend();
|
RockboxService.fb.suspend();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,6 @@ public class RockboxFramebuffer extends View
|
||||||
{
|
{
|
||||||
/* can't copy a partial buffer */
|
/* can't copy a partial buffer */
|
||||||
btm.copyPixelsFromBuffer(native_buf);
|
btm.copyPixelsFromBuffer(native_buf);
|
||||||
|
|
||||||
postInvalidate(x, y, x+w, y+h);
|
postInvalidate(x, y, x+w, y+h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,12 +59,14 @@ public class RockboxPCM extends AudioTrack
|
||||||
l = new PCMListener(buf_len);
|
l = new PCMListener(buf_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 */
|
||||||
return (bytes/4);
|
return (bytes/4);
|
||||||
}
|
}
|
||||||
|
|
||||||
int frames2bytes(int frames) {
|
private int frames2bytes(int frames)
|
||||||
|
{
|
||||||
/* 1 frame is 2 samples, 1 sample is 2 bytes */
|
/* 1 frame is 2 samples, 1 sample is 2 bytes */
|
||||||
return (frames*4);
|
return (frames*4);
|
||||||
}
|
}
|
||||||
|
|
@ -125,18 +127,21 @@ public class RockboxPCM extends AudioTrack
|
||||||
|
|
||||||
public native void pcmSamplesToByteArray(byte[] dest);
|
public native void pcmSamplesToByteArray(byte[] dest);
|
||||||
|
|
||||||
private class PCMListener implements OnPlaybackPositionUpdateListener {
|
private class PCMListener implements OnPlaybackPositionUpdateListener
|
||||||
int max_len;
|
{
|
||||||
int refill_mark;
|
private int max_len;
|
||||||
byte[] buf;
|
private int refill_mark;
|
||||||
public PCMListener(int len) {
|
private byte[] buf;
|
||||||
|
public PCMListener(int len)
|
||||||
|
{
|
||||||
max_len = len;
|
max_len = len;
|
||||||
/* refill to 100% when reached the 25% */
|
/* refill to 100% when reached the 25% */
|
||||||
buf = new byte[max_len*3/4];
|
buf = new byte[max_len*3/4];
|
||||||
refill_mark = max_len - buf.length;
|
refill_mark = max_len - buf.length;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onMarkerReached(AudioTrack track) {
|
public void onMarkerReached(AudioTrack track)
|
||||||
|
{
|
||||||
/* push new data to the hardware */
|
/* push new data to the hardware */
|
||||||
RockboxPCM pcm = (RockboxPCM)track;
|
RockboxPCM pcm = (RockboxPCM)track;
|
||||||
int result = -1;
|
int result = -1;
|
||||||
|
|
@ -149,7 +154,8 @@ public class RockboxPCM extends AudioTrack
|
||||||
case AudioTrack.PLAYSTATE_PLAYING:
|
case AudioTrack.PLAYSTATE_PLAYING:
|
||||||
case AudioTrack.PLAYSTATE_PAUSED:
|
case AudioTrack.PLAYSTATE_PAUSED:
|
||||||
/* refill at 25% no matter of how many bytes we've written */
|
/* refill at 25% no matter of how many bytes we've written */
|
||||||
if (setNotificationMarkerPosition(bytes2frames(refill_mark)) != AudioTrack.SUCCESS)
|
if (setNotificationMarkerPosition(bytes2frames(refill_mark))
|
||||||
|
!= AudioTrack.SUCCESS)
|
||||||
LOG("Error in onMarkerReached: Could not set notification marker");
|
LOG("Error in onMarkerReached: Could not set notification marker");
|
||||||
else /* recharge */
|
else /* recharge */
|
||||||
setPlaybackPositionUpdateListener(this, h);
|
setPlaybackPositionUpdateListener(this, h);
|
||||||
|
|
@ -167,8 +173,8 @@ public class RockboxPCM extends AudioTrack
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPeriodicNotification(AudioTrack track) {
|
public void onPeriodicNotification(AudioTrack track)
|
||||||
// TODO Auto-generated method stub
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,16 +65,20 @@ public class RockboxService extends Service
|
||||||
private IntentFilter itf;
|
private IntentFilter itf;
|
||||||
private BroadcastReceiver batt_monitor;
|
private BroadcastReceiver batt_monitor;
|
||||||
private int battery_level;
|
private int battery_level;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate()
|
public void onCreate()
|
||||||
{
|
{
|
||||||
mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
|
mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
mStartForeground = getClass().getMethod("startForeground",
|
mStartForeground = getClass().getMethod("startForeground",
|
||||||
mStartForegroundSignature);
|
mStartForegroundSignature);
|
||||||
mStopForeground = getClass().getMethod("stopForeground",
|
mStopForeground = getClass().getMethod("stopForeground",
|
||||||
mStopForegroundSignature);
|
mStopForegroundSignature);
|
||||||
} catch (NoSuchMethodException e) {
|
}
|
||||||
|
catch (NoSuchMethodException e)
|
||||||
|
{
|
||||||
/* Running on an older platform: fall back to old API */
|
/* Running on an older platform: fall back to old API */
|
||||||
mStartForeground = mStopForeground = null;
|
mStartForeground = mStopForeground = null;
|
||||||
}
|
}
|
||||||
|
|
@ -131,7 +135,8 @@ public class RockboxService extends Service
|
||||||
ZipFile zipfile = new ZipFile(file);
|
ZipFile zipfile = new ZipFile(file);
|
||||||
Enumeration<? extends ZipEntry> e = zipfile.entries();
|
Enumeration<? extends ZipEntry> e = zipfile.entries();
|
||||||
File folder;
|
File folder;
|
||||||
while(e.hasMoreElements()) {
|
while(e.hasMoreElements())
|
||||||
|
{
|
||||||
entry = (ZipEntry) e.nextElement();
|
entry = (ZipEntry) e.nextElement();
|
||||||
LOG("Extracting: " +entry);
|
LOG("Extracting: " +entry);
|
||||||
if (entry.isDirectory())
|
if (entry.isDirectory())
|
||||||
|
|
@ -140,7 +145,7 @@ public class RockboxService extends Service
|
||||||
LOG("mkdir "+ entry);
|
LOG("mkdir "+ entry);
|
||||||
try {
|
try {
|
||||||
folder.mkdirs();
|
folder.mkdirs();
|
||||||
} catch (SecurityException ex){
|
} catch (SecurityException ex) {
|
||||||
LOG(ex.getMessage());
|
LOG(ex.getMessage());
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -154,9 +159,8 @@ public class RockboxService extends Service
|
||||||
folder.mkdirs();
|
folder.mkdirs();
|
||||||
FileOutputStream fos = new FileOutputStream(entry.getName());
|
FileOutputStream fos = new FileOutputStream(entry.getName());
|
||||||
dest = new BufferedOutputStream(fos, BUFFER);
|
dest = new BufferedOutputStream(fos, BUFFER);
|
||||||
while ((count = is.read(data, 0, BUFFER)) != -1) {
|
while ((count = is.read(data, 0, BUFFER)) != -1)
|
||||||
dest.write(data, 0, count);
|
dest.write(data, 0, count);
|
||||||
}
|
|
||||||
dest.flush();
|
dest.flush();
|
||||||
dest.close();
|
dest.close();
|
||||||
is.close();
|
is.close();
|
||||||
|
|
@ -185,7 +189,8 @@ public class RockboxService extends Service
|
||||||
|
|
||||||
private native void main();
|
private native void main();
|
||||||
@Override
|
@Override
|
||||||
public IBinder onBind(Intent intent) {
|
public IBinder onBind(Intent intent)
|
||||||
|
{
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -207,8 +212,10 @@ public class RockboxService extends Service
|
||||||
/* we get literally spammed with battery statuses
|
/* we get literally spammed with battery statuses
|
||||||
* if we don't delay the re-attaching
|
* if we don't delay the re-attaching
|
||||||
*/
|
*/
|
||||||
TimerTask tk = new TimerTask() {
|
TimerTask tk = new TimerTask()
|
||||||
public void run() {
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
registerReceiver(batt_monitor, itf);
|
registerReceiver(batt_monitor, itf);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -327,7 +334,8 @@ public class RockboxService extends Service
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy()
|
||||||
|
{
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
/* Make sure our notification is gone. */
|
/* Make sure our notification is gone. */
|
||||||
stopForegroundCompat(R.string.notification);
|
stopForegroundCompat(R.string.notification);
|
||||||
|
|
|
||||||
|
|
@ -45,12 +45,14 @@ public class RockboxTimer extends Timer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run()
|
||||||
|
{
|
||||||
timerTask();
|
timerTask();
|
||||||
int state = tm.getCallState();
|
int state = tm.getCallState();
|
||||||
if (state != last_state)
|
if (state != last_state)
|
||||||
{
|
{
|
||||||
switch (state) {
|
switch (state)
|
||||||
|
{
|
||||||
case TelephonyManager.CALL_STATE_IDLE:
|
case TelephonyManager.CALL_STATE_IDLE:
|
||||||
postCallHungUp();
|
postCallHungUp();
|
||||||
break;
|
break;
|
||||||
|
|
@ -69,7 +71,7 @@ public class RockboxTimer extends Timer
|
||||||
|
|
||||||
public RockboxTimer(RockboxService instance, long period_inverval_in_ms)
|
public RockboxTimer(RockboxService instance, long period_inverval_in_ms)
|
||||||
{
|
{
|
||||||
super("tick timer", false);
|
super("tick timer");
|
||||||
task = new RockboxTimerTask(instance, this);
|
task = new RockboxTimerTask(instance, this);
|
||||||
schedule(task, 0, period_inverval_in_ms);
|
schedule(task, 0, period_inverval_in_ms);
|
||||||
interval = period_inverval_in_ms;
|
interval = period_inverval_in_ms;
|
||||||
|
|
@ -85,7 +87,8 @@ public class RockboxTimer extends Timer
|
||||||
/* methods called from native, keep them simple */
|
/* methods called from native, keep them simple */
|
||||||
public void java_wait_for_interrupt()
|
public void java_wait_for_interrupt()
|
||||||
{
|
{
|
||||||
synchronized(this) {
|
synchronized(this)
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
this.wait();
|
this.wait();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue