forked from len0rd/rockbox
Fix some whitespace errors.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29712 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
bbeba640bf
commit
968db0edff
1 changed files with 58 additions and 58 deletions
|
|
@ -52,14 +52,14 @@ import android.view.KeyEvent;
|
||||||
* All access should be done through RockboxService.get_instance() for safety.
|
* All access should be done through RockboxService.get_instance() for safety.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class RockboxService extends Service
|
public class RockboxService extends Service
|
||||||
{
|
{
|
||||||
/* this Service is really a singleton class - well almost.
|
/* this Service is really a singleton class - well almost.
|
||||||
* To do it properly this line should be instance = new RockboxService()
|
* To do it properly this line should be instance = new RockboxService()
|
||||||
* but apparently that doesnt work with the way android Services are created.
|
* but apparently that doesnt work with the way android Services are created.
|
||||||
*/
|
*/
|
||||||
private static RockboxService instance = null;
|
private static RockboxService instance = null;
|
||||||
|
|
||||||
/* locals needed for the c code and rockbox state */
|
/* locals needed for the c code and rockbox state */
|
||||||
private static volatile boolean rockbox_running;
|
private static volatile boolean rockbox_running;
|
||||||
private Activity current_activity = null;
|
private Activity current_activity = null;
|
||||||
|
|
@ -84,25 +84,25 @@ public class RockboxService extends Service
|
||||||
mMediaButtonReceiver = new MediaButtonReceiver(this);
|
mMediaButtonReceiver = new MediaButtonReceiver(this);
|
||||||
fg_runner = new RunForegroundManager(this);
|
fg_runner = new RunForegroundManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RockboxService get_instance()
|
public static RockboxService get_instance()
|
||||||
{
|
{
|
||||||
/* don't call the construtor here, the instances are managed by
|
/* don't call the construtor here, the instances are managed by
|
||||||
* android, so we can't just create a new one */
|
* android, so we can't just create a new one */
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRockboxRunning()
|
public boolean isRockboxRunning()
|
||||||
{
|
{
|
||||||
return rockbox_running;
|
return rockbox_running;
|
||||||
}
|
}
|
||||||
public Activity get_activity()
|
public Activity get_activity()
|
||||||
{
|
{
|
||||||
return current_activity;
|
return current_activity;
|
||||||
}
|
}
|
||||||
public void set_activity(Activity a)
|
public void set_activity(Activity a)
|
||||||
{
|
{
|
||||||
current_activity = a;
|
current_activity = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void do_start(Intent intent)
|
private void do_start(Intent intent)
|
||||||
|
|
@ -125,7 +125,7 @@ public class RockboxService extends Service
|
||||||
resultReceiver.send(RESULT_LIB_LOADED, null);
|
resultReceiver.send(RESULT_LIB_LOADED, null);
|
||||||
|
|
||||||
if (intent.getAction().equals(Intent.ACTION_MEDIA_BUTTON))
|
if (intent.getAction().equals(Intent.ACTION_MEDIA_BUTTON))
|
||||||
{
|
{
|
||||||
/* give it a bit of time so we can register button presses
|
/* give it a bit of time so we can register button presses
|
||||||
* sleeping longer doesn't work here, apparently Android
|
* sleeping longer doesn't work here, apparently Android
|
||||||
* surpresses long sleeps during intent handling */
|
* surpresses long sleeps during intent handling */
|
||||||
|
|
@ -142,7 +142,7 @@ public class RockboxService extends Service
|
||||||
mMediaButtonReceiver.register();
|
mMediaButtonReceiver.register();
|
||||||
if (resultReceiver != null)
|
if (resultReceiver != null)
|
||||||
resultReceiver.send(RESULT_SERVICE_RUNNING, null);
|
resultReceiver.send(RESULT_SERVICE_RUNNING, null);
|
||||||
|
|
||||||
rockbox_running = true;
|
rockbox_running = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -150,7 +150,7 @@ public class RockboxService extends Service
|
||||||
{
|
{
|
||||||
Log.d("Rockbox", (String) text);
|
Log.d("Rockbox", (String) text);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LOG(CharSequence text, Throwable tr)
|
private void LOG(CharSequence text, Throwable tr)
|
||||||
{
|
{
|
||||||
Log.d("Rockbox", (String) text, tr);
|
Log.d("Rockbox", (String) text, tr);
|
||||||
|
|
@ -168,7 +168,7 @@ public class RockboxService extends Service
|
||||||
|
|
||||||
private void startservice()
|
private void startservice()
|
||||||
{
|
{
|
||||||
final Object lock = new Object();
|
final Object lock = new Object();
|
||||||
Thread rb = new Thread(new Runnable()
|
Thread rb = new Thread(new Runnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
|
|
@ -183,35 +183,35 @@ public class RockboxService extends Service
|
||||||
lock.notify();
|
lock.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the following block unzips libmisc.so, which contains the files
|
/* the following block unzips libmisc.so, which contains the files
|
||||||
* we ship, such as themes. It's needed to put it into a .so file
|
* we ship, such as themes. It's needed to put it into a .so file
|
||||||
* because there's no other way to ship files and have access
|
* because there's no other way to ship files and have access
|
||||||
* to them from native code
|
* to them from native code
|
||||||
*/
|
*/
|
||||||
File libMisc = new File("/data/data/org.rockbox/lib/libmisc.so");
|
File libMisc = new File("/data/data/org.rockbox/lib/libmisc.so");
|
||||||
/* use arbitrary file to determine whether extracting is needed */
|
/* use arbitrary file to determine whether extracting is needed */
|
||||||
File arbitraryFile = new File(rockboxDir, "viewers.config");
|
File arbitraryFile = new File(rockboxDir, "viewers.config");
|
||||||
if (!arbitraryFile.exists() || (libMisc.lastModified() > arbitraryFile.lastModified()))
|
if (!arbitraryFile.exists() || (libMisc.lastModified() > arbitraryFile.lastModified()))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Bundle progressData = new Bundle();
|
Bundle progressData = new Bundle();
|
||||||
byte data[] = new byte[BUFFER];
|
byte data[] = new byte[BUFFER];
|
||||||
ZipFile zipfile = new ZipFile(libMisc);
|
ZipFile zipfile = new ZipFile(libMisc);
|
||||||
Enumeration<? extends ZipEntry> e = zipfile.entries();
|
Enumeration<? extends ZipEntry> e = zipfile.entries();
|
||||||
progressData.putInt("max", zipfile.size());
|
progressData.putInt("max", zipfile.size());
|
||||||
|
|
||||||
while(e.hasMoreElements())
|
while(e.hasMoreElements())
|
||||||
{
|
{
|
||||||
ZipEntry entry = (ZipEntry) e.nextElement();
|
ZipEntry entry = (ZipEntry) e.nextElement();
|
||||||
File file;
|
File file;
|
||||||
/* strip off /.rockbox when extracting */
|
/* strip off /.rockbox when extracting */
|
||||||
String fileName = entry.getName();
|
String fileName = entry.getName();
|
||||||
int slashIndex = fileName.indexOf('/', 1);
|
int slashIndex = fileName.indexOf('/', 1);
|
||||||
file = new File(rockboxDirPath + fileName.substring(slashIndex));
|
file = new File(rockboxDirPath + fileName.substring(slashIndex));
|
||||||
|
|
||||||
if (!entry.isDirectory())
|
if (!entry.isDirectory())
|
||||||
{
|
{
|
||||||
/* Create the parent folders if necessary */
|
/* Create the parent folders if necessary */
|
||||||
File folder = new File(file.getParent());
|
File folder = new File(file.getParent());
|
||||||
if (!folder.exists())
|
if (!folder.exists())
|
||||||
|
|
@ -229,22 +229,22 @@ public class RockboxService extends Service
|
||||||
dest.flush();
|
dest.flush();
|
||||||
dest.close();
|
dest.close();
|
||||||
is.close();
|
is.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resultReceiver != null) {
|
if (resultReceiver != null) {
|
||||||
progressData.putInt("value", progressData.getInt("value", 0) + 1);
|
progressData.putInt("value", progressData.getInt("value", 0) + 1);
|
||||||
resultReceiver.send(RESULT_LIB_LOAD_PROGRESS, progressData);
|
resultReceiver.send(RESULT_LIB_LOAD_PROGRESS, progressData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
LOG("Exception when unzipping", e);
|
LOG("Exception when unzipping", e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
if (resultReceiver != null) {
|
if (resultReceiver != null) {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString("error", getString(R.string.error_extraction));
|
bundle.putString("error", getString(R.string.error_extraction));
|
||||||
resultReceiver.send(RESULT_ERROR_OCCURED, bundle);
|
resultReceiver.send(RESULT_ERROR_OCCURED, bundle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Generate default config if none exists yet */
|
/* Generate default config if none exists yet */
|
||||||
|
|
@ -267,8 +267,8 @@ public class RockboxService extends Service
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start native code */
|
/* Start native code */
|
||||||
if (resultReceiver != null)
|
if (resultReceiver != null)
|
||||||
resultReceiver.send(RESULT_INVOKING_MAIN, null);
|
resultReceiver.send(RESULT_INVOKING_MAIN, null);
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
|
||||||
|
|
@ -281,10 +281,10 @@ public class RockboxService extends Service
|
||||||
}, "Rockbox thread");
|
}, "Rockbox thread");
|
||||||
rb.setDaemon(false);
|
rb.setDaemon(false);
|
||||||
/* wait at least until the library is loaded */
|
/* wait at least until the library is loaded */
|
||||||
synchronized (lock)
|
synchronized (lock)
|
||||||
{
|
{
|
||||||
rb.start();
|
rb.start();
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
lock.wait();
|
lock.wait();
|
||||||
|
|
@ -292,34 +292,34 @@ public class RockboxService extends Service
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initBatteryMonitor()
|
private void initBatteryMonitor()
|
||||||
{
|
{
|
||||||
itf = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
|
itf = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
|
||||||
batt_monitor = new BroadcastReceiver()
|
batt_monitor = new BroadcastReceiver()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent)
|
public void onReceive(Context context, Intent intent)
|
||||||
{
|
{
|
||||||
/* 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);
|
||||||
}
|
}
|
||||||
|
|
@ -332,25 +332,25 @@ public class RockboxService extends Service
|
||||||
battery_level = (rawlevel * 100) / scale;
|
battery_level = (rawlevel * 100) / scale;
|
||||||
else
|
else
|
||||||
battery_level = -1;
|
battery_level = -1;
|
||||||
/* query every 30s should be sufficient */
|
/* query every 30s should be sufficient */
|
||||||
t.schedule(tk, 30000);
|
t.schedule(tk, 30000);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
registerReceiver(batt_monitor, itf);
|
registerReceiver(batt_monitor, itf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void startForeground()
|
void startForeground()
|
||||||
{
|
{
|
||||||
fg_runner.startForeground();
|
fg_runner.startForeground();
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopForeground()
|
void stopForeground()
|
||||||
{
|
{
|
||||||
fg_runner.stopForeground();
|
fg_runner.stopForeground();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy()
|
public void onDestroy()
|
||||||
{
|
{
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
mMediaButtonReceiver.unregister();
|
mMediaButtonReceiver.unregister();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue