diff --git a/Dockerfile b/Dockerfile index 235606a..a9dccc9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,3 +28,4 @@ RUN chown 0:0 /entrypoint.sh RUN chmod 0700 /entrypoint.sh WORKDIR /apk ENTRYPOINT ["/entrypoint.sh"] +RUN echo "$YESACCEPT" | tee yesaccept diff --git a/Makefile b/Makefile index 0433371..00165ce 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,12 @@ +all: build install + build: docker-compose run compile +install: + adb install -r ./apk/bin/app1.apk clean: rm docker-compose-build.log || true diff --git a/apk/Makefile b/apk/Makefile index f84db2f..bab07e4 100644 --- a/apk/Makefile +++ b/apk/Makefile @@ -8,15 +8,12 @@ CXX_FLAGS = -march=armv8-a --sysroot=$(TOOLCHAIN)/sysroot -all: build deploy +all: build .PHONY : build .PHONY : deploy .PHONY : clean -deploy : - adb install -r ./bin/hellojni.apk - build : ./bin/app1.apk diff --git a/apk/src/de/alexmahr/app1/App1.java b/apk/src/de/alexmahr/app1/App1.java new file mode 100644 index 0000000..990f3ae --- /dev/null +++ b/apk/src/de/alexmahr/app1/App1.java @@ -0,0 +1,117 @@ +package de.alexmahr.app1; + +import android.util.Log; +import android.widget.TextView; +import android.app.Activity; +import android.os.Bundle; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.lang.Thread; +import java.util.concurrent.TimeUnit; +import android.text.method.ScrollingMovementMethod; + +class Threads1 implements Runnable { + + public String result = "alex"; + + public void run(){ + try{ + result = result.concat("step 2\n"); + URL url = new URL("https://alexmahr.de/word"); + result = result.concat("step 3\n"); + HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); + result = result.concat("step 4\n"); + BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); + result = result.concat("step 5\n"); + String inputLine; + StringBuffer response = new StringBuffer(); + result = result.concat("step 6\n"); + + while ((inputLine = in.readLine()) != null) { + result = result.concat("step 7\n"); + response.append(inputLine); + } + result = result.concat("step 8\n"); + in.close(); + result = result.concat("step 9\n"); + result = result.concat( "OK".concat(response.toString())); + urlConnection.disconnect(); + } catch (Exception e){ +// throw new RuntimeException(e); + } + } +} + + +public class App1 extends Activity +{ + + @Override + public void onCreate(Bundle savedInstanceState) + { + try + { + super.onCreate(savedInstanceState); + //volatile String result = "initial"; + String result = "initial"; + TextView tv = new TextView(this); + tv.setMovementMethod(new ScrollingMovementMethod()); + Threads1 threads1 = new Threads1(); + Thread thread = new Thread(threads1); + thread.start(); + thread.join(); + + // Thread thread = new Thread(new Runnable() { + + // @Override + // public void run() { + // try { + // result = result.concat("step 2\n"); + // URL url = new URL("https://alexmahr.de/word"); + // result = result.concat("step 3\n"); + // HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); + // result = result.concat("step 4\n"); + // BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); + // result = result.concat("step 5\n"); + // String inputLine; + // StringBuffer response = new StringBuffer(); + // result = result.concat("step 6\n"); + + // while ((inputLine = in.readLine()) != null) { + // result = result.concat("step 7\n"); + // response.append(inputLine); + // } + // result = result.concat("step 8\n"); + // in.close(); + // result = result.concat("step 9\n"); + // result = result.concat( "OK".concat(response.toString())); + // urlConnection.disconnect(); + + + // } catch (Exception e) { + // e.printStackTrace(); + // } + // } + // }); + // thread.start(); + // thread.join(); + tv.setText( result); + setContentView(tv); + try{ + // TimeUnit.SECONDS.sleep(1); + } catch (Exception e){ +// throw new RuntimeException(e); + } + tv.setText(result.concat(threads1.result)); + } catch (Exception e) { + throw new RuntimeException(e); + } + + } + + +} diff --git a/apk/src/de/alexmahr/app1/App1.kt b/apk/src/de/alexmahr/app1/App1.kt new file mode 100644 index 0000000..49a9b70 --- /dev/null +++ b/apk/src/de/alexmahr/app1/App1.kt @@ -0,0 +1,47 @@ +import android.os.Bundle +import android.view.Menu +import android.view.MenuItem +import android.widget.Toast +import androidx.appcompat.app.AppCompatActivity + +class MainActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + // calling this activity's function to + // use ActionBar utility methods + val actionBar = supportActionBar + + // providing title for the ActionBar + actionBar!!.title = " GfG | Action Bar" + + // providing subtitle for the ActionBar + actionBar.subtitle = " Design a custom Action Bar" + + // adding icon in the ActionBar + actionBar.setIcon(R.drawable.app_logo) + + // methods to display the icon in the ActionBar + actionBar.setDisplayUseLogoEnabled(true) + actionBar.setDisplayShowHomeEnabled(true) + } + + // method to inflate the options menu when + // the user opens the menu for the first time + override fun onCreateOptionsMenu(menu: Menu): Boolean { + menuInflater.inflate(R.menu.main, menu) + return super.onCreateOptionsMenu(menu) + } + + // methods to control the operations that will + // happen when user clicks on the action buttons + override fun onOptionsItemSelected(item: MenuItem): Boolean { + when (item.itemId) { + R.id.search -> Toast.makeText(this, "Search Clicked", Toast.LENGTH_SHORT).show() + R.id.refresh -> Toast.makeText(this, "Refresh Clicked", Toast.LENGTH_SHORT).show() + R.id.copy -> Toast.makeText(this, "Copy Clicked", Toast.LENGTH_SHORT).show() + } + return super.onOptionsItemSelected(item) + } +} diff --git a/apk/src/de/alexmahr/app1/App1.kt.back b/apk/src/de/alexmahr/app1/App1.kt.back new file mode 100644 index 0000000..a62120a --- /dev/null +++ b/apk/src/de/alexmahr/app1/App1.kt.back @@ -0,0 +1,93 @@ +package de.alexmahr.app1; + +//#import android.support.v7.app.AppCompatActivity +import android.os.Bundle +import android.util.Log; +import android.widget.TextView; +import android.app.Activity; +//import java.io.BufferedReader; +//import java.io.IOException; +//import java.io.InputStreamReader; +//import java.io.OutputStream; +//import java.net.HttpURLConnection; +//import java.net.URL; +//import java.lang.Thread; +//import java.util.concurrent.TimeUnit; +//import android.text.method.ScrollingMovementMethod; + +public class App1 extends Activity{ +{ + override fun onCreate(savedInstanceState: Bundle?) { + + super.onCreate(savedInstanceState); + val tv = TextView(this); + tv.setText( "result"); + setContentView(tv); + + } +} +// @Override +// public void onCreate(Bundle savedInstanceState) +// { +// try +// { +// super.onCreate(savedInstanceState); +// //volatile String result = "initial"; +// String result = "initial"; +// TextView tv = new TextView(this); +// tv.setMovementMethod(new ScrollingMovementMethod()); +// Threads1 threads1 = new Threads1(); +// Thread thread = new Thread(threads1); +// thread.start(); +// thread.join(); +// +// // Thread thread = new Thread(new Runnable() { +// +// // @Override +// // public void run() { +// // try { +// // result = result.concat("step 2\n"); +// // URL url = new URL("https://alexmahr.de/word"); +// // result = result.concat("step 3\n"); +// // HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); +// // result = result.concat("step 4\n"); +// // BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); +// // result = result.concat("step 5\n"); +// // String inputLine; +// // StringBuffer response = new StringBuffer(); +// // result = result.concat("step 6\n"); +// +// // while ((inputLine = in.readLine()) != null) { +// // result = result.concat("step 7\n"); +// // response.append(inputLine); +// // } +// // result = result.concat("step 8\n"); +// // in.close(); +// // result = result.concat("step 9\n"); +// // result = result.concat( "OK".concat(response.toString())); +// // urlConnection.disconnect(); +// +// +// // } catch (Exception e) { +// // e.printStackTrace(); +// // } +// // } +// // }); +// // thread.start(); +// // thread.join(); +// tv.setText( result); +// setContentView(tv); +// try{ +// // TimeUnit.SECONDS.sleep(1); +// } catch (Exception e){ +//// throw new RuntimeException(e); +// } +// tv.setText(result.concat(threads1.result)); +// } catch (Exception e) { +// throw new RuntimeException(e); +// } +// +// } +// +// +//} diff --git a/apk/src/de/alexmahr/app1/R.java b/apk/src/de/alexmahr/app1/R.java new file mode 100644 index 0000000..4725840 --- /dev/null +++ b/apk/src/de/alexmahr/app1/R.java @@ -0,0 +1,22 @@ +/* AUTO-GENERATED FILE. DO NOT MODIFY. + * + * This class was automatically generated by the + * aapt tool from the resource data it found. It + * should not be modified by hand. + */ + +package de.alexmahr.app1; + +public final class R { + public static final class attr { + } + public static final class drawable { + public static final int ic_launcher=0x7f020000; + } + public static final class layout { + public static final int main=0x7f030000; + } + public static final class string { + public static final int app_name=0x7f040000; + } +} diff --git a/apk/src/main b/apk/src/main new file mode 100755 index 0000000..e854338 Binary files /dev/null and b/apk/src/main differ diff --git a/apk/src/main.c b/apk/src/main.c new file mode 100644 index 0000000..4ccc8aa --- /dev/null +++ b/apk/src/main.c @@ -0,0 +1,6 @@ +#include + +int main(){ + printf("hallo"); + return 0; +} diff --git a/compose.yml b/compose.yml index 1cd0c5a..e036ee2 100644 --- a/compose.yml +++ b/compose.yml @@ -2,6 +2,8 @@ services: compile: build: context: . + args: + YESACCEPT: ${YESACCEPT} stop_grace_period: 1s volumes: - ./apk:/apk