hugorosario / transmission-android Goto Github PK
View Code? Open in Web Editor NEWTransmission daemon ported to Android.
License: Other
Transmission daemon ported to Android.
License: Other
ABOUT Transmission is a fast, easy, and free BitTorrent client. Visit https://transmissionbt.com/ for more information. This repository is an Android port of the transmission daemon version 2.94. Modifications have been made to the source code of transmission and dependency libraries in order to make this compile without errors. It provides a nice interactive build script and supports cross compiling to ARM and X86 android. BUILDING Download and extract the latest Android NDK from https://developer.android.com/ndk/downloads/ I already had revision 17c and it worked fine. Clone this repository. $ git clone https://github.com/hugorosario/transmission-android.git Edit the "build.sh" script inside the "builder" folder and set your NDK_ROOT directory to where you extracted it. For example, export NDK_ROOT=/home/dev/android-ndk Run the interactive build script. $ ./build.sh Select architecture (ARM or X86) to build the toolchain. Select "Build all (dependencies + transmission)". If everything went good, you should have a transmission-daemon binary in your toolchain sysroot/usr/bin folder. RUNNING Since this is a binary executable and not an APK, it needs to be launched from JAVA code. This means you need to build and APK to start/stop the daemon. In order to execute the daemon, you have to copy it to the app private space and make it executable. This is required because Android does not allow launching executables located on the SD card. Here is some code that extracts the binary from the RAW folder into getFilesDir() location and makes it executable: static boolean initialize(Context context) { try { initialized = false; String appFileDirectory = context.getFilesDir().getParent(); binary = new File(appFileDirectory + "/transmissiond"); extractResource(context, R.raw.transmission_x86, binary); if (binary.exists()) initialized = binary.setExecutable(true); } catch (Exception e) { e.printStackTrace(); } return initialized; } static void extractResource(Context context, int id, File dest){ try { InputStream ins = context.getResources().openRawResource(id); final byte[] buffer = new byte[ins.available()]; ins.read(buffer); ins.close(); if (dest.exists()) dest.delete(); FileOutputStream fos = new FileOutputStream(dest); fos.write(buffer); fos.close(); }catch (Exception e){ e.printStackTrace(); } } Here is some code that might help launching the daemon (many parameters are missing from this sample code): public static void startDaemon(final TransmissionListener listener){ new Thread(new Runnable() { @Override public void run() { try { if (isInitialized()){ process = new ProcessBuilder().command(binary.getAbsolutePath(),"-f").redirectErrorStream(true).start(); listener.onStatusUpdated(false, "transmission-daemon started!"); Thread readThread = new Thread(new Runnable() { @Override public void run() { try { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream())); while (!Thread.currentThread().isInterrupted()) { if (bufferedReader.ready()) { String line = bufferedReader.readLine(); listener.onLog(line); } } bufferedReader.close(); } catch (Exception e) { e.printStackTrace(); } } }); readThread.start(); Thread errorThread = new Thread(new Runnable() { @Override public void run() { try { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getErrorStream())); while (!Thread.currentThread().isInterrupted()) { if (bufferedReader.ready()) { String line = bufferedReader.readLine(); listener.onError(line); } } bufferedReader.close(); } catch (Exception e) { e.printStackTrace(); } } }); errorThread.start(); process.waitFor(); readThread.interrupt(); errorThread.interrupt(); process = null; listener.onStatusUpdated(false, "transmission-daemon stopped!"); } } catch (Exception e) { e.printStackTrace(); listener.onStatusUpdated(false, "FATAL ERROR : " + e.getMessage()); } } }).start(); } TODO I will soon add a sample APK that starts/stops the daemon and has a nice helper class for transmission settings.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.