Skip to content

Commit

Permalink
ACardEmulator: Added F-Droid build flavor with FOSS only
Browse files Browse the repository at this point in the history
- avoid precompiled JARs for JCardSim
- use gradle's shadow plugin to relocate JCardSim's use of Bouncycastle
- removes JCardSim's Hello world applet
- use vJCRE to avoid importing Oracle's api_classic.jar

(We may use vJCRE as full replacement for JCardSim in the future, but
JCardSim is currently the choice with more features and support)
  • Loading branch information
frankmorgner committed Sep 30, 2019
1 parent e6a42ef commit 1caff4f
Show file tree
Hide file tree
Showing 15 changed files with 160 additions and 77 deletions.
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
url = https://github.com/philipWendland/IsoApplet.git
[submodule "ACardEmulator/app/src/main/external/jcardsim"]
path = ACardEmulator/app/src/main/external/jcardsim
url = https://github.com/frankmorgner/jcardsim.git
url = https://github.com/licel/jcardsim
[submodule "ACardEmulator/app/src/main/external/MuscleApplet"]
path = ACardEmulator/app/src/main/external/MuscleApplet
url = https://github.com/martinpaljak/MuscleApplet.git
Expand All @@ -25,3 +25,6 @@
[submodule "ACardEmulator/app/src/main/external/PivApplet"]
path = ACardEmulator/app/src/main/external/PivApplet
url = https://github.com/frankmorgner/PivApplet
[submodule "ACardEmulator/app/src/main/external/vJCRE"]
path = ACardEmulator/app/src/main/external/vJCRE
url = https://github.com/martinpaljak/vJCRE
2 changes: 1 addition & 1 deletion ACardEmulator/ACardEmulator.iml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<content url="file:https://$MODULE_DIR$">
<excludeFolder url="file:https://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
80 changes: 58 additions & 22 deletions ACardEmulator/app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,73 @@
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="SELECTED_BUILD_VARIANT" value="fullDebug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleFullDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileFullDebugSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
<task>generateFullDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file:https://$MODULE_DIR$/src/main/res;file:https://$MODULE_DIR$/build/generated/res/rs/debug;file:https://$MODULE_DIR$/build/generated/res/resValues/debug" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file:https://$MODULE_DIR$/src/main/res;file:https://$MODULE_DIR$/build/generated/res/rs/full/debug;file:https://$MODULE_DIR$/build/generated/res/resValues/full/debug" />
<option name="TEST_RES_FOLDERS_RELATIVE_PATH" value="" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
<output url="file:https://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file:https://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<output url="file:https://$MODULE_DIR$/build/intermediates/classes/full/debug" />
<output-test url="file:https://$MODULE_DIR$/build/intermediates/classes/test/full/debug" />
<exclude-output />
<content url="file:https://$MODULE_DIR$">
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/source/aidl/full/debug" isTestSource="false" generated="true" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/source/buildConfig/full/debug" isTestSource="false" generated="true" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/source/rs/full/debug" isTestSource="false" generated="true" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/source/apt/full/debug" isTestSource="false" generated="true" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/res/rs/full/debug" type="java-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/res/resValues/full/debug" type="java-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/src/fullDebug/res" type="java-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/src/fullDebug/resources" type="java-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/src/fullDebug/assets" type="java-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/src/fullDebug/aidl" isTestSource="false" />
<sourceFolder url="file:https://$MODULE_DIR$/src/fullDebug/java" isTestSource="false" />
<sourceFolder url="file:https://$MODULE_DIR$/src/fullDebug/rs" isTestSource="false" />
<sourceFolder url="file:https://$MODULE_DIR$/src/fullDebug/shaders" isTestSource="false" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/source/aidl/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/source/rs/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/source/apt/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/res/rs/androidTest/full/debug" type="java-test-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/build/generated/res/resValues/androidTest/full/debug" type="java-test-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/src/testFullDebug/res" type="java-test-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/src/testFullDebug/resources" type="java-test-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/src/testFullDebug/assets" type="java-test-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/src/testFullDebug/aidl" isTestSource="true" />
<sourceFolder url="file:https://$MODULE_DIR$/src/testFullDebug/java" isTestSource="true" />
<sourceFolder url="file:https://$MODULE_DIR$/src/testFullDebug/rs" isTestSource="true" />
<sourceFolder url="file:https://$MODULE_DIR$/src/testFullDebug/shaders" isTestSource="true" />
<sourceFolder url="file:https://$MODULE_DIR$/src/full/res" type="java-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/src/full/resources" type="java-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/src/full/assets" type="java-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/src/full/aidl" isTestSource="false" />
<sourceFolder url="file:https://$MODULE_DIR$/src/full/java" isTestSource="false" />
<sourceFolder url="file:https://$MODULE_DIR$/src/full/rs" isTestSource="false" />
<sourceFolder url="file:https://$MODULE_DIR$/src/full/shaders" isTestSource="false" />
<sourceFolder url="file:https://$MODULE_DIR$/src/androidTestFull/res" type="java-test-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/src/androidTestFull/resources" type="java-test-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/src/androidTestFull/assets" type="java-test-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/src/androidTestFull/aidl" isTestSource="true" />
<sourceFolder url="file:https://$MODULE_DIR$/src/androidTestFull/java" isTestSource="true" />
<sourceFolder url="file:https://$MODULE_DIR$/src/androidTestFull/rs" isTestSource="true" />
<sourceFolder url="file:https://$MODULE_DIR$/src/androidTestFull/shaders" isTestSource="true" />
<sourceFolder url="file:https://$MODULE_DIR$/src/testFull/res" type="java-test-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/src/testFull/resources" type="java-test-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/src/testFull/assets" type="java-test-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/src/testFull/aidl" isTestSource="true" />
<sourceFolder url="file:https://$MODULE_DIR$/src/testFull/java" isTestSource="true" />
<sourceFolder url="file:https://$MODULE_DIR$/src/testFull/rs" isTestSource="true" />
<sourceFolder url="file:https://$MODULE_DIR$/src/testFull/shaders" isTestSource="true" />
<sourceFolder url="file:https://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/src/debug/assets" type="java-resource" />
Expand All @@ -59,6 +94,8 @@
<sourceFolder url="file:https://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file:https://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file:https://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file:https://$MODULE_DIR$/src/main/external/vJCRE/src" isTestSource="false" />
<sourceFolder url="file:https://$MODULE_DIR$/src/main/external/jcardsim/src/main/java" isTestSource="false" />
<sourceFolder url="file:https://$MODULE_DIR$/src/main/external/GidsApplet/src" isTestSource="false" />
<sourceFolder url="file:https://$MODULE_DIR$/src/main/external/IsoApplet/src" isTestSource="false" />
<sourceFolder url="file:https://$MODULE_DIR$/src/main/external/PivApplet/src" isTestSource="false" />
Expand All @@ -85,7 +122,6 @@
<excludeFolder url="file:https://$MODULE_DIR$/build/generated/source/r" />
<excludeFolder url="file:https://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file:https://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file:https://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file:https://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file:https://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file:https://$MODULE_DIR$/build/intermediates/incremental-classes" />
Expand All @@ -105,6 +141,7 @@
<excludeFolder url="file:https://$MODULE_DIR$/build/intermediates/split-apk" />
<excludeFolder url="file:https://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file:https://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file:https://$MODULE_DIR$/build/libs" />
<excludeFolder url="file:https://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file:https://$MODULE_DIR$/build/tmp" />
</content>
Expand All @@ -119,9 +156,8 @@
<orderEntry type="library" exported="" name="Gradle: __local_jars__:/home/fm/Dokumente/vsmartcard/ACardEmulator/app/libs/sdk-v1.0.0.jar:unspecified@jar" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.android.support:support-annotations:23.2.1@jar" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.android.support:appcompat-v7:23.2.1@aar" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.madgag.spongycastle:core:1.51.0.0@jar" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.android.support:support-v4:23.2.1@aar" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.journeyapps:zxing-android-embedded:3.2.0@aar" level="project" />
<orderEntry type="library" exported="" name="Gradle: __local_jars__:/home/fm/Dokumente/vsmartcard/ACardEmulator/app/libs/jcardsim-3.0.4-SNAPSHOT-android.jar:unspecified@jar" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.bouncycastle:bcprov-jdk14:1.49@jar" level="project" />
</component>
</module>
54 changes: 42 additions & 12 deletions ACardEmulator/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
apply plugin: 'com.android.application'
apply plugin: 'com.github.johnrengelman.shadow'

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
task shadowJar(type: ShadowJar) {
configurations = [project.configurations.shadow]
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn shadowJar
}

android {
compileSdkVersion 23
Expand All @@ -16,25 +25,43 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "distribution"
productFlavors {
full {
dimension "distribution"
}
fdroid {
dimension "distribution"
applicationIdSuffix ".fdroid"
}
}
sourceSets {
main.java.srcDirs += 'src/main/external/vJCRE/src'
main.java.exclude('pro/javacard/vre/VJCREProvider*')
main.java.exclude('visa/*')
main.java.srcDirs += 'src/main/external/jcardsim/src/main/java'
main.java.exclude('**/APDUScriptTool.java')
main.java.exclude('**/JavaxSmartCardInterface.java')
main.java.exclude('**/CardTerminalSimulator.java')
main.java.exclude('**/JCSCard*.java')
main.java.exclude('**/JCSTerminal.java')
main.java.exclude('**/JCSFactory.java')
main.java.exclude('**/CardSimulator.java')
main.java.exclude('**/CAD.java')
main.java.exclude('**/CardTerminalSimulator.java')
main.java.exclude('com/licel/jcardsim/smartcardio/*')
main.java.exclude('com/licel/jcardsim/remote/*')
main.java.exclude('com/licel/jcardsim/utils/APDUScriptTool*')
main.java.exclude('com/licel/jcardsim/io/JavaxSmartCardInterface*')
main.java.exclude('com/licel/jcardsim/io/CAD*')
main.java.exclude('javacard/framework/service/CardRemoteObject*')
main.java.exclude('javacard/framework/service/RMIService*')
main.java.exclude('com/licel/jcardsim/utils/JavaCardApiProcessor*')
main.java.exclude('com/licel/jcardsim/framework/service/*')
main.java.exclude('com/licel/jcardsim/samples/*')
main.java.exclude('com/licel/jcardsim/crypto/*')
main.java.srcDirs += 'src/main/external/GidsApplet/src'
main.java.exclude('**/gidsAppletTests/*.java')
main.java.exclude('com/mysmartlogon/gidsAppletTests/*')
main.java.srcDirs += 'src/main/external/IsoApplet/src'
main.java.srcDirs += 'src/main/external/PivApplet/src'
main.java.srcDirs += 'src/main/external/android-scio/src/main'
main.java.srcDirs += 'src/main/external/ykneo-openpgp/applet/src'
main.java.srcDirs += 'src/main/external/ykneo-oath/applet/src'
}
shadowJar {
relocate 'org.bouncycastle', 'com.vsmartcard.acardemulator.org.bouncycastle'
}
}

android.applicationVariants.all { variant ->
Expand All @@ -59,12 +86,15 @@ android.applicationVariants.all { variant ->
}

dependencies {
shadow localGroovy()
shadow gradleApi()

compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:design:23.2.1'
compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
compile 'com.google.zxing:core:3.2.1'
compile 'com.madgag.spongycastle:core:1.51.0.0'
compile files('libs/sdk-v1.0.0.jar')
compile 'org.bouncycastle:bcprov-jdk14:1.49'
fullCompile files('libs/sdk-v1.0.0.jar')
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (C) 2019 Frank Morgner
*
* This file is part of RemoteSmartCardReader.
*
* RemoteSmartCardReader is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* RemoteSmartCardReader is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* RemoteSmartCardReader. If not, see <http:https://www.gnu.org/licenses/>.
*/

package com.vsmartcard.acardemulator;

import android.app.IntentService;
import android.content.Intent;
import android.support.annotation.Nullable;

public class SmartcardProviderService extends IntentService {
public SmartcardProviderService () {
super("SmartcardProviderService");
}

@Override
protected void onHandleIntent(@Nullable Intent intent) {
}
}
2 changes: 1 addition & 1 deletion ACardEmulator/app/src/main/external/jcardsim
Submodule jcardsim updated 169 files
1 change: 1 addition & 0 deletions ACardEmulator/app/src/main/external/vJCRE
Submodule vJCRE added at 58650d
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,4 @@ protected void onPause() {
dialog.dismiss();
super.onPause();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,22 @@ public boolean onPreferenceClick(Preference preference) {
}
});

Preference gear_nfc = findPreference("gear_nfc");
gear_nfc.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
String gearPackage = "com.samsung.android.gearoplugin";
try {
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("market:https://details?id="+gearPackage)));
} catch (android.content.ActivityNotFoundException e) {
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id="+gearPackage)));
final Preference gear_nfc = findPreference("gear_nfc");
if (BuildConfig.FLAVOR.equals("fdroid")) {
gear_nfc.setSummary("Samsung Gear integration is disabled in F-Droid");
} else {
gear_nfc.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
String gearPackage = "com.samsung.android.gearoplugin";
try {
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("market:https://details?id="+gearPackage)));
} catch (android.content.ActivityNotFoundException e) {
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id="+gearPackage)));
}
return true;
}
return true;
}
});
});
}
}

@Override
Expand Down Expand Up @@ -288,4 +292,4 @@ public void onNewIntent(Intent intent) {
// onResume gets called after this to handle the intent
setIntent(intent);
}
}
}

0 comments on commit 1caff4f

Please sign in to comment.