Add GitHub action for Android Gradle build, update IDE/Android project (use Java 11, add -Werror)
parent
0bc0e07883
commit
94a74db505
|
@ -0,0 +1,52 @@
|
||||||
|
name: Android Gradle Build test logic
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
os:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
jdk_distro:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
jdk_version:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_wolfssljni:
|
||||||
|
runs-on: ${{ inputs.os }}
|
||||||
|
steps:
|
||||||
|
- name: Clone wolfssljni
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# Clone native wolfSSL
|
||||||
|
- name: Clone native wolfSSL
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: 'wolfssl/wolfssl'
|
||||||
|
path: IDE/Android/app/src/main/cpp/wolfssl
|
||||||
|
|
||||||
|
# Copy options.h.in to blank options.h
|
||||||
|
- name: Create blank options.h
|
||||||
|
run: cp IDE/Android/app/src/main/cpp/wolfssl/wolfssl/options.h.in IDE/Android/app/src/main/cpp/wolfssl/wolfssl/options.h
|
||||||
|
|
||||||
|
# Setup Java
|
||||||
|
- name: Setup java
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: ${{ inputs.jdk_distro }}
|
||||||
|
java-version: ${{ inputs.jdk_version }}
|
||||||
|
|
||||||
|
# Gradle assembleDebug
|
||||||
|
- name: Gradle assembleDebug
|
||||||
|
run: cd IDE/Android && ls && ./gradlew assembleDebug
|
||||||
|
|
||||||
|
# Gradle assembleDebugUnitTest
|
||||||
|
- name: Gradle assembleDebugUnitTest
|
||||||
|
run: cd IDE/Android && ls && ./gradlew assembleDebugUnitTest
|
||||||
|
|
||||||
|
# Gradle assembleDebugAndroidTest
|
||||||
|
- name: Gradle assembleDebugAndroidTest
|
||||||
|
run: cd IDE/Android && ls && ./gradlew assembleDebugAndroidTest
|
||||||
|
|
|
@ -118,3 +118,18 @@ jobs:
|
||||||
jdk_version: ${{ matrix.jdk_version }}
|
jdk_version: ${{ matrix.jdk_version }}
|
||||||
wolfssl_configure: ${{ matrix.wolfssl_configure }}
|
wolfssl_configure: ${{ matrix.wolfssl_configure }}
|
||||||
|
|
||||||
|
# ----------------------- Android Gradle build ------------------------
|
||||||
|
# Run Android gradle build over PR code, only running on Linux with one
|
||||||
|
# JDK/version for now.
|
||||||
|
android-gradle:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ 'ubuntu-latest' ]
|
||||||
|
jdk_version: [ '21' ]
|
||||||
|
name: Android Gradle (${{ matrix.os }} Zulu JDK ${{ matrix.jdk_version }})
|
||||||
|
uses: ./.github/workflows/android_gradle.yml
|
||||||
|
with:
|
||||||
|
os: ${{ matrix.os }}
|
||||||
|
jdk_distro: "zulu"
|
||||||
|
jdk_version: ${{ matrix.jdk_version }}
|
||||||
|
|
||||||
|
|
|
@ -13,4 +13,11 @@
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
<option name="id" value="Android" />
|
<option name="id" value="Android" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="VisualizationToolProject">
|
||||||
|
<option name="state">
|
||||||
|
<ProjectState>
|
||||||
|
<option name="scale" value="1.1" />
|
||||||
|
</ProjectState>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -1,11 +1,14 @@
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 30
|
compileSdk 33
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.example.wolfssl"
|
applicationId "com.example.wolfssl"
|
||||||
minSdkVersion 30
|
/* Min SDK should stay at 24 to detect if we try to use newer APIs
|
||||||
targetSdkVersion 30
|
* than were available in that Android SDK. We have users who are still
|
||||||
|
on SDK 24 (ref ZD 18311) */
|
||||||
|
minSdkVersion 24
|
||||||
|
targetSdkVersion 33
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
|
@ -15,6 +18,10 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_11
|
||||||
|
targetCompatibility JavaVersion.VERSION_11
|
||||||
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
|
@ -26,14 +33,18 @@ android {
|
||||||
path "src/main/cpp/CMakeLists.txt"
|
path "src/main/cpp/CMakeLists.txt"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sourceSets {
|
||||||
|
main.java.srcDirs += '../../src/java'
|
||||||
|
test.java.srcDirs += '../../src/test'
|
||||||
|
}
|
||||||
namespace 'com.example.wolfssl'
|
namespace 'com.example.wolfssl'
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
implementation 'com.android.support:appcompat-v7:28.0.0'
|
implementation 'com.android.support:appcompat-v7:28.0.0'
|
||||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
implementation 'com.android.support.constraint:constraint-layout:2.0.4'
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
|
@ -12,7 +11,7 @@
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
android:requestLegacyExternalStorage="true"
|
android:requestLegacyExternalStorage="true"
|
||||||
android:preserveLegacyExternalStorage="true">
|
android:preserveLegacyExternalStorage="true">
|
||||||
<activity android:name=".MainActivity">
|
<activity android:name=".MainActivity" android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
|
|
@ -11,6 +11,10 @@ project("wolfssljni-gradle" C ASM)
|
||||||
set(wolfssljni_DIR ${CMAKE_SOURCE_DIR}/../../../../../../)
|
set(wolfssljni_DIR ${CMAKE_SOURCE_DIR}/../../../../../../)
|
||||||
set(wolfssl_DIR ${CMAKE_SOURCE_DIR}/wolfssl/)
|
set(wolfssl_DIR ${CMAKE_SOURCE_DIR}/wolfssl/)
|
||||||
|
|
||||||
|
# set warnings as errors, used in this example project but may be different
|
||||||
|
# in production apps/environments.
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror")
|
||||||
|
|
||||||
# ------------------------- wolfSSL Normal vs. FIPS Ready Selection --------------------------------
|
# ------------------------- wolfSSL Normal vs. FIPS Ready Selection --------------------------------
|
||||||
# Select if wolfSSL is normal ("normal") or FIPS Ready ("fipsready")
|
# Select if wolfSSL is normal ("normal") or FIPS Ready ("fipsready")
|
||||||
# wolfSSL FIPS Ready is available for download on the wolfssl.com download page. For more
|
# wolfSSL FIPS Ready is available for download on the wolfssl.com download page. For more
|
||||||
|
@ -222,7 +226,10 @@ list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/ssl_bn.c)
|
||||||
list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/ssl_asn1.c)
|
list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/ssl_asn1.c)
|
||||||
list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/ssl_certman.c)
|
list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/ssl_certman.c)
|
||||||
list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/ssl_crypto.c)
|
list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/ssl_crypto.c)
|
||||||
|
list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/ssl_load.c)
|
||||||
list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/ssl_misc.c)
|
list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/ssl_misc.c)
|
||||||
|
list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/ssl_p7p12.c)
|
||||||
|
list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/ssl_sess.c)
|
||||||
list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/x509.c)
|
list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/x509.c)
|
||||||
list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/x509_str.c)
|
list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/x509_str.c)
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,6 @@
|
||||||
|
|
||||||
package com.example.wolfssl;
|
package com.example.wolfssl;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Environment;
|
|
||||||
import android.provider.Settings;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -35,17 +31,11 @@ import android.widget.TextView;
|
||||||
import com.wolfssl.WolfSSL;
|
import com.wolfssl.WolfSSL;
|
||||||
import com.wolfssl.WolfSSLException;
|
import com.wolfssl.WolfSSLException;
|
||||||
import com.wolfssl.provider.jsse.WolfSSLProvider;
|
import com.wolfssl.provider.jsse.WolfSSLProvider;
|
||||||
import com.wolfssl.provider.jsse.WolfSSLX509;
|
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.security.KeyStore;
|
|
||||||
import java.security.KeyStoreException;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.NoSuchProviderException;
|
import java.security.NoSuchProviderException;
|
||||||
import java.security.Provider;
|
import java.security.Provider;
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
import java.security.cert.CertificateException;
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
@ -55,7 +45,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
TextView tv = (TextView) findViewById(R.id.sample_text);
|
TextView tv = (TextView) findViewById(R.id.sample_text);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
testLoadCert(tv);
|
testFindProvider(tv);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -72,23 +62,11 @@ public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
TextView tv = (TextView) findViewById(R.id.sample_text);
|
TextView tv = (TextView) findViewById(R.id.sample_text);
|
||||||
tv.setText("wolfSSL JNI Android Studio Example App");
|
tv.setText("wolfSSL JNI Android Studio Example App");
|
||||||
|
|
||||||
if (!Environment.isExternalStorageManager()) {
|
|
||||||
Intent intent = new Intent(
|
|
||||||
Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
|
|
||||||
Uri uri = Uri.fromParts("package", getPackageName(), null);
|
|
||||||
intent.setData(uri);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLoadCert(TextView tv)
|
public void testFindProvider(TextView tv)
|
||||||
throws NoSuchProviderException, NoSuchAlgorithmException,
|
throws NoSuchProviderException, NoSuchAlgorithmException,
|
||||||
KeyStoreException, IOException, CertificateException,
|
|
||||||
WolfSSLException {
|
WolfSSLException {
|
||||||
String file = "/sdcard/examples/provider/all.bks";
|
|
||||||
WolfSSLX509 x509;
|
|
||||||
KeyStore ks;
|
|
||||||
|
|
||||||
WolfSSL.loadLibrary();
|
WolfSSL.loadLibrary();
|
||||||
|
|
||||||
|
@ -100,11 +78,8 @@ public class MainActivity extends AppCompatActivity {
|
||||||
System.out.println("Unable to find wolfJSSE provider");
|
System.out.println("Unable to find wolfJSSE provider");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
ks = KeyStore.getInstance("BKS");
|
}
|
||||||
ks.load(new FileInputStream(file), "wolfSSL test".toCharArray());
|
|
||||||
|
|
||||||
x509 = new WolfSSLX509(ks.getCertificate("server").getEncoded());
|
|
||||||
tv.setText("Server Certificate Found:\n" + x509.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,9 +8,13 @@
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/button"
|
android:id="@+id/button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="320dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Load Cert File" />
|
android:text="Test Provider Lookup"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/sample_text"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/sample_text"
|
android:id="@+id/sample_text"
|
||||||
|
@ -19,6 +23,7 @@
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:paddingVertical="16pt"
|
android:paddingVertical="16pt"
|
||||||
android:text="Hello World!"
|
android:text="Hello World!"
|
||||||
|
android:textColor="#000000"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintHorizontal_bias="0.461"
|
app:layout_constraintHorizontal_bias="0.461"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
|
|
@ -18,7 +18,12 @@ allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
|
}
|
||||||
|
gradle.projectsEvaluated {
|
||||||
|
tasks.withType(JavaCompile) {
|
||||||
|
options.compilerArgs << "-Xlint:all" << "-Werror"
|
||||||
|
options.deprecation = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
# Specifies the JVM arguments used for the daemon process.
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
# The setting is particularly useful for tweaking memory settings.
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
android.defaults.buildfeatures.buildconfig=true
|
|
||||||
android.nonFinalResIds=false
|
android.nonFinalResIds=false
|
||||||
android.nonTransitiveRClass=false
|
android.nonTransitiveRClass=false
|
||||||
org.gradle.jvmargs=-Xmx1536m
|
org.gradle.jvmargs=-Xmx1536m
|
||||||
|
|
Loading…
Reference in New Issue